www.mooseframework.org
PoroMechanicsAction.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 "PoroMechanicsAction.h"
11 
12 #include "Factory.h"
13 #include "FEProblem.h"
14 #include "Parser.h"
15 #include "Conversion.h"
16 
17 registerMooseAction("SolidMechanicsApp", PoroMechanicsAction, "setup_mesh_complete");
18 
19 registerMooseAction("SolidMechanicsApp", PoroMechanicsAction, "validate_coordinate_systems");
20 
21 registerMooseAction("SolidMechanicsApp", PoroMechanicsAction, "add_kernel");
22 
25 {
27  params.addRequiredParam<VariableName>("porepressure", "The pore pressure variable");
28  return params;
29 }
30 
33 {
34  if (_use_ad)
35  paramError("use_ad", "AD not setup for use with PoroMechanicsAction");
36 }
37 
38 void
40 {
42 
43  if (_current_task == "add_kernel")
44  {
45  // Prepare displacements and set value for dim
46  std::vector<VariableName> displacements = getParam<std::vector<VariableName>>("displacements");
47  unsigned int dim = displacements.size();
48 
49  // all the kernels added below have pore pressure as a coupled variable
50  // add this to the kernel's params
51  std::string type("PoroMechanicsCoupling");
53  VariableName pp_var(getParam<VariableName>("porepressure"));
54  params.addCoupledVar("porepressure", "");
55  params.set<std::vector<VariableName>>("porepressure") = {pp_var};
56 
57  // now add the kernels
58  for (unsigned int i = 0; i < dim; ++i)
59  {
60  std::string kernel_name = "PoroMechanics" + Moose::stringify(i);
61 
62  params.set<unsigned int>("component") = i;
63  params.set<NonlinearVariableName>("variable") = displacements[i];
64 
65  _problem->addKernel(type, kernel_name, params);
66  }
67  }
68 }
registerMooseAction("SolidMechanicsApp", PoroMechanicsAction, "setup_mesh_complete")
unsigned int dim
T & set(const std::string &name, bool quiet_mode=false)
InputParameters getValidParams(const std::string &name) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
Factory & _factory
static InputParameters validParams()
const std::string & type() const
const std::string & _current_task
void paramError(const std::string &param, Args... args) const
std::string stringify(const T &t)
void addCoupledVar(const std::string &name, const std::string &doc_string)
PoroMechanicsAction(const InputParameters &params)
std::shared_ptr< FEProblemBase > & _problem