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