https://mooseframework.inl.gov
TestNumericalFlux1D.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "TestNumericalFlux1D.h"
12 
14  : MooseObjectUnitTest("ThermalHydraulicsApp")
15 {
16 }
17 
18 void
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 }
58 
59 void
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 }
void testSymmetry()
Runs the symmetry test(s)
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::pair< std::vector< ADReal >, std::vector< ADReal > > > getPrimitiveSolutionsSymmetryTest() const =0
Gets a vector of pairs of primitive solution vectors to use for symmetry test.
void testConsistency()
Runs the consistency test(s)
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.