www.mooseframework.org
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
PressureAction Class Reference

#include <PressureAction.h>

Inheritance diagram for PressureAction:
[legend]

Public Member Functions

 PressureAction (const InputParameters &params)
 
virtual void act () override
 

Static Public Member Functions

static InputParameters validParams ()
 

Protected Attributes

const bool _use_ad
 Flag to use automatic differentiation. More...
 
std::vector< std::vector< AuxVariableName > > _save_in_vars
 
std::vector< bool > _has_save_in_vars
 

Detailed Description

Definition at line 14 of file PressureAction.h.

Constructor & Destructor Documentation

◆ PressureAction()

PressureAction::PressureAction ( const InputParameters &  params)

Definition at line 52 of file PressureAction.C.

53  : Action(params), _use_ad(getParam<bool>("use_automatic_differentiation"))
54 {
55  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_x"));
56  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_y"));
57  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_z"));
58 
59  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_x"));
60  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_y"));
61  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_z"));
62 }

Member Function Documentation

◆ act()

void PressureAction::act ( )
overridevirtual

Definition at line 65 of file PressureAction.C.

66 {
67  std::string ad_append = "";
68  std::string ad_prepend = "";
69  if (_use_ad)
70  {
71  ad_append = "<RESIDUAL>";
72  ad_prepend = "AD";
73  }
74 
75  std::string kernel_name = ad_prepend + "Pressure";
76 
77  std::vector<VariableName> displacements;
78  if (isParamValid("displacements"))
79  displacements = getParam<std::vector<VariableName>>("displacements");
80  else
81  {
82  // Legacy parameter scheme for displacements
83  if (!isParamValid("disp_x"))
84  mooseError("Specify displacement variables using the `displacements` parameter.");
85  displacements.push_back(getParam<VariableName>("disp_x"));
86 
87  if (isParamValid("disp_y"))
88  {
89  displacements.push_back(getParam<VariableName>("disp_y"));
90  if (isParamValid("disp_z"))
91  displacements.push_back(getParam<VariableName>("disp_z"));
92  }
93  }
94 
95  // Create pressure BCs
96  for (unsigned int i = 0; i < displacements.size(); ++i)
97  {
98  // Create unique kernel name for each of the components
99  std::string unique_kernel_name = kernel_name + "_" + _name + "_" + Moose::stringify(i);
100 
101  InputParameters params = _factory.getValidParams(kernel_name + ad_append);
102  params.applyParameters(parameters(), {"factor"});
103  params.set<bool>("use_displaced_mesh") = true;
104  params.set<unsigned int>("component") = i;
105  params.set<NonlinearVariableName>("variable") = displacements[i];
106 
107  if (_has_save_in_vars[i])
108  params.set<std::vector<AuxVariableName>>("save_in") = _save_in_vars[i];
109 
110  if (_use_ad)
111  {
112  params.set<Real>("constant") = getParam<Real>("factor");
113  _problem->addBoundaryCondition(
114  kernel_name + ad_append, unique_kernel_name + "_residual", params);
115  _problem->addBoundaryCondition(
116  kernel_name + "<JACOBIAN>", unique_kernel_name + "_jacobian", params);
117  _problem->haveADObjects(true);
118  }
119  else
120  {
121  params.set<Real>("factor") = getParam<Real>("factor");
122  _problem->addBoundaryCondition(kernel_name, unique_kernel_name, params);
123  }
124  }
125 }

◆ validParams()

InputParameters PressureAction::validParams ( )
static

Definition at line 20 of file PressureAction.C.

21 {
22  InputParameters params = Action::validParams();
23  params.addClassDescription("Set up Pressure boundary conditions");
24 
25  params.addRequiredParam<std::vector<BoundaryName>>(
26  "boundary", "The list of boundary IDs from the mesh where the pressure will be applied");
27 
28  params.addParam<VariableName>("disp_x", "The x displacement");
29  params.addParam<VariableName>("disp_y", "The y displacement");
30  params.addParam<VariableName>("disp_z", "The z displacement");
31 
32  params.addParam<std::vector<VariableName>>(
33  "displacements",
34  "The displacements appropriate for the simulation geometry and coordinate system");
35 
36  params.addParam<std::vector<AuxVariableName>>("save_in_disp_x",
37  "The save_in variables for x displacement");
38  params.addParam<std::vector<AuxVariableName>>("save_in_disp_y",
39  "The save_in variables for y displacement");
40  params.addParam<std::vector<AuxVariableName>>("save_in_disp_z",
41  "The save_in variables for z displacement");
42 
43  params.addParam<Real>("factor", 1.0, "The factor to use in computing the pressure");
44  params.addParam<Real>("alpha", 0.0, "alpha parameter for HHT time integration");
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  return params;
50 }

Member Data Documentation

◆ _has_save_in_vars

std::vector<bool> PressureAction::_has_save_in_vars
protected

Definition at line 28 of file PressureAction.h.

Referenced by act(), and PressureAction().

◆ _save_in_vars

std::vector<std::vector<AuxVariableName> > PressureAction::_save_in_vars
protected

Definition at line 27 of file PressureAction.h.

Referenced by act(), and PressureAction().

◆ _use_ad

const bool PressureAction::_use_ad
protected

Flag to use automatic differentiation.

Definition at line 25 of file PressureAction.h.

Referenced by act().


The documentation for this class was generated from the following files:
PressureAction::_save_in_vars
std::vector< std::vector< AuxVariableName > > _save_in_vars
Definition: PressureAction.h:27
validParams
InputParameters validParams()
PressureAction::_has_save_in_vars
std::vector< bool > _has_save_in_vars
Definition: PressureAction.h:28
PressureAction::_use_ad
const bool _use_ad
Flag to use automatic differentiation.
Definition: PressureAction.h:25