https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
INSAction Class Reference

This class allows us to have a section of the input file like the following which automatically adds variables, kernels, aux kernels, bcs for setting up the incompressible Navier-Stokes equation. More...

#include <INSAction.h>

Inheritance diagram for INSAction:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 INSAction (const InputParameters &parameters)
 
virtual void act () override
 
void timedAct ()
 
virtual void addRelationshipManagers (Moose::RelationshipManagerType when_type)
 
MooseObjectName uniqueActionName () const
 
const std::string & specificTaskName () const
 
const std::set< std::string > & getAllTasks () const
 
void appendTask (const std::string &task)
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
PerfGraphperfGraph ()
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 

Public Attributes

const ConsoleStream _console
 

Static Public Attributes

static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

void setKernelCommonParams (InputParameters &params)
 
void setNoBCCommonParams (InputParameters &params)
 
void addINSTimeKernels ()
 
void addINSMass ()
 
void addINSMomentum ()
 
void addINSTemperature ()
 
void addINSVelocityAux ()
 
void addINSVelocityBC ()
 
void addINSPinnedPressureBC ()
 
void addINSNoBCBC ()
 
void addINSPressureBC ()
 
void addINSTemperatureBC ()
 
bool addRelationshipManagers (Moose::RelationshipManagerType when_type, const InputParameters &moose_object_pars)
 
void associateWithParameter (const std::string &param_name, InputParameters &params) const
 
void associateWithParameter (const InputParameters &from_params, const std::string &param_name, InputParameters &params) const
 
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

MooseEnum _type
 Equation type, transient or steady-state. More...
 
std::vector< SubdomainName > _blocks
 Subdomains Navier-Stokes equation is defined on. More...
 
std::vector< BoundaryName > _velocity_boundary
 Boundaries with velocity specified. More...
 
std::vector< FunctionName > _velocity_function
 Velocity function names at velocity boundaries. More...
 
std::vector< BoundaryName > _pressure_boundary
 Boundaries with pressure specified. More...
 
std::vector< FunctionName > _pressure_function
 Pressure function names at pressure boundaries. More...
 
std::vector< BoundaryName > _no_bc_boundary
 No-BC boundaries. More...
 
bool _has_pinned_node
 Whether or not we need to pin pressure at a node. More...
 
BoundaryName _pinned_node
 The node set name of the pinned node. More...
 
std::vector< BoundaryName > _fixed_temperature_boundary
 Boundaries with temperature specified. More...
 
std::vector< FunctionName > _temperature_function
 Temperature function names at fixed temperature boundaries. More...
 
libMesh::FEType _fe_type
 FE type for various variables. More...
 
bool _use_ad
 Whether we use AD or not. More...
 
VariableName _temperature_variable_name
 Temperature variable name to facilitate temperature variable added outside. More...
 
unsigned int _dim
 Mesh dimension. More...
 
std::set< SubdomainID_block_ids
 Subdomain IDs. More...
 
const std::string _pressure_variable_name
 pressure variable name More...
 
std::string _registered_identifier
 
std::string _specific_task_name
 
std::set< std::string > _all_tasks
 
ActionWarehouse_awh
 
const std::string & _current_task
 
std::shared_ptr< MooseMesh > & _mesh
 
std::shared_ptr< MooseMesh > & _displaced_mesh
 
std::shared_ptr< FEProblemBase > & _problem
 
PerfID _act_timer
 
MooseApp_app
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Detailed Description

This class allows us to have a section of the input file like the following which automatically adds variables, kernels, aux kernels, bcs for setting up the incompressible Navier-Stokes equation.

[IncompressibleNavierStokes] []

Definition at line 25 of file INSAction.h.

Constructor & Destructor Documentation

◆ INSAction()

INSAction::INSAction ( const InputParameters parameters)

Definition at line 168 of file INSAction.C.

169  : Action(parameters),
170  _type(getParam<MooseEnum>("equation_type")),
171  _blocks(getParam<std::vector<SubdomainName>>("block")),
172  _velocity_boundary(getParam<std::vector<BoundaryName>>("velocity_boundary")),
173  _velocity_function(getParam<std::vector<FunctionName>>("velocity_function")),
174  _pressure_boundary(getParam<std::vector<BoundaryName>>("pressure_boundary")),
175  _pressure_function(getParam<std::vector<FunctionName>>("pressure_function")),
176  _no_bc_boundary(getParam<std::vector<BoundaryName>>("no_bc_boundary")),
177  _has_pinned_node(isParamValid("pressure_pinned_node")),
178  _pinned_node("ins_pinned_node"),
179  _fixed_temperature_boundary(getParam<std::vector<BoundaryName>>("fixed_temperature_boundary")),
180  _temperature_function(getParam<std::vector<FunctionName>>("temperature_function")),
181  _fe_type(Utility::string_to_enum<Order>(getParam<MooseEnum>("order")),
182  Utility::string_to_enum<FEFamily>(getParam<MooseEnum>("family"))),
183  _use_ad(getParam<bool>("use_ad")),
184  _temperature_variable_name(getParam<VariableName>("temperature_variable")),
185  _pressure_variable_name(isParamValid("pressure_variable_name")
186  ? getParam<std::string>("pressure_variable_name")
187  : "p")
188 {
189  if (_pressure_function.size() != _pressure_boundary.size())
190  paramError("pressure_function",
191  "Size is not the same as the number of boundaries in 'pressure_boundary'");
193  paramError("temperature_function",
194  "Size is not the same as the number of boundaries in 'fixed_temperature_boundary'");
195  if (_use_ad)
196  {
197  if (parameters.isParamSetByUser("convective_term"))
198  mooseWarning("'convective_term' is ignored for AD");
199  }
200  else
201  {
202  if (getParam<bool>("boussinesq_approximation"))
203  mooseError("Boussinesq approximation has not been implemented for non-AD");
204  }
205 
206  if (getParam<bool>("has_ambient_convection"))
207  {
208  if (!isParamValid("ambient_convection_alpha"))
209  mooseError(
210  "If 'has_ambient_convection' is true, then 'ambient_convection_alpha' must be set.");
211 
212  if (!isParamValid("ambient_temperature"))
213  mooseError("If 'has_ambient_convection' is true, then 'ambient_temperature' must be set.");
214  }
215 
216  if (getParam<bool>("has_heat_source"))
217  {
218  bool has_coupled = isParamValid("heat_source_var");
219  bool has_function = isParamValid("heat_source_function");
220  if (!has_coupled && !has_function)
221  mooseError("Either the 'heat_source_var' or 'heat_source_function' param must be "
222  "set for the "
223  "'INSADEnergySource' object");
224  else if (has_coupled && has_function)
225  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  if (getParam<bool>("has_coupled_force"))
230  {
231  bool has_coupled = isParamValid("coupled_force_var");
232  bool has_function = isParamValid("coupled_force_vector_function");
233  if (!has_coupled && !has_function)
234  mooseError("Either the 'coupled_force_var' or 'coupled_force_vector_function' param must be "
235  "set for the "
236  "'INSADMomentumCoupledForce' object");
237  }
238 }
BoundaryName _pinned_node
The node set name of the pinned node.
Definition: INSAction.h:70
Action(const InputParameters &parameters)
MooseEnum _type
Equation type, transient or steady-state.
Definition: INSAction.h:54
std::vector< FunctionName > _temperature_function
Temperature function names at fixed temperature boundaries.
Definition: INSAction.h:74
VariableName _temperature_variable_name
Temperature variable name to facilitate temperature variable added outside.
Definition: INSAction.h:80
void mooseWarning(Args &&... args) const
std::vector< BoundaryName > _velocity_boundary
Boundaries with velocity specified.
Definition: INSAction.h:58
bool isParamValid(const std::string &name) const
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
Definition: INSAction.h:56
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
bool _use_ad
Whether we use AD or not.
Definition: INSAction.h:78
const T & getParam(const std::string &name) const
void paramError(const std::string &param, Args... args) const
libMesh::FEType _fe_type
FE type for various variables.
Definition: INSAction.h:76
std::vector< FunctionName > _pressure_function
Pressure function names at pressure boundaries.
Definition: INSAction.h:64
bool isParamSetByUser(const std::string &name) const
std::vector< BoundaryName > _fixed_temperature_boundary
Boundaries with temperature specified.
Definition: INSAction.h:72
bool _has_pinned_node
Whether or not we need to pin pressure at a node.
Definition: INSAction.h:68
void mooseError(Args &&... args) const
const InputParameters & parameters() const
std::vector< BoundaryName > _pressure_boundary
Boundaries with pressure specified.
Definition: INSAction.h:62
std::vector< BoundaryName > _no_bc_boundary
No-BC boundaries.
Definition: INSAction.h:66
std::vector< FunctionName > _velocity_function
Velocity function names at velocity boundaries.
Definition: INSAction.h:60

Member Function Documentation

◆ act()

void INSAction::act ( )
overridevirtual

Implements Action.

Definition at line 241 of file INSAction.C.

242 {
243  if (_current_task == "append_mesh_generator")
244  {
245  if (_has_pinned_node)
246  {
247  if (_app.getMeshGeneratorNames().size() == 0)
248  mooseError("The new mesh generator system is required to pin pressure");
249 
250  InputParameters params = _factory.getValidParams("ExtraNodesetGenerator");
251  params.set<std::vector<BoundaryName>>("new_boundary") = {_pinned_node};
252  params.set<std::vector<unsigned int>>("nodes") = {
253  getParam<unsigned int>("pressure_pinned_node")};
254  _app.appendMeshGenerator("ExtraNodesetGenerator", _pinned_node, params);
255  }
256  }
257 
258  if (_current_task == "add_navier_stokes_variables")
259  {
260  _dim = _mesh->dimension();
261  for (const auto & subdomain_name : _blocks)
262  {
263  SubdomainID id = _mesh->getSubdomainID(subdomain_name);
264  _block_ids.insert(id);
265  if (_problem->getCoordSystem(id) != Moose::COORD_XYZ)
266  mooseError("RZ has not been added in action");
267  }
268  if (_blocks.size() == 0)
269  {
270  for (auto & id : _mesh->meshSubdomains())
271  if (_problem->getCoordSystem(id) != Moose::COORD_XYZ)
272  mooseError("RZ has not been added in action");
273  }
274  if (_velocity_function.size() != _velocity_boundary.size() * _dim)
275  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  auto var_type = AddVariableAction::variableType(_fe_type);
282  auto base_params = _factory.getValidParams(var_type);
283  if (_block_ids.size() != 0)
284  for (const SubdomainID & id : _block_ids)
285  base_params.set<std::vector<SubdomainName>>("block").push_back(Moose::stringify(id));
286  base_params.set<MooseEnum>("family") = Moose::stringify(_fe_type.family);
287  base_params.set<MooseEnum>("order") = _fe_type.order.get_order();
288 
289  // add primal variables
290  InputParameters params(base_params);
291  params.set<MooseEnum>("order") = _fe_type.order.get_order();
292 
293  if (_use_ad)
294  {
295  // AD is using vector variables
296  if (_fe_type.family != LAGRANGE)
297  mooseError("AD has to use LAGRANGE variable family");
299  auto vec_var_type = AddVariableAction::variableType(fetype);
300  auto adparams = _factory.getValidParams(vec_var_type);
301  if (_block_ids.size() != 0)
302  for (const SubdomainID & id : _block_ids)
303  adparams.set<std::vector<SubdomainName>>("block").push_back(Moose::stringify(id));
304  adparams.set<MooseEnum>("family") = Moose::stringify(fetype.family);
305  adparams.set<MooseEnum>("order") = _fe_type.order.get_order();
306 
307  auto vscaling = getParam<RealVectorValue>("velocity_scaling");
308  adparams.set<std::vector<Real>>("scaling").push_back(vscaling(0));
309  _problem->addVariable(vec_var_type, NS::velocity, adparams);
310 
311  // add normal velocity aux variables
312  if (getParam<bool>("add_standard_velocity_variables_for_ad"))
313  {
314  _problem->addAuxVariable(var_type, NS::velocity_x, base_params);
315  if (_dim >= 2)
316  _problem->addAuxVariable(var_type, NS::velocity_y, base_params);
317  if (_dim >= 3)
318  _problem->addAuxVariable(var_type, NS::velocity_z, base_params);
319  }
320  }
321  else
322  {
323  auto vscaling = getParam<RealVectorValue>("velocity_scaling");
324  params.set<std::vector<Real>>("scaling") = {vscaling(0)};
325  _problem->addVariable(var_type, NS::velocity_x, params);
326  if (_dim >= 2)
327  {
328  params.set<std::vector<Real>>("scaling") = {vscaling(1)};
329  _problem->addVariable(var_type, NS::velocity_y, params);
330  }
331  if (_dim >= 3)
332  {
333  params.set<std::vector<Real>>("scaling") = {vscaling(2)};
334  _problem->addVariable(var_type, NS::velocity_z, params);
335  }
336  }
337 
338  if (getParam<bool>("add_temperature_equation") &&
339  !_problem
340  ->getNonlinearSystemBase(_problem->nlSysNum(getParam<NonlinearSystemName>("nl_sys")))
341  .hasVariable(_temperature_variable_name))
342  {
343  params.set<std::vector<Real>>("scaling") = {getParam<Real>("temperature_scaling")};
344  _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  if (!getParam<bool>("pspg"))
350  order -= 1;
351  params.set<MooseEnum>("order") = order;
352  params.set<std::vector<Real>>("scaling") = {getParam<Real>("pressure_scaling")};
353  _problem->addVariable(var_type, _pressure_variable_name, params);
354  }
355 
356  if (_current_task == "add_navier_stokes_ics")
357  {
358  auto vvalue = getParam<RealVectorValue>("initial_velocity");
359  Real pvalue = getParam<Real>("initial_pressure");
360 
361  if (_use_ad)
362  {
363  if (vvalue.norm() != 0)
364  {
365  InputParameters params = _factory.getValidParams("VectorConstantIC");
366  params.set<VariableName>("variable") = NS::velocity;
367  params.set<Real>("x_value") = vvalue(0);
368  if (_dim >= 2)
369  params.set<Real>("y_value") = vvalue(1);
370  if (_dim >= 3)
371  params.set<Real>("z_value") = vvalue(2);
372  _problem->addInitialCondition("VectorConstantIC", "velocity_ic", params);
373  }
374  }
375  else
376  {
377  if (vvalue(0) != 0)
378  {
379  InputParameters params = _factory.getValidParams("ConstantIC");
380  params.set<VariableName>("variable") = NS::velocity_x;
381  params.set<Real>("value") = vvalue(0);
382  _problem->addInitialCondition("ConstantIC", NS::velocity_x + "_ic", params);
383  }
384  if (vvalue(1) != 0 && _dim >= 2)
385  {
386  InputParameters params = _factory.getValidParams("ConstantIC");
387  params.set<VariableName>("variable") = NS::velocity_y;
388  params.set<Real>("value") = vvalue(1);
389  _problem->addInitialCondition("ConstantIC", NS::velocity_y + "_ic", params);
390  }
391  if (vvalue(2) != 0 && _dim >= 3)
392  {
393  InputParameters params = _factory.getValidParams("ConstantIC");
394  params.set<VariableName>("variable") = NS::velocity_z;
395  params.set<Real>("value") = vvalue(2);
396  _problem->addInitialCondition("ConstantIC", NS::velocity_z + "_ic", params);
397  }
398  }
399 
400  if (getParam<bool>("add_temperature_equation"))
401  {
402  Real tvalue = getParam<Real>("initial_temperature");
403  InputParameters params = _factory.getValidParams("ConstantIC");
404  params.set<VariableName>("variable") = _temperature_variable_name;
405  params.set<Real>("value") = tvalue;
406  _problem->addInitialCondition("ConstantIC", "temperature_ic", params);
407  }
408 
409  if (pvalue != 0)
410  {
411  InputParameters params = _factory.getValidParams("ConstantIC");
412  params.set<VariableName>("variable") = _pressure_variable_name;
413  params.set<Real>("value") = pvalue;
414  _problem->addInitialCondition("ConstantIC", "pressure_ic", params);
415  }
416  }
417 
418  if (_current_task == "add_navier_stokes_kernels")
419  {
420  if (_type == "transient")
422 
423  // Add all the inviscid flux Kernels.
424  addINSMass();
425  addINSMomentum();
426 
427  if (getParam<bool>("add_temperature_equation"))
429 
430  if (_use_ad && getParam<bool>("add_standard_velocity_variables_for_ad"))
432  }
433 
434  if (_current_task == "add_navier_stokes_bcs")
435  {
436  if (_velocity_boundary.size() > 0)
438 
439  if (_has_pinned_node)
441 
442  if (_no_bc_boundary.size() > 0)
443  addINSNoBCBC();
444 
445  if (_pressure_boundary.size() > 0)
447 
448  if (getParam<bool>("add_temperature_equation"))
449  {
450  if (_fixed_temperature_boundary.size() > 0)
452  }
453  }
454 
455  if (_current_task == "add_material" && _use_ad)
456  {
457  auto set_common_parameters = [&](InputParameters & params)
458  {
459  if (_blocks.size() > 0)
460  params.set<std::vector<SubdomainName>>("block") = _blocks;
461  params.set<CoupledName>("velocity") = {NS::velocity};
463  params.set<MaterialPropertyName>("mu_name") =
464  getParam<MaterialPropertyName>("dynamic_viscosity_name");
465  params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
466  };
467 
468  auto set_common_3eqn_parameters = [&](InputParameters & params)
469  {
470  set_common_parameters(params);
471  params.set<CoupledName>("temperature") = {_temperature_variable_name};
472  params.set<MaterialPropertyName>("cp_name") =
473  getParam<MaterialPropertyName>("specific_heat_name");
474  };
475 
476  if (getParam<bool>("add_temperature_equation"))
477  {
478  if (getParam<bool>("supg") || getParam<bool>("pspg"))
479  {
480  InputParameters params = _factory.getValidParams("INSADStabilized3Eqn");
481  set_common_3eqn_parameters(params);
482  params.set<Real>("alpha") = getParam<Real>("alpha");
483  params.set<MaterialPropertyName>("k_name") =
484  getParam<MaterialPropertyName>("thermal_conductivity_name");
485  _problem->addMaterial("INSADStabilized3Eqn", "ins_ad_material", params);
486  }
487  else
488  {
489  InputParameters params = _factory.getValidParams("INSAD3Eqn");
490  set_common_3eqn_parameters(params);
491  _problem->addMaterial("INSAD3Eqn", "ins_ad_material", params);
492  }
493  }
494  else
495  {
496  if (getParam<bool>("supg") || getParam<bool>("pspg"))
497  {
498  InputParameters params = _factory.getValidParams("INSADTauMaterial");
499  set_common_parameters(params);
500  params.set<Real>("alpha") = getParam<Real>("alpha");
501  _problem->addMaterial("INSADTauMaterial", "ins_ad_material", params);
502  }
503  else
504  {
505  InputParameters params = _factory.getValidParams("INSADMaterial");
506  set_common_parameters(params);
507  _problem->addMaterial("INSADMaterial", "ins_ad_material", params);
508  }
509  }
510  }
511 }
BoundaryName _pinned_node
The node set name of the pinned node.
Definition: INSAction.h:70
LAGRANGE_VEC
void addINSMass()
Definition: INSAction.C:566
std::vector< std::string > getMeshGeneratorNames() const
void addINSTemperatureBC()
Definition: INSAction.C:934
MooseEnum _type
Equation type, transient or steady-state.
Definition: INSAction.h:54
MooseApp & _app
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
OrderWrapper order
static const std::string velocity_x
Definition: NS.h:46
VariableName _temperature_variable_name
Temperature variable name to facilitate temperature variable added outside.
Definition: INSAction.h:80
void addINSVelocityAux()
Definition: INSAction.C:602
std::vector< BoundaryName > _velocity_boundary
Boundaries with velocity specified.
Definition: INSAction.h:58
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
Definition: INSAction.h:56
Factory & _factory
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
std::set< SubdomainID > _block_ids
Subdomain IDs.
Definition: INSAction.h:84
bool _use_ad
Whether we use AD or not.
Definition: INSAction.h:78
void addINSVelocityBC()
Definition: INSAction.C:821
const std::string & _current_task
static std::string variableType(const libMesh::FEType &fe_type, const bool is_fv=false, const bool is_array=false)
static const std::string velocity_y
Definition: NS.h:47
void paramError(const std::string &param, Args... args) const
std::string stringify(const T &t)
libMesh::FEType _fe_type
FE type for various variables.
Definition: INSAction.h:76
void addINSMomentum()
Definition: INSAction.C:617
const MeshGenerator & appendMeshGenerator(const std::string &type, const std::string &name, InputParameters params)
void addINSPressureBC()
Definition: INSAction.C:968
void addINSNoBCBC()
Definition: INSAction.C:1006
void addINSTimeKernels()
Definition: INSAction.C:514
std::shared_ptr< MooseMesh > & _mesh
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< BoundaryName > _fixed_temperature_boundary
Boundaries with temperature specified.
Definition: INSAction.h:72
std::vector< VariableName > CoupledName
static const std::string pressure
Definition: NS.h:56
bool _has_pinned_node
Whether or not we need to pin pressure at a node.
Definition: INSAction.h:68
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82
void mooseError(Args &&... args) const
std::shared_ptr< FEProblemBase > & _problem
static const std::string velocity
Definition: NS.h:45
std::vector< BoundaryName > _pressure_boundary
Boundaries with pressure specified.
Definition: INSAction.h:62
void addINSTemperature()
Definition: INSAction.C:733
void addINSPinnedPressureBC()
Definition: INSAction.C:996
std::vector< BoundaryName > _no_bc_boundary
No-BC boundaries.
Definition: INSAction.h:66
std::vector< FunctionName > _velocity_function
Velocity function names at velocity boundaries.
Definition: INSAction.h:60

◆ addINSMass()

void INSAction::addINSMass ( )
protected

Definition at line 566 of file INSAction.C.

Referenced by act().

567 {
568  if (_use_ad)
569  {
570  {
571  const std::string kernel_type = "INSADMass";
572  InputParameters params = _factory.getValidParams(kernel_type);
573  params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
574  if (_blocks.size() > 0)
575  params.set<std::vector<SubdomainName>>("block") = _blocks;
576  _problem->addKernel(kernel_type, "ins_mass", params);
577  }
578 
579  if (getParam<bool>("pspg"))
580  {
581  const std::string kernel_type = "INSADMassPSPG";
582  InputParameters params = _factory.getValidParams(kernel_type);
583  params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
584  params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
585  if (_blocks.size() > 0)
586  params.set<std::vector<SubdomainName>>("block") = _blocks;
587  _problem->addKernel(kernel_type, "ins_mass_pspg", params);
588  }
589  }
590  else
591  {
592  const std::string kernel_type = "INSMass";
593  InputParameters params = _factory.getValidParams(kernel_type);
594  params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
595  setKernelCommonParams(params);
596  params.set<bool>("pspg") = getParam<bool>("pspg");
597  _problem->addKernel(kernel_type, "ins_mass", params);
598  }
599 }
T & set(const std::string &name, bool quiet_mode=false)
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
Definition: INSAction.h:56
Factory & _factory
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
bool _use_ad
Whether we use AD or not.
Definition: INSAction.h:78
void setKernelCommonParams(InputParameters &params)
Definition: INSAction.C:1040
std::shared_ptr< FEProblemBase > & _problem

◆ addINSMomentum()

void INSAction::addINSMomentum ( )
protected

Definition at line 617 of file INSAction.C.

Referenced by act().

618 {
619  if (_use_ad)
620  {
621  {
622  const std::string kernel_type = "INSADMomentumAdvection";
623  InputParameters params = _factory.getValidParams(kernel_type);
624  params.set<NonlinearVariableName>("variable") = NS::velocity;
625  if (_blocks.size() > 0)
626  params.set<std::vector<SubdomainName>>("block") = _blocks;
627  _problem->addKernel(kernel_type, "ins_momentum_convection", params);
628  }
629 
630  {
631  const std::string kernel_type = "INSADMomentumViscous";
632  InputParameters params = _factory.getValidParams(kernel_type);
633  params.set<NonlinearVariableName>("variable") = NS::velocity;
634  params.set<MooseEnum>("viscous_form") = (getParam<bool>("laplace") ? "laplace" : "traction");
635  if (_blocks.size() > 0)
636  params.set<std::vector<SubdomainName>>("block") = _blocks;
637  _problem->addKernel(kernel_type, "ins_momentum_viscous", params);
638  }
639 
640  {
641  const std::string kernel_type = "INSADMomentumPressure";
642  InputParameters params = _factory.getValidParams(kernel_type);
643  params.set<NonlinearVariableName>("variable") = NS::velocity;
644  if (_blocks.size() > 0)
645  params.set<std::vector<SubdomainName>>("block") = _blocks;
646  params.set<bool>("integrate_p_by_parts") = getParam<bool>("integrate_p_by_parts");
648  _problem->addKernel(kernel_type, "ins_momentum_pressure", params);
649  }
650 
651  auto gravity = getParam<RealVectorValue>("gravity");
652  if (gravity.norm() != 0)
653  {
654  const std::string kernel_type = "INSADGravityForce";
655  InputParameters params = _factory.getValidParams(kernel_type);
656  params.set<NonlinearVariableName>("variable") = NS::velocity;
657  if (_blocks.size() > 0)
658  params.set<std::vector<SubdomainName>>("block") = _blocks;
659  params.set<RealVectorValue>("gravity") = gravity;
660  _problem->addKernel(kernel_type, "ins_momentum_gravity", params);
661  }
662 
663  if (getParam<bool>("supg"))
664  {
665  const std::string kernel_type = "INSADMomentumSUPG";
666  InputParameters params = _factory.getValidParams(kernel_type);
667  params.set<NonlinearVariableName>("variable") = NS::velocity;
668  params.set<std::vector<VariableName>>("velocity") = {NS::velocity};
669  params.set<MaterialPropertyName>("tau_name") = "tau";
670  if (_blocks.size() > 0)
671  params.set<std::vector<SubdomainName>>("block") = _blocks;
672  _problem->addKernel(kernel_type, "ins_momentum_supg", params);
673  }
674 
675  if (getParam<bool>("boussinesq_approximation"))
676  {
677  const std::string kernel_type = "INSADBoussinesqBodyForce";
678  InputParameters params = _factory.getValidParams(kernel_type);
679  params.set<NonlinearVariableName>("variable") = NS::velocity;
680  params.set<std::vector<VariableName>>("temperature") = {_temperature_variable_name};
681  params.set<RealVectorValue>("gravity") = gravity;
682  params.set<MaterialPropertyName>("alpha_name") =
683  getParam<MaterialPropertyName>("thermal_expansion_name");
684  params.set<MaterialPropertyName>("ref_temp") =
685  getParam<MaterialPropertyName>("reference_temperature_name");
686  if (_blocks.size() > 0)
687  params.set<std::vector<SubdomainName>>("block") = _blocks;
688  _problem->addKernel(kernel_type, "ins_momentum_boussinesq_force", params);
689  }
690 
691  if (getParam<bool>("has_coupled_force"))
692  {
693  const std::string kernel_type = "INSADMomentumCoupledForce";
694  InputParameters params = _factory.getValidParams(kernel_type);
695  params.set<NonlinearVariableName>("variable") = NS::velocity;
696  if (_blocks.size() > 0)
697  params.set<std::vector<SubdomainName>>("block") = _blocks;
698  if (isParamValid("coupled_force_var"))
699  params.set<CoupledName>("coupled_vector_var") = getParam<CoupledName>("coupled_force_var");
700  if (isParamValid("coupled_force_vector_function"))
701  params.set<std::vector<FunctionName>>("vector_function") =
702  getParam<std::vector<FunctionName>>("coupled_force_vector_function");
703 
704  _problem->addKernel(kernel_type, "ins_momentum_coupled_force", params);
705  }
706  }
707  else
708  {
709  const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
710  std::string kernel_type;
711  if (getParam<bool>("laplace"))
712  kernel_type = "INSMomentumLaplaceForm";
713  else
714  kernel_type = "INSMomentumTractionForm";
715 
716  InputParameters params = _factory.getValidParams(kernel_type);
717  setKernelCommonParams(params);
718 
719  // Extra stuff needed by momentum Kernels
720  params.set<bool>("integrate_p_by_parts") = getParam<bool>("integrate_p_by_parts");
721  params.set<bool>("supg") = getParam<bool>("supg");
722 
723  for (unsigned int component = 0; component < _dim; ++component)
724  {
725  params.set<NonlinearVariableName>("variable") = momentums[component];
726  params.set<unsigned int>("component") = component;
727  _problem->addKernel(kernel_type, momentums[component] + std::string("_if"), params);
728  }
729  }
730 }
static const std::string component
Definition: NS.h:153
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
static const std::string velocity_x
Definition: NS.h:46
VariableName _temperature_variable_name
Temperature variable name to facilitate temperature variable added outside.
Definition: INSAction.h:80
bool isParamValid(const std::string &name) const
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
Definition: INSAction.h:56
Factory & _factory
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
bool _use_ad
Whether we use AD or not.
Definition: INSAction.h:78
static const std::string velocity_y
Definition: NS.h:47
std::vector< VariableName > CoupledName
static const std::string pressure
Definition: NS.h:56
void setKernelCommonParams(InputParameters &params)
Definition: INSAction.C:1040
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82
std::shared_ptr< FEProblemBase > & _problem
static const std::string velocity
Definition: NS.h:45

◆ addINSNoBCBC()

void INSAction::addINSNoBCBC ( )
protected

Definition at line 1006 of file INSAction.C.

Referenced by act().

1007 {
1008  if (_use_ad)
1009  {
1010  const std::string kernel_type = "INSADMomentumNoBCBC";
1011  InputParameters params = _factory.getValidParams(kernel_type);
1012  params.set<NonlinearVariableName>("variable") = NS::velocity;
1013  if (_blocks.size() > 0)
1014  params.set<std::vector<SubdomainName>>("block") = _blocks;
1015  params.set<bool>("integrate_p_by_parts") = getParam<bool>("integrate_p_by_parts");
1017  params.set<MooseEnum>("viscous_form") = (getParam<bool>("laplace") ? "laplace" : "traction");
1018  _problem->addBoundaryCondition(kernel_type, "ins_momentum_nobc_bc", params);
1019  }
1020  else
1021  {
1022  const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
1023  std::string kernel_type;
1024  if (getParam<bool>("laplace"))
1025  kernel_type = "INSMomentumNoBCBCLaplaceForm";
1026  else
1027  kernel_type = "INSMomentumNoBCBCTractionForm";
1028  InputParameters params = _factory.getValidParams(kernel_type);
1029  params.set<std::vector<BoundaryName>>("boundary") = _no_bc_boundary;
1030  setNoBCCommonParams(params);
1031  for (unsigned int component = 0; component < _dim; ++component)
1032  {
1033  params.set<NonlinearVariableName>("variable") = momentums[component];
1034  _problem->addBoundaryCondition(kernel_type, momentums[component] + "_nobc_bc", params);
1035  }
1036  }
1037 }
static const std::string component
Definition: NS.h:153
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
static const std::string velocity_x
Definition: NS.h:46
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
Definition: INSAction.h:56
Factory & _factory
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
bool _use_ad
Whether we use AD or not.
Definition: INSAction.h:78
void setNoBCCommonParams(InputParameters &params)
Definition: INSAction.C:1065
static const std::string velocity_y
Definition: NS.h:47
std::vector< VariableName > CoupledName
static const std::string pressure
Definition: NS.h:56
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82
std::shared_ptr< FEProblemBase > & _problem
static const std::string velocity
Definition: NS.h:45
std::vector< BoundaryName > _no_bc_boundary
No-BC boundaries.
Definition: INSAction.h:66

◆ addINSPinnedPressureBC()

void INSAction::addINSPinnedPressureBC ( )
protected

Definition at line 996 of file INSAction.C.

Referenced by act().

997 {
998  InputParameters params = _factory.getValidParams("DirichletBC");
999  params.set<Real>("value") = 0;
1000  params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
1001  params.set<std::vector<BoundaryName>>("boundary") = {_pinned_node};
1002  _problem->addBoundaryCondition("DirichletBC", "pressure_pin", params);
1003 }
BoundaryName _pinned_node
The node set name of the pinned node.
Definition: INSAction.h:70
T & set(const std::string &name, bool quiet_mode=false)
Factory & _factory
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::shared_ptr< FEProblemBase > & _problem

◆ addINSPressureBC()

void INSAction::addINSPressureBC ( )
protected

Definition at line 968 of file INSAction.C.

Referenced by act().

969 {
970  for (unsigned int i = 0; i < _pressure_boundary.size(); ++i)
971  {
972  const FunctionName func = _pressure_function[i];
973  std::stringstream ss(func);
974  Real val;
975  if ((ss >> val).fail() || !ss.eof())
976  {
977  InputParameters params = _factory.getValidParams("FunctionDirichletBC");
978  params.set<FunctionName>("function") = func;
979  params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
980  params.set<std::vector<BoundaryName>>("boundary") = {_pressure_boundary[i]};
981  _problem->addBoundaryCondition(
982  "FunctionDirichletBC", NS::pressure + _pressure_boundary[i], params);
983  }
984  else
985  {
986  InputParameters params = _factory.getValidParams("DirichletBC");
987  params.set<Real>("value") = val;
988  params.set<NonlinearVariableName>("variable") = _pressure_variable_name;
989  params.set<std::vector<BoundaryName>>("boundary") = {_pressure_boundary[i]};
990  _problem->addBoundaryCondition("DirichletBC", NS::pressure + _pressure_boundary[i], params);
991  }
992  }
993 }
T & set(const std::string &name, bool quiet_mode=false)
Factory & _factory
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
std::vector< FunctionName > _pressure_function
Pressure function names at pressure boundaries.
Definition: INSAction.h:64
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56
std::shared_ptr< FEProblemBase > & _problem
std::vector< BoundaryName > _pressure_boundary
Boundaries with pressure specified.
Definition: INSAction.h:62

◆ addINSTemperature()

void INSAction::addINSTemperature ( )
protected

Definition at line 733 of file INSAction.C.

Referenced by act().

734 {
735  if (_use_ad)
736  {
737  {
738  const std::string kernel_type = "INSADEnergyAdvection";
739  InputParameters params = _factory.getValidParams(kernel_type);
740  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
741  if (_blocks.size() > 0)
742  params.set<std::vector<SubdomainName>>("block") = _blocks;
743  _problem->addKernel(kernel_type, "ins_temperature_convection", params);
744  }
745  {
746  const std::string kernel_type = "ADHeatConduction";
747  InputParameters params = _factory.getValidParams(kernel_type);
748  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
749  params.set<MaterialPropertyName>("thermal_conductivity") =
750  getParam<MaterialPropertyName>("thermal_conductivity_name");
751  if (_blocks.size() > 0)
752  params.set<std::vector<SubdomainName>>("block") = _blocks;
753  _problem->addKernel(kernel_type, "ins_temperature_conduction", params);
754  }
755 
756  if (getParam<bool>("supg"))
757  {
758  const std::string kernel_type = "INSADEnergySUPG";
759  InputParameters params = _factory.getValidParams(kernel_type);
760  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
761  if (_blocks.size() > 0)
762  params.set<std::vector<SubdomainName>>("block") = _blocks;
763  params.set<CoupledName>("velocity") = {NS::velocity};
764  params.set<MaterialPropertyName>("tau_name") = "tau_energy";
765  _problem->addKernel(kernel_type, "ins_temperature_supg", params);
766  }
767 
768  if (getParam<bool>("has_ambient_convection"))
769  {
770  const std::string kernel_type = "INSADEnergyAmbientConvection";
771  InputParameters params = _factory.getValidParams(kernel_type);
772  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
773  if (_blocks.size() > 0)
774  params.set<std::vector<SubdomainName>>("block") = _blocks;
775  params.set<Real>("alpha") = getParam<Real>("ambient_convection_alpha");
776  params.set<Real>("T_ambient") = getParam<Real>("ambient_temperature");
777  _problem->addKernel(kernel_type, "ins_temperature_ambient_convection", params);
778  }
779 
780  if (getParam<bool>("has_heat_source"))
781  {
782  const std::string kernel_type = "INSADEnergySource";
783  InputParameters params = _factory.getValidParams(kernel_type);
784  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
785  if (_blocks.size() > 0)
786  params.set<std::vector<SubdomainName>>("block") = _blocks;
787  if (isParamValid("heat_source_var"))
788  params.set<CoupledName>("source_variable") = getParam<CoupledName>("heat_source_var");
789  else if (isParamValid("heat_source_function"))
790  params.set<FunctionName>("source_function") =
791  getParam<FunctionName>("heat_source_function");
792  else
793  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  _problem->addKernel(kernel_type, "ins_temperature_source", params);
797  }
798  }
799  else
800  {
801  const std::string kernel_type = "INSTemperature";
802  InputParameters params = _factory.getValidParams(kernel_type);
803  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
804  params.set<CoupledName>("u") = {NS::velocity_x};
805  if (_dim >= 2)
806  params.set<CoupledName>("v") = {NS::velocity_y};
807  if (_dim >= 3)
808  params.set<CoupledName>("w") = {NS::velocity_z};
809  params.set<MaterialPropertyName>("k_name") =
810  getParam<MaterialPropertyName>("thermal_conductivity_name");
811  params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
812  params.set<MaterialPropertyName>("cp_name") =
813  getParam<MaterialPropertyName>("specific_heat_name");
814  if (_blocks.size() > 0)
815  params.set<std::vector<SubdomainName>>("block") = _blocks;
816  _problem->addKernel(kernel_type, "ins_temperature", params);
817  }
818 }
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
static const std::string velocity_x
Definition: NS.h:46
VariableName _temperature_variable_name
Temperature variable name to facilitate temperature variable added outside.
Definition: INSAction.h:80
bool isParamValid(const std::string &name) const
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
Definition: INSAction.h:56
Factory & _factory
bool _use_ad
Whether we use AD or not.
Definition: INSAction.h:78
static const std::string velocity_y
Definition: NS.h:47
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< VariableName > CoupledName
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82
void mooseError(Args &&... args) const
std::shared_ptr< FEProblemBase > & _problem
static const std::string velocity
Definition: NS.h:45

◆ addINSTemperatureBC()

void INSAction::addINSTemperatureBC ( )
protected

Definition at line 934 of file INSAction.C.

Referenced by act().

935 {
936  for (unsigned int i = 0; i < _fixed_temperature_boundary.size(); ++i)
937  {
938  const FunctionName func = _temperature_function[i];
939  if (func == "NA")
940  continue;
941 
942  std::stringstream ss(func);
943  Real val;
944  if ((ss >> val).fail() || !ss.eof())
945  {
946  InputParameters params = _factory.getValidParams("FunctionDirichletBC");
947  params.set<FunctionName>("function") = func;
948  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
949  params.set<std::vector<BoundaryName>>("boundary") = {_fixed_temperature_boundary[i]};
950  _problem->addBoundaryCondition("FunctionDirichletBC",
953  params);
954  }
955  else
956  {
957  InputParameters params = _factory.getValidParams("DirichletBC");
958  params.set<Real>("value") = val;
959  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
960  params.set<std::vector<BoundaryName>>("boundary") = {_fixed_temperature_boundary[i]};
961  _problem->addBoundaryCondition(
962  "DirichletBC", _temperature_variable_name + "_" + _fixed_temperature_boundary[i], params);
963  }
964  }
965 }
T & set(const std::string &name, bool quiet_mode=false)
std::vector< FunctionName > _temperature_function
Temperature function names at fixed temperature boundaries.
Definition: INSAction.h:74
VariableName _temperature_variable_name
Temperature variable name to facilitate temperature variable added outside.
Definition: INSAction.h:80
Factory & _factory
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< BoundaryName > _fixed_temperature_boundary
Boundaries with temperature specified.
Definition: INSAction.h:72
std::shared_ptr< FEProblemBase > & _problem

◆ addINSTimeKernels()

void INSAction::addINSTimeKernels ( )
protected

Definition at line 514 of file INSAction.C.

Referenced by act().

515 {
516  if (_use_ad)
517  {
518  const std::string kernel_type = "INSADMomentumTimeDerivative";
519  InputParameters params = _factory.getValidParams(kernel_type);
520  if (_blocks.size() > 0)
521  params.set<std::vector<SubdomainName>>("block") = _blocks;
522  params.set<NonlinearVariableName>("variable") = NS::velocity;
523  _problem->addKernel(kernel_type, "ins_velocity_time_deriv", params);
524 
525  if (getParam<bool>("add_temperature_equation"))
526  {
527  const std::string kernel_type = "INSADHeatConductionTimeDerivative";
528  InputParameters params = _factory.getValidParams(kernel_type);
529  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
530  if (_blocks.size() > 0)
531  params.set<std::vector<SubdomainName>>("block") = _blocks;
532  _problem->addKernel(kernel_type, "ins_temperature_time_deriv", params);
533  }
534  }
535  else
536  {
537  const std::string kernel_type = "INSMomentumTimeDerivative";
538  InputParameters params = _factory.getValidParams(kernel_type);
539  if (_blocks.size() > 0)
540  params.set<std::vector<SubdomainName>>("block") = _blocks;
541  params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
542 
543  const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
544  for (unsigned int component = 0; component < _dim; ++component)
545  {
546  params.set<NonlinearVariableName>("variable") = momentums[component];
547  _problem->addKernel(kernel_type, momentums[component] + "_time_deriv", params);
548  }
549 
550  if (getParam<bool>("add_temperature_equation"))
551  {
552  const std::string kernel_type = "INSTemperatureTimeDerivative";
553  InputParameters params = _factory.getValidParams(kernel_type);
554  params.set<NonlinearVariableName>("variable") = _temperature_variable_name;
555  if (_blocks.size() > 0)
556  params.set<std::vector<SubdomainName>>("block") = _blocks;
557  params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
558  params.set<MaterialPropertyName>("cp_name") =
559  getParam<MaterialPropertyName>("specific_heat_name");
560  _problem->addKernel(kernel_type, "ins_temperature_time_deriv", params);
561  }
562  }
563 }
static const std::string component
Definition: NS.h:153
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
static const std::string velocity_x
Definition: NS.h:46
VariableName _temperature_variable_name
Temperature variable name to facilitate temperature variable added outside.
Definition: INSAction.h:80
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
Definition: INSAction.h:56
Factory & _factory
bool _use_ad
Whether we use AD or not.
Definition: INSAction.h:78
static const std::string velocity_y
Definition: NS.h:47
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82
std::shared_ptr< FEProblemBase > & _problem
static const std::string velocity
Definition: NS.h:45

◆ addINSVelocityAux()

void INSAction::addINSVelocityAux ( )
protected

Definition at line 602 of file INSAction.C.

Referenced by act().

603 {
604  const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
605  const static std::string coord[3] = {"x", "y", "z"};
606  InputParameters params = _factory.getValidParams("VectorVariableComponentAux");
607  params.set<CoupledName>("vector_variable") = {NS::velocity};
608  for (unsigned int component = 0; component < _dim; ++component)
609  {
610  params.set<AuxVariableName>("variable") = momentums[component];
611  params.set<MooseEnum>("component") = coord[component];
612  _problem->addAuxKernel("VectorVariableComponentAux", momentums[component] + "_aux", params);
613  }
614 }
static const std::string component
Definition: NS.h:153
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
static const std::string velocity_x
Definition: NS.h:46
Factory & _factory
static const std::string velocity_y
Definition: NS.h:47
std::vector< VariableName > CoupledName
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82
std::shared_ptr< FEProblemBase > & _problem
static const std::string velocity
Definition: NS.h:45

◆ addINSVelocityBC()

void INSAction::addINSVelocityBC ( )
protected

Definition at line 821 of file INSAction.C.

Referenced by act().

822 {
823  const static std::string momentums[3] = {NS::velocity_x, NS::velocity_y, NS::velocity_z};
824  for (unsigned int i = 0; i < _velocity_boundary.size(); ++i)
825  {
826  if (_use_ad)
827  {
828  InputParameters params = _factory.getValidParams("ADVectorFunctionDirichletBC");
829 
830  {
831  const FunctionName funcx = _velocity_function[i * _dim];
832  if (funcx == "NA")
833  params.set<bool>("set_x_comp") = false;
834  else
835  {
836  std::stringstream ss(funcx);
837  Real val;
838  if ((ss >> val).fail() || !ss.eof())
839  {
840  if (!_problem->hasFunction(funcx))
841  {
842  InputParameters func_params = _factory.getValidParams("ConstantFunction");
843  func_params.set<Real>("value") = val;
844  _problem->addFunction("ConstantFunction", funcx, func_params);
845  }
846  }
847  params.set<FunctionName>("function_x") = funcx;
848  }
849  }
850 
851  if (_dim >= 2)
852  {
853  const FunctionName funcy = _velocity_function[i * _dim + 1];
854  if (funcy == "NA")
855  params.set<bool>("set_y_comp") = false;
856  else
857  {
858  std::stringstream ss(funcy);
859  Real val;
860  if ((ss >> val).fail() || !ss.eof())
861  {
862  if (!_problem->hasFunction(funcy))
863  {
864  InputParameters func_params = _factory.getValidParams("ConstantFunction");
865  func_params.set<Real>("value") = val;
866  _problem->addFunction("ConstantFunction", funcy, func_params);
867  }
868  }
869  params.set<FunctionName>("function_y") = funcy;
870  }
871  }
872 
873  if (_dim >= 3)
874  {
875  const FunctionName funcz = _velocity_function[i * _dim + 1];
876  if (funcz == "NA")
877  params.set<bool>("set_z_comp") = false;
878  else
879  {
880  std::stringstream ss(funcz);
881  Real val;
882  if ((ss >> val).fail() || !ss.eof())
883  {
884  if (!_problem->hasFunction(funcz))
885  {
886  InputParameters func_params = _factory.getValidParams("ConstantFunction");
887  func_params.set<Real>("value") = val;
888  _problem->addFunction("ConstantFunction", funcz, func_params);
889  }
890  }
891  params.set<FunctionName>("function_z") = funcz;
892  }
893  }
894 
895  params.set<NonlinearVariableName>("variable") = NS::velocity;
896  params.set<std::vector<BoundaryName>>("boundary") = {_velocity_boundary[i]};
897  _problem->addBoundaryCondition(
898  "ADVectorFunctionDirichletBC", "ins_velocity_bc_" + _velocity_boundary[i], params);
899  }
900  else
901  {
902  for (unsigned int component = 0; component < _dim; ++component)
903  {
904  const FunctionName func = _velocity_function[i * _dim + component];
905  if (func == "NA")
906  continue;
907 
908  std::stringstream ss(func);
909  Real val;
910  if ((ss >> val).fail() || !ss.eof())
911  {
912  InputParameters params = _factory.getValidParams("FunctionDirichletBC");
913  params.set<FunctionName>("function") = func;
914  params.set<NonlinearVariableName>("variable") = momentums[component];
915  params.set<std::vector<BoundaryName>>("boundary") = {_velocity_boundary[i]};
916  _problem->addBoundaryCondition(
917  "FunctionDirichletBC", momentums[component] + "_" + _velocity_boundary[i], params);
918  }
919  else
920  {
921  InputParameters params = _factory.getValidParams("DirichletBC");
922  params.set<Real>("value") = val;
923  params.set<NonlinearVariableName>("variable") = momentums[component];
924  params.set<std::vector<BoundaryName>>("boundary") = {_velocity_boundary[i]};
925  _problem->addBoundaryCondition(
926  "DirichletBC", momentums[component] + "_" + _velocity_boundary[i], params);
927  }
928  }
929  }
930  }
931 }
static const std::string component
Definition: NS.h:153
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
static const std::string velocity_x
Definition: NS.h:46
std::vector< BoundaryName > _velocity_boundary
Boundaries with velocity specified.
Definition: INSAction.h:58
Factory & _factory
bool _use_ad
Whether we use AD or not.
Definition: INSAction.h:78
static const std::string velocity_y
Definition: NS.h:47
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82
std::shared_ptr< FEProblemBase > & _problem
static const std::string velocity
Definition: NS.h:45
std::vector< FunctionName > _velocity_function
Velocity function names at velocity boundaries.
Definition: INSAction.h:60

◆ setKernelCommonParams()

void INSAction::setKernelCommonParams ( InputParameters params)
protected

Definition at line 1040 of file INSAction.C.

Referenced by addINSMass(), and addINSMomentum().

1041 {
1042  if (_blocks.size() > 0)
1043  params.set<std::vector<SubdomainName>>("block") = _blocks;
1044 
1045  // coupled variables
1046  params.set<CoupledName>("u") = {NS::velocity_x};
1047  if (_dim >= 2)
1048  params.set<CoupledName>("v") = {NS::velocity_y};
1049  if (_dim >= 3)
1050  params.set<CoupledName>("w") = {NS::velocity_z};
1052  params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
1053  params.set<MaterialPropertyName>("mu_name") =
1054  getParam<MaterialPropertyName>("dynamic_viscosity_name");
1055  params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
1056  params.set<Real>("alpha") = getParam<Real>("alpha");
1057  params.set<bool>("laplace") = getParam<bool>("laplace");
1058  // this parameter only affecting Jacobian evaluation in non-AD
1059  params.set<bool>("convective_term") = getParam<bool>("convective_term");
1060  // FIXME: this parameter seems not changing solution much?
1061  params.set<bool>("transient_term") = (_type == "transient");
1062 }
MooseEnum _type
Equation type, transient or steady-state.
Definition: INSAction.h:54
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
static const std::string velocity_x
Definition: NS.h:46
std::vector< SubdomainName > _blocks
Subdomains Navier-Stokes equation is defined on.
Definition: INSAction.h:56
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
static const std::string velocity_y
Definition: NS.h:47
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< VariableName > CoupledName
static const std::string pressure
Definition: NS.h:56
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82

◆ setNoBCCommonParams()

void INSAction::setNoBCCommonParams ( InputParameters params)
protected

Definition at line 1065 of file INSAction.C.

Referenced by addINSNoBCBC().

1066 {
1067  // coupled variables
1068  params.set<CoupledName>("u") = {NS::velocity_x};
1069  if (_dim >= 2)
1070  params.set<CoupledName>("v") = {NS::velocity_y};
1071  if (_dim >= 3)
1072  params.set<CoupledName>("w") = {NS::velocity_z};
1074  params.set<RealVectorValue>("gravity") = getParam<RealVectorValue>("gravity");
1075  params.set<MaterialPropertyName>("mu_name") =
1076  getParam<MaterialPropertyName>("dynamic_viscosity_name");
1077  params.set<MaterialPropertyName>("rho_name") = getParam<MaterialPropertyName>("density_name");
1078  params.set<bool>("integrate_p_by_parts") = getParam<bool>("integrate_p_by_parts");
1079 }
T & set(const std::string &name, bool quiet_mode=false)
static const std::string velocity_z
Definition: NS.h:48
static const std::string velocity_x
Definition: NS.h:46
const std::string _pressure_variable_name
pressure variable name
Definition: INSAction.h:86
static const std::string velocity_y
Definition: NS.h:47
std::vector< VariableName > CoupledName
static const std::string pressure
Definition: NS.h:56
unsigned int _dim
Mesh dimension.
Definition: INSAction.h:82

◆ validParams()

InputParameters INSAction::validParams ( )
static

Definition at line 36 of file INSAction.C.

37 {
39  params.addClassDescription("This class allows us to have a section of the input file for "
40  "setting up incompressible Navier-Stokes equations.");
41 
42  MooseEnum type("steady-state transient", "steady-state");
43  params.addParam<MooseEnum>("equation_type", type, "Navier-Stokes equation type");
44 
45  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  params.addParam<bool>("boussinesq_approximation", false, "True to have Boussinesq approximation");
50  params.addParam<MaterialPropertyName>(
51  "reference_temperature_name", "temp_ref", "Material property name for reference temperature");
52  params.addParam<MaterialPropertyName>(
53  "thermal_expansion_name", "alpha", "The name of the thermal expansion");
54 
55  params.addParam<bool>("add_temperature_equation", false, "True to add temperature equation");
56  params.addParam<VariableName>(
57  "temperature_variable", NS::temperature, "Temperature variable name");
58  params.addParam<Real>("temperature_scaling", 1, "Scaling for the temperature variable");
59  params.addParam<Real>(
60  "initial_temperature", 0, "The initial temperature, assumed constant everywhere");
61  params.addParam<MaterialPropertyName>(
62  "thermal_conductivity_name", "k", "The name of the thermal conductivity");
63  params.addParam<MaterialPropertyName>(
64  "specific_heat_name", "cp", "The name of the specific heat");
65  params.addParam<std::vector<BoundaryName>>("natural_temperature_boundary",
66  std::vector<BoundaryName>(),
67  "Natural boundaries for temperature equation");
68  params.addParam<std::vector<BoundaryName>>("fixed_temperature_boundary",
69  std::vector<BoundaryName>(),
70  "Dirichlet boundaries for temperature equation");
71  params.addParam<std::vector<FunctionName>>(
72  "temperature_function", std::vector<FunctionName>(), "Temperature on Dirichlet boundaries");
74  params.addParam<bool>(
75  "has_heat_source", false, "Whether there is a heat source function object in the simulation");
76  params.addParam<FunctionName>("heat_source_function", "The function describing the heat source");
77  params.addCoupledVar("heat_source_var", "The coupled variable describing the heat source");
78 
79  params.addParam<RealVectorValue>(
80  "gravity", RealVectorValue(0, 0, 0), "Direction of the gravity vector");
81 
82  params.addParam<MaterialPropertyName>(
83  "dynamic_viscosity_name", "mu", "The name of the dynamic viscosity");
84  params.addParam<MaterialPropertyName>("density_name", "rho", "The name of the density");
85 
86  params.addParam<bool>("use_ad", false, "True to use AD");
87  params.addParam<bool>(
88  "laplace", true, "Whether the viscous term of the momentum equations is in laplace form");
89  params.addParam<bool>(
90  "integrate_p_by_parts", true, "Whether to integrate the pressure term by parts");
91  params.addParam<bool>(
92  "convective_term", true, "Whether to include the convective term in Jacobian");
93  params.addParam<bool>(
94  "supg", false, "Whether to perform SUPG stabilization of the momentum residuals");
95  params.addParam<bool>(
96  "pspg", false, "Whether to perform PSPG stabilization of the mass equation");
97  params.addParam<Real>("alpha", 1, "Multiplicative factor on the stabilization parameter tau");
98  params.addParam<bool>("add_standard_velocity_variables_for_ad",
99  true,
100  "True to convert vector velocity variables into standard aux variables");
101  params.addParam<bool>(
102  "has_coupled_force",
103  false,
104  "Whether the simulation has a force due to a coupled vector variable/vector function");
105  params.addCoupledVar("coupled_force_var", "The variable(s) providing the coupled force(s)");
106  params.addParam<std::vector<FunctionName>>("coupled_force_vector_function",
107  "The function(s) standing in as a coupled force");
108 
109  params.addParam<std::vector<BoundaryName>>(
110  "velocity_boundary", std::vector<BoundaryName>(), "Boundaries with given velocities");
111  params.addParam<std::vector<FunctionName>>(
112  "velocity_function", std::vector<FunctionName>(), "Functions for boundary velocities");
113  params.addParam<unsigned int>("pressure_pinned_node",
114  "The node where pressure needs to be pinned");
115  params.addParam<std::vector<BoundaryName>>(
116  "no_bc_boundary", std::vector<BoundaryName>(), "The so-called no-bc Boundaries");
117  params.addParam<std::vector<BoundaryName>>(
118  "pressure_boundary", std::vector<BoundaryName>(), "Boundaries with given pressures");
119  params.addParam<std::vector<FunctionName>>(
120  "pressure_function", std::vector<FunctionName>(), "Functions for boundary pressures");
121 
124  params.addParam<MooseEnum>(
125  "family", families, "Specifies the family of FE shape functions to use for this variable");
126  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  params.addParam<Real>("pressure_scaling", 1, "Scaling for the pressure variable");
132  params.addParam<RealVectorValue>(
133  "velocity_scaling", RealVectorValue(1, 1, 1), "Scaling for the velocity variables");
134 
135  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  params.addParam<RealVectorValue>("initial_velocity",
140  RealVectorValue(1e-15, 1e-15, 1e-15),
141  "The initial velocity, assumed constant everywhere");
142  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  params.addParam<NonlinearSystemName>(
146  "nl_sys", "nl0", "The nonlinear system that this action belongs to.");
147 
148  params.addParamNamesToGroup(
149  "equation_type block gravity dynamic_viscosity_name density_name boussinesq_approximation "
150  "reference_temperature_name thermal_expansion_name",
151  "Base");
152  params.addParamNamesToGroup("use_ad laplace integrate_p_by_parts convective_term supg pspg alpha",
153  "WeakFormControl");
154  params.addParamNamesToGroup("velocity_boundary velocity_function pressure_pinned_node "
155  "no_bc_boundary pressure_boundary pressure_function",
156  "BoundaryCondition");
157  params.addParamNamesToGroup(
158  "family order pressure_scaling velocity_scaling initial_pressure initial_velocity",
159  "Variable");
160  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  return params;
166 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static const std::string temperature
Definition: NS.h:59
static MooseEnum getNonlinearVariableFamilies()
static InputParameters validParams()
static MooseEnum getNonlinearVariableOrders()
const std::string & type() const
void addAmbientConvectionParams(InputParameters &params)
Global for adding ambient convection parameters.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _block_ids

std::set<SubdomainID> INSAction::_block_ids
protected

Subdomain IDs.

Definition at line 84 of file INSAction.h.

Referenced by act().

◆ _blocks

std::vector<SubdomainName> INSAction::_blocks
protected

Subdomains Navier-Stokes equation is defined on.

Definition at line 56 of file INSAction.h.

Referenced by act(), addINSMass(), addINSMomentum(), addINSNoBCBC(), addINSTemperature(), addINSTimeKernels(), and setKernelCommonParams().

◆ _dim

unsigned int INSAction::_dim
protected

◆ _fe_type

libMesh::FEType INSAction::_fe_type
protected

FE type for various variables.

Definition at line 76 of file INSAction.h.

Referenced by act().

◆ _fixed_temperature_boundary

std::vector<BoundaryName> INSAction::_fixed_temperature_boundary
protected

Boundaries with temperature specified.

Definition at line 72 of file INSAction.h.

Referenced by act(), addINSTemperatureBC(), and INSAction().

◆ _has_pinned_node

bool INSAction::_has_pinned_node
protected

Whether or not we need to pin pressure at a node.

Definition at line 68 of file INSAction.h.

Referenced by act().

◆ _no_bc_boundary

std::vector<BoundaryName> INSAction::_no_bc_boundary
protected

No-BC boundaries.

Definition at line 66 of file INSAction.h.

Referenced by act(), and addINSNoBCBC().

◆ _pinned_node

BoundaryName INSAction::_pinned_node
protected

The node set name of the pinned node.

Definition at line 70 of file INSAction.h.

Referenced by act(), and addINSPinnedPressureBC().

◆ _pressure_boundary

std::vector<BoundaryName> INSAction::_pressure_boundary
protected

Boundaries with pressure specified.

Definition at line 62 of file INSAction.h.

Referenced by act(), addINSPressureBC(), and INSAction().

◆ _pressure_function

std::vector<FunctionName> INSAction::_pressure_function
protected

Pressure function names at pressure boundaries.

Definition at line 64 of file INSAction.h.

Referenced by addINSPressureBC(), and INSAction().

◆ _pressure_variable_name

const std::string INSAction::_pressure_variable_name
protected

◆ _temperature_function

std::vector<FunctionName> INSAction::_temperature_function
protected

Temperature function names at fixed temperature boundaries.

Definition at line 74 of file INSAction.h.

Referenced by addINSTemperatureBC(), and INSAction().

◆ _temperature_variable_name

VariableName INSAction::_temperature_variable_name
protected

Temperature variable name to facilitate temperature variable added outside.

Definition at line 80 of file INSAction.h.

Referenced by act(), addINSMomentum(), addINSTemperature(), addINSTemperatureBC(), and addINSTimeKernels().

◆ _type

MooseEnum INSAction::_type
protected

Equation type, transient or steady-state.

Definition at line 54 of file INSAction.h.

Referenced by act(), and setKernelCommonParams().

◆ _use_ad

bool INSAction::_use_ad
protected

Whether we use AD or not.

Definition at line 78 of file INSAction.h.

Referenced by act(), addINSMass(), addINSMomentum(), addINSNoBCBC(), addINSTemperature(), addINSTimeKernels(), addINSVelocityBC(), and INSAction().

◆ _velocity_boundary

std::vector<BoundaryName> INSAction::_velocity_boundary
protected

Boundaries with velocity specified.

Definition at line 58 of file INSAction.h.

Referenced by act(), and addINSVelocityBC().

◆ _velocity_function

std::vector<FunctionName> INSAction::_velocity_function
protected

Velocity function names at velocity boundaries.

Definition at line 60 of file INSAction.h.

Referenced by act(), and addINSVelocityBC().


The documentation for this class was generated from the following files: