www.mooseframework.org
ContactLineSearchBase.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 "ContactLineSearchBase.h"
11 #include "PetscSupport.h"
12 #include "InputParameters.h"
13 #include "MooseEnum.h"
14 #include "FEProblem.h"
15 #include "MooseError.h"
16 
17 registerMooseObjectAliased("ContactApp", ContactLineSearchBase, "ContactLineSearch");
18 
19 template <>
20 InputParameters
22 {
23  InputParameters params = validParams<LineSearch>();
24  params.addRequiredParam<unsigned>("allowed_lambda_cuts",
25  "The number of times lambda is allowed to get cut");
26  params.addRequiredParam<Real>("contact_ltol",
27  "The linear tolerance to use when the contact set is changing.");
28  params.addRequiredParam<bool>("affect_ltol",
29  "Whether to change the linear tolerance from the default value "
30  "when the contact set is changing");
31  MooseEnum line_search_package("petsc moose");
32  return params;
33 }
34 
35 ContactLineSearchBase::ContactLineSearchBase(const InputParameters & parameters)
36  : LineSearch(parameters),
37  _user_ksp_rtol_set(false),
38  _allowed_lambda_cuts(getParam<unsigned>("allowed_lambda_cuts")),
39  _contact_ltol(getParam<Real>("contact_ltol")),
40  _affect_ltol(getParam<bool>("affect_ltol"))
41 {
42 }
43 
44 void
45 ContactLineSearchBase::printContactInfo(const std::set<dof_id_type> & contact_set)
46 {
47  if (!contact_set.empty())
48  _console << contact_set.size() << " nodes in contact\n";
49  else
50  _console << "No nodes in contact\n";
51 }
52 
53 void
54 ContactLineSearchBase::insertSet(const std::set<dof_id_type> & mech_set)
55 {
56  if (_current_contact_state.empty())
57  _current_contact_state = mech_set;
58  else
59  for (auto & node : mech_set)
60  _current_contact_state.insert(node);
61 }
62 
63 void
65 {
66  _current_contact_state.clear();
67  zeroIts();
68 }
registerMooseObjectAliased
registerMooseObjectAliased("ContactApp", ContactLineSearchBase, "ContactLineSearch")
validParams< ContactLineSearchBase >
InputParameters validParams< ContactLineSearchBase >()
Definition: ContactLineSearchBase.C:21
ContactLineSearchBase::reset
virtual void reset()
Reset the line search data.
Definition: ContactLineSearchBase.C:64
ContactLineSearchBase::printContactInfo
void printContactInfo(const std::set< dof_id_type > &contact_set)
Method for printing the contact information.
Definition: ContactLineSearchBase.C:45
ContactLineSearchBase
This class implements a custom line search for use with mechanical contact.
Definition: ContactLineSearchBase.h:38
ContactLineSearchBase::_current_contact_state
std::set< dof_id_type > _current_contact_state
The current contact set.
Definition: ContactLineSearchBase.h:60
ContactLineSearchBase::ContactLineSearchBase
ContactLineSearchBase(const InputParameters &parameters)
Definition: ContactLineSearchBase.C:35
ContactLineSearchBase::insertSet
void insertSet(const std::set< dof_id_type > &mech_set)
Unionize sets from different constraints.
Definition: ContactLineSearchBase.C:54
ContactLineSearchBase.h