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