https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ContactSplit.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
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#include "Conversion.h"
14
16
19{
21 params.addParam<std::vector<BoundaryName>>("contact_primary",
22 "Primary surface list for included contacts");
23 params.addParam<std::vector<BoundaryName>>("contact_secondary",
24 "Secondary surface list for included contacts");
25 params.addParam<std::vector<int>>(
26 "contact_displaced",
27 {},
28 "List of indicators whether displaced mesh is used to define included contact");
29 params.addParam<std::vector<BoundaryName>>("uncontact_primary",
30 "Primary surface list for excluded contacts");
31 params.addParam<std::vector<BoundaryName>>("uncontact_secondary",
32 "Secondary surface list for excluded contacts");
33 params.addParam<std::vector<int>>(
34 "uncontact_displaced",
35 {},
36 "List of indicators whether displaced mesh is used to define excluded contact");
37 params.addRequiredParam<bool>("include_all_contact_nodes",
38 "Whether to include all nodes on the contact surfaces");
39 params.addClassDescription("Split-based preconditioner that partitions the domain into DOFs "
40 "directly involved in contact (on contact surfaces) and those "
41 "that are not");
42 return params;
43}
44
46 : Split(params),
47 _contact_pairs(getParam<BoundaryName, BoundaryName>("contact_primary", "contact_secondary")),
48 _contact_displaced(getParam<std::vector<int>>("contact_displaced")),
49 _uncontact_pairs(
50 getParam<BoundaryName, BoundaryName>("uncontact_primary", "uncontact_secondary")),
51 _uncontact_displaced(getParam<std::vector<int>>("uncontact_displaced")),
52 _include_all_contact_nodes(getParam<bool>("include_all_contact_nodes"))
53{
54 if (!_contact_displaced.empty() && _contact_pairs.size() != _contact_displaced.size())
55 mooseError("Primary and displaced contact lists must have matching sizes: ",
56 _contact_pairs.size(),
57 " != ",
58 _contact_displaced.size());
59
60 if (_contact_displaced.empty())
62
63 if (!_uncontact_displaced.empty() && _uncontact_pairs.size() != _uncontact_displaced.size())
64 mooseError("Primary and displaced uncontact lists must have matching sizes: ",
65 _uncontact_pairs.size(),
66 " != ",
68
69 if (!_uncontact_displaced.size())
71}
72
73void
74ContactSplit::setup(NonlinearSystemBase & nl, const std::string & prefix)
75{
76 // A reference to the PetscOptions
78 // prefix
79 const std::string dmprefix = '-' + prefix + "dm_moose_";
80
81 // contacts options
82 if (!_contact_pairs.empty())
83 {
84 // append PETSc options
85 po.pairs.emplace_back(dmprefix + "ncontacts", Moose::stringify(_contact_pairs.size()));
86
87 for (std::size_t j = 0; j < _contact_pairs.size(); ++j)
88 {
89 auto opt = dmprefix + "contact_" + Moose::stringify(j);
90 po.pairs.emplace_back(opt, Moose::stringify(_contact_pairs[j], ","));
91
92 if (_contact_displaced[j])
93 po.pairs.emplace_back(opt + "_displaced", "yes");
94 }
95 }
96
97 // uncontacts options
98 if (!_uncontact_pairs.empty())
99 {
100 po.pairs.emplace_back(dmprefix + "nuncontacts", Moose::stringify(_uncontact_pairs.size()));
101
102 for (std::size_t j = 0; j < _uncontact_pairs.size(); ++j)
103 {
104 auto opt = dmprefix + "uncontact_" + Moose::stringify(j);
105 po.pairs.emplace_back(opt, Moose::stringify(_uncontact_pairs[j], ","));
106
108 po.pairs.emplace_back(opt + "_displaced", "yes");
109 }
110 }
111
112 // Whether to include all nodes on the contact surfaces
113 // into the contact subsolver
114 po.pairs.emplace_back(dmprefix + "includeAllContactNodes",
115 _include_all_contact_nodes ? "yes" : "no");
116 Split::setup(nl, prefix);
117}
registerMooseObject("ContactApp", ContactSplit)
oopt<< "-dm_moose_includeAllContactNodes";ohelp<< "Whether to include all nodes on the contact surfaces into the subsolver";LibmeshPetscCallQ(PetscOptionsBool(oopt.str().c_str(), ohelp.str().c_str(), "", PETSC_FALSE, &is_include_all_nodes, LIBMESH_PETSC_NULLPTR));dmm-> _include_all_contact_nodes
std::string opt
void ErrorVector unsigned int
Split-based preconditioner for contact problems.
const std::vector< std::pair< BoundaryName, BoundaryName > > _uncontact_pairs
virtual void setup(NonlinearSystemBase &nl, const std::string &prefix) override
bool _include_all_contact_nodes
std::vector< int > _uncontact_displaced
std::vector< int > _contact_displaced
const std::vector< std::pair< BoundaryName, BoundaryName > > _contact_pairs
ContactSplit(const InputParameters &params)
static InputParameters validParams()
Moose::PetscSupport::PetscOptions & getPetscOptions()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void mooseError(Args &&... args) const
std::vector< std::pair< std::string, std::string > > pairs
static InputParameters validParams()
virtual void setup(NonlinearSystemBase &nl, const std::string &prefix="")
FEProblemBase & _fe_problem
std::string stringify(const T &t)