21#include "libmesh/fe_base.h"
22#include "libmesh/quadrature.h"
23#include "libmesh/elem.h"
24#include "libmesh/point.h"
25#include "libmesh/mesh_base.h"
31 const std::vector<std::shared_ptr<MortarConstraintBase>> & mortar_constraints,
38 _subproblem(subproblem),
39 _fe_problem(fe_problem),
40 _displaced(displaced),
44 for (
auto mc : mortar_constraints)
70 const std::set<TagID> & vector_tag_ids,
71 const std::set<TagID> & )
75 unsigned int num_cached = 0;
79 typedef decltype(secondary_elems_to_mortar_segments.begin()) it_type;
81 std::vector<it_type> iterators;
82 for (
auto it = secondary_elems_to_mortar_segments.begin();
83 it != secondary_elems_to_mortar_segments.end();
92 iterators.push_back(it);
93 mooseAssert(secondary_elem->active(),
94 "We loop over active elements when building the mortar segment mesh, so we golly "
95 "well hope this is active.");
99 auto act_functor = [
this, &num_cached, compute_type, &vector_tags]()
103 switch (compute_type)
110 mc->computeResidual();
117 if (num_cached % 20 == 0)
128 mc->computeJacobian();
133 if (num_cached % 20 == 0)
143 mc->computeResidualAndJacobian();
151 if (num_cached % 20 == 0)
183 catch (MetaPhysicL::LogicError & e)
187 catch (std::exception & e)
189 if (!strstr(e.
what(),
"Jacobian") && !strstr(e.
what(),
"singular") &&
190 !strstr(e.
what(),
"det != 0"))
194 "We caught a libMesh degeneracy exception in ComputeMortarFunctor:\n" +
195 std::string(e.
what()));
214 if (_assembly.computingJacobian())
Key structure for APIs manipulating global vectors/matrices.
Keeps track of stuff related to assembling.
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 ...
bool computingResidual() const
void cacheResidualLower(GlobalDataKey, const std::vector< VectorTag > &tags)
Takes the values that are currently in _sub_Rl and appends them to the cached values.
void cacheJacobianMortar(GlobalDataKey)
Cache all portions of the Jacobian, e.g.
void addCachedJacobian(GlobalDataKey)
Adds the values that have been cached by calling cacheJacobian() and or cacheJacobianNeighbor() to th...
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 ...
void addCachedResiduals(GlobalDataKey, const std::vector< VectorTag > &tags)
Pushes all cached residuals to the global residual vectors associated with each tag.
This class is a container/interface for the objects involved in automatic generation of mortar spaces...
std::vector< MortarFilterIter > secondariesToMortarSegments(const Node &node) const
bool incorrectEdgeDropping() const
const std::unordered_set< const Elem * > & getInactiveLMElems() const
const std::unordered_set< const Node * > & getInactiveLMNodes() const
Assembly & _assembly
A reference to the assembly object.
void setupMortarMaterials()
Setup step for materials that needs to be re-done if subdomains change.
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.
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.
ComputeMortarFunctor(const std::vector< std::shared_ptr< MortarConstraintBase > > &mortar_constraints, const AutomaticMortarGeneration &amg, SubProblem &subproblem, FEProblemBase &fe_problem, bool displaced, Assembly &assembly)
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
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.
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
Generic class for solving transient nonlinear problems.
virtual MooseMesh & mesh()=0
std::vector< VectorTag > getVectorTags(const std::set< TagID > &tag_ids) const
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,...
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...
ComputeType
The type of nonlinear computation being performed.
void translateMetaPhysicLError(const MetaPhysicL::LogicError &)
emit a relatively clear error message when we catch a MetaPhysicL logic error