www.mooseframework.org
Public Member Functions | 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 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. More...
 

Protected Attributes

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. More...
 
std::deque< MaterialBase * > _secondary_boundary_mats
 A container that holds the boundary materials that will need to be reinit'd on the secondary face. More...
 

Private Attributes

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

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 27 of file ComputeMortarFunctor.C.

34  : _amg(amg),
35  _subproblem(subproblem),
36  _fe_problem(fe_problem),
37  _displaced(displaced),
38  _assembly(assembly)
39 {
40  // Construct the mortar constraints we will later loop over
41  for (auto mc : mortar_constraints)
42  _mortar_constraints.push_back(mc.get());
43 
46  _amg,
47  0,
51 }
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...
Definition: MortarUtils.h:326
SubProblem & _subproblem
A reference to the SubProblem object for reiniting lower-dimensional element quantities.
const AutomaticMortarGeneration & _amg
Automatic mortar generation (amg) object providing the mortar mesh to loop over.
std::map< SubdomainID, std::deque< MaterialBase * > > _secondary_ip_sub_to_mats
const bool _displaced
Whether the mortar constraints are operating on the displaced mesh.
std::deque< MaterialBase * > _secondary_boundary_mats
A container that holds the boundary materials that will need to be reinit&#39;d on the secondary face...
std::vector< MortarConstraintBase * > _mortar_constraints
The mortar constraints to loop over when on each element.
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&#39;d on...
FEProblemBase & _fe_problem
A reference to the FEProblemBase object for reiniting higher-dimensional element and neighbor element...
Assembly & _assembly
A reference to the assembly object.

Member Function Documentation

◆ 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 54 of file ComputeMortarFunctor.C.

57 {
58  libmesh_parallel_only(_fe_problem.comm());
59 
60  unsigned int num_cached = 0;
61  const auto & vector_tags = _fe_problem.getVectorTags(vector_tag_ids);
62 
63  const auto & secondary_elems_to_mortar_segments = _amg.secondariesToMortarSegments();
64  typedef decltype(secondary_elems_to_mortar_segments.begin()) it_type;
65 
66  std::vector<it_type> iterators;
67  for (auto it = secondary_elems_to_mortar_segments.begin();
68  it != secondary_elems_to_mortar_segments.end();
69  ++it)
70  {
71  auto * const secondary_elem = _subproblem.mesh().getMesh().query_elem_ptr(it->first);
72 
73  if (secondary_elem && secondary_elem->processor_id() == _subproblem.processor_id() &&
74  !it->second.empty())
75  {
76  // This is local and the mortar segment set isn't empty, so include
77  iterators.push_back(it);
78  mooseAssert(secondary_elem->active(),
79  "We loop over active elements when building the mortar segment mesh, so we golly "
80  "well hope this is active.");
81  }
82  }
83 
84  auto act_functor = [this, &num_cached, compute_type, &vector_tags]()
85  {
86  ++num_cached;
87 
88  switch (compute_type)
89  {
91  {
92  for (auto * const mc : _mortar_constraints)
93  {
94  mc->setNormals();
95  mc->computeResidual();
96  }
97 
101 
102  if (num_cached % 20 == 0)
104 
105  break;
106  }
107 
109  {
110  for (auto * const mc : _mortar_constraints)
111  {
112  mc->setNormals();
113  mc->computeJacobian();
114  }
115 
117 
118  if (num_cached % 20 == 0)
120  break;
121  }
122 
124  {
125  for (auto * const mc : _mortar_constraints)
126  {
127  mc->setNormals();
128  mc->computeResidualAndJacobian();
129  }
130 
135 
136  if (num_cached % 20 == 0)
137  {
140  }
141  break;
142  }
143  }
144  };
145 
146  PARALLEL_TRY
147  {
148  try
149  {
151  _assembly,
152  _subproblem,
153  _fe_problem,
154  _amg,
155  _displaced,
157  0,
161  act_functor,
162  /*reinit_mortar_user_objects=*/true);
163  }
164  catch (libMesh::LogicError & e)
165  {
166  _fe_problem.setException("We caught a libMesh::LogicError: " + std::string(e.what()));
167  }
168  catch (MooseException & e)
169  {
171  }
172  catch (MetaPhysicL::LogicError & e)
173  {
175  }
176  }
177  PARALLEL_CATCH;
178 
179  // Call any post operations for our mortar constraints
180  for (auto * const mc : _mortar_constraints)
181  {
183  mc->incorrectEdgeDroppingPost(_amg.getInactiveLMNodes());
184  else
185  mc->post();
186 
187  mc->zeroInactiveLMDofs(_amg.getInactiveLMNodes(), _amg.getInactiveLMElems());
188  }
189 
190  // Make sure any remaining cached residuals/Jacobians get added
195 }
virtual MooseMesh & mesh()=0
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:3451
std::vector< MortarFilterIter > secondariesToMortarSegments(const Node &node) const
virtual const char * what() const
Get out the error message.
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:3466
SubProblem & _subproblem
A reference to the SubProblem object for reiniting lower-dimensional element quantities.
const AutomaticMortarGeneration & _amg
Automatic mortar generation (amg) object providing the mortar mesh to loop over.
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error
Definition: MooseError.C:110
virtual void setException(const std::string &message)
Set an exception, which is stored at this point by toggling a member variable in this class...
const Parallel::Communicator & comm() const
const std::unordered_set< const Elem * > & getInactiveLMElems() const
std::map< SubdomainID, std::deque< MaterialBase * > > _secondary_ip_sub_to_mats
const bool _displaced
Whether the mortar constraints are operating on the displaced mesh.
void addCachedResiduals(GlobalDataKey, const std::vector< VectorTag > &tags)
Pushes all cached residuals to the global residual vectors associated with each tag.
Definition: Assembly.C:3481
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:3199
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:3400
std::deque< MaterialBase * > _secondary_boundary_mats
A container that holds the boundary materials that will need to be reinit&#39;d on the secondary face...
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
Definition: SubProblem.C:150
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:69
std::vector< MortarConstraintBase * > _mortar_constraints
The mortar constraints to loop over when on each element.
Provides a way for users to bail out of the current solve.
bool computingResidual() const
Definition: Assembly.h:1894
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&#39;d on...
const std::unordered_set< const Node * > & getInactiveLMNodes() const
bool computingJacobian() const
Definition: Assembly.h:1899
void cacheJacobianMortar(GlobalDataKey)
Cache all portions of the Jacobian, e.g.
Definition: Assembly.C:4144
processor_id_type processor_id() const
FEProblemBase & _fe_problem
A reference to the FEProblemBase object for reiniting higher-dimensional element and neighbor element...
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
Definition: Assembly.C:3811
Assembly & _assembly
A reference to the assembly object.
Key structure for APIs manipulating global vectors/matrices.
Definition: Assembly.h:794

Member Data Documentation

◆ _amg

const AutomaticMortarGeneration& ComputeMortarFunctor::_amg
private

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

Definition at line 59 of file ComputeMortarFunctor.h.

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

◆ _assembly

Assembly& ComputeMortarFunctor::_assembly
private

A reference to the assembly object.

Definition at line 73 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 70 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 67 of file ComputeMortarFunctor.h.

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

◆ _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 56 of file ComputeMortarFunctor.h.

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

◆ _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 43 of file MortarExecutorInterface.h.

Referenced by ComputeMortarFunctor(), MortarUserObjectThread::MortarUserObjectThread(), MortarUserObjectThread::operator()(), and operator()().

◆ _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 47 of file MortarExecutorInterface.h.

Referenced by ComputeMortarFunctor(), MortarUserObjectThread::MortarUserObjectThread(), MortarUserObjectThread::operator()(), and operator()().

◆ _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 39 of file MortarExecutorInterface.h.

Referenced by ComputeMortarFunctor(), MortarUserObjectThread::MortarUserObjectThread(), MortarUserObjectThread::operator()(), and operator()().

◆ _subproblem

SubProblem& ComputeMortarFunctor::_subproblem
private

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

Definition at line 62 of file ComputeMortarFunctor.h.

Referenced by operator()().


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