https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PorousFlowDictatorTest.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
11
13{
14 EXPECT_EQ(_dictator->numVariables(), (unsigned int)3);
15 EXPECT_EQ(_dictator_no_fetype->numVariables(), (unsigned int)2);
16}
17
19{
20 EXPECT_EQ(_dictator->numPhases(), (unsigned int)2);
21 EXPECT_EQ(_dictator_no_fetype->numPhases(), (unsigned int)1);
22}
23
25{
26 EXPECT_EQ(_dictator->numComponents(), (unsigned int)4);
27 EXPECT_EQ(_dictator_no_fetype->numComponents(), (unsigned int)3);
28}
29
30TEST_F(PorousFlowDictatorTest, numAqueousEquilibrium)
31{
32 EXPECT_EQ(_dictator->numAqueousEquilibrium(), (unsigned int)5);
33 EXPECT_EQ(_dictator_no_fetype->numAqueousEquilibrium(), (unsigned int)0);
34}
35
36TEST_F(PorousFlowDictatorTest, numAqueousKinetic)
37{
38 EXPECT_EQ(_dictator->numAqueousKinetic(), (unsigned int)6);
39 EXPECT_EQ(_dictator_no_fetype->numAqueousKinetic(), (unsigned int)0);
40}
41
42TEST_F(PorousFlowDictatorTest, aqueousPhaseNumber)
43{
44 EXPECT_EQ(_dictator->aqueousPhaseNumber(), (unsigned int)1);
45 EXPECT_EQ(_dictator_no_fetype->aqueousPhaseNumber(), (unsigned int)0);
46}
47
48TEST_F(PorousFlowDictatorTest, porousFlowVariableNum)
49{
50 EXPECT_EQ(_dictator->porousFlowVariableNum(1), (unsigned int)0);
51 EXPECT_EQ(_dictator->porousFlowVariableNum(4), (unsigned int)1);
52 EXPECT_EQ(_dictator->porousFlowVariableNum(3), (unsigned int)2);
53
54 try
55 {
56 _dictator->porousFlowVariableNum(0);
57 FAIL();
58 }
59 catch (const std::exception & err)
60 {
61 std::size_t pos = std::string(err.what())
62 .find("The Dictator proclaims that the moose variable with number 0 is "
63 "not a PorousFlow variable. Exiting with error code 1984.");
64 ASSERT_TRUE(pos != std::string::npos);
65 }
66
67 try
68 {
69 _dictator->porousFlowVariableNum(2);
70 FAIL();
71 }
72 catch (const std::exception & err)
73 {
74 std::size_t pos = std::string(err.what())
75 .find("The Dictator proclaims that the moose variable with number 2 is "
76 "not a PorousFlow variable. Exiting with error code 1984.");
77 ASSERT_TRUE(pos != std::string::npos);
78 }
79
80 try
81 {
82 _dictator->porousFlowVariableNum(5);
83 FAIL();
84 }
85 catch (const std::exception & err)
86 {
87 std::size_t pos = std::string(err.what())
88 .find("The Dictator proclaims that the moose variable with number 5 is "
89 "not a PorousFlow variable. Exiting with error code 1984.");
90 ASSERT_TRUE(pos != std::string::npos);
91 }
92
93 try
94 {
95 _dictator->porousFlowVariableNum(123);
96 FAIL();
97 }
98 catch (const std::exception & err)
99 {
100 std::size_t pos = std::string(err.what())
101 .find("The Dictator proclaims that the moose variable with number 123 is "
102 "not a PorousFlow variable. Exiting with error code 1984.");
103 ASSERT_TRUE(pos != std::string::npos);
104 }
105
106 EXPECT_EQ(_dictator_no_fetype->porousFlowVariableNum(1), (unsigned int)0);
107 EXPECT_EQ(_dictator_no_fetype->porousFlowVariableNum(6), (unsigned int)1);
108}
109
111{
112 EXPECT_EQ(_dictator->mooseVariableNum(0), (unsigned int)1);
113 EXPECT_EQ(_dictator->mooseVariableNum(1), (unsigned int)4);
114 EXPECT_EQ(_dictator->mooseVariableNum(2), (unsigned int)3);
115
116 try
117 {
118 _dictator->mooseVariableNum(3);
119 FAIL();
120 }
121 catch (const std::exception & err)
122 {
123 std::size_t pos = std::string(err.what())
124 .find("The Dictator proclaims that there is no such PorousFlow variable "
125 "with number 3. Exiting with error code 1984.");
126 ASSERT_TRUE(pos != std::string::npos);
127 }
128
129 EXPECT_EQ(_dictator_no_fetype->mooseVariableNum(0), (unsigned int)1);
130 EXPECT_EQ(_dictator_no_fetype->mooseVariableNum(1), (unsigned int)6);
131}
132
133TEST_F(PorousFlowDictatorTest, isPorousFlowVariable)
134{
135 ASSERT_TRUE(!_dictator->isPorousFlowVariable(0));
136 ASSERT_TRUE(_dictator->isPorousFlowVariable(1));
137 ASSERT_TRUE(!_dictator->isPorousFlowVariable(2));
138 ASSERT_TRUE(_dictator->isPorousFlowVariable(3));
139 ASSERT_TRUE(_dictator->isPorousFlowVariable(4));
140 ASSERT_TRUE(!_dictator->isPorousFlowVariable(5));
141 ASSERT_TRUE(!_dictator->isPorousFlowVariable(123));
142}
143
144TEST_F(PorousFlowDictatorTest, notPorousFlowVariable)
145{
146 ASSERT_TRUE(_dictator->notPorousFlowVariable(0));
147 ASSERT_TRUE(!_dictator->notPorousFlowVariable(1));
148 ASSERT_TRUE(_dictator->notPorousFlowVariable(2));
149 ASSERT_TRUE(!_dictator->notPorousFlowVariable(3));
150 ASSERT_TRUE(!_dictator->notPorousFlowVariable(4));
151 ASSERT_TRUE(_dictator->notPorousFlowVariable(5));
152 ASSERT_TRUE(_dictator->notPorousFlowVariable(123));
153}
154
156{
157 ASSERT_TRUE(_dictator->consistentFEType());
158 ASSERT_TRUE(!_dictator_no_fetype->consistentFEType());
159}
160
162{
163 auto linear_lagrange = FEType(Utility::string_to_enum<Order>("FIRST"),
164 Utility::string_to_enum<FEFamily>("LAGRANGE"));
165
166 ASSERT_EQ(_dictator->feType(), linear_lagrange);
167}
168
170{
171 try
172 {
173 InputParameters params = _factory.getValidParams("PorousFlowDictator");
174 params.set<std::vector<VariableName>>("porous_flow_vars") =
175 std::vector<VariableName>{"var3", "aux_var", "var0", "var5"};
176 params.set<unsigned>("number_fluid_phases") = 1;
177 params.set<unsigned>("number_fluid_components") = 2;
178 _fe_problem->addUserObject("PorousFlowDictator", "dictator_with_aux", params);
179 FAIL();
180 }
181 catch (const std::exception & err)
182 {
183 std::size_t pos =
184 std::string(err.what())
185 .find(
186 "PorousFlowDictator: AuxVariables variables must not be coupled into the Dictator "
187 "for this is against specification #1984. Variable 'aux_var' is either an "
188 "AuxVariable or from a different nonlinear system.");
189 ASSERT_TRUE(pos != std::string::npos);
190 }
191}
192
194{
195 try
196 {
197 InputParameters params = _factory.getValidParams("PorousFlowDictator");
198 params.set<std::vector<VariableName>>("porous_flow_vars") = std::vector<VariableName>{"var0"};
199 params.set<unsigned>("number_fluid_phases") = 1;
200 params.set<unsigned>("number_fluid_components") = 2;
201 params.set<unsigned>("aqueous_phase_number") = 1;
202 _fe_problem->addUserObject(
203 "PorousFlowDictator", "dictator_with_large_aqueous_phase_number", params);
204 FAIL();
205 }
206 catch (const std::exception & err)
207 {
208 std::size_t pos =
209 std::string(err.what())
210 .find("PorousflowDictator: The aqueous phase number must be less than the number of "
211 "fluid phases. The Dictator does not appreciate jokes.");
212 ASSERT_TRUE(pos != std::string::npos);
213 }
214}
TEST_F(PorousFlowDictatorTest, numVariables)
T & set(const std::string &name, bool quiet_mode=false)