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

#include <ComputeMortarFunctor.h>

Inheritance diagram for ComputeMortarFunctor:
[legend]

Public Member Functions

 ComputeMortarFunctor (const std::vector< std::shared_ptr< MortarConstraintBase > > &mortar_constraints, const AutomaticMortarGeneration &amg, SubProblem &subproblem, FEProblemBase &fe_problem, bool displaced, Assembly &assembly)
 
void setupMortarMaterials ()
 Setup step for materials that needs to be re-done if subdomains change.
 
void mortarSetup (const AutomaticMortarGeneration &amg) override
 Called by the MortarInterfaceWarehouse whenever amg's mortar segment mesh coverage has changed, so that this object may refresh any state (e.g.
 
void operator() (Moose::ComputeType compute_type, const std::set< TagID > &vector_tag_ids, const std::set< TagID > &matrix_tag_ids)
 Loops over the mortar segment mesh and computes the residual/Jacobian.
 

Protected Attributes

MortarInterfaceWarehouse & _mortar_warehouse
 The warehouse this object is registered with for mortar setup notifications.
 
Materials for Mortar

These containers hold the materials whose properties are required by a given set of consumers.

Note that these containers will also hold materials that may not provide properties explicitly needed by the consumers but do provided properties that are dependencies of the materials that do provide properties needed by the consumers

std::map< SubdomainID, std::deque< MaterialBase * > > _secondary_ip_sub_to_mats
 
std::map< SubdomainID, std::deque< MaterialBase * > > _primary_ip_sub_to_mats
 A map from primary interior parent subdomain IDs to the block materials that will need to reinit'd on the primary face.
 
std::deque< MaterialBase * > _secondary_boundary_mats
 A container that holds the boundary materials that will need to be reinit'd on the secondary face.
 

Private Attributes

std::vector< MortarConstraintBase * > _mortar_constraints
 The mortar constraints to loop over when on each element.
 
const AutomaticMortarGeneration & _amg
 Automatic mortar generation (amg) object providing the mortar mesh to loop over.
 
SubProblem & _subproblem
 A reference to the SubProblem object for reiniting lower-dimensional element quantities.
 
FEProblemBase & _fe_problem
 A reference to the FEProblemBase object for reiniting higher-dimensional element and neighbor element quantities.
 
const bool _displaced
 Whether the mortar constraints are operating on the displaced mesh.
 
Assembly & _assembly
 A reference to the assembly object.
 

Detailed Description

Definition at line 33 of file ComputeMortarFunctor.h.

Constructor & Destructor Documentation

◆ ComputeMortarFunctor()

ComputeMortarFunctor::ComputeMortarFunctor ( const std::vector< std::shared_ptr< MortarConstraintBase > > &  mortar_constraints,
const AutomaticMortarGeneration &  amg,
SubProblem &  subproblem,
FEProblemBase &  fe_problem,
bool  displaced,
Assembly &  assembly 
)

Definition at line 30 of file ComputeMortarFunctor.C.

37 : MortarExecutorInterface(fe_problem),
38 _amg(amg),
39 _subproblem(subproblem),
40 _fe_problem(fe_problem),
41 _displaced(displaced),
42 _assembly(assembly)
43{
44 // Construct the mortar constraints we will later loop over
45 for (auto mc : mortar_constraints)
46 _mortar_constraints.push_back(mc.get());
47
49}
Assembly & _assembly
A reference to the assembly object.
void setupMortarMaterials()
Setup step for materials that needs to be re-done if subdomains change.
const AutomaticMortarGeneration & _amg
Automatic mortar generation (amg) object providing the mortar mesh to loop over.
SubProblem & _subproblem
A reference to the SubProblem object for reiniting lower-dimensional element quantities.
FEProblemBase & _fe_problem
A reference to the FEProblemBase object for reiniting higher-dimensional element and neighbor element...
const bool _displaced
Whether the mortar constraints are operating on the displaced mesh.
std::vector< MortarConstraintBase * > _mortar_constraints
The mortar constraints to loop over when on each element.
Interface for objects that need to be notified when the mortar segment mesh for an interface they con...
const Elem & get(const ElemType type_in)

Member Function Documentation

◆ mortarSetup()

void ComputeMortarFunctor::mortarSetup ( const AutomaticMortarGeneration &  amg)
overridevirtual

Called by the MortarInterfaceWarehouse whenever amg's mortar segment mesh coverage has changed, so that this object may refresh any state (e.g.

material dependency lists) that depends on which subdomains/boundaries the mortar segment mesh currently touches.

Implements MortarExecutorInterface.

Definition at line 52 of file ComputeMortarFunctor.C.

53{
54 // We may be registered with a warehouse that owns multiple interfaces; only react to the one
55 // we actually consume.
56 if (&amg == &_amg)
58}

◆ operator()()

void ComputeMortarFunctor::operator() ( Moose::ComputeType  compute_type,
const std::set< TagID > &  vector_tag_ids,
const std::set< TagID > &  matrix_tag_ids 
)

Loops over the mortar segment mesh and computes the residual/Jacobian.

Definition at line 73 of file ComputeMortarFunctor.C.

76{
77 libmesh_parallel_only(_fe_problem.comm());
78
79 unsigned int num_cached = 0;
80 const auto & vector_tags = _fe_problem.getVectorTags(vector_tag_ids);
81
82 const auto & secondary_elems_to_mortar_segments = _amg.secondariesToMortarSegments();
83 typedef decltype(secondary_elems_to_mortar_segments.begin()) it_type;
84
85 std::vector<it_type> iterators;
86 for (auto it = secondary_elems_to_mortar_segments.begin();
87 it != secondary_elems_to_mortar_segments.end();
88 ++it)
89 {
90 auto * const secondary_elem = _subproblem.mesh().getMesh().query_elem_ptr(it->first);
91
92 if (secondary_elem && secondary_elem->processor_id() == _subproblem.processor_id() &&
93 !it->second.empty())
94 {
95 // This is local and the mortar segment set isn't empty, so include
96 iterators.push_back(it);
97 mooseAssert(secondary_elem->active(),
98 "We loop over active elements when building the mortar segment mesh, so we golly "
99 "well hope this is active.");
100 }
101 }
102
103 auto act_functor = [this, &num_cached, compute_type, &vector_tags]()
104 {
105 ++num_cached;
106
107 switch (compute_type)
108 {
110 {
111 for (auto * const mc : _mortar_constraints)
112 {
113 mc->setNormals();
114 mc->computeResidual();
115 }
116
120
121 if (num_cached % 20 == 0)
123
124 break;
125 }
126
128 {
129 for (auto * const mc : _mortar_constraints)
130 {
131 mc->setNormals();
132 mc->computeJacobian();
133 }
134
136
137 if (num_cached % 20 == 0)
139 break;
140 }
141
143 {
144 for (auto * const mc : _mortar_constraints)
145 {
146 mc->setNormals();
147 mc->computeResidualAndJacobian();
148 }
149
154
155 if (num_cached % 20 == 0)
156 {
159 }
160 break;
161 }
162 }
163 };
164
165 PARALLEL_TRY
166 {
167 try
168 {
170 _assembly,
173 _amg,
176 0,
180 act_functor,
181 /*reinit_mortar_user_objects=*/true);
182 }
183 catch (MooseException & e)
184 {
186 }
187 catch (MetaPhysicL::LogicError & e)
188 {
190 }
191 catch (std::exception & e)
192 {
193 if (!strstr(e.what(), "Jacobian") && !strstr(e.what(), "singular") &&
194 !strstr(e.what(), "det != 0"))
195 throw;
196
198 "We caught a libMesh degeneracy exception in ComputeMortarFunctor:\n" +
199 std::string(e.what()));
200 }
201 }
202 PARALLEL_CATCH;
203
204 // Call any post operations for our mortar constraints
205 for (auto * const mc : _mortar_constraints)
206 {
208 mc->incorrectEdgeDroppingPost(_amg.getInactiveLMNodes());
209 else
210 mc->post();
211
212 mc->zeroInactiveLMDofs(_amg.getInactiveLMNodes(), _amg.getInactiveLMElems());
213 }
214
215 // Make sure any remaining cached residuals/Jacobians get added
220}
Key structure for APIs manipulating global vectors/matrices.
Definition Assembly.h:836
void cacheResidualNeighbor(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Rn of all field variables and appends them to the cached ...
Definition Assembly.C:3477
bool computingResidual() const
Definition Assembly.h:1937
void cacheResidualLower(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Rl and appends them to the cached values.
Definition Assembly.C:3491
bool computingJacobian() const
Definition Assembly.h:1942
void cacheJacobianMortar(GlobalDataKey)
Cache all portions of the Jacobian, e.g.
Definition Assembly.C:4170
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition Assembly.C:3835
void cacheResidual(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Re of all field variables and appends them to the cached ...
Definition Assembly.C:3427
void addCachedResiduals(GlobalDataKey, const std::vector< VectorTag > &tags)
Pushes all cached residuals to the global residual vectors associated with each tag.
Definition Assembly.C:3505
std::vector< MortarFilterIter > secondariesToMortarSegments(const Node &node) const
const std::unordered_set< const Elem * > & getInactiveLMElems() const
const std::unordered_set< const Node * > & getInactiveLMNodes() const
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class,...
Provides a way for users to bail out of the current solve.
virtual const char * what() const
Get out the error message.
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition MooseMesh.C:3512
std::map< SubdomainID, std::deque< MaterialBase * > > _primary_ip_sub_to_mats
A map from primary interior parent subdomain IDs to the block materials that will need to reinit'd on...
std::deque< MaterialBase * > _secondary_boundary_mats
A container that holds the boundary materials that will need to be reinit'd on the secondary face.
std::map< SubdomainID, std::deque< MaterialBase * > > _secondary_ip_sub_to_mats
virtual MooseMesh & mesh()=0
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition SubProblem.C:161
processor_id_type processor_id() const
const Parallel::Communicator & comm() const
void loopOverMortarSegments(const Iterators &secondary_elems_to_mortar_segments, Assembly &assembly, SubProblem &subproblem, FEProblemBase &fe_problem, const AutomaticMortarGeneration &amg, const bool displaced, const Consumers &consumers, const THREAD_ID tid, const std::map< SubdomainID, std::deque< MaterialBase * > > &secondary_ip_sub_to_mats, const std::map< SubdomainID, std::deque< MaterialBase * > > &primary_ip_sub_to_mats, const std::deque< MaterialBase * > &secondary_boundary_mats, const ActionFunctor act, const bool reinit_mortar_user_objects)
This method will loop over pairs of secondary elements and their corresponding mortar segments,...
Definition MortarUtils.h:91
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
Definition MooseError.C:153

◆ setupMortarMaterials()

void ComputeMortarFunctor::setupMortarMaterials ( )

Setup step for materials that needs to be re-done if subdomains change.

Definition at line 61 of file ComputeMortarFunctor.C.

62{
65 _amg,
66 /*thread id*/ 0,
70}
void setupMortarMaterials(const Consumers &consumers, FEProblemBase &fe_problem, const AutomaticMortarGeneration &amg, const THREAD_ID tid, std::map< SubdomainID, std::deque< MaterialBase * > > &secondary_ip_sub_to_mats, std::map< SubdomainID, std::deque< MaterialBase * > > &primary_ip_sub_to_mats, std::deque< MaterialBase * > &secondary_boundary_mats)
This function creates containers of materials necessary to execute the mortar method for a supplied s...

Referenced by ComputeMortarFunctor(), and mortarSetup().

Member Data Documentation

◆ _amg

const AutomaticMortarGeneration& ComputeMortarFunctor::_amg
private

Automatic mortar generation (amg) object providing the mortar mesh to loop over.

Definition at line 64 of file ComputeMortarFunctor.h.

Referenced by mortarSetup(), operator()(), and setupMortarMaterials().

◆ _assembly

Assembly& ComputeMortarFunctor::_assembly
private

A reference to the assembly object.

Definition at line 78 of file ComputeMortarFunctor.h.

Referenced by operator()().

◆ _displaced

const bool ComputeMortarFunctor::_displaced
private

Whether the mortar constraints are operating on the displaced mesh.

Definition at line 75 of file ComputeMortarFunctor.h.

Referenced by operator()().

◆ _fe_problem

FEProblemBase& ComputeMortarFunctor::_fe_problem
private

A reference to the FEProblemBase object for reiniting higher-dimensional element and neighbor element quantities.

We use the FEProblemBase object for reiniting these because we may be using material properties from either undisplaced or displaced materials

Definition at line 72 of file ComputeMortarFunctor.h.

Referenced by operator()(), and setupMortarMaterials().

◆ _mortar_constraints

std::vector<MortarConstraintBase *> ComputeMortarFunctor::_mortar_constraints
private

The mortar constraints to loop over when on each element.

These must be pointers to the base class otherwise the compiler will fail to compile when running std::vector<MortarConstraint0>::push_back(MortarConstraint1> or visa versa

Definition at line 61 of file ComputeMortarFunctor.h.

Referenced by ComputeMortarFunctor(), operator()(), and setupMortarMaterials().

◆ _mortar_warehouse

MortarInterfaceWarehouse& MortarExecutorInterface::_mortar_warehouse
protectedinherited

The warehouse this object is registered with for mortar setup notifications.

Definition at line 69 of file MortarExecutorInterface.h.

Referenced by MortarExecutorInterface::MortarExecutorInterface(), MortarExecutorInterface::MortarExecutorInterface(), and MortarUserObjectThread::~MortarUserObjectThread().

◆ _primary_ip_sub_to_mats

std::map<SubdomainID, std::deque<MaterialBase *> > MortarExecutorInterface::_primary_ip_sub_to_mats
protectedinherited

A map from primary interior parent subdomain IDs to the block materials that will need to reinit'd on the primary face.

Definition at line 85 of file MortarExecutorInterface.h.

Referenced by MortarUserObjectThread::mortarSetup(), MortarUserObjectThread::operator()(), operator()(), and setupMortarMaterials().

◆ _secondary_boundary_mats

std::deque<MaterialBase *> MortarExecutorInterface::_secondary_boundary_mats
protectedinherited

A container that holds the boundary materials that will need to be reinit'd on the secondary face.

Definition at line 89 of file MortarExecutorInterface.h.

Referenced by MortarUserObjectThread::mortarSetup(), MortarUserObjectThread::operator()(), operator()(), and setupMortarMaterials().

◆ _secondary_ip_sub_to_mats

std::map<SubdomainID, std::deque<MaterialBase *> > MortarExecutorInterface::_secondary_ip_sub_to_mats
protectedinherited

A map from secondary interior parent subdomain IDs to the block materials that will need to reinit'd on the secondary face

Definition at line 81 of file MortarExecutorInterface.h.

Referenced by MortarUserObjectThread::mortarSetup(), MortarUserObjectThread::operator()(), operator()(), and setupMortarMaterials().

◆ _subproblem

SubProblem& ComputeMortarFunctor::_subproblem
private

A reference to the SubProblem object for reiniting lower-dimensional element quantities.

Definition at line 67 of file ComputeMortarFunctor.h.

Referenced by operator()().


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