18 #include "libmesh/quadrature.h" 19 #include "libmesh/elem.h" 20 #include "libmesh/point.h" 30 unsigned int sub_elem);
48 const Elem * primal_elem,
49 unsigned int sub_elem_index,
50 const QBase & qrule_msm,
51 std::vector<Point> & q_pts);
64 const QBase & qrule_msm,
65 std::vector<Point> & secondary_q_pts,
66 std::vector<Point> & primary_q_pts);
89 template <
typename Iterators,
typename Consumers,
typename ActionFunctor>
92 const Iterators & secondary_elems_to_mortar_segments,
98 const Consumers & consumers,
100 const std::map<
SubdomainID, std::deque<MaterialBase *>> & secondary_ip_sub_to_mats,
101 const std::map<
SubdomainID, std::deque<MaterialBase *>> & primary_ip_sub_to_mats,
102 const std::deque<MaterialBase *> & secondary_boundary_mats,
103 const ActionFunctor act,
104 const bool reinit_mortar_user_objects)
108 const auto primary_boundary_id = primary_secondary_boundary_id_pair.first;
109 const auto secondary_boundary_id = primary_secondary_boundary_id_pair.second;
112 unsigned int secondary_sub_elem_index = 0, primary_sub_elem_index = 0;
115 secondary_sub_elem_index = amg.
mortarSegmentMesh().get_elem_integer_index(
"secondary_sub_elem");
116 primary_sub_elem_index = amg.
mortarSegmentMesh().get_elem_integer_index(
"primary_sub_elem");
124 const auto & JxW_msm = assembly.
jxWMortar();
127 std::unordered_set<unsigned int> needed_mat_props;
128 for (
const auto & consumer : consumers)
130 const auto & mp_deps = consumer->getMatPropDependencies();
131 needed_mat_props.insert(mp_deps.begin(), mp_deps.end());
137 for (
const auto elem_to_msm : secondary_elems_to_mortar_segments)
139 const Elem * secondary_face_elem = subproblem.
mesh().
getMesh().elem_ptr(elem_to_msm->first);
141 const Elem * secondary_ip = secondary_face_elem->interior_parent();
142 unsigned int secondary_side_id = secondary_ip->which_side_am_i(secondary_face_elem);
143 const auto & secondary_ip_mats =
144 libmesh_map_find(secondary_ip_sub_to_mats, secondary_ip->subdomain_id());
146 const auto & msm_elems = elem_to_msm->second;
154 std::vector<Point> secondary_xi_pts, primary_xi_pts;
156 std::vector<Real> JxW;
159 unsigned int expected_length = 0;
163 for (
const auto msm_elem : msm_elems)
171 if (msm_elem->dim() == 1)
173 for (
unsigned int qp = 0; qp < qrule_msm->n_points(); qp++)
175 const Real eta = qrule_msm->qp(qp)(0);
178 const Real xi1_eta = 0.5 * (1 - eta) * msinfo.
xi1_a + 0.5 * (1 + eta) * msinfo.
xi1_b;
179 secondary_xi_pts.push_back(xi1_eta);
182 const Real xi2_eta = 0.5 * (1 - eta) * msinfo.
xi2_a + 0.5 * (1 + eta) * msinfo.
xi2_b;
183 primary_xi_pts.push_back(xi2_eta);
188 if (amg.
mortar3DQpMapping() == Mortar3DQuadraturePointMapping::REFERENCE_INTERPOLATION)
199 secondary_sub_elem_index,
203 msm_elem, msinfo.
primary_elem, primary_sub_elem_index, *qrule_msm, primary_xi_pts);
209 std::copy(std::begin(JxW_msm), std::end(JxW_msm), std::back_inserter(JxW));
213 expected_length += qrule_msm->n_points();
214 mooseAssert(secondary_xi_pts.size() == expected_length,
215 "Fewer than expected secondary quadrature points");
216 mooseAssert(primary_xi_pts.size() == expected_length,
217 "Fewer than expected primary quadrature points");
220 mooseAssert(JxW.size() == expected_length,
"Fewer than expected JxW values computed");
227 assembly.
reinitDual(secondary_face_elem, secondary_xi_pts, JxW);
229 unsigned int n_segment = 0;
232 for (
const auto msm_elem : msm_elems)
237 std::vector<Point> xi1_pts, xi2_pts;
243 const Elem * primary_ip = msinfo.
primary_elem->interior_parent();
244 unsigned int primary_side_id = primary_ip->which_side_am_i(msinfo.
primary_elem);
245 const auto & primary_ip_mats =
246 libmesh_map_find(primary_ip_sub_to_mats, primary_ip->subdomain_id());
254 const unsigned int start = (n_segment - 1) * qrule_msm->n_points();
255 const unsigned int end = n_segment * qrule_msm->n_points();
257 xi1_pts.begin(), secondary_xi_pts.begin() + start, secondary_xi_pts.begin() + end);
258 xi2_pts.insert(xi2_pts.begin(), primary_xi_pts.begin() + start, primary_xi_pts.begin() + end);
260 const Elem * reinit_secondary_elem = secondary_ip;
265 reinit_secondary_elem = fe_problem.
mesh().
elemPtr(reinit_secondary_elem->id());
281 reinit_secondary_elem, secondary_side_id, TOLERANCE, &xi1_pts,
nullptr, tid);
283 const Elem * reinit_primary_elem = primary_ip;
288 reinit_primary_elem = fe_problem.
mesh().
elemPtr(reinit_primary_elem->id());
292 reinit_primary_elem, primary_side_id, TOLERANCE, &xi2_pts,
nullptr, tid);
320 secondary_boundary_id, tid,
false, &secondary_boundary_mats);
322 if (reinit_mortar_user_objects)
345 template <
typename Consumers>
351 std::map<
SubdomainID, std::deque<MaterialBase *>> & secondary_ip_sub_to_mats,
352 std::map<
SubdomainID, std::deque<MaterialBase *>> & primary_ip_sub_to_mats,
353 std::deque<MaterialBase *> & secondary_boundary_mats)
355 secondary_ip_sub_to_mats.clear();
356 primary_ip_sub_to_mats.clear();
357 secondary_boundary_mats.clear();
360 auto get_required_sub_mats =
361 [&mat_warehouse, tid, &consumers](
365 if (mat_warehouse[mat_data_type].hasActiveBlockObjects(sub_id, tid))
376 for (
const auto secondary_ip_sub : secondary_ip_sub_ids)
377 secondary_ip_sub_to_mats.emplace(
382 for (
const auto primary_ip_sub : primary_ip_sub_ids)
383 primary_ip_sub_to_mats.emplace(
388 const auto secondary_boundary = boundary_pr.second;
389 if (mat_warehouse.hasActiveBoundaryObjects(secondary_boundary, tid))
391 auto & boundary_mats = mat_warehouse.getActiveBoundaryObjects(secondary_boundary, tid);
392 secondary_boundary_mats =
virtual MooseMesh & mesh()=0
void setActiveMaterialProperties(const std::unordered_set< unsigned int > &mat_prop_ids, const THREAD_ID tid)
Record and set the material properties required by the current computing thread.
void reinitNeighborLowerDElem(const Elem *elem, const THREAD_ID tid=0)
reinitialize a neighboring lower dimensional element
const std::pair< BoundaryID, BoundaryID > & primarySecondaryBoundaryIDPair() const
virtual void reinitLowerDElem(const Elem *lower_d_elem, const THREAD_ID tid, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr)
Keeps track of stuff related to assembling.
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getActiveBlockObjects(THREAD_ID tid=0) const
virtual Elem * elemPtr(const dof_id_type i)
std::vector< unsigned int > getMortarSubElementNodeIndices(const Elem &parent_elem, unsigned int sub_elem)
Return the node indices for a first-order sub-element of a parent face.
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...
MaterialDataType
MaterialData types.
void reinitMortarUserObjects(BoundaryID primary_boundary_id, BoundaryID secondary_boundary_id, bool displaced)
Call reinit on mortar user objects with matching primary boundary ID, secondary boundary ID...
void reinitMaterialsBoundary(BoundaryID boundary_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase *> *reinit_mats=nullptr)
reinit materials on a boundary
const libMesh::QBase *const & qRuleMortar() const
Returns a reference to the quadrature rule for the mortar segments.
const std::set< SubdomainID > & primaryIPSubIDs() const
void mapQPoints3dFromReference(const Elem &mortar_segment_elem, const MortarSegmentReferencePoints &reference_points, const QBase &qrule_msm, std::vector< Point > &secondary_q_pts, std::vector< Point > &primary_q_pts)
3D mapping operator that interpolates stored parent reference points on each triangular mortar segmen...
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
const MaterialWarehouse & getRegularMaterialsWarehouse() const
void reinitMaterialsFace(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase *> *reinit_mats=nullptr)
reinit materials on element faces
const std::set< SubdomainID > & secondaryIPSubIDs() const
This class is a container/interface for the objects involved in automatic generation of mortar spaces...
virtual void reinitElemFaceRef(const Elem *elem, unsigned int side, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr, const THREAD_ID tid=0) override
reinitialize FE objects on a given element on a given side at a given set of reference points and the...
const Elem * primary_elem
bool needDual() const
Indicates whether dual shape functions are used (computation is now repeated on each element so expen...
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
void reinitMaterialsNeighbor(SubdomainID blk_id, const THREAD_ID tid, bool swap_stateful=true, const std::deque< MaterialBase *> *reinit_mats=nullptr)
reinit materials on the neighboring element face
const MortarSegmentReferencePoints & mortarSegmentReferencePoints(const Elem &mortar_segment_elem) const
Return the parent-face reference coordinates for a mortar segment.
virtual void reinitNeighborFaceRef(const Elem *neighbor_elem, unsigned int neighbor_side, Real tolerance, const std::vector< Point > *const pts, const std::vector< Real > *const weights=nullptr, const THREAD_ID tid=0) override
reinitialize FE objects on a given neighbor element on a given side at a given set of reference point...
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...
const Elem * secondary_elem
Mortar3DQuadraturePointMapping mortar3DQpMapping() const
Return the 3D mortar quadrature-point mapping method.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Holds xi^(1), xi^(2), and other data for a given mortar segment.
Generic class for solving transient nonlinear problems.
Parent-face reference coordinates associated with the vertices of one triangular mortar segment...
static std::deque< MaterialBase * > buildRequiredMaterials(const Consumers &mat_consumers, const std::vector< std::shared_ptr< MaterialBase >> &mats, const bool allow_stateful)
Build the materials required by a set of consumer objects.
const std::unordered_map< const Elem *, MortarSegmentInfo > & mortarSegmentMeshElemToInfo() const
virtual MooseMesh & mesh() override
const MeshBase & mortarSegmentMesh() const
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
const std::vector< Real > & jxWMortar() const
Returns a reference to JxW for mortar segment elements.
void reinitMortarElem(const Elem *elem, const THREAD_ID tid=0)
Reinit a mortar element to obtain a valid JxW.
void projectQPoints3d(const Elem *msm_elem, const Elem *primal_elem, unsigned int sub_elem_index, const QBase &qrule_msm, std::vector< Point > &q_pts)
3D projection operator for mapping qpoints on mortar segments to secondary or primary elements ...
void reinitDual(const Elem *elem, const std::vector< Point > &pts, const std::vector< Real > &JxW)
Reintialize dual basis coefficients based on a customized quadrature rule.