www.mooseframework.org
PressureAction.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "PressureAction.h"
11 #include "Factory.h"
12 #include "FEProblem.h"
13 #include "Conversion.h"
14 
15 registerMooseAction("SolidMechanicsApp", PressureAction, "add_bc");
16 
19 {
21  params.addClassDescription("Set up Pressure boundary conditions");
22 
23  params.addRequiredParam<std::vector<BoundaryName>>(
24  "boundary", "The list of boundary IDs from the mesh where the pressure will be applied");
25 
26  params.addRequiredParam<std::vector<VariableName>>(
27  "displacements",
28  "The displacements appropriate for the simulation geometry and coordinate system");
29 
30  params.addParam<std::vector<AuxVariableName>>(
31  "save_in_disp_x", {}, "The save_in variables for x displacement");
32  params.addParam<std::vector<AuxVariableName>>(
33  "save_in_disp_y", {}, "The save_in variables for y displacement");
34  params.addParam<std::vector<AuxVariableName>>(
35  "save_in_disp_z", {}, "The save_in variables for z displacement");
36 
37  params.addParam<Real>("factor", 1.0, "The factor to use in computing the pressure");
38  params.addParam<bool>("use_displaced_mesh", true, "Whether to use the displaced mesh.");
39  params.addParam<Real>("hht_alpha",
40  0,
41  "alpha parameter for mass dependent numerical damping induced "
42  "by HHT time integration scheme");
43  params.addDeprecatedParam<Real>(
44  "alpha", "alpha parameter for HHT time integration", "Please use hht_alpha");
45  params.addParam<FunctionName>("function", "The function that describes the pressure");
46  params.addParam<bool>("use_automatic_differentiation",
47  false,
48  "Flag to use automatic differentiation (AD) objects when possible");
49  params.addParam<std::vector<TagName>>("extra_vector_tags",
50  "The extra tags for the vectors this Kernel should fill");
51  params.addParam<std::vector<TagName>>(
52  "absolute_value_vector_tags",
53  "The tags for the vectors this residual object should fill with the "
54  "absolute value of the residual contribution");
55  return params;
56 }
57 
59  : Action(params), _use_ad(getParam<bool>("use_automatic_differentiation"))
60 {
61  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_x"));
62  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_y"));
63  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_z"));
64 
65  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_x"));
66  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_y"));
67  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_z"));
68 }
69 
70 void
72 {
73  std::string ad_prepend = "";
74  if (_use_ad)
75  ad_prepend = "AD";
76 
77  std::string kernel_name = ad_prepend + "Pressure";
78 
79  std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements");
80 
81  // Create pressure BCs
82  for (unsigned int i = 0; i < displacements.size(); ++i)
83  {
84  // Create unique kernel name for each of the components
85  std::string unique_kernel_name = kernel_name + "_" + _name + "_" + Moose::stringify(i);
86 
87  InputParameters params = _factory.getValidParams(kernel_name);
88  params.applyParameters(parameters(), {"factor"});
89  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
90  params.set<Real>("alpha") =
91  isParamValid("alpha") ? getParam<Real>("alpha") : getParam<Real>("hht_alpha");
92 
93  params.set<NonlinearVariableName>("variable") = displacements[i];
94 
95  if (_has_save_in_vars[i])
96  params.set<std::vector<AuxVariableName>>("save_in") = _save_in_vars[i];
97 
98  params.set<Real>("factor") = getParam<Real>("factor");
99  _problem->addBoundaryCondition(kernel_name, unique_kernel_name, params);
100  }
101 }
void addDeprecatedParam(const std::string &name, const T &value, const std::string &doc_string, const std::string &deprecation_message)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
void addRequiredParam(const std::string &name, const std::string &doc_string)
PressureAction(const InputParameters &params)
std::vector< bool > _has_save_in_vars
bool isParamValid(const std::string &name) const
Factory & _factory
static InputParameters validParams()
std::vector< std::vector< AuxVariableName > > _save_in_vars
const T & getParam(const std::string &name) const
std::string stringify(const T &t)
const std::string _name
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void act() override
const bool _use_ad
Flag to use automatic differentiation.
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
const InputParameters & parameters() const
registerMooseAction("SolidMechanicsApp", PressureAction, "add_bc")
static InputParameters validParams()
bool isParamValid(const std::string &name) const