www.mooseframework.org
ConstraintWarehouse.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 "ConstraintWarehouse.h"
16 
17 // MOOSE includes
18 #include "ElemElemConstraint.h"
19 #include "FaceFaceConstraint.h"
20 #include "MooseVariable.h"
21 #include "NodalConstraint.h"
22 #include "NodeFaceConstraint.h"
23 
25 
26 void
27 ConstraintWarehouse::addObject(std::shared_ptr<Constraint> object, THREAD_ID /*tid = 0*/)
28 {
29  // Adds to the storage of _all_objects
31 
32  // Cast the the possible Contraint types
33  std::shared_ptr<NodeFaceConstraint> nfc = std::dynamic_pointer_cast<NodeFaceConstraint>(object);
34  std::shared_ptr<FaceFaceConstraint> ffc = std::dynamic_pointer_cast<FaceFaceConstraint>(object);
35  std::shared_ptr<NodalConstraint> nc = std::dynamic_pointer_cast<NodalConstraint>(object);
36  std::shared_ptr<ElemElemConstraint> ec = std::dynamic_pointer_cast<ElemElemConstraint>(object);
37 
38  // NodeFaceConstraint
39  if (nfc)
40  {
41  MooseMesh & mesh = nfc->getParam<FEProblemBase *>("_fe_problem_base")->mesh();
42  unsigned int slave = mesh.getBoundaryID(nfc->getParam<BoundaryName>("slave"));
43  bool displaced = nfc->parameters().have_parameter<bool>("use_displaced_mesh") &&
44  nfc->getParam<bool>("use_displaced_mesh");
45 
46  if (displaced)
47  _displaced_node_face_constraints[slave].addObject(nfc);
48  else
49  _node_face_constraints[slave].addObject(nfc);
50  }
51 
52  // FaceFaceConstraint
53  else if (ffc)
54  {
55  const std::string & interface = ffc->getParam<std::string>("interface");
56  _face_face_constraints[interface].addObject(ffc);
57  }
58 
59  // ElemElemConstraint
60  else if (ec)
61  {
62  const InterfaceID interface_id = ec->getParam<InterfaceID>("interface_id");
63  _element_constraints[interface_id].addObject(ec);
64  }
65 
66  // NodalConstraint
67  else if (nc)
69 
70  else
71  mooseError("Unknown type of Constraint object");
72 }
73 
74 const std::vector<std::shared_ptr<NodalConstraint>> &
76 {
78 }
79 
80 const std::vector<std::shared_ptr<NodeFaceConstraint>> &
82 {
83  std::map<BoundaryID, MooseObjectWarehouse<NodeFaceConstraint>>::const_iterator it, end_it;
84 
85  if (displaced)
86  {
87  it = _displaced_node_face_constraints.find(boundary_id);
88  end_it = _displaced_node_face_constraints.end();
89  }
90 
91  else
92  {
93  it = _node_face_constraints.find(boundary_id);
94  end_it = _node_face_constraints.end();
95  }
96 
97  mooseAssert(it != end_it,
98  "Unable to locate storage for NodeFaceConstraint objects for the given boundary id: "
99  << boundary_id);
100  return it->second.getActiveObjects();
101 }
102 
103 const std::vector<std::shared_ptr<FaceFaceConstraint>> &
104 ConstraintWarehouse::getActiveFaceFaceConstraints(const std::string & interface) const
105 {
106  std::map<std::string, MooseObjectWarehouse<FaceFaceConstraint>>::const_iterator it =
107  _face_face_constraints.find(interface);
108  mooseAssert(it != _face_face_constraints.end(),
109  "Unable to locate storage for FaceFaceConstraint objects for the given interface: "
110  << interface);
111  return it->second.getActiveObjects();
112 }
113 
114 const std::vector<std::shared_ptr<ElemElemConstraint>> &
116 {
117  std::map<unsigned int, MooseObjectWarehouse<ElemElemConstraint>>::const_iterator it =
118  _element_constraints.find(interface_id);
119  mooseAssert(it != _element_constraints.end(),
120  "Unable to locate storage for ElemElemConstraint objects for the given interface id: "
121  << interface_id);
122  return it->second.getActiveObjects();
123 }
124 
125 bool
127 {
129 }
130 
131 bool
132 ConstraintWarehouse::hasActiveFaceFaceConstraints(const std::string & interface) const
133 {
134  std::map<std::string, MooseObjectWarehouse<FaceFaceConstraint>>::const_iterator it =
135  _face_face_constraints.find(interface);
136  return (it != _face_face_constraints.end() && it->second.hasActiveObjects());
137 }
138 
139 bool
141 {
142  std::map<unsigned int, MooseObjectWarehouse<ElemElemConstraint>>::const_iterator it =
143  _element_constraints.find(interface_id);
144  return (it != _element_constraints.end() && it->second.hasActiveObjects());
145 }
146 
147 bool
149 {
150  std::map<BoundaryID, MooseObjectWarehouse<NodeFaceConstraint>>::const_iterator it, end_it;
151 
152  if (displaced)
153  {
154  it = _displaced_node_face_constraints.find(boundary_id);
155  end_it = _displaced_node_face_constraints.end();
156  }
157 
158  else
159  {
160  it = _node_face_constraints.find(boundary_id);
161  end_it = _node_face_constraints.end();
162  }
163 
164  return (it != end_it && it->second.hasActiveObjects());
165 }
166 
168 {
171 
172  for (auto & it : _node_face_constraints)
173  it.second.updateActive();
174 
175  for (auto & it : _displaced_node_face_constraints)
176  it.second.updateActive();
177 
178  // FIXME: We call updateActive() on the NodeFaceConstraints again?
179  for (auto & it : _node_face_constraints)
180  it.second.updateActive();
181 
182  for (auto & it : _element_constraints)
183  it.second.updateActive();
184 }
185 
186 void
187 ConstraintWarehouse::subdomainsCovered(std::set<SubdomainID> & subdomains_covered,
188  std::set<std::string> & unique_variables,
189  THREAD_ID /*tid=0*/) const
190 {
191  for (const auto & it : _face_face_constraints)
192  {
193  const auto & objects = it.second.getActiveObjects();
194  for (const auto & ffc : objects)
195  {
196  MooseVariable & var = ffc->variable();
197  unique_variables.insert(var.name());
198  const std::set<SubdomainID> & subdomains = var.activeSubdomains();
199  subdomains_covered.insert(subdomains.begin(), subdomains.end());
200  }
201  }
202 }
MooseObjectWarehouse< NodalConstraint > _nodal_constraints
NodalConstraint objects.
std::map< BoundaryID, MooseObjectWarehouse< NodeFaceConstraint > > _displaced_node_face_constraints
NodeFaceConstraint objects (displaced)
void subdomainsCovered(std::set< SubdomainID > &subdomains_covered, std::set< std::string > &unique_variables, THREAD_ID tid=0) const
Update supplied subdomain and variable coverate containters.
Class for stuff related to variables.
Definition: MooseVariable.h:43
if(nl->nonlinearSolver() ->matvec &&nl->nonlinearSolver() ->residual_and_jacobian_object)
User for mortar methods.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
A storage container for MooseObjects that inherit from SetupInterface.
Base class for all Constraint types.
Definition: Constraint.h:42
virtual void addObject(std::shared_ptr< T > object, THREAD_ID tid=0)
Adds an object to the storage structure.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const std::string & name() const
Get the variable name.
std::map< std::string, MooseObjectWarehouse< FaceFaceConstraint > > _face_face_constraints
FaceFaceConstraints.
BoundaryID getBoundaryID(const BoundaryName &boundary_name) const
Get the associated BoundaryID for the boundary name.
Definition: MooseMesh.C:929
const std::set< SubdomainID > & activeSubdomains() const
void addObject(std::shared_ptr< Constraint > object, THREAD_ID tid=0)
Add Constraint object to the warehouse.
const std::vector< std::shared_ptr< ElemElemConstraint > > & getActiveElemElemConstraints(InterfaceID interface_id) const
A NodeFaceConstraint is used when you need to create constraints between two surfaces in a mesh...
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
unsigned int InterfaceID
Definition: MooseTypes.h:76
bool hasActiveObjects(THREAD_ID tid=0) const
Convenience functions for determining if objects exist.
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:122
std::map< unsigned int, MooseObjectWarehouse< ElemElemConstraint > > _element_constraints
ElemElemConstraints.
const std::vector< std::shared_ptr< NodalConstraint > > & getActiveNodalConstraints() const
Access methods for active objects.
void updateActive(THREAD_ID tid=0)
Update the various active lists.
bool hasActiveElemElemConstraints(const InterfaceID interface_id) const
bool hasActiveNodalConstraints() const
Deterimine if active objects exist.
const std::vector< std::shared_ptr< FaceFaceConstraint > > & getActiveFaceFaceConstraints(const std::string &interface) const
const std::vector< std::shared_ptr< T > > & getActiveObjects(THREAD_ID tid=0) const
Retrieve complete vector to the active all/block/boundary restricted objects for a given thread...
void insert(NumericVector< Number > &residual)
bool hasActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
const std::vector< std::shared_ptr< NodeFaceConstraint > > & getActiveNodeFaceConstraints(BoundaryID boundary_id, bool displaced) const
virtual void updateActive(THREAD_ID tid=0)
Updates the active objects storage.
bool hasActiveFaceFaceConstraints(const std::string &interface) const
std::map< BoundaryID, MooseObjectWarehouse< NodeFaceConstraint > > _node_face_constraints
NodeFaceConstraint objects (non-displaced)
boundary_id_type BoundaryID
Definition: MooseTypes.h:75
unsigned int THREAD_ID
Definition: MooseTypes.h:79