Line data Source code
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 "SIMPLESolveBase.h"
11 : #include "FEProblem.h"
12 : #include "SegregatedSolverUtils.h"
13 :
14 : InputParameters
15 3268 : SIMPLESolveBase::validParams()
16 : {
17 3268 : InputParameters params = emptyInputParameters();
18 6536 : params.addRequiredParam<UserObjectName>("rhie_chow_user_object", "The rhie-chow user-object");
19 :
20 : /*
21 : * The names of the different systems in the segregated solver
22 : */
23 6536 : params.addRequiredParam<std::vector<SolverSystemName>>(
24 : "momentum_systems", "The solver system(s) for the momentum equation(s).");
25 6536 : params.addRequiredParam<SolverSystemName>("pressure_system",
26 : "The solver system for the pressure equation.");
27 6536 : params.addParam<SolverSystemName>("energy_system", "The solver system for the energy equation.");
28 6536 : params.addParam<SolverSystemName>("solid_energy_system",
29 : "The solver system for the solid energy equation.");
30 6536 : params.addParam<std::vector<SolverSystemName>>(
31 : "passive_scalar_systems", {}, "The solver system for each scalar advection equation.");
32 6536 : params.addParam<std::vector<SolverSystemName>>(
33 : "turbulence_systems", {}, "The solver system for each surrogate turbulence equation.");
34 :
35 : /*
36 : * Parameters to control the solution of the momentum equation
37 : */
38 :
39 9804 : params.addRangeCheckedParam<Real>(
40 : "momentum_equation_relaxation",
41 6536 : 1.0,
42 : "0.0<momentum_equation_relaxation<=1.0",
43 : "The relaxation which should be used for the momentum equation. (=1 for no relaxation, "
44 : "diagonal dominance will still be enforced)");
45 :
46 6536 : params.addParam<MultiMooseEnum>("momentum_petsc_options",
47 6536 : Moose::PetscSupport::getCommonPetscFlags(),
48 : "Singleton PETSc options for the momentum equation");
49 6536 : params.addParam<MultiMooseEnum>("momentum_petsc_options_iname",
50 6536 : Moose::PetscSupport::getCommonPetscKeys(),
51 : "Names of PETSc name/value pairs for the momentum equation");
52 6536 : params.addParam<std::vector<std::string>>(
53 : "momentum_petsc_options_value",
54 : "Values of PETSc name/value pairs (must correspond with \"petsc_options_iname\" for the "
55 : "momentum equation");
56 :
57 9804 : params.addRangeCheckedParam<Real>(
58 : "momentum_absolute_tolerance",
59 6536 : 1e-5,
60 : "0.0<momentum_absolute_tolerance",
61 : "The absolute tolerance on the normalized residual of the momentum equation.");
62 :
63 9804 : params.addRangeCheckedParam<Real>("momentum_l_tol",
64 6536 : 1e-5,
65 : "0.0<=momentum_l_tol & momentum_l_tol<1.0",
66 : "The relative tolerance on the normalized residual in the "
67 : "linear solver of the momentum equation.");
68 9804 : params.addRangeCheckedParam<Real>("momentum_l_abs_tol",
69 6536 : 1e-50,
70 : "0.0<momentum_l_abs_tol",
71 : "The absolute tolerance on the normalized residual in the "
72 : "linear solver of the momentum equation.");
73 6536 : params.addParam<unsigned int>(
74 : "momentum_l_max_its",
75 6536 : 10000,
76 : "The maximum allowed iterations in the linear solver of the momentum equation.");
77 :
78 6536 : params.addParamNamesToGroup(
79 : "momentum_equation_relaxation momentum_petsc_options momentum_petsc_options_iname "
80 : "momentum_petsc_options_value momentum_petsc_options_value momentum_absolute_tolerance "
81 : "momentum_l_tol momentum_l_abs_tol momentum_l_max_its momentum_systems",
82 : "Momentum Equation");
83 :
84 : /*
85 : * Parameters to control the solution of the pressure equation
86 : */
87 9804 : params.addRangeCheckedParam<Real>(
88 : "pressure_variable_relaxation",
89 6536 : 1.0,
90 : "0.0<pressure_variable_relaxation<=1.0",
91 : "The relaxation which should be used for the pressure variable (=1 for no relaxation).");
92 :
93 6536 : params.addParam<MultiMooseEnum>("pressure_petsc_options",
94 6536 : Moose::PetscSupport::getCommonPetscFlags(),
95 : "Singleton PETSc options for the pressure equation");
96 6536 : params.addParam<MultiMooseEnum>("pressure_petsc_options_iname",
97 6536 : Moose::PetscSupport::getCommonPetscKeys(),
98 : "Names of PETSc name/value pairs for the pressure equation");
99 6536 : params.addParam<std::vector<std::string>>(
100 : "pressure_petsc_options_value",
101 : "Values of PETSc name/value pairs (must correspond with \"petsc_options_iname\" for the "
102 : "pressure equation");
103 :
104 9804 : params.addRangeCheckedParam<Real>(
105 : "pressure_absolute_tolerance",
106 6536 : 1e-5,
107 : "0.0<pressure_absolute_tolerance",
108 : "The absolute tolerance on the normalized residual of the pressure equation.");
109 :
110 9804 : params.addRangeCheckedParam<Real>("pressure_l_tol",
111 6536 : 1e-5,
112 : "0.0<=pressure_l_tol & pressure_l_tol<1.0",
113 : "The relative tolerance on the normalized residual in the "
114 : "linear solver of the pressure equation.");
115 9804 : params.addRangeCheckedParam<Real>("pressure_l_abs_tol",
116 6536 : 1e-10,
117 : "0.0<pressure_l_abs_tol",
118 : "The absolute tolerance on the normalized residual in the "
119 : "linear solver of the pressure equation.");
120 6536 : params.addParam<unsigned int>(
121 : "pressure_l_max_its",
122 6536 : 10000,
123 : "The maximum allowed iterations in the linear solver of the pressure equation.");
124 :
125 6536 : params.addParamNamesToGroup(
126 : "pressure_variable_relaxation pressure_petsc_options pressure_petsc_options_iname "
127 : "pressure_petsc_options_value pressure_petsc_options_value pressure_absolute_tolerance "
128 : "pressure_l_tol pressure_l_abs_tol pressure_l_max_its pressure_system",
129 : "Pressure Equation");
130 :
131 : /*
132 : * Pressure pin parameters for enclosed flows
133 : */
134 :
135 6536 : params.addParam<bool>(
136 6536 : "pin_pressure", false, "If the pressure field needs to be pinned at a point.");
137 6536 : params.addParam<Real>(
138 6536 : "pressure_pin_value", 0.0, "The value which needs to be enforced for the pressure.");
139 6536 : params.addParam<Point>("pressure_pin_point", "The point where the pressure needs to be pinned.");
140 :
141 6536 : params.addParamNamesToGroup("pin_pressure pressure_pin_value pressure_pin_point", "Pressure Pin");
142 :
143 6536 : params.addParam<bool>(
144 : "print_fields",
145 6536 : false,
146 : "Use this to print the coupling and solution fields and matrices throughout the iteration.");
147 :
148 : /*
149 : * Parameters to control the solution of the energy equation
150 : */
151 :
152 9804 : params.addRangeCheckedParam<Real>(
153 : "energy_equation_relaxation",
154 6536 : 1.0,
155 : "0.0<energy_equation_relaxation<=1.0",
156 : "The relaxation which should be used for the energy equation. (=1 for no relaxation, "
157 : "diagonal dominance will still be enforced)");
158 :
159 6536 : params.addParam<MultiMooseEnum>("energy_petsc_options",
160 6536 : Moose::PetscSupport::getCommonPetscFlags(),
161 : "Singleton PETSc options for the energy equation");
162 6536 : params.addParam<MultiMooseEnum>("energy_petsc_options_iname",
163 6536 : Moose::PetscSupport::getCommonPetscKeys(),
164 : "Names of PETSc name/value pairs for the energy equation");
165 6536 : params.addParam<std::vector<std::string>>(
166 : "energy_petsc_options_value",
167 : "Values of PETSc name/value pairs (must correspond with \"petsc_options_iname\" for the "
168 : "energy equation");
169 :
170 9804 : params.addRangeCheckedParam<Real>(
171 : "energy_absolute_tolerance",
172 6536 : 1e-5,
173 : "0.0<energy_absolute_tolerance",
174 : "The absolute tolerance on the normalized residual of the energy equation.");
175 :
176 9804 : params.addRangeCheckedParam<Real>("energy_l_tol",
177 6536 : 1e-5,
178 : "0.0<=energy_l_tol & energy_l_tol<1.0",
179 : "The relative tolerance on the normalized residual in the "
180 : "linear solver of the energy equation.");
181 9804 : params.addRangeCheckedParam<Real>("energy_l_abs_tol",
182 6536 : 1e-10,
183 : "0.0<energy_l_abs_tol",
184 : "The absolute tolerance on the normalized residual in the "
185 : "linear solver of the energy equation.");
186 9804 : params.addRangeCheckedParam<unsigned int>(
187 : "energy_l_max_its",
188 6536 : 10000,
189 : "0<energy_l_max_its",
190 : "The maximum allowed iterations in the linear solver of the energy equation.");
191 :
192 6536 : params.addParamNamesToGroup(
193 : "energy_equation_relaxation energy_petsc_options energy_petsc_options_iname "
194 : "energy_petsc_options_value energy_petsc_options_value energy_absolute_tolerance "
195 : "energy_l_tol energy_l_abs_tol energy_l_max_its",
196 : "Energy Equation");
197 :
198 : /*
199 : * Parameters to control the solution of the solid energy equation
200 : */
201 :
202 6536 : params.addParam<MultiMooseEnum>("solid_energy_petsc_options",
203 6536 : Moose::PetscSupport::getCommonPetscFlags(),
204 : "Singleton PETSc options for the solid energy equation");
205 6536 : params.addParam<MultiMooseEnum>("solid_energy_petsc_options_iname",
206 6536 : Moose::PetscSupport::getCommonPetscKeys(),
207 : "Names of PETSc name/value pairs for the solid energy equation");
208 6536 : params.addParam<std::vector<std::string>>(
209 : "solid_energy_petsc_options_value",
210 : "Values of PETSc name/value pairs (must correspond with \"petsc_options_iname\" for the "
211 : "solid energy equation");
212 :
213 9804 : params.addRangeCheckedParam<Real>(
214 : "solid_energy_absolute_tolerance",
215 6536 : 1e-5,
216 : "0.0<solid_energy_absolute_tolerance",
217 : "The absolute tolerance on the normalized residual of the solid energy equation.");
218 :
219 9804 : params.addRangeCheckedParam<Real>("solid_energy_l_tol",
220 6536 : 1e-5,
221 : "0.0<=solid_energy_l_tol & solid_energy_l_tol<1.0",
222 : "The relative tolerance on the normalized residual in the "
223 : "linear solver of the solid energy equation.");
224 :
225 9804 : params.addRangeCheckedParam<Real>("solid_energy_l_abs_tol",
226 6536 : 1e-10,
227 : "0.0<solid_energy_l_abs_tol",
228 : "The absolute tolerance on the normalized residual in the "
229 : "linear solver of the solid energy equation.");
230 9804 : params.addRangeCheckedParam<unsigned int>(
231 : "solid_energy_l_max_its",
232 6536 : 10000,
233 : "0<solid_energy_l_max_its",
234 : "The maximum allowed iterations in the linear solver of the solid energy equation.");
235 :
236 6536 : params.addParamNamesToGroup("solid_energy_petsc_options solid_energy_petsc_options_iname "
237 : "solid_energy_petsc_options_value solid_energy_absolute_tolerance "
238 : "solid_energy_l_tol solid_energy_l_abs_tol solid_energy_l_max_its",
239 : "Solid Energy Equation");
240 :
241 : /*
242 : * Parameters to control the solution of each scalar advection system
243 : */
244 3268 : params.addParam<std::vector<Real>>("passive_scalar_equation_relaxation",
245 3268 : std::vector<Real>(),
246 : "The relaxation which should be used for the passive scalar "
247 : "equations. (=1 for no relaxation, "
248 : "diagonal dominance will still be enforced)");
249 :
250 6536 : params.addParam<MultiMooseEnum>("passive_scalar_petsc_options",
251 6536 : Moose::PetscSupport::getCommonPetscFlags(),
252 : "Singleton PETSc options for the passive scalar equation(s)");
253 6536 : params.addParam<MultiMooseEnum>(
254 : "passive_scalar_petsc_options_iname",
255 6536 : Moose::PetscSupport::getCommonPetscKeys(),
256 : "Names of PETSc name/value pairs for the passive scalar equation(s)");
257 6536 : params.addParam<std::vector<std::string>>(
258 : "passive_scalar_petsc_options_value",
259 : "Values of PETSc name/value pairs (must correspond with \"petsc_options_iname\" for the "
260 : "passive scalar equation(s)");
261 3268 : params.addParam<std::vector<Real>>(
262 : "passive_scalar_absolute_tolerance",
263 3268 : std::vector<Real>(),
264 : "The absolute tolerance(s) on the normalized residual(s) of the passive scalar equation(s).");
265 9804 : params.addRangeCheckedParam<Real>("passive_scalar_l_tol",
266 6536 : 1e-5,
267 : "0.0<=passive_scalar_l_tol & passive_scalar_l_tol<1.0",
268 : "The relative tolerance on the normalized residual in the "
269 : "linear solver of the passive scalar equation(s).");
270 9804 : params.addRangeCheckedParam<Real>("passive_scalar_l_abs_tol",
271 6536 : 1e-10,
272 : "0.0<passive_scalar_l_abs_tol",
273 : "The absolute tolerance on the normalized residual in the "
274 : "linear solver of the passive scalar equation(s).");
275 6536 : params.addParam<unsigned int>(
276 : "passive_scalar_l_max_its",
277 6536 : 10000,
278 : "The maximum allowed iterations in the linear solver of the turbulence equation.");
279 :
280 6536 : params.addParamNamesToGroup(
281 : "passive_scalar_systems passive_scalar_equation_relaxation passive_scalar_petsc_options "
282 : "passive_scalar_petsc_options_iname "
283 : "passive_scalar_petsc_options_value passive_scalar_petsc_options_value "
284 : "passive_scalar_absolute_tolerance "
285 : "passive_scalar_l_tol passive_scalar_l_abs_tol passive_scalar_l_max_its",
286 : "passive_scalar Equation");
287 :
288 : /*
289 : * Parameters to control the solution of each turbulence system
290 : */
291 3268 : params.addParam<std::vector<Real>>("turbulence_equation_relaxation",
292 3268 : std::vector<Real>(),
293 : "The relaxation which should be used for the turbulence "
294 : "equations. (=1 for no relaxation, "
295 : "diagonal dominance will still be enforced)");
296 :
297 3268 : params.addParam<std::vector<Real>>("turbulence_field_relaxation",
298 3268 : std::vector<Real>(),
299 : "The relaxation which should be used for the turbulence "
300 : "fields.");
301 :
302 3268 : params.addParam<std::vector<Real>>(
303 : "turbulence_field_min_limit",
304 3268 : std::vector<Real>(),
305 : "The lower limit imposed on turbulent quantities. The recommended value for robustness "
306 : "is 1e-8. This is the imposed default if not set.");
307 :
308 6536 : params.addParam<MultiMooseEnum>("turbulence_petsc_options",
309 6536 : Moose::PetscSupport::getCommonPetscFlags(),
310 : "Singleton PETSc options for the turbulence equation(s)");
311 6536 : params.addParam<MultiMooseEnum>("turbulence_petsc_options_iname",
312 6536 : Moose::PetscSupport::getCommonPetscKeys(),
313 : "Names of PETSc name/value pairs for the turbulence equation(s)");
314 6536 : params.addParam<std::vector<std::string>>(
315 : "turbulence_petsc_options_value",
316 : "Values of PETSc name/value pairs (must correspond with \"petsc_options_iname\" for the "
317 : "turbulence equation(s)");
318 3268 : params.addParam<std::vector<Real>>(
319 : "turbulence_absolute_tolerance",
320 3268 : std::vector<Real>(),
321 : "The absolute tolerance(s) on the normalized residual(s) of the turbulence equation(s).");
322 9804 : params.addRangeCheckedParam<Real>("turbulence_l_tol",
323 6536 : 1e-5,
324 : "0.0<=turbulence_l_tol & turbulence_l_tol<1.0",
325 : "The relative tolerance on the normalized residual in the "
326 : "linear solver of the turbulence equation(s).");
327 9804 : params.addRangeCheckedParam<Real>("turbulence_l_abs_tol",
328 6536 : 1e-10,
329 : "0.0<turbulence_l_abs_tol",
330 : "The absolute tolerance on the normalized residual in the "
331 : "linear solver of the turbulence equation(s).");
332 6536 : params.addParam<unsigned int>(
333 : "turbulence_l_max_its",
334 6536 : 10000,
335 : "The maximum allowed iterations in the linear solver of the turbulence equation.");
336 :
337 6536 : params.addParamNamesToGroup("turbulence_systems "
338 : "turbulence_equation_relaxation "
339 : "turbulence_field_relaxation "
340 : "turbulence_field_min_limit "
341 : "turbulence_petsc_options "
342 : "turbulence_petsc_options_iname "
343 : "turbulence_petsc_options_value turbulence_petsc_options_value "
344 : "turbulence_absolute_tolerance "
345 : "turbulence_l_tol turbulence_l_abs_tol turbulence_l_max_its",
346 : "Turbulence Equations");
347 :
348 : /*
349 : * SIMPLE iteration control
350 : */
351 :
352 9804 : params.addRangeCheckedParam<unsigned int>(
353 : "num_iterations",
354 6536 : 1000,
355 : "0<num_iterations",
356 : "The number of momentum-pressure-(other fields) iterations needed.");
357 :
358 6536 : params.addParam<bool>("continue_on_max_its",
359 6536 : false,
360 : "If solve should continue if maximum number of iterations is hit.");
361 :
362 3268 : return params;
363 0 : }
364 :
365 1634 : SIMPLESolveBase::SIMPLESolveBase(Executioner & ex)
366 : : SolveObject(ex),
367 : UserObjectInterface(this),
368 1634 : _momentum_system_names(getParam<std::vector<SolverSystemName>>("momentum_systems")),
369 3268 : _momentum_l_abs_tol(getParam<Real>("momentum_l_abs_tol")),
370 3268 : _momentum_equation_relaxation(getParam<Real>("momentum_equation_relaxation")),
371 3268 : _pressure_system_name(getParam<SolverSystemName>("pressure_system")),
372 3268 : _pressure_l_abs_tol(getParam<Real>("pressure_l_abs_tol")),
373 3268 : _pressure_variable_relaxation(getParam<Real>("pressure_variable_relaxation")),
374 3268 : _pin_pressure(getParam<bool>("pin_pressure")),
375 3268 : _pressure_pin_value(getParam<Real>("pressure_pin_value")),
376 1634 : _pressure_pin_dof(libMesh::invalid_uint),
377 3268 : _has_energy_system(isParamValid("energy_system")),
378 3268 : _energy_equation_relaxation(getParam<Real>("energy_equation_relaxation")),
379 3268 : _energy_l_abs_tol(getParam<Real>("energy_l_abs_tol")),
380 2150 : _has_solid_energy_system(_has_energy_system && isParamValid("solid_energy_system")),
381 3268 : _solid_energy_l_abs_tol(getParam<Real>("solid_energy_l_abs_tol")),
382 3268 : _passive_scalar_system_names(getParam<std::vector<SolverSystemName>>("passive_scalar_systems")),
383 1634 : _has_passive_scalar_systems(!_passive_scalar_system_names.empty()),
384 3268 : _passive_scalar_equation_relaxation(
385 : getParam<std::vector<Real>>("passive_scalar_equation_relaxation")),
386 3268 : _passive_scalar_l_abs_tol(getParam<Real>("passive_scalar_l_abs_tol")),
387 3268 : _turbulence_system_names(getParam<std::vector<SolverSystemName>>("turbulence_systems")),
388 1634 : _has_turbulence_systems(!_turbulence_system_names.empty()),
389 3268 : _turbulence_equation_relaxation(getParam<std::vector<Real>>("turbulence_equation_relaxation")),
390 3268 : _turbulence_field_relaxation(getParam<std::vector<Real>>("turbulence_field_relaxation")),
391 3268 : _turbulence_field_min_limit(getParam<std::vector<Real>>("turbulence_field_min_limit")),
392 3268 : _turbulence_l_abs_tol(getParam<Real>("turbulence_l_abs_tol")),
393 3268 : _momentum_absolute_tolerance(getParam<Real>("momentum_absolute_tolerance")),
394 3268 : _pressure_absolute_tolerance(getParam<Real>("pressure_absolute_tolerance")),
395 3268 : _energy_absolute_tolerance(getParam<Real>("energy_absolute_tolerance")),
396 3268 : _solid_energy_absolute_tolerance(getParam<Real>("solid_energy_absolute_tolerance")),
397 3268 : _passive_scalar_absolute_tolerance(
398 : getParam<std::vector<Real>>("passive_scalar_absolute_tolerance")),
399 3268 : _turbulence_absolute_tolerance(getParam<std::vector<Real>>("turbulence_absolute_tolerance")),
400 3268 : _num_iterations(getParam<unsigned int>("num_iterations")),
401 3268 : _continue_on_max_its(getParam<bool>("continue_on_max_its")),
402 14706 : _print_fields(getParam<bool>("print_fields"))
403 : {
404 1634 : if (_momentum_system_names.size() != _problem.mesh().dimension())
405 0 : paramError("momentum_systems",
406 : "The number of momentum components should be equal to the number of "
407 : "spatial dimensions on the mesh.");
408 :
409 1634 : const auto & momentum_petsc_options = getParam<MultiMooseEnum>("momentum_petsc_options");
410 : const auto & momentum_petsc_pair_options = getParam<MooseEnumItem, std::string>(
411 3268 : "momentum_petsc_options_iname", "momentum_petsc_options_value");
412 1634 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
413 : momentum_petsc_options, "", *this, _momentum_petsc_options);
414 3268 : Moose::PetscSupport::addPetscPairsToPetscOptions(
415 1634 : momentum_petsc_pair_options, _problem.mesh().dimension(), "", *this, _momentum_petsc_options);
416 :
417 3268 : _momentum_linear_control.real_valued_data["rel_tol"] = getParam<Real>("momentum_l_tol");
418 3268 : _momentum_linear_control.real_valued_data["abs_tol"] = getParam<Real>("momentum_l_abs_tol");
419 1634 : _momentum_linear_control.int_valued_data["max_its"] =
420 3268 : getParam<unsigned int>("momentum_l_max_its");
421 :
422 1634 : const auto & pressure_petsc_options = getParam<MultiMooseEnum>("pressure_petsc_options");
423 : const auto & pressure_petsc_pair_options = getParam<MooseEnumItem, std::string>(
424 3268 : "pressure_petsc_options_iname", "pressure_petsc_options_value");
425 1634 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
426 : pressure_petsc_options, "", *this, _pressure_petsc_options);
427 3268 : Moose::PetscSupport::addPetscPairsToPetscOptions(
428 1634 : pressure_petsc_pair_options, _problem.mesh().dimension(), "", *this, _pressure_petsc_options);
429 :
430 3268 : _pressure_linear_control.real_valued_data["rel_tol"] = getParam<Real>("pressure_l_tol");
431 3268 : _pressure_linear_control.real_valued_data["abs_tol"] = getParam<Real>("pressure_l_abs_tol");
432 1634 : _pressure_linear_control.int_valued_data["max_its"] =
433 3268 : getParam<unsigned int>("pressure_l_max_its");
434 :
435 1634 : if (_has_energy_system)
436 : {
437 516 : const auto & energy_petsc_options = getParam<MultiMooseEnum>("energy_petsc_options");
438 : const auto & energy_petsc_pair_options = getParam<MooseEnumItem, std::string>(
439 1032 : "energy_petsc_options_iname", "energy_petsc_options_value");
440 516 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
441 : energy_petsc_options, "", *this, _energy_petsc_options);
442 1032 : Moose::PetscSupport::addPetscPairsToPetscOptions(
443 516 : energy_petsc_pair_options, _problem.mesh().dimension(), "", *this, _energy_petsc_options);
444 :
445 1032 : _energy_linear_control.real_valued_data["rel_tol"] = getParam<Real>("energy_l_tol");
446 1032 : _energy_linear_control.real_valued_data["abs_tol"] = getParam<Real>("energy_l_abs_tol");
447 1032 : _energy_linear_control.int_valued_data["max_its"] = getParam<unsigned int>("energy_l_max_its");
448 516 : }
449 : else
450 2236 : checkDependentParameterError("energy_system",
451 : {"energy_petsc_options",
452 : "energy_petsc_options_iname",
453 : "energy_petsc_options_value",
454 : "energy_l_tol",
455 : "energy_l_abs_tol",
456 : "energy_l_max_its",
457 : "energy_absolute_tolerance",
458 : "energy_equation_relaxation"},
459 : false);
460 :
461 1634 : if (_has_solid_energy_system)
462 : {
463 : const auto & solid_energy_petsc_options =
464 63 : getParam<MultiMooseEnum>("solid_energy_petsc_options");
465 : const auto & solid_energy_petsc_pair_options = getParam<MooseEnumItem, std::string>(
466 126 : "solid_energy_petsc_options_iname", "solid_energy_petsc_options_value");
467 63 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
468 : solid_energy_petsc_options, "", *this, _solid_energy_petsc_options);
469 126 : Moose::PetscSupport::addPetscPairsToPetscOptions(solid_energy_petsc_pair_options,
470 63 : _problem.mesh().dimension(),
471 : "",
472 : *this,
473 : _solid_energy_petsc_options);
474 :
475 126 : _solid_energy_linear_control.real_valued_data["rel_tol"] = getParam<Real>("solid_energy_l_tol");
476 63 : _solid_energy_linear_control.real_valued_data["abs_tol"] =
477 126 : getParam<Real>("solid_energy_l_abs_tol");
478 63 : _solid_energy_linear_control.int_valued_data["max_its"] =
479 126 : getParam<unsigned int>("solid_energy_l_max_its");
480 63 : }
481 : else
482 3142 : checkDependentParameterError("solid_energy_system",
483 : {"solid_energy_petsc_options",
484 : "solid_energy_petsc_options_iname",
485 : "solid_energy_petsc_options_value",
486 : "solid_energy_l_tol",
487 : "solid_energy_l_abs_tol",
488 : "solid_energy_l_max_its",
489 : "solid_energy_absolute_tolerance",
490 : "solid_energy_equation_relaxation"},
491 : false);
492 :
493 : // We check for input errors with regards to the passive scalar equations. At the same time, we
494 : // set up the corresponding system numbers
495 1634 : if (_has_passive_scalar_systems)
496 : {
497 101 : if (_passive_scalar_system_names.size() != _passive_scalar_equation_relaxation.size())
498 0 : paramError("passive_scalar_equation_relaxation",
499 : "The number of equation relaxation parameters does not match the number of "
500 : "passive scalar equations!");
501 101 : if (_passive_scalar_system_names.size() != _passive_scalar_absolute_tolerance.size())
502 0 : paramError("passive_scalar_absolute_tolerance",
503 : "The number of absolute tolerances does not match the number of "
504 : "passive scalar equations!");
505 : }
506 1634 : if (_has_passive_scalar_systems)
507 : {
508 : const auto & passive_scalar_petsc_options =
509 101 : getParam<MultiMooseEnum>("passive_scalar_petsc_options");
510 : const auto & passive_scalar_petsc_pair_options = getParam<MooseEnumItem, std::string>(
511 202 : "passive_scalar_petsc_options_iname", "passive_scalar_petsc_options_value");
512 101 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
513 : passive_scalar_petsc_options, "", *this, _passive_scalar_petsc_options);
514 202 : Moose::PetscSupport::addPetscPairsToPetscOptions(passive_scalar_petsc_pair_options,
515 101 : _problem.mesh().dimension(),
516 : "",
517 : *this,
518 : _passive_scalar_petsc_options);
519 :
520 101 : _passive_scalar_linear_control.real_valued_data["rel_tol"] =
521 202 : getParam<Real>("passive_scalar_l_tol");
522 101 : _passive_scalar_linear_control.real_valued_data["abs_tol"] =
523 202 : getParam<Real>("passive_scalar_l_abs_tol");
524 101 : _passive_scalar_linear_control.int_valued_data["max_its"] =
525 202 : getParam<unsigned int>("passive_scalar_l_max_its");
526 101 : }
527 : else
528 3066 : checkDependentParameterError("passive_scalar_systems",
529 : {"passive_scalar_petsc_options",
530 : "passive_scalar_petsc_options_iname",
531 : "passive_scalar_petsc_options_value",
532 : "passive_scalar_l_tol",
533 : "passive_scalar_l_abs_tol",
534 : "passive_scalar_l_max_its",
535 : "passive_scalar_equation_relaxation",
536 : "passive_scalar_absolute_tolerance"},
537 : false);
538 :
539 : // We check for input errors with regards to the surrogate turbulence equations. At the same time,
540 : // we set up the corresponding system numbers
541 1634 : if (_has_turbulence_systems)
542 : {
543 347 : if (_turbulence_system_names.size() != _turbulence_equation_relaxation.size())
544 0 : paramError("turbulence_equation_relaxation",
545 : "The number of equation relaxation parameters does not match the number of "
546 : "turbulence equations!");
547 347 : if (_turbulence_system_names.size() != _turbulence_absolute_tolerance.size())
548 0 : paramError("turbulence_absolute_tolerance",
549 : "The number of absolute tolerances does not match the number of "
550 : "turbulence equations!");
551 347 : if (_turbulence_field_min_limit.empty())
552 : // If no minimum bounds are given, initialize to default value 1e-8
553 347 : _turbulence_field_min_limit.resize(_turbulence_system_names.size(), 1e-8);
554 :
555 : // Assign turbulence field relaxation as 1.0 if not defined
556 347 : if (_turbulence_field_relaxation.empty())
557 320 : _turbulence_field_relaxation.resize(_turbulence_system_names.size(), 1.0);
558 :
559 347 : const auto & turbulence_petsc_options = getParam<MultiMooseEnum>("turbulence_petsc_options");
560 : const auto & turbulence_petsc_pair_options = getParam<MooseEnumItem, std::string>(
561 694 : "turbulence_petsc_options_iname", "turbulence_petsc_options_value");
562 347 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
563 : turbulence_petsc_options, "", *this, _turbulence_petsc_options);
564 694 : Moose::PetscSupport::addPetscPairsToPetscOptions(turbulence_petsc_pair_options,
565 347 : _problem.mesh().dimension(),
566 : "",
567 : *this,
568 : _turbulence_petsc_options);
569 :
570 694 : _turbulence_linear_control.real_valued_data["rel_tol"] = getParam<Real>("turbulence_l_tol");
571 694 : _turbulence_linear_control.real_valued_data["abs_tol"] = getParam<Real>("turbulence_l_abs_tol");
572 347 : _turbulence_linear_control.int_valued_data["max_its"] =
573 694 : getParam<unsigned int>("turbulence_l_max_its");
574 347 : }
575 : else
576 2574 : checkDependentParameterError("turbulence_systems",
577 : {"turbulence_petsc_options",
578 : "turbulence_petsc_options_iname",
579 : "turbulence_petsc_options_value",
580 : "turbulence_l_tol",
581 : "turbulence_l_abs_tol",
582 : "turbulence_l_max_its",
583 : "turbulence_equation_relaxation",
584 : "turbulence_field_relaxation",
585 : "turbulence_field_min_limit",
586 : "turbulence_absolute_tolerance"},
587 : false);
588 1634 : }
589 :
590 : void
591 1632 : SIMPLESolveBase::setupPressurePin()
592 : {
593 1632 : if (_pin_pressure)
594 1736 : _pressure_pin_dof = NS::FV::findPointDoFID(_problem.getVariable(0, "pressure"),
595 868 : _problem.mesh(),
596 : getParam<Point>("pressure_pin_point"));
597 1632 : }
598 :
599 : void
600 5957 : SIMPLESolveBase::checkDependentParameterError(const std::string & main_parameter,
601 : const std::vector<std::string> & dependent_parameters,
602 : const bool should_be_defined)
603 : {
604 56187 : for (const auto & param : dependent_parameters)
605 50230 : if (parameters().isParamSetByUser(param) == !should_be_defined)
606 0 : paramError(param,
607 0 : "This parameter should " + std::string(should_be_defined ? "" : "not") +
608 0 : " be given by the user with the corresponding " + main_parameter +
609 : " setting!");
610 5957 : }
|