www.mooseframework.org
PressureAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
7 #include "PressureAction.h"
8 #include "Factory.h"
9 #include "FEProblem.h"
10 #include "Conversion.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<Action>();
17  params.addClassDescription("Set up Pressure boundary conditions");
18 
19  params.addRequiredParam<std::vector<BoundaryName>>(
20  "boundary", "The list of boundary IDs from the mesh where the pressure will be applied");
21 
22  params.addParam<NonlinearVariableName>("disp_x", "The x displacement");
23  params.addParam<NonlinearVariableName>("disp_y", "The y displacement");
24  params.addParam<NonlinearVariableName>("disp_z", "The z displacement");
25 
26  params.addParam<std::vector<NonlinearVariableName>>(
27  "displacements",
28  "The displacements appropriate for the simulation geometry and coordinate system");
29 
30  params.addParam<std::vector<AuxVariableName>>("save_in_disp_x",
31  "The save_in variables for x displacement");
32  params.addParam<std::vector<AuxVariableName>>("save_in_disp_y",
33  "The save_in variables for y displacement");
34  params.addParam<std::vector<AuxVariableName>>("save_in_disp_z",
35  "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<Real>("alpha", 0.0, "alpha parameter for HHT time integration");
39  params.addParam<FunctionName>("function", "The function that describes the pressure");
40  return params;
41 }
42 
43 PressureAction::PressureAction(const InputParameters & params) : Action(params)
44 {
45  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_x"));
46  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_y"));
47  _save_in_vars.push_back(getParam<std::vector<AuxVariableName>>("save_in_disp_z"));
48 
49  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_x"));
50  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_y"));
51  _has_save_in_vars.push_back(params.isParamValid("save_in_disp_z"));
52 }
53 
54 void
56 {
57  const std::string kernel_name = "Pressure";
58 
59  std::vector<NonlinearVariableName> displacements;
60  if (isParamValid("displacements"))
61  displacements = getParam<std::vector<NonlinearVariableName>>("displacements");
62  else
63  {
64  // Legacy parameter scheme for displacements
65  if (!isParamValid("disp_x"))
66  mooseError("Specify displacement variables using the `displacements` parameter.");
67  displacements.push_back(getParam<NonlinearVariableName>("disp_x"));
68 
69  if (isParamValid("disp_y"))
70  {
71  displacements.push_back(getParam<NonlinearVariableName>("disp_y"));
72  if (isParamValid("disp_z"))
73  displacements.push_back(getParam<NonlinearVariableName>("disp_z"));
74  }
75  }
76 
77  // Create pressure BCs
78  for (unsigned int i = 0; i < displacements.size(); ++i)
79  {
80  // Create unique kernel name for each of the components
81  std::string unique_kernel_name = kernel_name + "_" + _name + "_" + Moose::stringify(i);
82 
83  InputParameters params = _factory.getValidParams(kernel_name);
84  params.applyParameters(parameters());
85  params.set<bool>("use_displaced_mesh") = true;
86  params.set<unsigned int>("component") = i;
87  params.set<NonlinearVariableName>("variable") = displacements[i];
88 
89  if (_has_save_in_vars[i])
90  params.set<std::vector<AuxVariableName>>("save_in") = _save_in_vars[i];
91 
92  _problem->addBoundaryCondition(kernel_name, unique_kernel_name, params);
93  }
94 }
InputParameters validParams< PressureAction >()
PressureAction(const InputParameters &params)
std::vector< bool > _has_save_in_vars
std::vector< std::vector< AuxVariableName > > _save_in_vars
virtual void act() override