https://mooseframework.inl.gov
GeneralizedPlaneStrainActionPD.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 
11 #include "NonlinearSystemBase.h"
12 #include "Factory.h"
13 #include "FEProblemBase.h"
14 #include "MooseObjectAction.h"
15 
16 registerMooseAction("PeridynamicsApp", GeneralizedPlaneStrainActionPD, "add_kernel");
17 registerMooseAction("PeridynamicsApp", GeneralizedPlaneStrainActionPD, "add_user_object");
18 registerMooseAction("PeridynamicsApp", GeneralizedPlaneStrainActionPD, "add_scalar_kernel");
19 
22 {
24  params.addClassDescription("Class for setting up the Kernel, ScalarKernel, and UserObject for "
25  "peridynamic generalized plane strain model");
26 
27  params.addRequiredParam<std::vector<VariableName>>(
28  "displacements", "Nonlinear variable name for the displacements");
29  params.addRequiredParam<VariableName>("scalar_out_of_plane_strain",
30  "Scalar variable for strain in the out-of-plane direction");
31  params.addParam<VariableName>("temperature", "Nonlinear variable for the temperature");
32  MooseEnum formulation_option("ORDINARY_STATE NONORDINARY_STATE", "NONORDINARY_STATE");
33  params.addParam<MooseEnum>("formulation", formulation_option, "Peridynamic formulation options");
34  MooseEnum strain_type("SMALL FINITE", "SMALL");
35  params.addParam<MooseEnum>("strain", strain_type, "Strain formulation");
36  params.addParam<VariableName>("out_of_plane_stress_variable",
37  "Name of out-of-plane stress auxiliary variable");
38  params.addParam<FunctionName>(
39  "out_of_plane_pressure",
40  "0",
41  "Function used to prescribe pressure in the out-of-plane direction");
42  params.addParam<Real>("factor", 1.0, "Scale factor applied to prescribed out-of-plane pressure");
43  params.addParam<bool>("full_jacobian",
44  false,
45  "Parameter to set whether to use the nonlocal full Jacobian formulation "
46  "for the scalar components");
47  params.addParam<std::vector<SubdomainName>>("block",
48  "List of ids of the blocks (subdomains) that the "
49  "GeneralizedPlaneStrainActionPD will be applied "
50  "to");
51  params.addParam<std::vector<MaterialPropertyName>>(
52  "eigenstrain_names", {}, "List of eigenstrains to be applied in this strain calculation");
53 
54  return params;
55 }
56 
58  : Action(params),
59  _displacements(getParam<std::vector<VariableName>>("displacements")),
60  _ndisp(_displacements.size()),
61  _formulation(getParam<MooseEnum>("formulation")),
62  _scalar_out_of_plane_strain(getParam<VariableName>("scalar_out_of_plane_strain"))
63 {
64  // Generalized plane strain only applies to two dimensional modeling and simulation
65  if (_ndisp != 2)
66  mooseError("GeneralizedPlaneStrainPD only works for two dimensional case!");
67 
68  // Consistency check
69  if (_formulation == "NONORDINARY_STATE" && isParamValid("out_of_plane_stress_variable"))
70  mooseWarning("Variable out_of_plane_stress_variable will not be used in NONORDINARY_STATE "
71  "formulation option!");
72  if (_formulation == "ORDINARY_STATE" && !isParamValid("out_of_plane_stress_variable"))
73  mooseError("Variable out_of_plane_stress_variable must be provided for ORDINARY_STATE "
74  "formulation option!");
75 }
76 
77 void
79 {
80  if (_current_task == "add_kernel")
81  {
82  std::string k_type;
83  if (_formulation == "ORDINARY_STATE")
84  k_type = "GeneralizedPlaneStrainOffDiagOSPD"; // Based on the ordinary state-based model
85  else if (_formulation == "NONORDINARY_STATE")
86  k_type = "GeneralizedPlaneStrainOffDiagNOSPD"; // Based on Form I of horizon-stabilized
87  // correspondence model
88  else
89  paramError("formulation", "Unsupported peridynamic formulation");
90 
91  InputParameters params = _factory.getValidParams(k_type);
92 
93  params.applyParameters(parameters(),
94  {"displacements", "temperature", "scalar_out_of_plane_strain"});
95 
96  params.set<std::vector<VariableName>>("displacements") = _displacements;
97  params.set<std::vector<VariableName>>("scalar_out_of_plane_strain") = {
99 
100  // Coupling between scalar out-of-plane strain and in-plane displacements
101  for (unsigned int i = 0; i < _ndisp; ++i)
102  {
103  std::string k_name = name() + "_GeneralizedPlaneStrainPDOffDiag_disp_" + Moose::stringify(i);
104  params.set<NonlinearVariableName>("variable") = _displacements[i];
105 
106  _problem->addKernel(k_type, k_name, params);
107  }
108 
109  // Coupling between scalar out-of-plane strain and temperature (only when temperature is a
110  // nonlinear variable)
111  if (isParamValid("temperature"))
112  {
113  VariableName temp = getParam<VariableName>("temperature");
114  if (_problem->getNonlinearSystemBase(/*nl_sys_num=*/0).hasVariable(temp))
115  {
116  params.set<std::vector<VariableName>>("temperature") = {temp};
117 
118  std::string k_name = name() + "_GeneralizedPlaneStrainPDOffDiag_temp";
119  params.set<NonlinearVariableName>("variable") = temp;
120 
121  if (_formulation == "NONORDINARY_STATE")
122  params.set<std::vector<MaterialPropertyName>>("eigenstrain_names") =
123  getParam<std::vector<MaterialPropertyName>>("eigenstrain_names");
124 
125  _problem->addKernel(k_type, k_name, params);
126  }
127  }
128  }
129  else if (_current_task == "add_user_object")
130  {
131  std::string uo_type;
132  if (_formulation == "ORDINARY_STATE")
133  uo_type = "GeneralizedPlaneStrainUserObjectOSPD";
134  else if (_formulation == "NONORDINARY_STATE")
135  uo_type = "GeneralizedPlaneStrainUserObjectNOSPD";
136  else
137  paramError("formulation", "Unsupported peridynamic formulation!");
138 
139  InputParameters params = _factory.getValidParams(uo_type);
140 
141  std::string uo_name = name() + "_GeneralizedPlaneStrainPDUserObject";
142 
143  params.applyParameters(parameters(), {"out_of_plane_stress_variable"});
144 
145  if (_formulation == "ORDINARY_STATE")
146  params.set<std::vector<VariableName>>("out_of_plane_stress_variable") = {
147  getParam<VariableName>("out_of_plane_stress_variable")};
148 
149  _problem->addUserObject(uo_type, uo_name, params);
150  }
151  else if (_current_task == "add_scalar_kernel")
152  {
153  std::string sk_type("GeneralizedPlaneStrainPD");
154  InputParameters params = _factory.getValidParams(sk_type);
155 
156  std::string sk_name = name() + "_GeneralizedPlaneStrainPD";
157 
158  params.set<NonlinearVariableName>("variable") = _scalar_out_of_plane_strain;
159 
160  // set the UserObjectName using added UserObject
161  params.set<UserObjectName>("generalized_plane_strain_uo") =
162  name() + "_GeneralizedPlaneStrainPDUserObject";
163 
164  _problem->addScalarKernel(sk_type, sk_name, params);
165  }
166  else
167  mooseError("Task error in GeneralizedPlaneStrainActionPD!");
168 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
VariableName _scalar_out_of_plane_strain
Scalar variable for out-of-plane strain variable.
T & set(const std::string &name, bool quiet_mode=false)
std::vector< VariableName > _displacements
Displacement variables.
InputParameters getValidParams(const std::string &name) const
void applyParameters(const InputParameters &common, const std::vector< std::string > &exclude={}, const bool allow_private=false)
virtual const std::string & name() const
void mooseWarning(Args &&... args) const
void addRequiredParam(const std::string &name, const std::string &doc_string)
bool isParamValid(const std::string &name) const
Factory & _factory
registerMooseAction("PeridynamicsApp", GeneralizedPlaneStrainActionPD, "add_kernel")
static InputParameters validParams()
const MooseEnum _formulation
Option to choose which peridynamic model to use for generalized plane strain formulation: ordinary st...
const T & getParam(const std::string &name) const
const std::string & _current_task
GeneralizedPlaneStrainActionPD(const InputParameters &params)
void paramError(const std::string &param, Args... args) const
std::string stringify(const T &t)
Action class to setup peridynamic generalized plane strain models.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
std::shared_ptr< FEProblemBase > & _problem
const InputParameters & parameters() const