https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
MortarInterfaceWarehouse Class Reference

#include <MortarInterfaceWarehouse.h>

Inheritance diagram for MortarInterfaceWarehouse:
[legend]

Public Member Functions

 MortarInterfaceWarehouse (const libMesh::ParallelObject &other)
 
void createMortarInterface (const std::pair< BoundaryID, BoundaryID > &boundary_key, const std::pair< SubdomainID, SubdomainID > &subdomain_key, SubProblem &subproblem, bool on_displaced, bool periodic, const bool debug, const bool correct_edge_dropping, const Real minimum_projection_angle, const Mortar3DSubpatchPlane mortar_3d_subpatch_plane, const MooseEnum &triangulation, const bool triangulate_triangles, const Mortar3DQuadraturePointMapping mortar_3d_qp_mapping=Mortar3DQuadraturePointMapping::NORMAL_PROJECTION)
 Create mortar generation object.
 
const AutomaticMortarGenerationgetMortarInterface (const std::pair< BoundaryID, BoundaryID > &boundary_key, const std::pair< SubdomainID, SubdomainID > &, bool on_displaced) const
 Getter to retrieve the AutomaticMortarGeneration object corresponding to the boundary and subdomain keys.
 
AutomaticMortarGenerationgetMortarInterface (const std::pair< BoundaryID, BoundaryID > &boundary_key, const std::pair< SubdomainID, SubdomainID > &, bool on_displaced)
 Non-const getter to retrieve the AutomaticMortarGeneration object corresponding to the boundary and subdomain keys.
 
const std::unordered_map< std::pair< BoundaryID, BoundaryID >, MortarInterfaceConfig > & getMortarInterfaces (bool on_displaced) const
 Return the per-interface configuration map (AutomaticMortarGeneration object plus the associated user flags) for either the displaced or undisplaced mesh.
 
const std::set< SubdomainID > & getMortarSubdomainIDs () const
 Returns the mortar covered subdomains.
 
const std::set< BoundaryID > & getMortarBoundaryIDs () const
 Returns the mortar covered boundaries.
 
void update ()
 Builds mortar segment meshes for each mortar interface.
 
void meshChanged ()
 Invalidates cached MSM node/element ID offsets on all mortar interfaces so they are recomputed on the next update().
 
bool hasDisplacedObjects () const
 Returns whether any of the AutomaticMortarGeneration objects are running on a displaced mesh.
 
bool hasObjects () const
 Returns whether we have any active AutomaticMortarGeneration objects.
 
const std::set< SubdomainID > & getHigherDimSubdomainIDs (SubdomainID lower_d_subdomain_id) const
 Returns the higher dimensional subdomain ids of the interior parents of the given lower-d subdomain id.
 
void notifyWhenMortarSetup (MortarExecutorInterface *mei)
 Adds mei to the container of objects that will have their mortarSetup method called as soon as the mortar mesh has been generated for the first time
 
void dontNotifyWhenMortarSetup (MortarExecutorInterface *mei)
 Removes mei from the container of objects that will have their mortarSetup method called as soon as the mortar mesh has been generated for the first time
 
bool initialized () const
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Attributes

const Parallel::Communicator_communicator
 

Private Types

typedef std::pair< BoundaryID, BoundaryIDMortarKey
 

Private Member Functions

void update (AutomaticMortarGeneration &amg)
 Builds mortar segment mesh from specific AutomaticMortarGeneration object.
 

Private Attributes

std::unordered_map< MortarKey, MortarInterfaceConfig_mortar_interfaces
 Map from primary-secondary (in that order) boundary ID pair to the configuration of the undisplaced mortar interface (AMG object + per-interface flags).
 
std::unordered_map< MortarKey, MortarInterfaceConfig_displaced_mortar_interfaces
 Map from primary-secondary (in that order) boundary ID pair to the configuration of the displaced mortar interface (AMG object + per-interface flags).
 
std::set< SubdomainID_mortar_subdomain_coverage
 A set containing the subdomain ids covered by all the mortar interfaces in this MortarInterfaceWarehouse object.
 
std::set< BoundaryID_mortar_boundary_coverage
 A set containing the boundary ids covered by all the mortar interfaces in this MortarInterfaceWarehouse object.
 
std::unordered_map< SubdomainID, std::set< SubdomainID > > _lower_d_sub_to_higher_d_subs
 Map from lower dimensional subdomain ids to corresponding higher simensional subdomain ids (e.g.
 
std::set< MortarExecutorInterface * > _mei_objs
 A container of objects for whom the mortarSetup method will be called after the mortar mesh has been setup for the first time.
 
bool _mortar_initd
 Whether we have performed any mortar mesh construction.
 

Detailed Description

Definition at line 47 of file MortarInterfaceWarehouse.h.

Member Typedef Documentation

◆ MortarKey

Definition at line 177 of file MortarInterfaceWarehouse.h.

Constructor & Destructor Documentation

◆ MortarInterfaceWarehouse()

MortarInterfaceWarehouse::MortarInterfaceWarehouse ( const libMesh::ParallelObject other)

Definition at line 38 of file MortarInterfaceWarehouse.C.

40{
41}
bool _mortar_initd
Whether we have performed any mortar mesh construction.

Member Function Documentation

◆ createMortarInterface()

void MortarInterfaceWarehouse::createMortarInterface ( const std::pair< BoundaryID, BoundaryID > &  boundary_key,
const std::pair< SubdomainID, SubdomainID > &  subdomain_key,
SubProblem subproblem,
bool  on_displaced,
bool  periodic,
const bool  debug,
const bool  correct_edge_dropping,
const Real  minimum_projection_angle,
const Mortar3DSubpatchPlane  mortar_3d_subpatch_plane,
const MooseEnum triangulation,
const bool  triangulate_triangles,
const Mortar3DQuadraturePointMapping  mortar_3d_qp_mapping = Mortar3DQuadraturePointMapping::NORMAL_PROJECTION 
)

Create mortar generation object.

Parameters
boundary_keyThe primary-secondary boundary pair on which the AMG objects lives
subdomain_keyThe primary-secondary subdomain pair on which the AMG objects lives
subproblemA reference to the subproblem
on_displacedWhether the AMG object lives on the displaced mesh
periodicWhether the AMG object will be used for enforcing periodic constraints. Note that this changes the direction of the projection normals so one AMG object cannot be used to enforce both periodic and non-periodic constraints
debugwhether to output mortar segment mesh exodus file for debugging purposes
correct_edge_droppingedge dropping treatment selection
minimum_projection_angleminimum projection angle allowed for building mortar segment mesh
mortar_3d_subpatch_planemethod for constructing 3D mortar subpatch planes
triangulationtriangulation strategy used for clipped 3D mortar polygons
triangulate_triangleswhether a clipped polygon that is already a triangle should still be subdivided
mortar_3d_qp_mappingmethod for mapping 3D mortar quadrature points to faces

Definition at line 44 of file MortarInterfaceWarehouse.C.

57{
58 _mortar_subdomain_coverage.insert(subdomain_key.first);
59 _mortar_subdomain_coverage.insert(subdomain_key.second);
60
61 _mortar_boundary_coverage.insert(boundary_key.first);
62 _mortar_boundary_coverage.insert(boundary_key.second);
63
64 MeshBase & mesh = subproblem.mesh().getMesh();
65
66 auto & mortar_interfaces = on_displaced ? _displaced_mortar_interfaces : _mortar_interfaces;
67 const auto triangulation_mode = toTriangulationMode(triangulation);
68
69 auto interface_iterator = mortar_interfaces.find(boundary_key);
70 if (interface_iterator != mortar_interfaces.end())
71 {
72 // Existing entry: every per-interface flag must agree across constraints sharing the same
73 // primary-secondary surface pair.
74 const auto & existing = interface_iterator->second;
75 if (existing.periodic != periodic)
76 mooseError("We do not currently support enforcing both periodic and non-periodic constraints "
77 "on the same boundary primary-secondary pair");
78 if (existing.debug != debug)
80 "We do not currently support generating and not generating debug output "
81 "on the same boundary primary-secondary surface pair. Please set debug_mesh = true for "
82 "all constraints sharing the same primary-secondary surface pairs");
83 if (!MooseUtils::absoluteFuzzyEqual(existing.minimum_projection_angle,
84 minimum_projection_angle))
85 mooseError("We do not currently support multiple values of 'minimum_projection_angle' on "
86 "the same boundary primary-secondary surface pair.");
87 if (existing.mortar_3d_subpatch_plane != mortar_3d_subpatch_plane)
88 mooseError("Mortar constraints sharing the same primary/secondary mortar interface must use "
89 "the same 'mortar_3d_subpatch_plane' value.");
90 if (existing.triangulation != triangulation_mode)
91 mooseError("We do not currently support multiple values of 'triangulation' on the same "
92 "boundary primary-secondary surface pair.");
93 if (existing.triangulate_triangles != triangulate_triangles)
94 mooseError("We do not currently support multiple values of 'triangulate_triangles' on the "
95 "same boundary primary-secondary surface pair.");
96 if (existing.mortar_3d_qp_mapping != mortar_3d_qp_mapping)
97 mooseError("We do not currently support multiple values of 'mortar_3d_qp_mapping' on the "
98 "same boundary primary-secondary surface pair.");
99 }
100 else
101 {
103 std::make_unique<AutomaticMortarGeneration>(subproblem.getMooseApp(),
104 mesh,
105 boundary_key,
106 subdomain_key,
107 on_displaced,
108 periodic,
109 debug,
110 correct_edge_dropping,
111 minimum_projection_angle,
112 mortar_3d_subpatch_plane,
113 triangulation_mode,
114 triangulate_triangles,
115 mortar_3d_qp_mapping),
116 periodic,
117 debug,
118 minimum_projection_angle,
119 mortar_3d_subpatch_plane,
120 triangulation_mode,
121 triangulate_triangles,
122 mortar_3d_qp_mapping};
123 config.amg->initOutput();
124 mortar_interfaces.emplace(boundary_key, std::move(config));
125 }
126
127 // See whether to query the mesh
128 SubdomainID key1 = subdomain_key.first;
129 SubdomainID key2 = subdomain_key.second;
130
131 // it(1,2) is a a pair consisting of an iterator to the inserted element (or to the element that
132 // prevented the insertion) and a bool denoting whether the insertion took place.
133 auto it1 = _lower_d_sub_to_higher_d_subs.insert(std::make_pair(key1, std::set<SubdomainID>{}));
134 auto it2 = _lower_d_sub_to_higher_d_subs.insert(std::make_pair(key2, std::set<SubdomainID>{}));
135
136 // Each entry in this vector will be a pair. The first member of the pair corresponds to
137 // the lower dimensional subomain ID. The second member of the pair corresponds to the higher
138 // dimensional subdomain ids of the lower dimeionsal interior parents
139 std::vector<std::pair<SubdomainID, std::set<SubdomainID> *>> subdomains_to_probe;
140
141 if (it1.second)
142 subdomains_to_probe.push_back(std::make_pair(key1, &it1.first->second));
143 if (it2.second)
144 subdomains_to_probe.push_back(std::make_pair(key2, &it2.first->second));
145
146 for (auto & pr : subdomains_to_probe)
147 {
148 for (const Elem * lower_d_elem : as_range(mesh.active_local_subdomain_elements_begin(pr.first),
149 mesh.active_local_subdomain_elements_end(pr.first)))
150 {
151 const Elem * ip = lower_d_elem->interior_parent();
152 mooseAssert(
153 ip,
154 "Lower dimensional elements should always have an interior parent set when using mortar");
155 pr.second->insert(ip->subdomain_id());
156 }
157
158 // Make sure that we get this right in parallel
159 _communicator.set_union(*pr.second);
160 }
161}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
MooseApp & getMooseApp() const
Get the MooseApp this class is associated with.
Definition MooseBase.h:87
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3549
std::unordered_map< SubdomainID, std::set< SubdomainID > > _lower_d_sub_to_higher_d_subs
Map from lower dimensional subdomain ids to corresponding higher simensional subdomain ids (e....
std::unordered_map< MortarKey, MortarInterfaceConfig > _displaced_mortar_interfaces
Map from primary-secondary (in that order) boundary ID pair to the configuration of the displaced mor...
std::unordered_map< MortarKey, MortarInterfaceConfig > _mortar_interfaces
Map from primary-secondary (in that order) boundary ID pair to the configuration of the undisplaced m...
std::set< SubdomainID > _mortar_subdomain_coverage
A set containing the subdomain ids covered by all the mortar interfaces in this MortarInterfaceWareho...
std::set< BoundaryID > _mortar_boundary_coverage
A set containing the boundary ids covered by all the mortar interfaces in this MortarInterfaceWarehou...
virtual MooseMesh & mesh()=0
void set_union(T &data, const unsigned int root_id) const
const Parallel::Communicator & _communicator
MeshBase & mesh
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
Per-mortar-interface configuration.
std::unique_ptr< AutomaticMortarGeneration > amg

◆ dontNotifyWhenMortarSetup()

void MortarInterfaceWarehouse::dontNotifyWhenMortarSetup ( MortarExecutorInterface mei)

Removes mei from the container of objects that will have their mortarSetup method called as soon as the mortar mesh has been generated for the first time

Definition at line 265 of file MortarInterfaceWarehouse.C.

266{
267 _mei_objs.erase(mei_obj);
268}
std::set< MortarExecutorInterface * > _mei_objs
A container of objects for whom the mortarSetup method will be called after the mortar mesh has been ...

◆ getHigherDimSubdomainIDs()

const std::set< SubdomainID > & MortarInterfaceWarehouse::getHigherDimSubdomainIDs ( SubdomainID  lower_d_subdomain_id) const

Returns the higher dimensional subdomain ids of the interior parents of the given lower-d subdomain id.

Definition at line 248 of file MortarInterfaceWarehouse.C.

249{
250 if (_lower_d_sub_to_higher_d_subs.find(lower_d_subdomain_id) ==
252 mooseError("The lower dimensional ID ",
253 lower_d_subdomain_id,
254 " has not been added to MortarInterfaceWarehouse yet");
255 return _lower_d_sub_to_higher_d_subs.at(lower_d_subdomain_id);
256}

◆ getMortarBoundaryIDs()

const std::set< BoundaryID > & MortarInterfaceWarehouse::getMortarBoundaryIDs ( ) const
inline

Returns the mortar covered boundaries.

Definition at line 125 of file MortarInterfaceWarehouse.h.

◆ getMortarInterface() [1/2]

AutomaticMortarGeneration & MortarInterfaceWarehouse::getMortarInterface ( const std::pair< BoundaryID, BoundaryID > &  boundary_key,
const std::pair< SubdomainID, SubdomainID > &  subdomain_key,
bool  on_displaced 
)

Non-const getter to retrieve the AutomaticMortarGeneration object corresponding to the boundary and subdomain keys.

If the AutomaticMortarGeneration object does not yet exist, then we error

Definition at line 178 of file MortarInterfaceWarehouse.C.

182{
183 return const_cast<AutomaticMortarGeneration &>(
184 const_cast<const MortarInterfaceWarehouse *>(this)->getMortarInterface(
185 boundary_key, subdomain_key, on_displaced));
186}
This class is a container/interface for the objects involved in automatic generation of mortar spaces...
const AutomaticMortarGeneration & getMortarInterface(const std::pair< BoundaryID, BoundaryID > &boundary_key, const std::pair< SubdomainID, SubdomainID > &, bool on_displaced) const
Getter to retrieve the AutomaticMortarGeneration object corresponding to the boundary and subdomain k...

◆ getMortarInterface() [2/2]

const AutomaticMortarGeneration & MortarInterfaceWarehouse::getMortarInterface ( const std::pair< BoundaryID, BoundaryID > &  boundary_key,
const std::pair< SubdomainID, SubdomainID > &  ,
bool  on_displaced 
) const

Getter to retrieve the AutomaticMortarGeneration object corresponding to the boundary and subdomain keys.

If the AutomaticMortarGeneration object does not yet exist, then we error

Definition at line 164 of file MortarInterfaceWarehouse.C.

168{
169 auto & mortar_interfaces = on_displaced ? _displaced_mortar_interfaces : _mortar_interfaces;
170 auto it = mortar_interfaces.find(boundary_key);
171 if (it == mortar_interfaces.end())
173 "The requested mortar interface AutomaticMortarGeneration object does not yet exist!");
174 return *it->second.amg;
175}

Referenced by getMortarInterface().

◆ getMortarInterfaces()

const std::unordered_map< std::pair< BoundaryID, BoundaryID >, MortarInterfaceConfig > & MortarInterfaceWarehouse::getMortarInterfaces ( bool  on_displaced) const
inline

Return the per-interface configuration map (AutomaticMortarGeneration object plus the associated user flags) for either the displaced or undisplaced mesh.

Iterating callers should reach the AMG via the value's amg member.

Definition at line 109 of file MortarInterfaceWarehouse.h.

110 {
111 if (on_displaced)
113 else
114 return _mortar_interfaces;
115 }

◆ getMortarSubdomainIDs()

const std::set< SubdomainID > & MortarInterfaceWarehouse::getMortarSubdomainIDs ( ) const
inline

Returns the mortar covered subdomains.

Definition at line 120 of file MortarInterfaceWarehouse.h.

◆ hasDisplacedObjects()

bool MortarInterfaceWarehouse::hasDisplacedObjects ( ) const
inline

Returns whether any of the AutomaticMortarGeneration objects are running on a displaced mesh.

Definition at line 141 of file MortarInterfaceWarehouse.h.

141{ return _displaced_mortar_interfaces.size(); }

◆ hasObjects()

bool MortarInterfaceWarehouse::hasObjects ( ) const
inline

Returns whether we have any active AutomaticMortarGeneration objects.

Definition at line 146 of file MortarInterfaceWarehouse.h.

146{ return _mortar_interfaces.size(); }

◆ initialized()

bool MortarInterfaceWarehouse::initialized ( ) const
inline
Returns
whether we have performed an initial mortar mesh construction

Definition at line 169 of file MortarInterfaceWarehouse.h.

169{ return _mortar_initd; }

◆ meshChanged()

void MortarInterfaceWarehouse::meshChanged ( )

Invalidates cached MSM node/element ID offsets on all mortar interfaces so they are recomputed on the next update().

Call when mesh topology changes.

Definition at line 200 of file MortarInterfaceWarehouse.C.

201{
202 for (auto & mortar_pair : _mortar_interfaces)
203 mortar_pair.second.amg->meshChanged();
204 for (auto & mortar_pair : _displaced_mortar_interfaces)
205 mortar_pair.second.amg->meshChanged();
206 update();
207}
void meshChanged()
Invalidates cached MSM node/element ID offsets on all mortar interfaces so they are recomputed on the...
void update()
Builds mortar segment meshes for each mortar interface.

◆ notifyWhenMortarSetup()

void MortarInterfaceWarehouse::notifyWhenMortarSetup ( MortarExecutorInterface mei)

Adds mei to the container of objects that will have their mortarSetup method called as soon as the mortar mesh has been generated for the first time

Definition at line 259 of file MortarInterfaceWarehouse.C.

260{
261 _mei_objs.insert(mei_obj);
262}

◆ update() [1/2]

void MortarInterfaceWarehouse::update ( )

Builds mortar segment meshes for each mortar interface.

Definition at line 189 of file MortarInterfaceWarehouse.C.

190{
191 for (auto & mortar_pair : _mortar_interfaces)
192 update(*mortar_pair.second.amg);
193 for (auto & mortar_pair : _displaced_mortar_interfaces)
194 update(*mortar_pair.second.amg);
195
196 _mortar_initd = true;
197}

Referenced by meshChanged(), and update().

◆ update() [2/2]

void MortarInterfaceWarehouse::update ( AutomaticMortarGeneration amg)
private

Builds mortar segment mesh from specific AutomaticMortarGeneration object.

Definition at line 210 of file MortarInterfaceWarehouse.C.

211{
212 // Clear exiting data
213 amg.clear();
214
215 const auto dim = amg.dim();
216
217 if (dim == 1)
218 mooseError("Mortar constraints are not currently supported for 1D meshes");
219 else if (dim != 2 && dim != 3)
220 mooseError("Invalid mesh dimension for mortar constraint");
221
222 // Construct maps from nodes -> lower dimensional elements on the primary and secondary
223 // boundaries.
225
226 // Compute nodal geometry (normals and tangents).
228
229 if (dim == 2)
230 {
231 // Project secondary nodes (find xi^(2) values).
233
234 // Project primary nodes (find xi^(1) values).
236
237 // Build the mortar segment mesh on the secondary boundary.
239 }
240 else // dim == 3
242
245}
unsigned int dim
void computeNodalGeometry()
Computes and stores the nodal normal/tangent vectors in a local data structure instead of using the E...
void buildMortarSegmentMesh()
Builds the mortar segment mesh once the secondary and primary node projections have been completed.
void projectSecondaryNodes()
Project secondary nodes (find xi^(2) values) to the closest points on the primary surface.
void buildMortarSegmentMesh3d()
Builds the mortar segment mesh once the secondary and primary node projections have been completed.
void computeInactiveLMElems()
Get list of secondary elems without any corresponding primary elements.
void buildNodeToElemMaps()
Once the secondary_requested_boundary_ids and primary_requested_boundary_ids containers have been fil...
void clear()
Clears the mortar segment mesh and accompanying data structures.
void projectPrimaryNodes()
(Inverse) project primary nodes to the points on the secondary surface where they would have come fro...
void computeInactiveLMNodes()
Get list of secondary nodes that don't contribute to interaction with any primary element.

Member Data Documentation

◆ _displaced_mortar_interfaces

std::unordered_map<MortarKey, MortarInterfaceConfig> MortarInterfaceWarehouse::_displaced_mortar_interfaces
private

Map from primary-secondary (in that order) boundary ID pair to the configuration of the displaced mortar interface (AMG object + per-interface flags).

Definition at line 185 of file MortarInterfaceWarehouse.h.

Referenced by createMortarInterface(), getMortarInterface(), getMortarInterfaces(), hasDisplacedObjects(), meshChanged(), and update().

◆ _lower_d_sub_to_higher_d_subs

std::unordered_map<SubdomainID, std::set<SubdomainID> > MortarInterfaceWarehouse::_lower_d_sub_to_higher_d_subs
private

Map from lower dimensional subdomain ids to corresponding higher simensional subdomain ids (e.g.

the ids of the interior parents)

Definition at line 197 of file MortarInterfaceWarehouse.h.

Referenced by createMortarInterface(), and getHigherDimSubdomainIDs().

◆ _mei_objs

std::set<MortarExecutorInterface *> MortarInterfaceWarehouse::_mei_objs
private

A container of objects for whom the mortarSetup method will be called after the mortar mesh has been setup for the first time.

Definition at line 201 of file MortarInterfaceWarehouse.h.

Referenced by dontNotifyWhenMortarSetup(), and notifyWhenMortarSetup().

◆ _mortar_boundary_coverage

std::set<BoundaryID> MortarInterfaceWarehouse::_mortar_boundary_coverage
private

A set containing the boundary ids covered by all the mortar interfaces in this MortarInterfaceWarehouse object.

Definition at line 193 of file MortarInterfaceWarehouse.h.

Referenced by createMortarInterface(), and getMortarBoundaryIDs().

◆ _mortar_initd

bool MortarInterfaceWarehouse::_mortar_initd
private

Whether we have performed any mortar mesh construction.

Definition at line 204 of file MortarInterfaceWarehouse.h.

Referenced by initialized(), and update().

◆ _mortar_interfaces

std::unordered_map<MortarKey, MortarInterfaceConfig> MortarInterfaceWarehouse::_mortar_interfaces
private

Map from primary-secondary (in that order) boundary ID pair to the configuration of the undisplaced mortar interface (AMG object + per-interface flags).

Definition at line 181 of file MortarInterfaceWarehouse.h.

Referenced by createMortarInterface(), getMortarInterface(), getMortarInterfaces(), hasObjects(), meshChanged(), and update().

◆ _mortar_subdomain_coverage

std::set<SubdomainID> MortarInterfaceWarehouse::_mortar_subdomain_coverage
private

A set containing the subdomain ids covered by all the mortar interfaces in this MortarInterfaceWarehouse object.

Definition at line 189 of file MortarInterfaceWarehouse.h.

Referenced by createMortarInterface(), and getMortarSubdomainIDs().


The documentation for this class was generated from the following files: