https://mooseframework.inl.gov
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. More...
 
virtual std::vector< ADRealcomputeConservativeSolution (const std::vector< ADReal > &W, const ADReal &A) const =0
 Computes the conservative solution from the primitive solution. More...
 
virtual std::vector< ADRealcomputeFluxFromPrimitive (const std::vector< ADReal > &W, const ADReal &A) const =0
 Computes the 1D flux vector from the primitive solution. More...
 
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. More...
 
virtual std::vector< std::vector< ADReal > > getPrimitiveSolutionsConsistencyTest () const =0
 Gets a vector of primitive solution vectors to use for consistency test. More...
 
void testConsistency ()
 Runs the consistency test(s) More...
 
void testSymmetry ()
 Runs the symmetry test(s) More...
 
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.

14  : MooseObjectUnitTest("ThermalHydraulicsApp")
15 {
16 }
MooseObjectUnitTest(const std::string &app_name)

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 60 of file TestNumericalFlux1D.C.

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

◆ testSymmetry()

void TestNumericalFlux1D::testSymmetry ( )
protected

Runs the symmetry test(s)

Definition at line 19 of file TestNumericalFlux1D.C.

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

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