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 3102 : SIMPLESolveBase::validParams()
16 : {
17 3102 : InputParameters params = emptyInputParameters();
18 6204 : 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 6204 : params.addRequiredParam<std::vector<SolverSystemName>>(
24 : "momentum_systems", "The solver system(s) for the momentum equation(s).");
25 6204 : params.addRequiredParam<SolverSystemName>("pressure_system",
26 : "The solver system for the pressure equation.");
27 6204 : params.addParam<SolverSystemName>("energy_system", "The solver system for the energy equation.");
28 6204 : params.addParam<SolverSystemName>("solid_energy_system",
29 : "The solver system for the solid energy equation.");
30 6204 : params.addParam<std::vector<SolverSystemName>>(
31 : "passive_scalar_systems", {}, "The solver system for each scalar advection equation.");
32 6204 : 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 9306 : params.addRangeCheckedParam<Real>(
40 : "momentum_equation_relaxation",
41 6204 : 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 6204 : params.addParam<MultiMooseEnum>("momentum_petsc_options",
47 6204 : Moose::PetscSupport::getCommonPetscFlags(),
48 : "Singleton PETSc options for the momentum equation");
49 6204 : params.addParam<MultiMooseEnum>("momentum_petsc_options_iname",
50 6204 : Moose::PetscSupport::getCommonPetscKeys(),
51 : "Names of PETSc name/value pairs for the momentum equation");
52 6204 : 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 9306 : params.addRangeCheckedParam<Real>(
58 : "momentum_absolute_tolerance",
59 6204 : 1e-5,
60 : "0.0<momentum_absolute_tolerance",
61 : "The absolute tolerance on the normalized residual of the momentum equation.");
62 :
63 9306 : params.addRangeCheckedParam<Real>("momentum_l_tol",
64 6204 : 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 9306 : params.addRangeCheckedParam<Real>("momentum_l_abs_tol",
69 6204 : 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 6204 : params.addParam<unsigned int>(
74 : "momentum_l_max_its",
75 6204 : 10000,
76 : "The maximum allowed iterations in the linear solver of the momentum equation.");
77 :
78 6204 : 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 9306 : params.addRangeCheckedParam<Real>(
88 : "pressure_variable_relaxation",
89 6204 : 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 6204 : params.addParam<MultiMooseEnum>("pressure_petsc_options",
94 6204 : Moose::PetscSupport::getCommonPetscFlags(),
95 : "Singleton PETSc options for the pressure equation");
96 6204 : params.addParam<MultiMooseEnum>("pressure_petsc_options_iname",
97 6204 : Moose::PetscSupport::getCommonPetscKeys(),
98 : "Names of PETSc name/value pairs for the pressure equation");
99 6204 : 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 9306 : params.addRangeCheckedParam<Real>(
105 : "pressure_absolute_tolerance",
106 6204 : 1e-5,
107 : "0.0<pressure_absolute_tolerance",
108 : "The absolute tolerance on the normalized residual of the pressure equation.");
109 :
110 9306 : params.addRangeCheckedParam<Real>("pressure_l_tol",
111 6204 : 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 9306 : params.addRangeCheckedParam<Real>("pressure_l_abs_tol",
116 6204 : 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 6204 : params.addParam<unsigned int>(
121 : "pressure_l_max_its",
122 6204 : 10000,
123 : "The maximum allowed iterations in the linear solver of the pressure equation.");
124 :
125 6204 : 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 6204 : params.addParam<bool>(
136 6204 : "pin_pressure", false, "If the pressure field needs to be pinned at a point.");
137 6204 : params.addParam<Real>(
138 6204 : "pressure_pin_value", 0.0, "The value which needs to be enforced for the pressure.");
139 6204 : params.addParam<Point>("pressure_pin_point", "The point where the pressure needs to be pinned.");
140 :
141 6204 : params.addParamNamesToGroup("pin_pressure pressure_pin_value pressure_pin_point", "Pressure Pin");
142 :
143 6204 : params.addParam<bool>(
144 : "print_fields",
145 6204 : 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 9306 : params.addRangeCheckedParam<Real>(
153 : "energy_equation_relaxation",
154 6204 : 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 6204 : params.addParam<MultiMooseEnum>("energy_petsc_options",
160 6204 : Moose::PetscSupport::getCommonPetscFlags(),
161 : "Singleton PETSc options for the energy equation");
162 6204 : params.addParam<MultiMooseEnum>("energy_petsc_options_iname",
163 6204 : Moose::PetscSupport::getCommonPetscKeys(),
164 : "Names of PETSc name/value pairs for the energy equation");
165 6204 : 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 9306 : params.addRangeCheckedParam<Real>(
171 : "energy_absolute_tolerance",
172 6204 : 1e-5,
173 : "0.0<energy_absolute_tolerance",
174 : "The absolute tolerance on the normalized residual of the energy equation.");
175 :
176 9306 : params.addRangeCheckedParam<Real>("energy_l_tol",
177 6204 : 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 9306 : params.addRangeCheckedParam<Real>("energy_l_abs_tol",
182 6204 : 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 9306 : params.addRangeCheckedParam<unsigned int>(
187 : "energy_l_max_its",
188 6204 : 10000,
189 : "0<energy_l_max_its",
190 : "The maximum allowed iterations in the linear solver of the energy equation.");
191 :
192 6204 : 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 6204 : params.addParam<MultiMooseEnum>("solid_energy_petsc_options",
203 6204 : Moose::PetscSupport::getCommonPetscFlags(),
204 : "Singleton PETSc options for the solid energy equation");
205 6204 : params.addParam<MultiMooseEnum>("solid_energy_petsc_options_iname",
206 6204 : Moose::PetscSupport::getCommonPetscKeys(),
207 : "Names of PETSc name/value pairs for the solid energy equation");
208 6204 : 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 9306 : params.addRangeCheckedParam<Real>(
214 : "solid_energy_absolute_tolerance",
215 6204 : 1e-5,
216 : "0.0<solid_energy_absolute_tolerance",
217 : "The absolute tolerance on the normalized residual of the solid energy equation.");
218 :
219 9306 : params.addRangeCheckedParam<Real>("solid_energy_l_tol",
220 6204 : 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 9306 : params.addRangeCheckedParam<Real>("solid_energy_l_abs_tol",
226 6204 : 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 9306 : params.addRangeCheckedParam<unsigned int>(
231 : "solid_energy_l_max_its",
232 6204 : 10000,
233 : "0<solid_energy_l_max_its",
234 : "The maximum allowed iterations in the linear solver of the solid energy equation.");
235 :
236 6204 : 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 3102 : params.addParam<std::vector<Real>>("passive_scalar_equation_relaxation",
245 3102 : 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 6204 : params.addParam<MultiMooseEnum>("passive_scalar_petsc_options",
251 6204 : Moose::PetscSupport::getCommonPetscFlags(),
252 : "Singleton PETSc options for the passive scalar equation(s)");
253 6204 : params.addParam<MultiMooseEnum>(
254 : "passive_scalar_petsc_options_iname",
255 6204 : Moose::PetscSupport::getCommonPetscKeys(),
256 : "Names of PETSc name/value pairs for the passive scalar equation(s)");
257 6204 : 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 3102 : params.addParam<std::vector<Real>>(
262 : "passive_scalar_absolute_tolerance",
263 3102 : std::vector<Real>(),
264 : "The absolute tolerance(s) on the normalized residual(s) of the passive scalar equation(s).");
265 9306 : params.addRangeCheckedParam<Real>("passive_scalar_l_tol",
266 6204 : 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 9306 : params.addRangeCheckedParam<Real>("passive_scalar_l_abs_tol",
271 6204 : 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 6204 : params.addParam<unsigned int>(
276 : "passive_scalar_l_max_its",
277 6204 : 10000,
278 : "The maximum allowed iterations in the linear solver of the turbulence equation.");
279 :
280 6204 : 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 3102 : params.addParam<std::vector<Real>>("turbulence_equation_relaxation",
292 3102 : 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 3102 : params.addParam<std::vector<Real>>("turbulence_field_relaxation",
298 3102 : std::vector<Real>(),
299 : "The relaxation which should be used for the turbulence "
300 : "fields.");
301 :
302 3102 : params.addParam<std::vector<Real>>(
303 : "turbulence_field_min_limit",
304 3102 : 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 6204 : params.addParam<MultiMooseEnum>("turbulence_petsc_options",
309 6204 : Moose::PetscSupport::getCommonPetscFlags(),
310 : "Singleton PETSc options for the turbulence equation(s)");
311 6204 : params.addParam<MultiMooseEnum>("turbulence_petsc_options_iname",
312 6204 : Moose::PetscSupport::getCommonPetscKeys(),
313 : "Names of PETSc name/value pairs for the turbulence equation(s)");
314 6204 : 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 3102 : params.addParam<std::vector<Real>>(
319 : "turbulence_absolute_tolerance",
320 3102 : std::vector<Real>(),
321 : "The absolute tolerance(s) on the normalized residual(s) of the turbulence equation(s).");
322 9306 : params.addRangeCheckedParam<Real>("turbulence_l_tol",
323 6204 : 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 9306 : params.addRangeCheckedParam<Real>("turbulence_l_abs_tol",
328 6204 : 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 6204 : params.addParam<unsigned int>(
333 : "turbulence_l_max_its",
334 6204 : 10000,
335 : "The maximum allowed iterations in the linear solver of the turbulence equation.");
336 :
337 6204 : 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 9306 : params.addRangeCheckedParam<unsigned int>(
353 : "num_iterations",
354 6204 : 1000,
355 : "0<num_iterations",
356 : "The number of momentum-pressure-(other fields) iterations needed.");
357 :
358 6204 : params.addParam<bool>("continue_on_max_its",
359 6204 : false,
360 : "If solve should continue if maximum number of iterations is hit.");
361 :
362 3102 : return params;
363 0 : }
364 :
365 1551 : SIMPLESolveBase::SIMPLESolveBase(Executioner & ex)
366 : : SolveObject(ex),
367 : UserObjectInterface(this),
368 1551 : _momentum_system_names(getParam<std::vector<SolverSystemName>>("momentum_systems")),
369 3102 : _momentum_l_abs_tol(getParam<Real>("momentum_l_abs_tol")),
370 3102 : _momentum_equation_relaxation(getParam<Real>("momentum_equation_relaxation")),
371 3102 : _pressure_system_name(getParam<SolverSystemName>("pressure_system")),
372 3102 : _pressure_l_abs_tol(getParam<Real>("pressure_l_abs_tol")),
373 3102 : _pressure_variable_relaxation(getParam<Real>("pressure_variable_relaxation")),
374 3102 : _pin_pressure(getParam<bool>("pin_pressure")),
375 3102 : _pressure_pin_value(getParam<Real>("pressure_pin_value")),
376 1551 : _pressure_pin_dof(libMesh::invalid_uint),
377 3102 : _has_energy_system(isParamValid("energy_system")),
378 3102 : _energy_equation_relaxation(getParam<Real>("energy_equation_relaxation")),
379 3102 : _energy_l_abs_tol(getParam<Real>("energy_l_abs_tol")),
380 1993 : _has_solid_energy_system(_has_energy_system && isParamValid("solid_energy_system")),
381 3102 : _solid_energy_l_abs_tol(getParam<Real>("solid_energy_l_abs_tol")),
382 3102 : _passive_scalar_system_names(getParam<std::vector<SolverSystemName>>("passive_scalar_systems")),
383 1551 : _has_passive_scalar_systems(!_passive_scalar_system_names.empty()),
384 3102 : _passive_scalar_equation_relaxation(
385 : getParam<std::vector<Real>>("passive_scalar_equation_relaxation")),
386 3102 : _passive_scalar_l_abs_tol(getParam<Real>("passive_scalar_l_abs_tol")),
387 3102 : _turbulence_system_names(getParam<std::vector<SolverSystemName>>("turbulence_systems")),
388 1551 : _has_turbulence_systems(!_turbulence_system_names.empty()),
389 3102 : _turbulence_equation_relaxation(getParam<std::vector<Real>>("turbulence_equation_relaxation")),
390 3102 : _turbulence_field_relaxation(getParam<std::vector<Real>>("turbulence_field_relaxation")),
391 3102 : _turbulence_field_min_limit(getParam<std::vector<Real>>("turbulence_field_min_limit")),
392 3102 : _turbulence_l_abs_tol(getParam<Real>("turbulence_l_abs_tol")),
393 3102 : _momentum_absolute_tolerance(getParam<Real>("momentum_absolute_tolerance")),
394 3102 : _pressure_absolute_tolerance(getParam<Real>("pressure_absolute_tolerance")),
395 3102 : _energy_absolute_tolerance(getParam<Real>("energy_absolute_tolerance")),
396 3102 : _solid_energy_absolute_tolerance(getParam<Real>("solid_energy_absolute_tolerance")),
397 3102 : _passive_scalar_absolute_tolerance(
398 : getParam<std::vector<Real>>("passive_scalar_absolute_tolerance")),
399 3102 : _turbulence_absolute_tolerance(getParam<std::vector<Real>>("turbulence_absolute_tolerance")),
400 3102 : _num_iterations(getParam<unsigned int>("num_iterations")),
401 3102 : _continue_on_max_its(getParam<bool>("continue_on_max_its")),
402 13959 : _print_fields(getParam<bool>("print_fields"))
403 : {
404 1551 : 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 1551 : const auto & momentum_petsc_options = getParam<MultiMooseEnum>("momentum_petsc_options");
410 : const auto & momentum_petsc_pair_options = getParam<MooseEnumItem, std::string>(
411 3102 : "momentum_petsc_options_iname", "momentum_petsc_options_value");
412 1551 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
413 : momentum_petsc_options, "-", *this, _momentum_petsc_options);
414 3102 : Moose::PetscSupport::addPetscPairsToPetscOptions(momentum_petsc_pair_options,
415 1551 : _problem.mesh().dimension(),
416 : "-",
417 : *this,
418 : _momentum_petsc_options);
419 :
420 3102 : _momentum_linear_control.real_valued_data["rel_tol"] = getParam<Real>("momentum_l_tol");
421 3102 : _momentum_linear_control.real_valued_data["abs_tol"] = getParam<Real>("momentum_l_abs_tol");
422 1551 : _momentum_linear_control.int_valued_data["max_its"] =
423 3102 : getParam<unsigned int>("momentum_l_max_its");
424 :
425 1551 : const auto & pressure_petsc_options = getParam<MultiMooseEnum>("pressure_petsc_options");
426 : const auto & pressure_petsc_pair_options = getParam<MooseEnumItem, std::string>(
427 3102 : "pressure_petsc_options_iname", "pressure_petsc_options_value");
428 1551 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
429 : pressure_petsc_options, "-", *this, _pressure_petsc_options);
430 3102 : Moose::PetscSupport::addPetscPairsToPetscOptions(pressure_petsc_pair_options,
431 1551 : _problem.mesh().dimension(),
432 : "-",
433 : *this,
434 : _pressure_petsc_options);
435 :
436 3102 : _pressure_linear_control.real_valued_data["rel_tol"] = getParam<Real>("pressure_l_tol");
437 3102 : _pressure_linear_control.real_valued_data["abs_tol"] = getParam<Real>("pressure_l_abs_tol");
438 1551 : _pressure_linear_control.int_valued_data["max_its"] =
439 3102 : getParam<unsigned int>("pressure_l_max_its");
440 :
441 1551 : if (_has_energy_system)
442 : {
443 442 : const auto & energy_petsc_options = getParam<MultiMooseEnum>("energy_petsc_options");
444 : const auto & energy_petsc_pair_options = getParam<MooseEnumItem, std::string>(
445 884 : "energy_petsc_options_iname", "energy_petsc_options_value");
446 442 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
447 : energy_petsc_options, "-", *this, _energy_petsc_options);
448 884 : Moose::PetscSupport::addPetscPairsToPetscOptions(
449 442 : energy_petsc_pair_options, _problem.mesh().dimension(), "-", *this, _energy_petsc_options);
450 :
451 884 : _energy_linear_control.real_valued_data["rel_tol"] = getParam<Real>("energy_l_tol");
452 884 : _energy_linear_control.real_valued_data["abs_tol"] = getParam<Real>("energy_l_abs_tol");
453 884 : _energy_linear_control.int_valued_data["max_its"] = getParam<unsigned int>("energy_l_max_its");
454 442 : }
455 : else
456 2218 : checkDependentParameterError("energy_system",
457 : {"energy_petsc_options",
458 : "energy_petsc_options_iname",
459 : "energy_petsc_options_value",
460 : "energy_l_tol",
461 : "energy_l_abs_tol",
462 : "energy_l_max_its",
463 : "energy_absolute_tolerance",
464 : "energy_equation_relaxation"},
465 : false);
466 :
467 1551 : if (_has_solid_energy_system)
468 : {
469 : const auto & solid_energy_petsc_options =
470 27 : getParam<MultiMooseEnum>("solid_energy_petsc_options");
471 : const auto & solid_energy_petsc_pair_options = getParam<MooseEnumItem, std::string>(
472 54 : "solid_energy_petsc_options_iname", "solid_energy_petsc_options_value");
473 27 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
474 : solid_energy_petsc_options, "-", *this, _solid_energy_petsc_options);
475 54 : Moose::PetscSupport::addPetscPairsToPetscOptions(solid_energy_petsc_pair_options,
476 27 : _problem.mesh().dimension(),
477 : "-",
478 : *this,
479 : _solid_energy_petsc_options);
480 :
481 54 : _solid_energy_linear_control.real_valued_data["rel_tol"] = getParam<Real>("solid_energy_l_tol");
482 27 : _solid_energy_linear_control.real_valued_data["abs_tol"] =
483 54 : getParam<Real>("solid_energy_l_abs_tol");
484 27 : _solid_energy_linear_control.int_valued_data["max_its"] =
485 54 : getParam<unsigned int>("solid_energy_l_max_its");
486 27 : }
487 : else
488 3048 : checkDependentParameterError("solid_energy_system",
489 : {"solid_energy_petsc_options",
490 : "solid_energy_petsc_options_iname",
491 : "solid_energy_petsc_options_value",
492 : "solid_energy_l_tol",
493 : "solid_energy_l_abs_tol",
494 : "solid_energy_l_max_its",
495 : "solid_energy_absolute_tolerance",
496 : "solid_energy_equation_relaxation"},
497 : false);
498 :
499 : // We check for input errors with regards to the passive scalar equations. At the same time, we
500 : // set up the corresponding system numbers
501 1551 : if (_has_passive_scalar_systems)
502 : {
503 101 : if (_passive_scalar_system_names.size() != _passive_scalar_equation_relaxation.size())
504 0 : paramError("passive_scalar_equation_relaxation",
505 : "The number of equation relaxation parameters does not match the number of "
506 : "passive scalar equations!");
507 101 : if (_passive_scalar_system_names.size() != _passive_scalar_absolute_tolerance.size())
508 0 : paramError("passive_scalar_absolute_tolerance",
509 : "The number of absolute tolerances does not match the number of "
510 : "passive scalar equations!");
511 : }
512 1551 : if (_has_passive_scalar_systems)
513 : {
514 : const auto & passive_scalar_petsc_options =
515 101 : getParam<MultiMooseEnum>("passive_scalar_petsc_options");
516 : const auto & passive_scalar_petsc_pair_options = getParam<MooseEnumItem, std::string>(
517 202 : "passive_scalar_petsc_options_iname", "passive_scalar_petsc_options_value");
518 101 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
519 : passive_scalar_petsc_options, "-", *this, _passive_scalar_petsc_options);
520 202 : Moose::PetscSupport::addPetscPairsToPetscOptions(passive_scalar_petsc_pair_options,
521 101 : _problem.mesh().dimension(),
522 : "-",
523 : *this,
524 : _passive_scalar_petsc_options);
525 :
526 101 : _passive_scalar_linear_control.real_valued_data["rel_tol"] =
527 202 : getParam<Real>("passive_scalar_l_tol");
528 101 : _passive_scalar_linear_control.real_valued_data["abs_tol"] =
529 202 : getParam<Real>("passive_scalar_l_abs_tol");
530 101 : _passive_scalar_linear_control.int_valued_data["max_its"] =
531 202 : getParam<unsigned int>("passive_scalar_l_max_its");
532 101 : }
533 : else
534 2900 : checkDependentParameterError("passive_scalar_systems",
535 : {"passive_scalar_petsc_options",
536 : "passive_scalar_petsc_options_iname",
537 : "passive_scalar_petsc_options_value",
538 : "passive_scalar_l_tol",
539 : "passive_scalar_l_abs_tol",
540 : "passive_scalar_l_max_its",
541 : "passive_scalar_equation_relaxation",
542 : "passive_scalar_absolute_tolerance"},
543 : false);
544 :
545 : // We check for input errors with regards to the surrogate turbulence equations. At the same time,
546 : // we set up the corresponding system numbers
547 1551 : if (_has_turbulence_systems)
548 : {
549 338 : if (_turbulence_system_names.size() != _turbulence_equation_relaxation.size())
550 0 : paramError("turbulence_equation_relaxation",
551 : "The number of equation relaxation parameters does not match the number of "
552 : "turbulence equations!");
553 338 : if (_turbulence_system_names.size() != _turbulence_absolute_tolerance.size())
554 0 : paramError("turbulence_absolute_tolerance",
555 : "The number of absolute tolerances does not match the number of "
556 : "turbulence equations!");
557 338 : if (_turbulence_field_min_limit.empty())
558 : // If no minimum bounds are given, initialize to default value 1e-8
559 338 : _turbulence_field_min_limit.resize(_turbulence_system_names.size(), 1e-8);
560 :
561 : // Assign turbulence field relaxation as 1.0 if not defined
562 338 : if (_turbulence_field_relaxation.empty())
563 320 : _turbulence_field_relaxation.resize(_turbulence_system_names.size(), 1.0);
564 :
565 338 : const auto & turbulence_petsc_options = getParam<MultiMooseEnum>("turbulence_petsc_options");
566 : const auto & turbulence_petsc_pair_options = getParam<MooseEnumItem, std::string>(
567 676 : "turbulence_petsc_options_iname", "turbulence_petsc_options_value");
568 338 : Moose::PetscSupport::addPetscFlagsToPetscOptions(
569 : turbulence_petsc_options, "-", *this, _turbulence_petsc_options);
570 676 : Moose::PetscSupport::addPetscPairsToPetscOptions(turbulence_petsc_pair_options,
571 338 : _problem.mesh().dimension(),
572 : "-",
573 : *this,
574 : _turbulence_petsc_options);
575 :
576 676 : _turbulence_linear_control.real_valued_data["rel_tol"] = getParam<Real>("turbulence_l_tol");
577 676 : _turbulence_linear_control.real_valued_data["abs_tol"] = getParam<Real>("turbulence_l_abs_tol");
578 338 : _turbulence_linear_control.int_valued_data["max_its"] =
579 676 : getParam<unsigned int>("turbulence_l_max_its");
580 338 : }
581 : else
582 2426 : checkDependentParameterError("turbulence_systems",
583 : {"turbulence_petsc_options",
584 : "turbulence_petsc_options_iname",
585 : "turbulence_petsc_options_value",
586 : "turbulence_l_tol",
587 : "turbulence_l_abs_tol",
588 : "turbulence_l_max_its",
589 : "turbulence_equation_relaxation",
590 : "turbulence_field_relaxation",
591 : "turbulence_field_min_limit",
592 : "turbulence_absolute_tolerance"},
593 : false);
594 1551 : }
595 :
596 : void
597 1549 : SIMPLESolveBase::setupPressurePin()
598 : {
599 1549 : if (_pin_pressure)
600 1660 : _pressure_pin_dof = NS::FV::findPointDoFID(_problem.getVariable(0, "pressure"),
601 830 : _problem.mesh(),
602 : getParam<Point>("pressure_pin_point"));
603 1549 : }
604 :
605 : void
606 5744 : SIMPLESolveBase::checkDependentParameterError(const std::string & main_parameter,
607 : const std::vector<std::string> & dependent_parameters,
608 : const bool should_be_defined)
609 : {
610 54122 : for (const auto & param : dependent_parameters)
611 48378 : if (parameters().isParamSetByUser(param) == !should_be_defined)
612 0 : paramError(param,
613 0 : "This parameter should " + std::string(should_be_defined ? "" : "not") +
614 0 : " be given by the user with the corresponding " + main_parameter +
615 : " setting!");
616 5744 : }
|