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 : // Navier-Stokes includes
11 : #include "INSAction.h"
12 :
13 : #include "NS.h"
14 : #include "AddVariableAction.h"
15 : #include "MooseObject.h"
16 : #include "INSADObjectTracker.h"
17 : #include "NonlinearSystemBase.h"
18 :
19 : // MOOSE includes
20 : #include "FEProblem.h"
21 :
22 : #include "libmesh/fe.h"
23 : #include "libmesh/vector_value.h"
24 : #include "libmesh/string_to_enum.h"
25 :
26 : using namespace libMesh;
27 :
28 : registerMooseAction("NavierStokesApp", INSAction, "append_mesh_generator");
29 : registerMooseAction("NavierStokesApp", INSAction, "add_navier_stokes_variables");
30 : registerMooseAction("NavierStokesApp", INSAction, "add_navier_stokes_ics");
31 : registerMooseAction("NavierStokesApp", INSAction, "add_navier_stokes_kernels");
32 : registerMooseAction("NavierStokesApp", INSAction, "add_navier_stokes_bcs");
33 : registerMooseAction("NavierStokesApp", INSAction, "add_material");
34 :
35 : InputParameters
36 424 : INSAction::validParams()
37 : {
38 424 : InputParameters params = Action::validParams();
39 424 : params.addClassDescription("This class allows us to have a section of the input file for "
40 : "setting up incompressible Navier-Stokes equations.");
41 :
42 848 : MooseEnum type("steady-state transient", "steady-state");
43 848 : params.addParam<MooseEnum>("equation_type", type, "Navier-Stokes equation type");
44 :
45 848 : params.addParam<std::vector<SubdomainName>>(
46 : "block", {}, "The list of block ids (SubdomainID) on which NS equation is defined on");
47 :
48 : // temperature equation parameters
49 848 : params.addParam<bool>("boussinesq_approximation", false, "True to have Boussinesq approximation");
50 848 : params.addParam<MaterialPropertyName>(
51 : "reference_temperature_name", "temp_ref", "Material property name for reference temperature");
52 848 : params.addParam<MaterialPropertyName>(
53 : "thermal_expansion_name", "alpha", "The name of the thermal expansion");
54 :
55 848 : params.addParam<bool>("add_temperature_equation", false, "True to add temperature equation");
56 848 : params.addParam<VariableName>(
57 : "temperature_variable", NS::temperature, "Temperature variable name");
58 848 : params.addParam<Real>("temperature_scaling", 1, "Scaling for the temperature variable");
59 848 : params.addParam<Real>(
60 848 : "initial_temperature", 0, "The initial temperature, assumed constant everywhere");
61 848 : params.addParam<MaterialPropertyName>(
62 : "thermal_conductivity_name", "k", "The name of the thermal conductivity");
63 848 : params.addParam<MaterialPropertyName>(
64 : "specific_heat_name", "cp", "The name of the specific heat");
65 424 : params.addParam<std::vector<BoundaryName>>("natural_temperature_boundary",
66 424 : std::vector<BoundaryName>(),
67 : "Natural boundaries for temperature equation");
68 424 : params.addParam<std::vector<BoundaryName>>("fixed_temperature_boundary",
69 424 : std::vector<BoundaryName>(),
70 : "Dirichlet boundaries for temperature equation");
71 424 : params.addParam<std::vector<FunctionName>>(
72 424 : "temperature_function", std::vector<FunctionName>(), "Temperature on Dirichlet boundaries");
73 424 : addAmbientConvectionParams(params);
74 848 : params.addParam<bool>(
75 848 : "has_heat_source", false, "Whether there is a heat source function object in the simulation");
76 848 : params.addParam<FunctionName>("heat_source_function", "The function describing the heat source");
77 848 : params.addCoupledVar("heat_source_var", "The coupled variable describing the heat source");
78 :
79 424 : params.addParam<RealVectorValue>(
80 424 : "gravity", RealVectorValue(0, 0, 0), "Direction of the gravity vector");
81 :
82 848 : params.addParam<MaterialPropertyName>(
83 : "dynamic_viscosity_name", "mu", "The name of the dynamic viscosity");
84 848 : params.addParam<MaterialPropertyName>("density_name", "rho", "The name of the density");
85 :
86 848 : params.addParam<bool>("use_ad", false, "True to use AD");
87 848 : params.addParam<bool>(
88 848 : "laplace", true, "Whether the viscous term of the momentum equations is in laplace form");
89 848 : params.addParam<bool>(
90 848 : "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts");
91 848 : params.addParam<bool>(
92 848 : "convective_term", true, "Whether to include the convective term in Jacobian");
93 848 : params.addParam<bool>(
94 848 : "supg", false, "Whether to perform SUPG stabilization of the momentum residuals");
95 848 : params.addParam<bool>(
96 848 : "pspg", false, "Whether to perform PSPG stabilization of the mass equation");
97 848 : params.addParam<Real>("alpha", 1, "Multiplicative factor on the stabilization parameter tau");
98 848 : params.addParam<bool>("add_standard_velocity_variables_for_ad",
99 848 : true,
100 : "True to convert vector velocity variables into standard aux variables");
101 848 : params.addParam<bool>(
102 : "has_coupled_force",
103 848 : false,
104 : "Whether the simulation has a force due to a coupled vector variable/vector function");
105 848 : params.addCoupledVar("coupled_force_var", "The variable(s) providing the coupled force(s)");
106 848 : params.addParam<std::vector<FunctionName>>("coupled_force_vector_function",
107 : "The function(s) standing in as a coupled force");
108 :
109 424 : params.addParam<std::vector<BoundaryName>>(
110 424 : "velocity_boundary", std::vector<BoundaryName>(), "Boundaries with given velocities");
111 424 : params.addParam<std::vector<FunctionName>>(
112 424 : "velocity_function", std::vector<FunctionName>(), "Functions for boundary velocities");
113 848 : params.addParam<unsigned int>("pressure_pinned_node",
114 : "The node where pressure needs to be pinned");
115 424 : params.addParam<std::vector<BoundaryName>>(
116 424 : "no_bc_boundary", std::vector<BoundaryName>(), "The so-called no-bc Boundaries");
117 424 : params.addParam<std::vector<BoundaryName>>(
118 424 : "pressure_boundary", std::vector<BoundaryName>(), "Boundaries with given pressures");
119 424 : params.addParam<std::vector<FunctionName>>(
120 424 : "pressure_function", std::vector<FunctionName>(), "Functions for boundary pressures");
121 :
122 1272 : MooseEnum families(AddVariableAction::getNonlinearVariableFamilies(), "LAGRANGE");
123 424 : MooseEnum orders(AddVariableAction::getNonlinearVariableOrders());
124 848 : params.addParam<MooseEnum>(
125 : "family", families, "Specifies the family of FE shape functions to use for this variable");
126 848 : params.addParam<MooseEnum>("order",
127 : orders,
128 : "Specifies the order of the FE shape function to use "
129 : "for this variable (additional orders not listed are "
130 : "allowed)");
131 848 : params.addParam<Real>("pressure_scaling", 1, "Scaling for the pressure variable");
132 424 : params.addParam<RealVectorValue>(
133 424 : "velocity_scaling", RealVectorValue(1, 1, 1), "Scaling for the velocity variables");
134 :
135 848 : params.addParam<Real>("initial_pressure", 0, "The initial pressure, assumed constant everywhere");
136 :
137 : // We perturb slightly from zero to avoid divide by zero exceptions from stabilization terms
138 : // involving a velocity norm in the denominator
139 424 : params.addParam<RealVectorValue>("initial_velocity",
140 424 : RealVectorValue(1e-15, 1e-15, 1e-15),
141 : "The initial velocity, assumed constant everywhere");
142 848 : params.addParam<std::string>("pressure_variable_name",
143 : "A name for the pressure variable. If this is not provided, a "
144 : "sensible default will be used.");
145 848 : params.addParam<NonlinearSystemName>(
146 : "nl_sys", "nl0", "The nonlinear system that this action belongs to.");
147 :
148 848 : params.addParamNamesToGroup(
149 : "equation_type block gravity dynamic_viscosity_name density_name boussinesq_approximation "
150 : "reference_temperature_name thermal_expansion_name",
151 : "Base");
152 848 : params.addParamNamesToGroup("use_ad laplace integrate_p_by_parts convective_term supg pspg alpha",
153 : "WeakFormControl");
154 848 : params.addParamNamesToGroup("velocity_boundary velocity_function pressure_pinned_node "
155 : "no_bc_boundary pressure_boundary pressure_function",
156 : "BoundaryCondition");
157 848 : params.addParamNamesToGroup(
158 : "family order pressure_scaling velocity_scaling initial_pressure initial_velocity",
159 : "Variable");
160 848 : params.addParamNamesToGroup(
161 : "add_temperature_equation temperature_variable temperature_scaling initial_temperature "
162 : "thermal_conductivity_name specific_heat_name natural_temperature_boundary "
163 : "fixed_temperature_boundary temperature_function",
164 : "Temperature");
165 424 : return params;
166 424 : }
167 :
168 424 : INSAction::INSAction(const InputParameters & parameters)
169 : : Action(parameters),
170 424 : _type(getParam<MooseEnum>("equation_type")),
171 848 : _blocks(getParam<std::vector<SubdomainName>>("block")),
172 848 : _velocity_boundary(getParam<std::vector<BoundaryName>>("velocity_boundary")),
173 848 : _velocity_function(getParam<std::vector<FunctionName>>("velocity_function")),
174 848 : _pressure_boundary(getParam<std::vector<BoundaryName>>("pressure_boundary")),
175 848 : _pressure_function(getParam<std::vector<FunctionName>>("pressure_function")),
176 848 : _no_bc_boundary(getParam<std::vector<BoundaryName>>("no_bc_boundary")),
177 848 : _has_pinned_node(isParamValid("pressure_pinned_node")),
178 : _pinned_node("ins_pinned_node"),
179 848 : _fixed_temperature_boundary(getParam<std::vector<BoundaryName>>("fixed_temperature_boundary")),
180 848 : _temperature_function(getParam<std::vector<FunctionName>>("temperature_function")),
181 1272 : _fe_type(Utility::string_to_enum<Order>(getParam<MooseEnum>("order")),
182 424 : Utility::string_to_enum<FEFamily>(getParam<MooseEnum>("family"))),
183 848 : _use_ad(getParam<bool>("use_ad")),
184 848 : _temperature_variable_name(getParam<VariableName>("temperature_variable")),
185 848 : _pressure_variable_name(isParamValid("pressure_variable_name")
186 424 : ? getParam<std::string>("pressure_variable_name")
187 424 : : "p")
188 : {
189 424 : if (_pressure_function.size() != _pressure_boundary.size())
190 0 : paramError("pressure_function",
191 : "Size is not the same as the number of boundaries in 'pressure_boundary'");
192 424 : if (_temperature_function.size() != _fixed_temperature_boundary.size())
193 0 : paramError("temperature_function",
194 : "Size is not the same as the number of boundaries in 'fixed_temperature_boundary'");
195 424 : if (_use_ad)
196 : {
197 560 : if (parameters.isParamSetByUser("convective_term"))
198 0 : mooseWarning("'convective_term' is ignored for AD");
199 : }
200 : else
201 : {
202 288 : if (getParam<bool>("boussinesq_approximation"))
203 0 : mooseError("Boussinesq approximation has not been implemented for non-AD");
204 : }
205 :
206 848 : if (getParam<bool>("has_ambient_convection"))
207 : {
208 76 : if (!isParamValid("ambient_convection_alpha"))
209 0 : mooseError(
210 : "If 'has_ambient_convection' is true, then 'ambient_convection_alpha' must be set.");
211 :
212 76 : if (!isParamValid("ambient_temperature"))
213 0 : mooseError("If 'has_ambient_convection' is true, then 'ambient_temperature' must be set.");
214 : }
215 :
216 848 : if (getParam<bool>("has_heat_source"))
217 : {
218 38 : bool has_coupled = isParamValid("heat_source_var");
219 38 : bool has_function = isParamValid("heat_source_function");
220 38 : if (!has_coupled && !has_function)
221 0 : mooseError("Either the 'heat_source_var' or 'heat_source_function' param must be "
222 : "set for the "
223 : "'INSADEnergySource' object");
224 38 : else if (has_coupled && has_function)
225 0 : mooseError("Both the 'heat_source_var' or 'heat_source_function' param are set for the "
226 : "'INSADEnergySource' object. Please use one or the other.");
227 : }
228 :
229 848 : if (getParam<bool>("has_coupled_force"))
230 : {
231 111 : bool has_coupled = isParamValid("coupled_force_var");
232 111 : bool has_function = isParamValid("coupled_force_vector_function");
233 111 : if (!has_coupled && !has_function)
234 0 : mooseError("Either the 'coupled_force_var' or 'coupled_force_vector_function' param must be "
235 : "set for the "
236 : "'INSADMomentumCoupledForce' object");
237 : }
238 424 : }
239 :
240 : void
241 2524 : INSAction::act()
242 : {
243 2524 : if (_current_task == "append_mesh_generator")
244 : {
245 424 : if (_has_pinned_node)
246 : {
247 298 : if (_app.getMeshGeneratorNames().size() == 0)
248 0 : mooseError("The new mesh generator system is required to pin pressure");
249 :
250 596 : InputParameters params = _factory.getValidParams("ExtraNodesetGenerator");
251 894 : params.set<std::vector<BoundaryName>>("new_boundary") = {_pinned_node};
252 596 : params.set<std::vector<unsigned int>>("nodes") = {
253 894 : getParam<unsigned int>("pressure_pinned_node")};
254 596 : _app.appendMeshGenerator("ExtraNodesetGenerator", _pinned_node, params);
255 298 : }
256 : }
257 :
258 2524 : if (_current_task == "add_navier_stokes_variables")
259 : {
260 424 : _dim = _mesh->dimension();
261 433 : for (const auto & subdomain_name : _blocks)
262 : {
263 9 : SubdomainID id = _mesh->getSubdomainID(subdomain_name);
264 9 : _block_ids.insert(id);
265 9 : if (_problem->getCoordSystem(id) != Moose::COORD_XYZ)
266 0 : mooseError("RZ has not been added in action");
267 : }
268 424 : if (_blocks.size() == 0)
269 : {
270 1044 : for (auto & id : _mesh->meshSubdomains())
271 629 : if (_problem->getCoordSystem(id) != Moose::COORD_XYZ)
272 0 : mooseError("RZ has not been added in action");
273 : }
274 424 : if (_velocity_function.size() != _velocity_boundary.size() * _dim)
275 0 : paramError("velocity_function",
276 : "Size is not the same as the number of boundaries in 'velocity_boundary' times "
277 : "the mesh dimension");
278 :
279 : // FIXME: need to check boundaries are non-overlapping and enclose the blocks
280 :
281 424 : auto var_type = AddVariableAction::variableType(_fe_type);
282 424 : auto base_params = _factory.getValidParams(var_type);
283 424 : if (_block_ids.size() != 0)
284 18 : for (const SubdomainID & id : _block_ids)
285 18 : base_params.set<std::vector<SubdomainName>>("block").push_back(Moose::stringify(id));
286 848 : base_params.set<MooseEnum>("family") = Moose::stringify(_fe_type.family);
287 424 : base_params.set<MooseEnum>("order") = _fe_type.order.get_order();
288 :
289 : // add primal variables
290 424 : InputParameters params(base_params);
291 424 : params.set<MooseEnum>("order") = _fe_type.order.get_order();
292 :
293 424 : if (_use_ad)
294 : {
295 : // AD is using vector variables
296 280 : if (_fe_type.family != LAGRANGE)
297 0 : mooseError("AD has to use LAGRANGE variable family");
298 : FEType fetype(_fe_type.order.get_order(), LAGRANGE_VEC);
299 280 : auto vec_var_type = AddVariableAction::variableType(fetype);
300 280 : auto adparams = _factory.getValidParams(vec_var_type);
301 280 : if (_block_ids.size() != 0)
302 0 : for (const SubdomainID & id : _block_ids)
303 0 : adparams.set<std::vector<SubdomainName>>("block").push_back(Moose::stringify(id));
304 560 : adparams.set<MooseEnum>("family") = Moose::stringify(fetype.family);
305 280 : adparams.set<MooseEnum>("order") = _fe_type.order.get_order();
306 :
307 560 : auto vscaling = getParam<RealVectorValue>("velocity_scaling");
308 280 : adparams.set<std::vector<Real>>("scaling").push_back(vscaling(0));
309 280 : _problem->addVariable(vec_var_type, NS::velocity, adparams);
310 :
311 : // add normal velocity aux variables
312 560 : if (getParam<bool>("add_standard_velocity_variables_for_ad"))
313 : {
314 18 : _problem->addAuxVariable(var_type, NS::velocity_x, base_params);
315 18 : if (_dim >= 2)
316 18 : _problem->addAuxVariable(var_type, NS::velocity_y, base_params);
317 18 : if (_dim >= 3)
318 0 : _problem->addAuxVariable(var_type, NS::velocity_z, base_params);
319 : }
320 280 : }
321 : else
322 : {
323 288 : auto vscaling = getParam<RealVectorValue>("velocity_scaling");
324 144 : params.set<std::vector<Real>>("scaling") = {vscaling(0)};
325 144 : _problem->addVariable(var_type, NS::velocity_x, params);
326 144 : if (_dim >= 2)
327 : {
328 144 : params.set<std::vector<Real>>("scaling") = {vscaling(1)};
329 144 : _problem->addVariable(var_type, NS::velocity_y, params);
330 : }
331 144 : if (_dim >= 3)
332 : {
333 0 : params.set<std::vector<Real>>("scaling") = {vscaling(2)};
334 0 : _problem->addVariable(var_type, NS::velocity_z, params);
335 : }
336 : }
337 :
338 1422 : if (getParam<bool>("add_temperature_equation") &&
339 150 : !_problem
340 874 : ->getNonlinearSystemBase(_problem->nlSysNum(getParam<NonlinearSystemName>("nl_sys")))
341 150 : .hasVariable(_temperature_variable_name))
342 : {
343 393 : params.set<std::vector<Real>>("scaling") = {getParam<Real>("temperature_scaling")};
344 131 : _problem->addVariable(var_type, _temperature_variable_name, params);
345 : }
346 :
347 : // for non-stablized form, the FE order for pressure need to be at least one order lower
348 : int order = _fe_type.order.get_order();
349 848 : if (!getParam<bool>("pspg"))
350 144 : order -= 1;
351 424 : params.set<MooseEnum>("order") = order;
352 1272 : params.set<std::vector<Real>>("scaling") = {getParam<Real>("pressure_scaling")};
353 424 : _problem->addVariable(var_type, _pressure_variable_name, params);
354 424 : }
355 :
356 2524 : if (_current_task == "add_navier_stokes_ics")
357 : {
358 848 : auto vvalue = getParam<RealVectorValue>("initial_velocity");
359 848 : Real pvalue = getParam<Real>("initial_pressure");
360 :
361 424 : if (_use_ad)
362 : {
363 280 : if (vvalue.norm() != 0)
364 : {
365 560 : InputParameters params = _factory.getValidParams("VectorConstantIC");
366 560 : params.set<VariableName>("variable") = NS::velocity;
367 280 : params.set<Real>("x_value") = vvalue(0);
368 280 : if (_dim >= 2)
369 280 : params.set<Real>("y_value") = vvalue(1);
370 280 : if (_dim >= 3)
371 0 : params.set<Real>("z_value") = vvalue(2);
372 560 : _problem->addInitialCondition("VectorConstantIC", "velocity_ic", params);
373 280 : }
374 : }
375 : else
376 : {
377 144 : if (vvalue(0) != 0)
378 : {
379 288 : InputParameters params = _factory.getValidParams("ConstantIC");
380 288 : params.set<VariableName>("variable") = NS::velocity_x;
381 144 : params.set<Real>("value") = vvalue(0);
382 288 : _problem->addInitialCondition("ConstantIC", NS::velocity_x + "_ic", params);
383 144 : }
384 144 : if (vvalue(1) != 0 && _dim >= 2)
385 : {
386 288 : InputParameters params = _factory.getValidParams("ConstantIC");
387 288 : params.set<VariableName>("variable") = NS::velocity_y;
388 144 : params.set<Real>("value") = vvalue(1);
389 288 : _problem->addInitialCondition("ConstantIC", NS::velocity_y + "_ic", params);
390 144 : }
391 144 : if (vvalue(2) != 0 && _dim >= 3)
392 : {
393 0 : InputParameters params = _factory.getValidParams("ConstantIC");
394 0 : params.set<VariableName>("variable") = NS::velocity_z;
395 0 : params.set<Real>("value") = vvalue(2);
396 0 : _problem->addInitialCondition("ConstantIC", NS::velocity_z + "_ic", params);
397 0 : }
398 : }
399 :
400 848 : if (getParam<bool>("add_temperature_equation"))
401 : {
402 300 : Real tvalue = getParam<Real>("initial_temperature");
403 150 : InputParameters params = _factory.getValidParams("ConstantIC");
404 150 : params.set<VariableName>("variable") = _temperature_variable_name;
405 150 : params.set<Real>("value") = tvalue;
406 300 : _problem->addInitialCondition("ConstantIC", "temperature_ic", params);
407 150 : }
408 :
409 424 : if (pvalue != 0)
410 : {
411 0 : InputParameters params = _factory.getValidParams("ConstantIC");
412 0 : params.set<VariableName>("variable") = _pressure_variable_name;
413 0 : params.set<Real>("value") = pvalue;
414 0 : _problem->addInitialCondition("ConstantIC", "pressure_ic", params);
415 0 : }
416 : }
417 :
418 2524 : if (_current_task == "add_navier_stokes_kernels")
419 : {
420 414 : if (_type == "transient")
421 56 : addINSTimeKernels();
422 :
423 : // Add all the inviscid flux Kernels.
424 414 : addINSMass();
425 414 : addINSMomentum();
426 :
427 828 : if (getParam<bool>("add_temperature_equation"))
428 150 : addINSTemperature();
429 :
430 974 : if (_use_ad && getParam<bool>("add_standard_velocity_variables_for_ad"))
431 18 : addINSVelocityAux();
432 : }
433 :
434 2524 : if (_current_task == "add_navier_stokes_bcs")
435 : {
436 414 : if (_velocity_boundary.size() > 0)
437 414 : addINSVelocityBC();
438 :
439 414 : if (_has_pinned_node)
440 298 : addINSPinnedPressureBC();
441 :
442 414 : if (_no_bc_boundary.size() > 0)
443 0 : addINSNoBCBC();
444 :
445 414 : if (_pressure_boundary.size() > 0)
446 116 : addINSPressureBC();
447 :
448 828 : if (getParam<bool>("add_temperature_equation"))
449 : {
450 150 : if (_fixed_temperature_boundary.size() > 0)
451 150 : addINSTemperatureBC();
452 : }
453 : }
454 :
455 2524 : if (_current_task == "add_material" && _use_ad)
456 : {
457 280 : auto set_common_parameters = [&](InputParameters & params)
458 : {
459 280 : if (_blocks.size() > 0)
460 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
461 840 : params.set<CoupledName>("velocity") = {NS::velocity};
462 840 : params.set<CoupledName>(NS::pressure) = {_pressure_variable_name};
463 560 : params.set<MaterialPropertyName>("mu_name") =
464 280 : getParam<MaterialPropertyName>("dynamic_viscosity_name");
465 840 : params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
466 280 : };
467 :
468 141 : auto set_common_3eqn_parameters = [&](InputParameters & params)
469 : {
470 141 : set_common_parameters(params);
471 423 : params.set<CoupledName>("temperature") = {_temperature_variable_name};
472 282 : params.set<MaterialPropertyName>("cp_name") =
473 141 : getParam<MaterialPropertyName>("specific_heat_name");
474 141 : };
475 :
476 560 : if (getParam<bool>("add_temperature_equation"))
477 : {
478 300 : if (getParam<bool>("supg") || getParam<bool>("pspg"))
479 : {
480 132 : InputParameters params = _factory.getValidParams("INSADStabilized3Eqn");
481 132 : set_common_3eqn_parameters(params);
482 264 : params.set<Real>("alpha") = getParam<Real>("alpha");
483 264 : params.set<MaterialPropertyName>("k_name") =
484 132 : getParam<MaterialPropertyName>("thermal_conductivity_name");
485 264 : _problem->addMaterial("INSADStabilized3Eqn", "ins_ad_material", params);
486 132 : }
487 : else
488 : {
489 9 : InputParameters params = _factory.getValidParams("INSAD3Eqn");
490 9 : set_common_3eqn_parameters(params);
491 18 : _problem->addMaterial("INSAD3Eqn", "ins_ad_material", params);
492 9 : }
493 : }
494 : else
495 : {
496 278 : if (getParam<bool>("supg") || getParam<bool>("pspg"))
497 : {
498 139 : InputParameters params = _factory.getValidParams("INSADTauMaterial");
499 139 : set_common_parameters(params);
500 278 : params.set<Real>("alpha") = getParam<Real>("alpha");
501 278 : _problem->addMaterial("INSADTauMaterial", "ins_ad_material", params);
502 139 : }
503 : else
504 : {
505 0 : InputParameters params = _factory.getValidParams("INSADMaterial");
506 0 : set_common_parameters(params);
507 0 : _problem->addMaterial("INSADMaterial", "ins_ad_material", params);
508 0 : }
509 : }
510 : }
511 2524 : }
512 :
513 : void
514 56 : INSAction::addINSTimeKernels()
515 : {
516 56 : if (_use_ad)
517 : {
518 47 : const std::string kernel_type = "INSADMomentumTimeDerivative";
519 47 : InputParameters params = _factory.getValidParams(kernel_type);
520 47 : if (_blocks.size() > 0)
521 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
522 94 : params.set<NonlinearVariableName>("variable") = NS::velocity;
523 47 : _problem->addKernel(kernel_type, "ins_velocity_time_deriv", params);
524 :
525 94 : if (getParam<bool>("add_temperature_equation"))
526 : {
527 28 : const std::string kernel_type = "INSADHeatConductionTimeDerivative";
528 28 : InputParameters params = _factory.getValidParams(kernel_type);
529 56 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
530 28 : if (_blocks.size() > 0)
531 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
532 28 : _problem->addKernel(kernel_type, "ins_temperature_time_deriv", params);
533 28 : }
534 47 : }
535 : else
536 : {
537 9 : const std::string kernel_type = "INSMomentumTimeDerivative";
538 9 : InputParameters params = _factory.getValidParams(kernel_type);
539 9 : if (_blocks.size() > 0)
540 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
541 27 : params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
542 :
543 9 : const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
544 27 : for (unsigned int component = 0; component < _dim; ++component)
545 : {
546 36 : params.set<NonlinearVariableName>("variable") = momentums[component];
547 36 : _problem->addKernel(kernel_type, momentums[component] + "_time_deriv", params);
548 : }
549 :
550 18 : if (getParam<bool>("add_temperature_equation"))
551 : {
552 9 : const std::string kernel_type = "INSTemperatureTimeDerivative";
553 9 : InputParameters params = _factory.getValidParams(kernel_type);
554 18 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
555 9 : if (_blocks.size() > 0)
556 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
557 27 : params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
558 18 : params.set<MaterialPropertyName>("cp_name") =
559 9 : getParam<MaterialPropertyName>("specific_heat_name");
560 9 : _problem->addKernel(kernel_type, "ins_temperature_time_deriv", params);
561 9 : }
562 9 : }
563 56 : }
564 :
565 : void
566 414 : INSAction::addINSMass()
567 : {
568 414 : if (_use_ad)
569 : {
570 : {
571 280 : const std::string kernel_type = "INSADMass";
572 280 : InputParameters params = _factory.getValidParams(kernel_type);
573 560 : params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
574 280 : if (_blocks.size() > 0)
575 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
576 280 : _problem->addKernel(kernel_type, "ins_mass", params);
577 280 : }
578 :
579 560 : if (getParam<bool>("pspg"))
580 : {
581 271 : const std::string kernel_type = "INSADMassPSPG";
582 271 : InputParameters params = _factory.getValidParams(kernel_type);
583 542 : params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
584 813 : params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
585 271 : if (_blocks.size() > 0)
586 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
587 271 : _problem->addKernel(kernel_type, "ins_mass_pspg", params);
588 271 : }
589 : }
590 : else
591 : {
592 134 : const std::string kernel_type = "INSMass";
593 134 : InputParameters params = _factory.getValidParams(kernel_type);
594 268 : params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
595 134 : setKernelCommonParams(params);
596 268 : params.set<bool>("pspg") = getParam<bool>("pspg");
597 134 : _problem->addKernel(kernel_type, "ins_mass", params);
598 134 : }
599 414 : }
600 :
601 : void
602 18 : INSAction::addINSVelocityAux()
603 : {
604 18 : const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
605 18 : const static std::string coord[3] = {"x", "y", "z"};
606 36 : InputParameters params = _factory.getValidParams("VectorVariableComponentAux");
607 54 : params.set<CoupledName>("vector_variable") = {NS::velocity};
608 54 : for (unsigned int component = 0; component < _dim; ++component)
609 : {
610 72 : params.set<AuxVariableName>("variable") = momentums[component];
611 36 : params.set<MooseEnum>("component") = coord[component];
612 72 : _problem->addAuxKernel("VectorVariableComponentAux", momentums[component] + "_aux", params);
613 : }
614 18 : }
615 :
616 : void
617 414 : INSAction::addINSMomentum()
618 : {
619 414 : if (_use_ad)
620 : {
621 : {
622 280 : const std::string kernel_type = "INSADMomentumAdvection";
623 280 : InputParameters params = _factory.getValidParams(kernel_type);
624 560 : params.set<NonlinearVariableName>("variable") = NS::velocity;
625 280 : if (_blocks.size() > 0)
626 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
627 280 : _problem->addKernel(kernel_type, "ins_momentum_convection", params);
628 280 : }
629 :
630 : {
631 280 : const std::string kernel_type = "INSADMomentumViscous";
632 280 : InputParameters params = _factory.getValidParams(kernel_type);
633 560 : params.set<NonlinearVariableName>("variable") = NS::velocity;
634 1120 : params.set<MooseEnum>("viscous_form") = (getParam<bool>("laplace") ? "laplace" : "traction");
635 280 : if (_blocks.size() > 0)
636 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
637 280 : _problem->addKernel(kernel_type, "ins_momentum_viscous", params);
638 280 : }
639 :
640 : {
641 280 : const std::string kernel_type = "INSADMomentumPressure";
642 280 : InputParameters params = _factory.getValidParams(kernel_type);
643 560 : params.set<NonlinearVariableName>("variable") = NS::velocity;
644 280 : if (_blocks.size() > 0)
645 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
646 560 : params.set<bool>("integrate_p_by_parts") = getParam<bool>("integrate_p_by_parts");
647 840 : params.set<CoupledName>(NS::pressure) = {_pressure_variable_name};
648 280 : _problem->addKernel(kernel_type, "ins_momentum_pressure", params);
649 280 : }
650 :
651 560 : auto gravity = getParam<RealVectorValue>("gravity");
652 280 : if (gravity.norm() != 0)
653 : {
654 18 : const std::string kernel_type = "INSADGravityForce";
655 18 : InputParameters params = _factory.getValidParams(kernel_type);
656 36 : params.set<NonlinearVariableName>("variable") = NS::velocity;
657 18 : if (_blocks.size() > 0)
658 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
659 18 : params.set<RealVectorValue>("gravity") = gravity;
660 18 : _problem->addKernel(kernel_type, "ins_momentum_gravity", params);
661 18 : }
662 :
663 560 : if (getParam<bool>("supg"))
664 : {
665 271 : const std::string kernel_type = "INSADMomentumSUPG";
666 271 : InputParameters params = _factory.getValidParams(kernel_type);
667 542 : params.set<NonlinearVariableName>("variable") = NS::velocity;
668 813 : params.set<std::vector<VariableName>>("velocity") = {NS::velocity};
669 542 : params.set<MaterialPropertyName>("tau_name") = "tau";
670 271 : if (_blocks.size() > 0)
671 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
672 271 : _problem->addKernel(kernel_type, "ins_momentum_supg", params);
673 271 : }
674 :
675 560 : if (getParam<bool>("boussinesq_approximation"))
676 : {
677 18 : const std::string kernel_type = "INSADBoussinesqBodyForce";
678 18 : InputParameters params = _factory.getValidParams(kernel_type);
679 36 : params.set<NonlinearVariableName>("variable") = NS::velocity;
680 54 : params.set<std::vector<VariableName>>("temperature") = {_temperature_variable_name};
681 18 : params.set<RealVectorValue>("gravity") = gravity;
682 36 : params.set<MaterialPropertyName>("alpha_name") =
683 18 : getParam<MaterialPropertyName>("thermal_expansion_name");
684 36 : params.set<MaterialPropertyName>("ref_temp") =
685 36 : getParam<MaterialPropertyName>("reference_temperature_name");
686 18 : if (_blocks.size() > 0)
687 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
688 18 : _problem->addKernel(kernel_type, "ins_momentum_boussinesq_force", params);
689 18 : }
690 :
691 560 : if (getParam<bool>("has_coupled_force"))
692 : {
693 111 : const std::string kernel_type = "INSADMomentumCoupledForce";
694 111 : InputParameters params = _factory.getValidParams(kernel_type);
695 222 : params.set<NonlinearVariableName>("variable") = NS::velocity;
696 111 : if (_blocks.size() > 0)
697 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
698 222 : if (isParamValid("coupled_force_var"))
699 195 : params.set<CoupledName>("coupled_vector_var") = getParam<CoupledName>("coupled_force_var");
700 222 : if (isParamValid("coupled_force_vector_function"))
701 130 : params.set<std::vector<FunctionName>>("vector_function") =
702 195 : getParam<std::vector<FunctionName>>("coupled_force_vector_function");
703 :
704 111 : _problem->addKernel(kernel_type, "ins_momentum_coupled_force", params);
705 111 : }
706 : }
707 : else
708 : {
709 134 : const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
710 : std::string kernel_type;
711 268 : if (getParam<bool>("laplace"))
712 : kernel_type = "INSMomentumLaplaceForm";
713 : else
714 : kernel_type = "INSMomentumTractionForm";
715 :
716 134 : InputParameters params = _factory.getValidParams(kernel_type);
717 134 : setKernelCommonParams(params);
718 :
719 : // Extra stuff needed by momentum Kernels
720 268 : params.set<bool>("integrate_p_by_parts") = getParam<bool>("integrate_p_by_parts");
721 268 : params.set<bool>("supg") = getParam<bool>("supg");
722 :
723 402 : for (unsigned int component = 0; component < _dim; ++component)
724 : {
725 536 : params.set<NonlinearVariableName>("variable") = momentums[component];
726 268 : params.set<unsigned int>("component") = component;
727 536 : _problem->addKernel(kernel_type, momentums[component] + std::string("_if"), params);
728 : }
729 134 : }
730 414 : }
731 :
732 : void
733 150 : INSAction::addINSTemperature()
734 : {
735 150 : if (_use_ad)
736 : {
737 : {
738 141 : const std::string kernel_type = "INSADEnergyAdvection";
739 141 : InputParameters params = _factory.getValidParams(kernel_type);
740 282 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
741 141 : if (_blocks.size() > 0)
742 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
743 141 : _problem->addKernel(kernel_type, "ins_temperature_convection", params);
744 141 : }
745 : {
746 141 : const std::string kernel_type = "ADHeatConduction";
747 141 : InputParameters params = _factory.getValidParams(kernel_type);
748 282 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
749 282 : params.set<MaterialPropertyName>("thermal_conductivity") =
750 282 : getParam<MaterialPropertyName>("thermal_conductivity_name");
751 141 : if (_blocks.size() > 0)
752 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
753 141 : _problem->addKernel(kernel_type, "ins_temperature_conduction", params);
754 141 : }
755 :
756 282 : if (getParam<bool>("supg"))
757 : {
758 132 : const std::string kernel_type = "INSADEnergySUPG";
759 132 : InputParameters params = _factory.getValidParams(kernel_type);
760 264 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
761 132 : if (_blocks.size() > 0)
762 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
763 396 : params.set<CoupledName>("velocity") = {NS::velocity};
764 264 : params.set<MaterialPropertyName>("tau_name") = "tau_energy";
765 132 : _problem->addKernel(kernel_type, "ins_temperature_supg", params);
766 132 : }
767 :
768 282 : if (getParam<bool>("has_ambient_convection"))
769 : {
770 38 : const std::string kernel_type = "INSADEnergyAmbientConvection";
771 38 : InputParameters params = _factory.getValidParams(kernel_type);
772 76 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
773 38 : if (_blocks.size() > 0)
774 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
775 76 : params.set<Real>("alpha") = getParam<Real>("ambient_convection_alpha");
776 76 : params.set<Real>("T_ambient") = getParam<Real>("ambient_temperature");
777 38 : _problem->addKernel(kernel_type, "ins_temperature_ambient_convection", params);
778 38 : }
779 :
780 282 : if (getParam<bool>("has_heat_source"))
781 : {
782 38 : const std::string kernel_type = "INSADEnergySource";
783 38 : InputParameters params = _factory.getValidParams(kernel_type);
784 76 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
785 38 : if (_blocks.size() > 0)
786 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
787 76 : if (isParamValid("heat_source_var"))
788 57 : params.set<CoupledName>("source_variable") = getParam<CoupledName>("heat_source_var");
789 38 : else if (isParamValid("heat_source_function"))
790 38 : params.set<FunctionName>("source_function") =
791 38 : getParam<FunctionName>("heat_source_function");
792 : else
793 0 : mooseError("Either the 'heat_source_var' or 'heat_source_function' param must be "
794 : "set if adding the 'INSADEnergySource' through the incompressible Navier-Stokes "
795 : "action.");
796 38 : _problem->addKernel(kernel_type, "ins_temperature_source", params);
797 38 : }
798 : }
799 : else
800 : {
801 9 : const std::string kernel_type = "INSTemperature";
802 9 : InputParameters params = _factory.getValidParams(kernel_type);
803 18 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
804 27 : params.set<CoupledName>("u") = {NS::velocity_x};
805 9 : if (_dim >= 2)
806 27 : params.set<CoupledName>("v") = {NS::velocity_y};
807 9 : if (_dim >= 3)
808 0 : params.set<CoupledName>("w") = {NS::velocity_z};
809 18 : params.set<MaterialPropertyName>("k_name") =
810 9 : getParam<MaterialPropertyName>("thermal_conductivity_name");
811 27 : params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
812 18 : params.set<MaterialPropertyName>("cp_name") =
813 18 : getParam<MaterialPropertyName>("specific_heat_name");
814 9 : if (_blocks.size() > 0)
815 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
816 9 : _problem->addKernel(kernel_type, "ins_temperature", params);
817 9 : }
818 150 : }
819 :
820 : void
821 414 : INSAction::addINSVelocityBC()
822 : {
823 414 : const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
824 1954 : for (unsigned int i = 0; i < _velocity_boundary.size(); ++i)
825 : {
826 1540 : if (_use_ad)
827 : {
828 1120 : InputParameters params = _factory.getValidParams("ADVectorFunctionDirichletBC");
829 :
830 : {
831 1120 : const FunctionName funcx = _velocity_function[i * _dim];
832 1120 : if (funcx == "NA")
833 0 : params.set<bool>("set_x_comp") = false;
834 : else
835 : {
836 1120 : std::stringstream ss(funcx);
837 : Real val;
838 1120 : if ((ss >> val).fail() || !ss.eof())
839 : {
840 151 : if (!_problem->hasFunction(funcx))
841 : {
842 0 : InputParameters func_params = _factory.getValidParams("ConstantFunction");
843 0 : func_params.set<Real>("value") = val;
844 0 : _problem->addFunction("ConstantFunction", funcx, func_params);
845 0 : }
846 : }
847 1120 : params.set<FunctionName>("function_x") = funcx;
848 1120 : }
849 : }
850 :
851 1120 : if (_dim >= 2)
852 : {
853 1120 : const FunctionName funcy = _velocity_function[i * _dim + 1];
854 1120 : if (funcy == "NA")
855 0 : params.set<bool>("set_y_comp") = false;
856 : else
857 : {
858 1120 : std::stringstream ss(funcy);
859 : Real val;
860 1120 : if ((ss >> val).fail() || !ss.eof())
861 : {
862 0 : if (!_problem->hasFunction(funcy))
863 : {
864 0 : InputParameters func_params = _factory.getValidParams("ConstantFunction");
865 0 : func_params.set<Real>("value") = val;
866 0 : _problem->addFunction("ConstantFunction", funcy, func_params);
867 0 : }
868 : }
869 1120 : params.set<FunctionName>("function_y") = funcy;
870 1120 : }
871 : }
872 :
873 1120 : if (_dim >= 3)
874 : {
875 0 : const FunctionName funcz = _velocity_function[i * _dim + 1];
876 0 : if (funcz == "NA")
877 0 : params.set<bool>("set_z_comp") = false;
878 : else
879 : {
880 0 : std::stringstream ss(funcz);
881 : Real val;
882 0 : if ((ss >> val).fail() || !ss.eof())
883 : {
884 0 : if (!_problem->hasFunction(funcz))
885 : {
886 0 : InputParameters func_params = _factory.getValidParams("ConstantFunction");
887 0 : func_params.set<Real>("value") = val;
888 0 : _problem->addFunction("ConstantFunction", funcz, func_params);
889 0 : }
890 : }
891 0 : params.set<FunctionName>("function_z") = funcz;
892 0 : }
893 : }
894 :
895 2240 : params.set<NonlinearVariableName>("variable") = NS::velocity;
896 3360 : params.set<std::vector<BoundaryName>>("boundary") = {_velocity_boundary[i]};
897 2240 : _problem->addBoundaryCondition(
898 1120 : "ADVectorFunctionDirichletBC", "ins_velocity_bc_" + _velocity_boundary[i], params);
899 1120 : }
900 : else
901 : {
902 1260 : for (unsigned int component = 0; component < _dim; ++component)
903 : {
904 840 : const FunctionName func = _velocity_function[i * _dim + component];
905 840 : if (func == "NA")
906 : continue;
907 :
908 821 : std::stringstream ss(func);
909 : Real val;
910 821 : if ((ss >> val).fail() || !ss.eof())
911 : {
912 18 : InputParameters params = _factory.getValidParams("FunctionDirichletBC");
913 18 : params.set<FunctionName>("function") = func;
914 36 : params.set<NonlinearVariableName>("variable") = momentums[component];
915 54 : params.set<std::vector<BoundaryName>>("boundary") = {_velocity_boundary[i]};
916 54 : _problem->addBoundaryCondition(
917 18 : "FunctionDirichletBC", momentums[component] + "_" + _velocity_boundary[i], params);
918 18 : }
919 : else
920 : {
921 803 : InputParameters params = _factory.getValidParams("DirichletBC");
922 803 : params.set<Real>("value") = val;
923 1606 : params.set<NonlinearVariableName>("variable") = momentums[component];
924 2409 : params.set<std::vector<BoundaryName>>("boundary") = {_velocity_boundary[i]};
925 2409 : _problem->addBoundaryCondition(
926 803 : "DirichletBC", momentums[component] + "_" + _velocity_boundary[i], params);
927 803 : }
928 821 : }
929 : }
930 : }
931 414 : }
932 :
933 : void
934 150 : INSAction::addINSTemperatureBC()
935 : {
936 450 : for (unsigned int i = 0; i < _fixed_temperature_boundary.size(); ++i)
937 : {
938 : const FunctionName func = _temperature_function[i];
939 300 : if (func == "NA")
940 : continue;
941 :
942 300 : std::stringstream ss(func);
943 : Real val;
944 300 : if ((ss >> val).fail() || !ss.eof())
945 : {
946 0 : InputParameters params = _factory.getValidParams("FunctionDirichletBC");
947 0 : params.set<FunctionName>("function") = func;
948 0 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
949 0 : params.set<std::vector<BoundaryName>>("boundary") = {_fixed_temperature_boundary[i]};
950 0 : _problem->addBoundaryCondition("FunctionDirichletBC",
951 0 : _temperature_variable_name + "_" +
952 : _fixed_temperature_boundary[i],
953 : params);
954 0 : }
955 : else
956 : {
957 300 : InputParameters params = _factory.getValidParams("DirichletBC");
958 300 : params.set<Real>("value") = val;
959 600 : params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
960 900 : params.set<std::vector<BoundaryName>>("boundary") = {_fixed_temperature_boundary[i]};
961 900 : _problem->addBoundaryCondition(
962 300 : "DirichletBC", _temperature_variable_name + "_" + _fixed_temperature_boundary[i], params);
963 300 : }
964 300 : }
965 150 : }
966 :
967 : void
968 116 : INSAction::addINSPressureBC()
969 : {
970 251 : for (unsigned int i = 0; i < _pressure_boundary.size(); ++i)
971 : {
972 : const FunctionName func = _pressure_function[i];
973 135 : std::stringstream ss(func);
974 : Real val;
975 135 : if ((ss >> val).fail() || !ss.eof())
976 : {
977 0 : InputParameters params = _factory.getValidParams("FunctionDirichletBC");
978 0 : params.set<FunctionName>("function") = func;
979 0 : params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
980 0 : params.set<std::vector<BoundaryName>>("boundary") = {_pressure_boundary[i]};
981 0 : _problem->addBoundaryCondition(
982 0 : "FunctionDirichletBC", NS::pressure + _pressure_boundary[i], params);
983 0 : }
984 : else
985 : {
986 135 : InputParameters params = _factory.getValidParams("DirichletBC");
987 135 : params.set<Real>("value") = val;
988 270 : params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
989 405 : params.set<std::vector<BoundaryName>>("boundary") = {_pressure_boundary[i]};
990 270 : _problem->addBoundaryCondition("DirichletBC", NS::pressure + _pressure_boundary[i], params);
991 135 : }
992 135 : }
993 116 : }
994 :
995 : void
996 298 : INSAction::addINSPinnedPressureBC()
997 : {
998 298 : InputParameters params = _factory.getValidParams("DirichletBC");
999 298 : params.set<Real>("value") = 0;
1000 596 : params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
1001 894 : params.set<std::vector<BoundaryName>>("boundary") = {_pinned_node};
1002 596 : _problem->addBoundaryCondition("DirichletBC", "pressure_pin", params);
1003 298 : }
1004 :
1005 : void
1006 0 : INSAction::addINSNoBCBC()
1007 : {
1008 0 : if (_use_ad)
1009 : {
1010 0 : const std::string kernel_type = "INSADMomentumNoBCBC";
1011 0 : InputParameters params = _factory.getValidParams(kernel_type);
1012 0 : params.set<NonlinearVariableName>("variable") = NS::velocity;
1013 0 : if (_blocks.size() > 0)
1014 0 : params.set<std::vector<SubdomainName>>("block") = _blocks;
1015 0 : params.set<bool>("integrate_p_by_parts") = getParam<bool>("integrate_p_by_parts");
1016 0 : params.set<CoupledName>(NS::pressure) = {_pressure_variable_name};
1017 0 : params.set<MooseEnum>("viscous_form") = (getParam<bool>("laplace") ? "laplace" : "traction");
1018 0 : _problem->addBoundaryCondition(kernel_type, "ins_momentum_nobc_bc", params);
1019 0 : }
1020 : else
1021 : {
1022 0 : const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
1023 : std::string kernel_type;
1024 0 : if (getParam<bool>("laplace"))
1025 : kernel_type = "INSMomentumNoBCBCLaplaceForm";
1026 : else
1027 : kernel_type = "INSMomentumNoBCBCTractionForm";
1028 0 : InputParameters params = _factory.getValidParams(kernel_type);
1029 0 : params.set<std::vector<BoundaryName>>("boundary") = _no_bc_boundary;
1030 0 : setNoBCCommonParams(params);
1031 0 : for (unsigned int component = 0; component < _dim; ++component)
1032 : {
1033 0 : params.set<NonlinearVariableName>("variable") = momentums[component];
1034 0 : _problem->addBoundaryCondition(kernel_type, momentums[component] + "_nobc_bc", params);
1035 : }
1036 0 : }
1037 0 : }
1038 :
1039 : void
1040 268 : INSAction::setKernelCommonParams(InputParameters & params)
1041 : {
1042 268 : if (_blocks.size() > 0)
1043 36 : params.set<std::vector<SubdomainName>>("block") = _blocks;
1044 :
1045 : // coupled variables
1046 804 : params.set<CoupledName>("u") = {NS::velocity_x};
1047 268 : if (_dim >= 2)
1048 804 : params.set<CoupledName>("v") = {NS::velocity_y};
1049 268 : if (_dim >= 3)
1050 0 : params.set<CoupledName>("w") = {NS::velocity_z};
1051 804 : params.set<CoupledName>(NS::pressure) = {_pressure_variable_name};
1052 536 : params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
1053 536 : params.set<MaterialPropertyName>("mu_name") =
1054 268 : getParam<MaterialPropertyName>("dynamic_viscosity_name");
1055 804 : params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
1056 536 : params.set<Real>("alpha") = getParam<Real>("alpha");
1057 536 : params.set<bool>("laplace") = getParam<bool>("laplace");
1058 : // this parameter only affecting Jacobian evaluation in non-AD
1059 536 : params.set<bool>("convective_term") = getParam<bool>("convective_term");
1060 : // FIXME: this parameter seems not changing solution much?
1061 268 : params.set<bool>("transient_term") = (_type == "transient");
1062 268 : }
1063 :
1064 : void
1065 0 : INSAction::setNoBCCommonParams(InputParameters & params)
1066 : {
1067 : // coupled variables
1068 0 : params.set<CoupledName>("u") = {NS::velocity_x};
1069 0 : if (_dim >= 2)
1070 0 : params.set<CoupledName>("v") = {NS::velocity_y};
1071 0 : if (_dim >= 3)
1072 0 : params.set<CoupledName>("w") = {NS::velocity_z};
1073 0 : params.set<CoupledName>(NS::pressure) = {_pressure_variable_name};
1074 0 : params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
1075 0 : params.set<MaterialPropertyName>("mu_name") =
1076 0 : getParam<MaterialPropertyName>("dynamic_viscosity_name");
1077 0 : params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
1078 0 : params.set<bool>("integrate_p_by_parts") = getParam<bool>("integrate_p_by_parts");
1079 0 : }
|