www.mooseframework.org
ContactSplit.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 "ContactSplit.h"
11 #include "InputParameters.h"
12 #include "FEProblem.h"
13 
14 #if defined(LIBMESH_HAVE_PETSC) && !PETSC_VERSION_LESS_THAN(3, 3, 0)
15 registerMooseObject("ContactApp", ContactSplit);
16 
17 template <>
18 InputParameters
20 {
21  InputParameters params = validParams<Split>();
22  params.addParam<std::vector<std::string>>("contact_master",
23  "Master surface list for included contacts");
24  params.addParam<std::vector<std::string>>("contact_slave",
25  "Slave surface list for included contacts");
26  params.addParam<std::vector<int>>(
27  "contact_displaced",
28  "List of indicators whether displaced mesh is used to define included contact");
29  params.addParam<std::vector<std::string>>("uncontact_master",
30  "Master surface list for excluded contacts");
31  params.addParam<std::vector<std::string>>("uncontact_slave",
32  "Slave surface list for excluded contacts");
33  params.addParam<std::vector<int>>(
34  "uncontact_displaced",
35  "List of indicators whether displaced mesh is used to define excluded contact");
36  // Right now, we consider this as a required parameter.
37  // After some tests from BISON, we will set a default value for this parameter.
38  params.addRequiredParam<bool>("include_all_contact_nodes",
39  "Whether to include all nodes on the contact surfaces");
40  return params;
41 }
42 
43 ContactSplit::ContactSplit(const InputParameters & params)
44  : Split(params),
45  _contact_master(getParam<std::vector<std::string>>("contact_master")),
46  _contact_slave(getParam<std::vector<std::string>>("contact_slave")),
47  _contact_displaced(getParam<std::vector<int>>("contact_displaced")),
48  _uncontact_master(getParam<std::vector<std::string>>("uncontact_master")),
49  _uncontact_slave(getParam<std::vector<std::string>>("uncontact_slave")),
50  _uncontact_displaced(getParam<std::vector<int>>("uncontact_displaced")),
51  _include_all_contact_nodes(getParam<bool>("include_all_contact_nodes"))
52 {
53  if (_contact_master.size() != _contact_slave.size())
54  {
55  std::ostringstream err;
56  err << "Master and slave contact lists must have matching sizes: " << _contact_master.size()
57  << " != " << _contact_slave.size();
58  mooseError(err.str());
59  }
60  if (_contact_displaced.size() && _contact_master.size() != _contact_displaced.size())
61  {
62  std::ostringstream err;
63  err << "Master and displaced contact lists must have matching sizes: " << _contact_master.size()
64  << " != " << _contact_displaced.size();
65  mooseError(err.str());
66  }
67  if (!_contact_displaced.size())
68  _contact_displaced.resize(_contact_master.size());
69 
70  if (_uncontact_master.size() != _uncontact_slave.size())
71  {
72  std::ostringstream err;
73  err << "Master and slave uncontact lists must have matching sizes: " << _uncontact_master.size()
74  << " != " << _uncontact_slave.size();
75  mooseError(err.str());
76  }
77  if (_uncontact_displaced.size() && _uncontact_master.size() != _uncontact_displaced.size())
78  {
79  std::ostringstream err;
80  err << "Master and displaced uncontact lists must have matching sizes: "
81  << _uncontact_master.size() << " != " << _uncontact_displaced.size();
82  mooseError(err.str());
83  }
84  if (!_uncontact_displaced.size())
86 }
87 
88 void
89 ContactSplit::setup(const std::string & prefix)
90 {
91  // A reference to the PetscOptions
92  Moose::PetscSupport::PetscOptions & po = _fe_problem.getPetscOptions();
93  // prefix
94  std::string dmprefix = prefix + "dm_moose_", opt, val;
95 
96  // contacts options
97  if (_contact_master.size())
98  {
99  opt = dmprefix + "ncontacts";
100  {
101  std::ostringstream oval;
102  oval << _contact_master.size();
103  val = oval.str();
104  }
105  // push back PETSc options
106  if (val == "")
107  po.flags.push_back(opt);
108  else
109  {
110  po.inames.push_back(opt);
111  po.values.push_back(val);
112  }
113  for (unsigned int j = 0; j < _contact_master.size(); ++j)
114  {
115  std::ostringstream oopt;
116  oopt << dmprefix << "contact_" << j;
117  opt = oopt.str();
118  val = _contact_master[j] + "," + _contact_slave[j];
119  // push back PETSc options
120  if (val == "")
121  po.flags.push_back(opt);
122  else
123  {
124  po.inames.push_back(opt);
125  po.values.push_back(val);
126  }
127  if (_contact_displaced[j])
128  {
129  opt = opt + "_displaced";
130  val = "yes";
131  // push back PETSc options
132  if (val == "")
133  po.flags.push_back(opt);
134  else
135  {
136  po.inames.push_back(opt);
137  po.values.push_back(val);
138  }
139  }
140  }
141  }
142  // uncontacts options
143  if (_uncontact_master.size())
144  {
145  opt = dmprefix + "nuncontacts";
146  {
147  std::ostringstream oval;
148  oval << _uncontact_master.size();
149  val = oval.str();
150  }
151  // push back PETSc options
152  if (val == "")
153  po.flags.push_back(opt);
154  else
155  {
156  po.inames.push_back(opt);
157  po.values.push_back(val);
158  }
159  for (unsigned int j = 0; j < _uncontact_master.size(); ++j)
160  {
161  std::ostringstream oopt;
162  oopt << dmprefix << "uncontact_" << j;
163  opt = oopt.str();
164  val = _uncontact_master[j] + "," + _uncontact_slave[j];
165  // push back PETSc options
166  if (val == "")
167  po.flags.push_back(opt);
168  else
169  {
170  po.inames.push_back(opt);
171  po.values.push_back(val);
172  }
173  if (_uncontact_displaced[j])
174  {
175  opt = opt + "_displaced";
176  val = "yes";
177  // push back PETSc options
178  if (val == "")
179  po.flags.push_back(opt);
180  else
181  {
182  po.inames.push_back(opt);
183  po.values.push_back(val);
184  }
185  }
186  }
187  }
188 
189  // Whether to include all nodes on the contact surfaces
190  // into the contact subsolver
191  opt = dmprefix + "includeAllContactNodes";
193  val = "yes";
194  else
195  val = "no";
196  po.inames.push_back(opt);
197  po.values.push_back(val);
198  Split::setup(prefix);
199 }
200 #endif
ContactSplit::setup
virtual void setup(const std::string &prefix="-") override
Definition: ContactSplit.C:89
ContactSplit::_uncontact_displaced
std::vector< int > _uncontact_displaced
Definition: ContactSplit.h:36
ContactSplit::_uncontact_slave
std::vector< std::string > _uncontact_slave
Definition: ContactSplit.h:35
ContactSplit::_contact_displaced
std::vector< int > _contact_displaced
Definition: ContactSplit.h:33
ContactSplit::_contact_slave
std::vector< std::string > _contact_slave
Definition: ContactSplit.h:32
validParams< ContactSplit >
InputParameters validParams< ContactSplit >()
Definition: ContactSplit.C:19
ContactSplit::_contact_master
std::vector< std::string > _contact_master
Definition: ContactSplit.h:31
ContactSplit
Split-based preconditioner for contact problems.
Definition: ContactSplit.h:23
ContactSplit.h
registerMooseObject
registerMooseObject("ContactApp", ContactSplit)
ContactSplit::_uncontact_master
std::vector< std::string > _uncontact_master
Definition: ContactSplit.h:34
ContactSplit::_include_all_contact_nodes
bool _include_all_contact_nodes
Definition: ContactSplit.h:37
ContactSplit::ContactSplit
ContactSplit(const InputParameters &params)
Definition: ContactSplit.C:43