https://mooseframework.inl.gov
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TestNumericalFluxGasMixHLLC Class Reference

Tests NumericalFluxGasMixHLLC. More...

#include <TestNumericalFluxGasMixHLLC.h>

Inheritance diagram for TestNumericalFluxGasMixHLLC:
[legend]

Public Member Functions

 TestNumericalFluxGasMixHLLC ()
 

Protected Member Functions

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

Protected Attributes

const UserObjectName _fp_mix_name
 Mixture fluid properties name. More...
 
const IdealGasMixtureFluidProperties_fp_mix
 Fluid properties user object. More...
 
std::unique_ptr< MooseMesh_mesh
 
std::shared_ptr< MooseApp_app
 
Factory_factory
 
std::shared_ptr< FEProblem_fe_problem
 

Detailed Description

Tests NumericalFluxGasMixHLLC.

Definition at line 17 of file TestNumericalFluxGasMixHLLC.h.

Constructor & Destructor Documentation

◆ TestNumericalFluxGasMixHLLC()

TestNumericalFluxGasMixHLLC::TestNumericalFluxGasMixHLLC ( )

Member Function Documentation

◆ addFluidProperties()

void TestNumericalFluxGasMixBase::addFluidProperties ( )
protectedinherited

Adds fluid properties objects needed for testing.

Definition at line 36 of file TestNumericalFluxGasMixBase.C.

Referenced by TestNumericalFluxGasMixBase::TestNumericalFluxGasMixBase().

37 {
38  const std::string fp_steam_name = "fp_steam";
39  const std::string fp_nitrogen_name = "fp_nitrogen";
40 
41  // steam fluid properties; parameters correspond to T in range 298 K to 473 K
42  {
43  const std::string class_name = "IdealGasFluidProperties";
44  InputParameters params = _factory.getValidParams(class_name);
45  params.set<Real>("gamma") = 1.43;
46  params.set<Real>("molar_mass") = 0.01801488;
47  params.set<Real>("mu") = 0.000013277592; // at 400 K and 1.e5 Pa
48  params.set<Real>("k") = 0.026824977826; // at 400 K and 1.e5 Pa
49  _fe_problem->addUserObject(class_name, fp_steam_name, params);
50  }
51 
52  // nitrogen fluid properties
53  {
54  const std::string class_name = "IdealGasFluidProperties";
55  InputParameters params = _factory.getValidParams(class_name);
56  params.set<Real>("gamma") = 1.4;
57  params.set<Real>("molar_mass") = 0.028012734746133888;
58  params.set<Real>("mu") = 0.0000222084; // at 400 K and 1.e5 Pa
59  params.set<Real>("k") = 0.032806168; // at 400 K and 1.e5 Pa
60  _fe_problem->addUserObject(class_name, fp_nitrogen_name, params);
61  }
62 
63  // mixture fluid properties
64  {
65  const std::string class_name = "IdealGasMixtureFluidProperties";
66  InputParameters params = _factory.getValidParams(class_name);
67  params.set<std::vector<UserObjectName>>("component_fluid_properties") = {fp_steam_name, fp_nitrogen_name};
68  _fe_problem->addUserObject(class_name, _fp_mix_name, params);
70  }
71 }
std::shared_ptr< FEProblem > _fe_problem
const IdealGasMixtureFluidProperties * _fp_mix
Fluid properties user object.
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
const UserObjectName _fp_mix_name
Mixture fluid properties name.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Class for fluid properties of an ideal gas mixture.

◆ computeConservativeSolution()

std::vector< ADReal > TestNumericalFluxGasMixBase::computeConservativeSolution ( const std::vector< ADReal > &  W,
const ADReal A 
) const
overrideprotectedvirtualinherited

Computes the conservative solution from the primitive solution.

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

Implements TestNumericalFlux1D.

Definition at line 22 of file TestNumericalFluxGasMixBase.C.

24 {
25  return FlowModelGasMixUtils::computeConservativeSolution<true>(W, A, *_fp_mix);
26 }
const IdealGasMixtureFluidProperties * _fp_mix
Fluid properties user object.

◆ computeFluxFromPrimitive()

std::vector< ADReal > TestNumericalFluxGasMixBase::computeFluxFromPrimitive ( const std::vector< ADReal > &  W,
const ADReal A 
) const
overrideprotectedvirtualinherited

Computes the 1D flux vector from the primitive solution.

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

Implements TestNumericalFlux1D.

Definition at line 29 of file TestNumericalFluxGasMixBase.C.

31 {
32  return FlowModelGasMixUtils::computeFluxFromPrimitive<true>(W, A, *_fp_mix);
33 }
const IdealGasMixtureFluidProperties * _fp_mix
Fluid properties user object.

◆ createFluxObject()

const NumericalFlux1D & TestNumericalFluxGasMixHLLC::createFluxObject ( )
overrideprotectedvirtual

Creates the flux object to be tested.

Implements TestNumericalFlux1D.

Definition at line 29 of file TestNumericalFluxGasMixHLLC.C.

30 {
31  const std::string class_name = "NumericalFluxGasMixHLLC";
32  const std::string flux_mix_name = "flux_mix";
33  InputParameters params = _factory.getValidParams(class_name);
34  params.set<UserObjectName>("fluid_properties") = _fp_mix_name;
35  _fe_problem->addUserObject(class_name, flux_mix_name, params);
36 
37  return _fe_problem->getUserObject<NumericalFluxGasMixHLLC>(flux_mix_name);
38 }
std::shared_ptr< FEProblem > _fe_problem
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
const UserObjectName _fp_mix_name
Mixture fluid properties name.
Computes the numerical flux for FlowModelGasMix using the HLLC approximate Riemann solver...

◆ getPrimitiveSolutionsConsistencyTest()

std::vector< std::vector< ADReal > > TestNumericalFluxGasMixHLLC::getPrimitiveSolutionsConsistencyTest ( ) const
overrideprotectedvirtual

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

Implements TestNumericalFlux1D.

Definition at line 77 of file TestNumericalFluxGasMixHLLC.C.

78 {
79  std::vector<ADReal> W1(THMGasMix1D::N_PRIM_VARS);
81  W1[THMGasMix1D::PRESSURE] = 1e5;
82  W1[THMGasMix1D::TEMPERATURE] = 300;
83  W1[THMGasMix1D::VELOCITY] = 1.5;
84 
85  std::vector<std::vector<ADReal>> W_list;
86  W_list.push_back(W1);
87 
88  return W_list;
89 }
static const unsigned int N_PRIM_VARS

◆ getPrimitiveSolutionsSymmetryTest()

std::vector< std::pair< std::vector< ADReal >, std::vector< ADReal > > > TestNumericalFluxGasMixHLLC::getPrimitiveSolutionsSymmetryTest ( ) const
overrideprotectedvirtual

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

Implements TestNumericalFlux1D.

Definition at line 41 of file TestNumericalFluxGasMixHLLC.C.

42 {
43  // sL < 0 < sM
44  std::vector<ADReal> W1(THMGasMix1D::N_PRIM_VARS);
46  W1[THMGasMix1D::PRESSURE] = 1e5;
47  W1[THMGasMix1D::TEMPERATURE] = 300;
48  W1[THMGasMix1D::VELOCITY] = 20;
49 
50  std::vector<ADReal> W2(THMGasMix1D::N_PRIM_VARS);
52  W2[THMGasMix1D::PRESSURE] = 2e5;
53  W2[THMGasMix1D::TEMPERATURE] = 310;
54  W2[THMGasMix1D::VELOCITY] = 1.2;
55 
56  // sL > 0
57  std::vector<ADReal> W3(THMGasMix1D::N_PRIM_VARS);
59  W3[THMGasMix1D::PRESSURE] = 1e5;
60  W3[THMGasMix1D::TEMPERATURE] = 300;
61  W3[THMGasMix1D::VELOCITY] = 500;
62 
63  std::vector<ADReal> W4(THMGasMix1D::N_PRIM_VARS);
65  W4[THMGasMix1D::PRESSURE] = 2e5;
66  W4[THMGasMix1D::TEMPERATURE] = 310;
67  W4[THMGasMix1D::VELOCITY] = 550;
68 
69  std::vector<std::pair<std::vector<ADReal>, std::vector<ADReal>>> W_pairs;
70  W_pairs.push_back(std::pair<std::vector<ADReal>, std::vector<ADReal>>(W1, W2));
71  W_pairs.push_back(std::pair<std::vector<ADReal>, std::vector<ADReal>>(W3, W4));
72 
73  return W_pairs;
74 }
static const unsigned int N_PRIM_VARS

◆ testConsistency()

void TestNumericalFlux1D::testConsistency ( )
protectedinherited

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, 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 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 ( )
protectedinherited

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, true > 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.

Member Data Documentation

◆ _fp_mix

const IdealGasMixtureFluidProperties* TestNumericalFluxGasMixBase::_fp_mix
protectedinherited

◆ _fp_mix_name

const UserObjectName TestNumericalFluxGasMixBase::_fp_mix_name
protectedinherited

Mixture fluid properties name.

Definition at line 36 of file TestNumericalFluxGasMixBase.h.

Referenced by TestNumericalFluxGasMixBase::addFluidProperties(), and createFluxObject().


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