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 22 of file ContactAction.h.

Constructor & Destructor Documentation

◆ ContactAction()

ContactAction::ContactAction ( const InputParameters &  params)

Definition at line 94 of file ContactAction.C.

95  : Action(params),
96  _master(getParam<BoundaryName>("master")),
97  _slave(getParam<BoundaryName>("slave")),
98  _model(getParam<std::string>("model")),
99  _formulation(getParam<MooseEnum>("formulation")),
100  _system(getParam<MooseEnum>("system"))
101 {
102  if (_formulation == "tangential_penalty")
103  {
104  if (_system != "Constraint")
105  mooseError(
106  "The 'tangential_penalty' formulation can only be used with the 'Constraint' system");
107  if (_model != "coulomb")
108  mooseError("The 'tangential_penalty' formulation can only be used with the 'coulomb' model");
109  }
110 }
const MooseEnum _system
Definition: ContactAction.h:34
const std::string _formulation
Definition: ContactAction.h:33
const BoundaryName _slave
Definition: ContactAction.h:31
const std::string _model
Definition: ContactAction.h:32
const BoundaryName _master
Definition: ContactAction.h:30

Member Function Documentation

◆ act()

void ContactAction::act ( )
overridevirtual

Definition at line 113 of file ContactAction.C.

114 {
115  if (!_problem->getDisplacedProblem())
116  mooseError("Contact requires updated coordinates. Use the 'displacements = ...' line in the "
117  "Mesh block.");
118 
119  // It is risky to apply this optimization to contact problems
120  // since the problem configuration may be changed during Jacobian
121  // evaluation. We therefore turn it off for all contact problems so that
122  // PETSc-3.8.4 or higher will have the same behavior as PETSc-3.8.3.
123  if (!_problem->isSNESMFReuseBaseSetbyUser())
124  _problem->setSNESMFReuseBase(false, false);
125 
126  std::string action_name = MooseUtils::shortName(name());
127 
128  std::vector<NonlinearVariableName> displacements;
129  if (isParamValid("displacements"))
130  displacements = getParam<std::vector<NonlinearVariableName>>("displacements");
131  else
132  {
133  // Legacy parameter scheme for displacements
134  if (!isParamValid("disp_x"))
135  mooseError("Specify displacement variables using the `displacements` parameter.");
136  displacements.push_back(getParam<NonlinearVariableName>("disp_x"));
137 
138  if (isParamValid("disp_y"))
139  {
140  displacements.push_back(getParam<NonlinearVariableName>("disp_y"));
141  if (isParamValid("disp_z"))
142  displacements.push_back(getParam<NonlinearVariableName>("disp_z"));
143  }
144 
145  mooseDeprecated("use the `displacements` parameter rather than the `disp_*` parameters (those "
146  "will go away with the deprecation of the Solid Mechanics module).");
147  }
148 
149  // Determine number of dimensions
150  const unsigned int ndisp = displacements.size();
151 
152  // convert vector of NonlinearVariableName to vector of VariableName
153  std::vector<VariableName> coupled_displacements(ndisp);
154  for (unsigned int i = 0; i < ndisp; ++i)
155  coupled_displacements[i] = displacements[i];
156 
157  if (_current_task == "add_dirac_kernel")
158  {
159  // MechanicalContactConstraint has to be added after the init_problem task, so it cannot be
160  // added for the add_constraint task.
161  if (_system == "Constraint")
162  {
163  InputParameters params = _factory.getValidParams("MechanicalContactConstraint");
164  params.applyParameters(parameters(), {"displacements", "formulation"});
165  params.set<std::string>("formulation") = _formulation;
166  params.set<std::vector<VariableName>>("nodal_area") = {"nodal_area_" + name()};
167  params.set<std::vector<VariableName>>("displacements") = coupled_displacements;
168  params.set<BoundaryName>("boundary") = _master;
169  params.set<bool>("use_displaced_mesh") = true;
170 
171  for (unsigned int i = 0; i < ndisp; ++i)
172  {
173  std::string name = action_name + "_constraint_" + Moose::stringify(i);
174 
175  params.set<unsigned int>("component") = i;
176  params.set<NonlinearVariableName>("variable") = displacements[i];
177  params.set<std::vector<VariableName>>("master_variable") = {coupled_displacements[i]};
178  _problem->addConstraint("MechanicalContactConstraint", name, params);
179  }
180  }
181 
182  if (_system == "DiracKernel")
183  {
184  {
185  InputParameters params = _factory.getValidParams("ContactMaster");
186  params.applyParameters(parameters(), {"displacements", "formulation"});
187  params.set<std::string>("formulation") = _formulation;
188  params.set<std::vector<VariableName>>("nodal_area") = {"nodal_area_" + name()};
189  params.set<std::vector<VariableName>>("displacements") = coupled_displacements;
190  params.set<BoundaryName>("boundary") = _master;
191  params.set<bool>("use_displaced_mesh") = true;
192 
193  for (unsigned int i = 0; i < ndisp; ++i)
194  {
195  std::string name = action_name + "_master_" + Moose::stringify(i);
196  params.set<unsigned int>("component") = i;
197  params.set<NonlinearVariableName>("variable") = displacements[i];
198  _problem->addDiracKernel("ContactMaster", name, params);
199  }
200  }
201 
202  {
203  InputParameters params = _factory.getValidParams("SlaveConstraint");
204  params.applyParameters(parameters(), {"displacements", "formulation"});
205  params.set<std::string>("formulation") = _formulation;
206  params.set<std::vector<VariableName>>("nodal_area") = {"nodal_area_" + name()};
207  params.set<std::vector<VariableName>>("displacements") = coupled_displacements;
208  params.set<BoundaryName>("boundary") = _slave;
209  params.set<bool>("use_displaced_mesh") = true;
210 
211  for (unsigned int i = 0; i < ndisp; ++i)
212  {
213  std::string name = action_name + "_slave_" + Moose::stringify(i);
214  params.set<unsigned int>("component") = i;
215  params.set<NonlinearVariableName>("variable") = displacements[i];
216  _problem->addDiracKernel("SlaveConstraint", name, params);
217  }
218  }
219  }
220  }
221 }
const MooseEnum _system
Definition: ContactAction.h:34
const std::string _formulation
Definition: ContactAction.h:33
const std::string name
Definition: Setup.h:22
const BoundaryName _slave
Definition: ContactAction.h:31
const BoundaryName _master
Definition: ContactAction.h:30

Member Data Documentation

◆ _formulation

const std::string ContactAction::_formulation
protected

Definition at line 33 of file ContactAction.h.

Referenced by act(), and ContactAction().

◆ _master

const BoundaryName ContactAction::_master
protected

Definition at line 30 of file ContactAction.h.

Referenced by act().

◆ _model

const std::string ContactAction::_model
protected

Definition at line 32 of file ContactAction.h.

Referenced by ContactAction().

◆ _slave

const BoundaryName ContactAction::_slave
protected

Definition at line 31 of file ContactAction.h.

Referenced by act().

◆ _system

const MooseEnum ContactAction::_system
protected

Definition at line 34 of file ContactAction.h.

Referenced by act(), and ContactAction().


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