www.mooseframework.org
CavityPressureAction.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 "CavityPressureAction.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.addRequiredParam<std::vector<BoundaryName>>(
18  "boundary", "The list of boundary IDs from the mesh where the pressure will be applied");
19  params.addRequiredParam<std::vector<NonlinearVariableName>>(
20  "displacements", "The nonlinear displacement variables");
21  params.addParam<std::vector<AuxVariableName>>(
22  "save_in", "Auxiliary variables to save the displacement residuals");
23  params.addParam<std::string>("output", "The name to use for the plenum pressure value");
24  params.addParam<bool>(
25  "use_displaced_mesh", true, "Whether to use displaced mesh in the boundary condition");
26  return params;
27 }
28 
29 CavityPressureAction::CavityPressureAction(const InputParameters & params) : Action(params) {}
30 
31 void
33 {
34  auto displacements = getParam<std::vector<NonlinearVariableName>>("displacements");
35  auto save_in = getParam<std::vector<AuxVariableName>>("save_in");
36 
37  unsigned int ndisp = displacements.size();
38  if (save_in.size() > 0 && save_in.size() != ndisp)
39  mooseError("Number of save_in variables should equal to the number of displacement variables ",
40  ndisp);
41 
42  InputParameters params = _factory.getValidParams("Pressure");
43  params.applyParameters(parameters());
44 
45  params.set<PostprocessorName>("postprocessor") =
46  isParamValid("output") ? getParam<std::string>("output") : _name;
47 
48  for (unsigned int i = 0; i < ndisp; ++i)
49  {
50  params.set<unsigned int>("component") = i;
51  params.set<NonlinearVariableName>("variable") = displacements[i];
52  if (!save_in.empty())
53  params.set<std::vector<AuxVariableName>>("save_in") = {save_in[i]};
54 
55  _problem->addBoundaryCondition("Pressure", _name + "_" + Moose::stringify(i), params);
56  }
57 }
InputParameters validParams< CavityPressureAction >()
CavityPressureAction(const InputParameters &params)
virtual void act() override