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

#include <ContactAction.h>

Inheritance diagram for ContactAction:
[legend]

Public Member Functions

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

Protected Attributes

const BoundaryName _master
 
const BoundaryName _slave
 
const std::string _model
 
const std::string _formulation
 
const MooseEnum _system
 

Detailed Description

Definition at line 19 of file ContactAction.h.

Constructor & Destructor Documentation

ContactAction::ContactAction ( const InputParameters &  params)

Definition at line 81 of file ContactAction.C.

82  : Action(params),
83  _master(getParam<BoundaryName>("master")),
84  _slave(getParam<BoundaryName>("slave")),
85  _model(getParam<std::string>("model")),
86  _formulation(getParam<MooseEnum>("formulation")),
87  _system(getParam<MooseEnum>("system"))
88 {
89  if (_formulation == "tangential_penalty")
90  {
91  if (_system != "Constraint")
92  mooseError(
93  "The 'tangential_penalty' formulation can only be used with the 'Constraint' system");
94  if (_model != "coulomb")
95  mooseError("The 'tangential_penalty' formulation can only be used with the 'coulomb' model");
96  }
97 }
const MooseEnum _system
Definition: ContactAction.h:31
const std::string _formulation
Definition: ContactAction.h:30
const BoundaryName _slave
Definition: ContactAction.h:28
const std::string _model
Definition: ContactAction.h:29
const BoundaryName _master
Definition: ContactAction.h:27

Member Function Documentation

void ContactAction::act ( )
overridevirtual

Definition at line 100 of file ContactAction.C.

101 {
102  if (!_problem->getDisplacedProblem())
103  mooseError("Contact requires updated coordinates. Use the 'displacements = ...' line in the "
104  "Mesh block.");
105 
106  std::string action_name = MooseUtils::shortName(name());
107 
108  std::vector<NonlinearVariableName> displacements;
109  if (isParamValid("displacements"))
110  displacements = getParam<std::vector<NonlinearVariableName>>("displacements");
111  else
112  {
113  // Legacy parameter scheme for displacements
114  if (!isParamValid("disp_x"))
115  mooseError("Specify displacement variables using the `displacements` parameter.");
116  displacements.push_back(getParam<NonlinearVariableName>("disp_x"));
117 
118  if (isParamValid("disp_y"))
119  {
120  displacements.push_back(getParam<NonlinearVariableName>("disp_y"));
121  if (isParamValid("disp_z"))
122  displacements.push_back(getParam<NonlinearVariableName>("disp_z"));
123  }
124 
125  mooseDeprecated("use the `displacements` parameter rather than the `disp_*` parameters (those "
126  "will go away with the deprecation of the Solid Mechanics module).");
127  }
128 
129  // Determine number of dimensions
130  const unsigned int ndisp = displacements.size();
131 
132  // convert vector of NonlinearVariableName to vector of VariableName
133  std::vector<VariableName> coupled_displacements(ndisp);
134  for (unsigned int i = 0; i < ndisp; ++i)
135  coupled_displacements[i] = displacements[i];
136 
137  if (_current_task == "add_dirac_kernel")
138  {
139  // MechanicalContactConstraint has to be added after the init_problem task, so it cannot be
140  // added for the add_constraint task.
141  if (_system == "Constraint")
142  {
143  InputParameters params = _factory.getValidParams("MechanicalContactConstraint");
144  params.applyParameters(parameters(), {"displacements", "formulation"});
145  params.set<std::string>("formulation") = _formulation;
146  params.set<std::vector<VariableName>>("nodal_area") = {"nodal_area_" + name()};
147  params.set<std::vector<VariableName>>("displacements") = coupled_displacements;
148  params.set<BoundaryName>("boundary") = _master;
149  params.set<bool>("use_displaced_mesh") = true;
150 
151  for (unsigned int i = 0; i < ndisp; ++i)
152  {
153  std::string name = action_name + "_constraint_" + Moose::stringify(i);
154 
155  params.set<unsigned int>("component") = i;
156  params.set<NonlinearVariableName>("variable") = displacements[i];
157  params.set<std::vector<VariableName>>("master_variable") = {coupled_displacements[i]};
158 
159  _problem->addConstraint("MechanicalContactConstraint", name, params);
160  }
161  }
162 
163  if (_system == "DiracKernel")
164  {
165  {
166  InputParameters params = _factory.getValidParams("ContactMaster");
167  params.applyParameters(parameters(), {"displacements", "formulation"});
168  params.set<std::string>("formulation") = _formulation;
169  params.set<std::vector<VariableName>>("nodal_area") = {"nodal_area_" + name()};
170  params.set<std::vector<VariableName>>("displacements") = coupled_displacements;
171  params.set<BoundaryName>("boundary") = _master;
172  params.set<bool>("use_displaced_mesh") = true;
173 
174  for (unsigned int i = 0; i < ndisp; ++i)
175  {
176  std::string name = action_name + "_master_" + Moose::stringify(i);
177  params.set<unsigned int>("component") = i;
178  params.set<NonlinearVariableName>("variable") = displacements[i];
179  _problem->addDiracKernel("ContactMaster", name, params);
180  }
181  }
182 
183  {
184  InputParameters params = _factory.getValidParams("SlaveConstraint");
185  params.applyParameters(parameters(), {"displacements", "formulation"});
186  params.set<std::string>("formulation") = _formulation;
187  params.set<std::vector<VariableName>>("nodal_area") = {"nodal_area_" + name()};
188  params.set<std::vector<VariableName>>("displacements") = coupled_displacements;
189  params.set<BoundaryName>("boundary") = _slave;
190  params.set<bool>("use_displaced_mesh") = true;
191 
192  for (unsigned int i = 0; i < ndisp; ++i)
193  {
194  std::string name = action_name + "_slave_" + Moose::stringify(i);
195  params.set<unsigned int>("component") = i;
196  params.set<NonlinearVariableName>("variable") = displacements[i];
197  _problem->addDiracKernel("SlaveConstraint", name, params);
198  }
199  }
200  }
201  }
202 }
const MooseEnum _system
Definition: ContactAction.h:31
const std::string _formulation
Definition: ContactAction.h:30
const BoundaryName _slave
Definition: ContactAction.h:28
const BoundaryName _master
Definition: ContactAction.h:27

Member Data Documentation

const std::string ContactAction::_formulation
protected

Definition at line 30 of file ContactAction.h.

Referenced by act(), and ContactAction().

const BoundaryName ContactAction::_master
protected

Definition at line 27 of file ContactAction.h.

Referenced by act().

const std::string ContactAction::_model
protected

Definition at line 29 of file ContactAction.h.

Referenced by ContactAction().

const BoundaryName ContactAction::_slave
protected

Definition at line 28 of file ContactAction.h.

Referenced by act().

const MooseEnum ContactAction::_system
protected

Definition at line 31 of file ContactAction.h.

Referenced by act(), and ContactAction().


The documentation for this class was generated from the following files: