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