• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CSMMLab / KiT-RT / #95

28 May 2025 02:06AM UTC coverage: 46.655% (-11.1%) from 57.728%
#95

push

travis-ci

web-flow
Release 2025 (#44)

* New neural models (#30)

* extend kitrt script

* added new neural models

* extend to m3 models

* added M3_2D models

* added M2 and M4 models

* configure ml optimizer for high order models

* added configuration for high order models

* add option for rotation postprcessing in neural networks. remove unneccessary python scripts

* started rotational symmetric postprocessing

* added rotational invariance postprocessing for m2 and m1 models

* fix post merge bugs

* created hohlraum mesh

* add hohlraum tes case

* add hohlraum test case

* add hohlraum cfg filees

* fixed hohlraum testcase

* add hohlraum cfg files

* changed hohlraum cfg

* changed hohlraum testcase to isotropic inflow source boundary condition

* added ghost cell bonudary for hohlraum testcase

* update readme and linesource mesh creator

* added proper scaling for linesource reference solution

* regularized newton debugging

* Data generator with reduced objective functional (#33)

* added reduced optimizer for sampling

* remove old debugging comments

* mesh acceleration (#38)

* added new ansatz (#36)

* added new ansatz

* debug new ansatz

* branch should be abandoned here

* debug new ansatz

* fix scaling error new ansatz

* fix config errors

* temporarily fixed dynamic ansatz rotation bug

* fix inheritance error for new ansatz

* mesh acceleration

* add structured hohlraum

* Mesh acc (#41)

* mesh acceleration

* added floor value for starmap moment methods

* enable accelleration

* delete minimum value starmap

* Update README.md

* Spherical harmonics nn (#40)

* added new ansatz

* debug new ansatz

* branch should be abandoned here

* debug new ansatz

* fix scaling error new ansatz

* fix config errors

* temporarily fixed dynamic ansatz rotation bug

* fix inheritance error for new ansatz

* mesh acceleration

* add structured hohlraum

* added sph... (continued)

767 of 3019 new or added lines in 51 files covered. (25.41%)

131 existing lines in 8 files now uncovered.

4422 of 9478 relevant lines covered (46.66%)

57163.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/problems/aircavity1d.cpp
1
#include "problems/aircavity1d.hpp"
2
#include "common/config.hpp"
3
#include "common/mesh.hpp"
4
#include "quadratures/qgausslegendretensorized.hpp"
5
#include "quadratures/quadraturebase.hpp"
6
#include "toolboxes/textprocessingtoolbox.hpp"
7
#include "velocitybasis/sphericalbase.hpp"
8
#include "velocitybasis/sphericalharmonics.hpp"
9

NEW
10
AirCavity1D::AirCavity1D( Config* settings, Mesh* mesh, QuadratureBase* quad ) : ProblemBase( settings, mesh, quad ) {
×
NEW
11
    _sigmaS = settings->GetSigmaS();
×
12
}
13

14
AirCavity1D::~AirCavity1D() {}
×
15

×
16
std::vector<VectorVector> AirCavity1D::GetExternalSource( const Vector& energies ) {
×
17
    return std::vector<VectorVector>( energies.size(), std::vector<Vector>( _mesh->GetNumCells(), Vector( _settings->GetNQuadPoints(), 0.0 ) ) );
18
}
×
19

×
20
VectorVector AirCavity1D::SetupIC() {
21
    VectorVector psi( _mesh->GetNumCells(), Vector( _settings->GetNQuadPoints(), 1e-10 ) );
22
    VectorVector cellMids         = _mesh->GetCellMidPoints();
×
23
    double s                      = 0.1;
×
24
    QuadratureBase* quad          = QuadratureBase::Create( _settings );
×
25
    VectorVector quadPointsSphere = quad->GetPointsSphere();
×
26
    for( unsigned j = 0; j < cellMids.size(); ++j ) {
×
27
        double x = cellMids[j][0];
×
28
        // anisotropic inflow that concentrates all particles on the last quadrature point
×
29
        for( unsigned idx_quad = 0; idx_quad < _settings->GetNQuadPoints(); idx_quad++ ) {
×
30
            if( quadPointsSphere[idx_quad][0] > 0.5 ) {    // if my >0
31
                psi[j][idx_quad] = 1.0 / ( s * sqrt( 2 * M_PI ) ) * std::exp( -x * x / ( 2 * s * s ) );
×
32
            }
×
33
        }
×
34
    }
35
    delete quad;
36
    return psi;
37
}
×
38

×
39
std::vector<double> AirCavity1D::GetDensity( const VectorVector& cellMidPoints ) {
40
    std::vector<double> densities( cellMidPoints.size(), 1.0 );
41
    for( unsigned j = 0; j < cellMidPoints.size(); ++j ) {
×
42
        if( cellMidPoints[j][0] > 1.5 - 2.5 && cellMidPoints[j][0] < 2.0 - 2.5 ) densities[j] = 0.01;
×
43
    }
×
44
    return densities;
×
45
}
46

×
47
VectorVector AirCavity1D::GetScatteringXS( const Vector& energies ) {
48
    return VectorVector( energies.size(), Vector( _mesh->GetNumCells(), _sigmaS ) );
49
}
×
50

×
51
VectorVector AirCavity1D::GetTotalXS( const Vector& energies ) { return VectorVector( energies.size(), Vector( _mesh->GetNumCells(), _sigmaS ) ); }
52

53
// ------ Moment version ---
×
54

55
AirCavity1D_Moment::AirCavity1D_Moment( Config* settings, Mesh* mesh, QuadratureBase* quad ) : ProblemBase( settings, mesh, quad ) {
56
    _sigmaS = settings->GetSigmaS();
NEW
57
}
×
58

×
59
AirCavity1D_Moment::~AirCavity1D_Moment() {}
60

61
std::vector<VectorVector> AirCavity1D_Moment::GetExternalSource( const Vector& /*energies*/ ) {
×
62
    SphericalBase* tempBase  = SphericalBase::Create( _settings );
×
63
    unsigned ntotalEquations = tempBase->GetBasisSize();
×
64
    VectorVector Q( _mesh->GetNumCells(), Vector( ntotalEquations, 0.0 ) );    // zero could lead to problems?
65
    delete tempBase;                                                           // Only temporally needed
×
66
    return std::vector<VectorVector>( 1u, Q );
×
67
}
×
68

×
69
VectorVector AirCavity1D_Moment::SetupIC() {
×
70
    if( _settings->GetSolverName() == PN_SOLVER ) {
×
71

72
        // In case of PN, spherical basis is per default SPHERICAL_HARMONICS in 3 velocity dimensions
73

×
74
        SphericalBase* tempBase  = new SphericalHarmonics( _settings->GetMaxMomentDegree(), 3 );
×
75
        unsigned ntotalEquations = tempBase->GetBasisSize();
76

77
        double epsilon = 1e-3;
78

×
79
        VectorVector initialSolution( _mesh->GetNumCells(), Vector( ntotalEquations, 0.0 ) );    // zero could lead to problems?
×
80
        VectorVector cellMids = _mesh->GetCellMidPoints();
81

×
82
        QuadratureBase* quad          = new QGaussLegendreTensorized( _settings );
83
        VectorVector quadPointsSphere = quad->GetPointsSphere();
×
84
        Vector w                      = quad->GetWeights();
×
85
        Vector cellKineticDensity( quad->GetNq(), epsilon );
86

×
87
        // compute moment basis
×
88
        VectorVector moments = VectorVector( quad->GetNq(), Vector( ntotalEquations, 0.0 ) );
×
89
        double my, phi;    // quadpoints in spherical coordinates
×
90
        for( unsigned idx_quad = 0; idx_quad < quad->GetNq(); idx_quad++ ) {
91
            my                = quadPointsSphere[idx_quad][0];
92
            phi               = quadPointsSphere[idx_quad][1];
×
93
            moments[idx_quad] = tempBase->ComputeSphericalBasis( my, phi );
94
        }
×
95
        delete tempBase;
×
96
        double s = 0.1;
×
97
        // create kinetic density( SN initial condition )
×
98
        for( unsigned idx_cell = 0; idx_cell < cellMids.size(); ++idx_cell ) {
99
            double x = cellMids[idx_cell][0];
×
100
            // anisotropic inflow that concentrates all particles on the last quadrature point
×
101
            for( unsigned idx_quad = 0; idx_quad < _settings->GetNQuadPoints(); idx_quad++ ) {
102
                if( quadPointsSphere[idx_quad][0] > 0.5 ) {    // if my >0
×
103
                    cellKineticDensity[idx_quad] = std::max( 1.0 / ( s * sqrt( 2 * M_PI ) ) * std::exp( -x * x / ( 2 * s * s ) ), epsilon );
×
104
                }
105
            }
×
106
            // Compute moments of this kinetic density
×
107
            for( unsigned idx_quad = 0; idx_quad < quad->GetNq(); idx_quad++ ) {
×
108
                initialSolution[idx_cell] += cellKineticDensity[idx_quad] * w[idx_quad] * moments[idx_quad];
109
            }
110
        }
111
        delete quad;
×
112
        return initialSolution;
×
113
    }
114
    else {
115
        SphericalBase* tempBase  = SphericalBase::Create( _settings );
×
116
        unsigned ntotalEquations = tempBase->GetBasisSize();
×
117

118
        double epsilon = 1e-3;
119

×
120
        Vector cellKineticDensity( _settings->GetNQuadPoints(), epsilon );
×
121
        VectorVector initialSolution( _mesh->GetNumCells(), Vector( ntotalEquations, 0 ) );    // zero could lead to problems?
122
        VectorVector cellMids = _mesh->GetCellMidPoints();
×
123

124
        QuadratureBase* quad          = QuadratureBase::Create( _settings );
×
125
        VectorVector quadPointsSphere = quad->GetPointsSphere();
×
126
        Vector w                      = quad->GetWeights();
×
127

128
        // compute moment basis
×
129
        VectorVector moments = VectorVector( quad->GetNq(), Vector( ntotalEquations, 0.0 ) );
×
130
        double my, phi;    // quadpoints in spherical coordinates
×
131
        for( unsigned idx_quad = 0; idx_quad < quad->GetNq(); idx_quad++ ) {
132
            my                = quadPointsSphere[idx_quad][0];
133
            phi               = quadPointsSphere[idx_quad][1];
×
134
            moments[idx_quad] = tempBase->ComputeSphericalBasis( my, phi );
135
        }
×
136
        delete tempBase;
×
137

×
138
        double s = 0.1;
×
139
        // create kinetic density( SN initial condition )
140
        for( unsigned idx_cell = 0; idx_cell < cellMids.size(); ++idx_cell ) {
×
141
            double x = cellMids[idx_cell][0];
142
            // anisotropic inflow that concentrates all particles on the last quadrature point
×
143
            for( unsigned idx_quad = 0; idx_quad < _settings->GetNQuadPoints(); idx_quad++ ) {
144
                if( quadPointsSphere[idx_quad][0] > 0.5 ) {    // if my >0
×
145
                    cellKineticDensity[idx_quad] = std::max( 1.0 / ( s * sqrt( 2 * M_PI ) ) * std::exp( -x * x / ( 2 * s * s ) ), epsilon );
×
146
                }
147
            }
×
148
            // Compute moments of this kinetic density
×
149
            for( unsigned idx_quad = 0; idx_quad < quad->GetNq(); idx_quad++ ) {
×
150
                initialSolution[idx_cell] += cellKineticDensity[idx_quad] * w[idx_quad] * moments[idx_quad];
151
            }
152
        }
153
        delete quad;
×
154
        return initialSolution;
×
155
    }
156
}
157

×
158
std::vector<double> AirCavity1D_Moment::GetDensity( const VectorVector& cellMidPoints ) {
×
159
    std::vector<double> densities( cellMidPoints.size(), 1.0 );
160

161
    for( unsigned j = 0; j < cellMidPoints.size(); ++j ) {
162
        if( cellMidPoints[j][0] > 1.5 - 2.5 && cellMidPoints[j][0] < 2.0 - 2.5 ) densities[j] = 0.01;
×
163
    }
×
164
    return densities;
165
}
×
166

×
167
VectorVector AirCavity1D_Moment::GetScatteringXS( const Vector& energies ) {
168
    return VectorVector( energies.size(), Vector( _mesh->GetNumCells(), _sigmaS ) );
×
169
}
170

171
VectorVector AirCavity1D_Moment::GetTotalXS( const Vector& energies ) {
×
172
    return VectorVector( energies.size(), Vector( _mesh->GetNumCells(), _sigmaS ) );
×
173
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc