https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TestNumericalFlux1D Class Referenceabstract

Base class for testing NumericalFlux1D objects. More...

#include <TestNumericalFlux1D.h>

Inheritance diagram for TestNumericalFlux1D:
[legend]

Public Member Functions

 TestNumericalFlux1D ()
 

Protected Member Functions

virtual const NumericalFlux1DcreateFluxObject ()=0
 Creates the flux object to be tested.
 
virtual std::vector< ADRealcomputeConservativeSolution (const std::vector< ADReal > &W, const ADReal &A) const =0
 Computes the conservative solution from the primitive solution.
 
virtual std::vector< ADRealcomputeFluxFromPrimitive (const std::vector< ADReal > &W, const ADReal &A) const =0
 Computes the 1D flux vector from the primitive solution.
 
virtual std::vector< std::pair< std::vector< ADReal >, std::vector< ADReal > > > getPrimitiveSolutionsSymmetryTest () const =0
 Gets a vector of pairs of primitive solution vectors to use for symmetry test.
 
virtual std::vector< std::vector< ADReal > > getPrimitiveSolutionsConsistencyTest () const =0
 Gets a vector of primitive solution vectors to use for consistency test.
 
void testConsistency ()
 Runs the consistency test(s)
 
void testSymmetry ()
 Runs the symmetry test(s)
 
void buildObjects ()
 
TaddObject (const std::string &type, const std::string &name, InputParameters &params)
 

Protected Attributes

std::unique_ptr< MooseMesh_mesh
 
std::shared_ptr< MooseApp_app
 
Factory_factory
 
std::shared_ptr< FEProblem_fe_problem
 

Detailed Description

Base class for testing NumericalFlux1D objects.

Definition at line 18 of file TestNumericalFlux1D.h.

Constructor & Destructor Documentation

◆ TestNumericalFlux1D()

TestNumericalFlux1D::TestNumericalFlux1D ( )

Definition at line 13 of file TestNumericalFlux1D.C.

13: MooseObjectUnitTest("ThermalHydraulicsApp") {}

Member Function Documentation

◆ computeConservativeSolution()

virtual std::vector< ADReal > TestNumericalFlux1D::computeConservativeSolution ( const std::vector< ADReal > &  W,
const ADReal A 
) const
protectedpure virtual

Computes the conservative solution from the primitive solution.

Parameters
[in]WPrimitive solution vector
[in]ACross-sectional area

Implemented in TestNumericalFlux3EqnBase, and TestNumericalFluxGasMixBase.

Referenced by testConsistency(), and testSymmetry().

◆ computeFluxFromPrimitive()

virtual std::vector< ADReal > TestNumericalFlux1D::computeFluxFromPrimitive ( const std::vector< ADReal > &  W,
const ADReal A 
) const
protectedpure virtual

Computes the 1D flux vector from the primitive solution.

Parameters
[in]WPrimitive solution vector
[in]ACross-sectional area

Implemented in TestNumericalFlux3EqnBase, and TestNumericalFluxGasMixBase.

Referenced by testConsistency().

◆ createFluxObject()

virtual const NumericalFlux1D & TestNumericalFlux1D::createFluxObject ( )
protectedpure virtual

Creates the flux object to be tested.

Implemented in TestNumericalFlux3EqnCentered, TestNumericalFlux3EqnHLLC, and TestNumericalFluxGasMixHLLC.

Referenced by testConsistency(), and testSymmetry().

◆ getPrimitiveSolutionsConsistencyTest()

virtual std::vector< std::vector< ADReal > > TestNumericalFlux1D::getPrimitiveSolutionsConsistencyTest ( ) const
protectedpure virtual

Gets a vector of primitive solution vectors to use for consistency test.

Implemented in TestNumericalFlux3EqnCentered, TestNumericalFlux3EqnHLLC, and TestNumericalFluxGasMixHLLC.

Referenced by testConsistency().

◆ getPrimitiveSolutionsSymmetryTest()

virtual std::vector< std::pair< std::vector< ADReal >, std::vector< ADReal > > > TestNumericalFlux1D::getPrimitiveSolutionsSymmetryTest ( ) const
protectedpure virtual

Gets a vector of pairs of primitive solution vectors to use for symmetry test.

Implemented in TestNumericalFlux3EqnCentered, TestNumericalFlux3EqnHLLC, and TestNumericalFluxGasMixHLLC.

Referenced by testSymmetry().

◆ testConsistency()

void TestNumericalFlux1D::testConsistency ( )
protected

Runs the consistency test(s)

Definition at line 57 of file TestNumericalFlux1D.C.

58{
59 const auto & flux = createFluxObject();
60
61 unsigned int i_side = 0;
62 const auto W_list = getPrimitiveSolutionsConsistencyTest();
63 for (const auto & W : W_list)
64 {
65 const ADReal A = 2.0;
66
67 const auto U = computeConservativeSolution(W, A);
68 const auto F_expected = computeFluxFromPrimitive(W, A);
69
70 const auto & FL_computed_pos = flux.getFlux(i_side, 0, true, U, U, 1.0);
71 const auto & FR_computed_pos = flux.getFlux(i_side, 0, false, U, U, 1.0);
72 i_side++;
73
74 const auto & FL_computed_neg = flux.getFlux(i_side, 0, true, U, U, -1.0);
75 const auto & FR_computed_neg = flux.getFlux(i_side, 0, false, U, U, -1.0);
76 i_side++;
77
78 for (unsigned int i = 0; i < FL_computed_pos.size(); ++i)
79 {
80 REL_TEST(FL_computed_pos[i], F_expected[i], REL_TOL_CONSISTENCY);
81 REL_TEST(FR_computed_pos[i], F_expected[i], REL_TOL_CONSISTENCY);
82
83 REL_TEST(FL_computed_neg[i], F_expected[i], REL_TOL_CONSISTENCY);
84 REL_TEST(FR_computed_neg[i], F_expected[i], REL_TOL_CONSISTENCY);
85 }
86 }
87}
DualNumber< Real, DNDerivativeType, true > ADReal
virtual std::vector< ADReal > computeConservativeSolution(const std::vector< ADReal > &W, const ADReal &A) const =0
Computes the conservative solution from the primitive solution.
virtual const NumericalFlux1D & createFluxObject()=0
Creates the flux object to be tested.
virtual std::vector< ADReal > computeFluxFromPrimitive(const std::vector< ADReal > &W, const ADReal &A) const =0
Computes the 1D flux vector from the primitive solution.
virtual std::vector< std::vector< ADReal > > getPrimitiveSolutionsConsistencyTest() const =0
Gets a vector of primitive solution vectors to use for consistency test.

◆ testSymmetry()

void TestNumericalFlux1D::testSymmetry ( )
protected

Runs the symmetry test(s)

Definition at line 16 of file TestNumericalFlux1D.C.

17{
18 const auto & flux = createFluxObject();
19
20 std::set<unsigned int> flux_regions;
21
22 unsigned int i_side = 0;
23 const auto W_pairs = getPrimitiveSolutionsSymmetryTest();
24 for (const auto & W_pair : W_pairs)
25 {
26 const auto & WL = W_pair.first;
27 const auto & WR = W_pair.second;
28
29 const ADReal AL = 1.0;
30 const ADReal AR = 1.5;
31
32 const std::vector<ADReal> UL = computeConservativeSolution(WL, AL);
33 const std::vector<ADReal> UR = computeConservativeSolution(WR, AR);
34
35 const auto FLR = flux.getFlux(i_side, 0, true, UL, UR, 1.0);
36 const auto FRL = flux.getFlux(i_side, 0, false, UL, UR, 1.0);
37 i_side++;
38 flux_regions.insert(flux.getLastRegionIndex());
39
40 const auto FRL_flipped = flux.getFlux(i_side, 0, true, UR, UL, -1.0);
41 const auto FLR_flipped = flux.getFlux(i_side, 0, false, UR, UL, -1.0);
42 i_side++;
43 flux_regions.insert(flux.getLastRegionIndex());
44
45 for (unsigned int i = 0; i < FLR.size(); ++i)
46 {
47 REL_TEST(FLR[i], FLR_flipped[i], REL_TOL_CONSISTENCY);
48 REL_TEST(FRL[i], FRL_flipped[i], REL_TOL_CONSISTENCY);
49 }
50 }
51
52 // Check that all of the regions in the flux have been tested.
53 EXPECT_TRUE(flux_regions.size() == flux.getNumberOfRegions());
54}
virtual std::vector< std::pair< std::vector< ADReal >, std::vector< ADReal > > > getPrimitiveSolutionsSymmetryTest() const =0
Gets a vector of pairs of primitive solution vectors to use for symmetry test.

The documentation for this class was generated from the following files: