25 constexpr std::array<const DefaultElementAdjacency::DefEntTypeMap *, MBMAXTYPE>
30 std::vector<EntityHandle> &adjacency) {
34 adjacency.push_back(fe.
getEnt());
36 for (
auto ent : adjacency)
41 for (
auto ent : adjacency) {
43 .insert(boost::shared_ptr<SideNumber>(
new SideNumber(ent, -1, 0, 0)));
48 "this field is not implemented for VERTEX finite element");
57 std::vector<EntityHandle> &adjacency) {
63 CHKERR moab.get_connectivity(&fe_ent, 1, adjacency,
true);
66 adjacency.push_back(fe_ent);
68 for (
auto e : adjacency)
73 for (
auto e : adjacency) {
75 .insert(boost::shared_ptr<SideNumber>(
new SideNumber(e, -1, 0, 0)));
80 "this field is not implemented for EDGE finite element");
89 std::vector<EntityHandle> &adjacency) {
95 CHKERR moab.get_connectivity(&fe_ent, 1, adjacency,
true);
97 CHKERR moab.get_adjacencies(&fe_ent, 1, 1,
false, adjacency,
98 moab::Interface::UNION);
101 adjacency.push_back(fe_ent);
103 for (
auto ent : adjacency)
108 for (
auto ent : adjacency) {
110 .insert(boost::shared_ptr<SideNumber>(
new SideNumber(ent, -1, 0, 0)));
115 "this field is not implemented for TRI finite element");
123 std::vector<EntityHandle> &adjacency) {
128 CHKERR moab.get_connectivity(&fe_ent, 1, adjacency,
true);
130 CHKERR moab.get_adjacencies(&fe_ent, 1, 1,
false, adjacency,
131 moab::Interface::UNION);
133 CHKERR moab.get_adjacencies(&fe_ent, 1, 2,
false, adjacency,
134 moab::Interface::UNION);
136 adjacency.push_back(fe_ent);
138 for (
auto ent : adjacency)
143 for (
auto ent : adjacency) {
145 .insert(boost::shared_ptr<SideNumber>(
new SideNumber(ent, -1, 0, 0)));
150 "this field is not implemented for TRI finite element");
159 std::vector<EntityHandle> &adjacency) {
166 CHKERR moab.side_element(prism, 2, 3, face_side3);
167 CHKERR moab.side_element(prism, 2, 4, face_side4);
170 for (
int qq = 0; qq < 3; qq++) {
172 rval = moab.side_element(prism, 2, qq, quad);
173 if (
rval != MB_SUCCESS || quad == 0)
175 int side_number, sense, offset;
176 rval = moab.side_number(prism, quad, side_number, sense, offset);
177 if (side_number == -1 ||
rval != MB_SUCCESS)
180 .insert(boost::shared_ptr<SideNumber>(
181 new SideNumber(quad, side_number, sense, offset)));
184 for (; ee < 3; ee++) {
186 CHKERR moab.side_element(prism, 1, ee, edge);
187 boost::shared_ptr<SideNumber> side_ptr =
189 if (side_ptr->side_number != ee) {
191 "data inconsistency for edge %d while in FE data structure is "
193 ee, side_ptr->side_number);
195 CHKERR moab.side_element(prism, 1, 6 + ee, edge);
197 if (side_ptr->side_number != ee + 6) {
198 if (side_ptr->side_number != ee) {
200 "data inconsistency for edge %d while in FE data structure "
202 ee, side_ptr->side_number);
204 side_ptr->brother_side_number = ee + 6;
208 for (; ee < 6; ee++) {
210 rval = moab.side_element(prism, 1, ee, edge);
211 if (
rval != MB_SUCCESS || edge == 0)
213 int side_number, sense, offset;
214 rval = moab.side_number(prism, edge, side_number, sense, offset);
215 if (side_number == -1 ||
rval != MB_SUCCESS)
218 .insert(boost::shared_ptr<SideNumber>(
219 new SideNumber(edge, side_number, sense, offset)));
222 for (; nn < 3; nn++) {
224 CHKERR moab.side_element(prism, 0, nn, node);
225 boost::shared_ptr<SideNumber> side_ptr =
227 if (side_ptr->side_number != nn) {
229 "data inconsistency for node %d while in FE datastructure is "
231 nn, side_ptr->side_number);
233 CHKERR moab.side_element(prism, 0, nn + 3, node);
235 if (side_ptr->side_number != nn + 3) {
236 if (side_ptr->side_number != nn) {
238 "data inconsistency for node %d while in FE datastructure is "
240 nn, side_ptr->side_number);
242 side_ptr->brother_side_number = nn + 3;
253 CHKERR moab.get_adjacencies(&prism, 1, 0,
false, nodes,
254 moab::Interface::UNION);
257 CHKERR moab.get_connectivity(&prism, 1, topo_nodes,
true);
259 CHKERR moab.get_connectivity(&prism, 1, mid_nodes,
false);
260 mid_nodes = subtract(mid_nodes, topo_nodes);
261 nodes = subtract(nodes, mid_nodes);
263 adjacency.insert(adjacency.end(), nodes.begin(), nodes.end());
265 auto siit = side_table.get<0>().lower_bound(get_id_for_min_type<MBEDGE>());
267 side_table.get<0>().upper_bound(get_id_for_max_type<MBEDGE>());
268 for (; siit != hi_siit; siit++)
269 adjacency.push_back(siit->get()->ent);
272 auto siit = side_table.get<0>().lower_bound(get_id_for_min_type<MBTRI>());
274 side_table.get<0>().upper_bound(get_id_for_max_type<MBQUAD>());
275 for (; siit != hi_siit; siit++)
276 adjacency.push_back(siit->get()->ent);
279 adjacency.push_back(prism);
283 for (
auto ent : adjacency) {
285 .insert(boost::shared_ptr<SideNumber>(
new SideNumber(ent, -1, 0, 0)));
290 "this field is not implemented for TRI finite element");
297 std::vector<EntityHandle> &adjacency) {
303 CHKERR moab.get_entities_by_type(fe_ent, MBVERTEX, adjacency,
true);
305 CHKERR moab.get_entities_by_type(fe_ent, MBEDGE, adjacency,
true);
307 CHKERR moab.get_entities_by_dimension(fe_ent, 2, adjacency,
true);
309 CHKERR moab.get_entities_by_dimension(fe_ent, 3, adjacency,
true);
313 for (
auto ent : adjacency) {
315 .insert(boost::shared_ptr<SideNumber>(
new SideNumber(ent, -1, 0, 0)));
326 : meshset(_meshset) {
330 moab.tag_get_by_ptr(th_FEId, &
meshset, 1, (
const void **)&
tagId),
333 CHK_MOAB_THROW(moab.tag_get_handle(
"_FEName", th_FEName),
"get tag");
337 Tag th_FEIdCol, th_FEIdRow, th_FEIdData;
338 CHK_MOAB_THROW(moab.tag_get_handle(
"_FEIdCol", th_FEIdCol),
"get_tag");
342 CHK_MOAB_THROW(moab.tag_get_handle(
"_FEIdRow", th_FEIdRow),
"get tag");
346 CHK_MOAB_THROW(moab.tag_get_handle(
"_FEIdData", th_FEIdData),
"get tag");
364 os << e.
getNameRef() <<
" fe_id " << e.
getId().to_ulong() <<
" f_id_row "
371 boost::shared_ptr<FiniteElement> &fe) {
376 boost::shared_ptr<FiniteElement> &fe) {
381 boost::shared_ptr<FiniteElement> &fe) {
386 boost::shared_ptr<FiniteElement> &fe) {
391 boost::shared_ptr<FiniteElement> &fe) {
396 boost::shared_ptr<FiniteElement> &fe) {
401 boost::shared_ptr<FiniteElement> &fe) {
402 static_cast<BitFieldId *
>(fe->tag_BitFieldId_col_data)->reset();
406 boost::shared_ptr<FiniteElement> &fe) {
407 static_cast<BitFieldId *
>(fe->tag_BitFieldId_row_data)->reset();
411 boost::shared_ptr<FiniteElement> &fe) {
412 static_cast<BitFieldId *
>(fe->tag_BitFieldId_data)->reset();
417 const boost::shared_ptr<RefElement> &ref_finite_element,
418 const boost::shared_ptr<FiniteElement> &fe_ptr)
433 std::vector<EntityHandle> &adjacency) {
440 moab, *field_ptr, *this_fe_ptr, adjacency);
448 const boost::shared_ptr<EntFiniteElement> &sptr)
451 boost::weak_ptr<FENumeredDofEntity>
453 auto comp = [idx](
const auto &
a) {
return a->getPetscGlobalDofIdx() == idx; };
456 if (
auto e = it.lock()) {
457 if (
auto cache = e->entityCacheColDofs.lock()) {
458 auto dit = std::find_if(cache->loHi[0], cache->loHi[1], comp);
459 if (dit != cache->loHi[1])
460 return boost::reinterpret_pointer_cast<FENumeredDofEntity>(*dit);
466 return boost::weak_ptr<FENumeredDofEntity>();
469 boost::weak_ptr<FENumeredDofEntity>
472 auto comp = [idx](
const auto &
a) {
return a->getPetscGlobalDofIdx() == idx; };
475 if (
auto e = it.lock()) {
476 if (
auto cache = e->entityCacheColDofs.lock()) {
477 auto dit = std::find_if(cache->loHi[0], cache->loHi[1], comp);
478 if (dit != cache->loHi[1])
479 return boost::reinterpret_pointer_cast<FENumeredDofEntity>(*dit);
485 return boost::weak_ptr<FENumeredDofEntity>();
493 template <
typename ENTSVIEW,
typename DOFSVIEW,
typename EXTRACTOR,
497 EXTRACTOR &&extractor, INSERTER &&inserter) {
500 auto hint = dofs_view->end();
501 using ValType =
typename std::remove_reference<decltype(**hint)>
::type;
503 for (
auto &it : *ents_view) {
504 if (
auto e = it.lock()) {
506 if (
auto cache = extractor(e).lock())
507 for (
auto dit = cache->loHi[0]; dit != cache->loHi[1]; ++dit)
508 hint = inserter(dofs_view, hint,
509 boost::reinterpret_pointer_cast<ValType>(*dit));
518 boost::shared_ptr<FEDofEntity_multiIndex>
522 boost::weak_ptr<EntityCacheDofs>
523 operator()(boost::shared_ptr<FieldEntity> &e) {
524 return e->entityCacheDataDofs;
529 FEDofEntity_multiIndex::iterator
530 operator()(boost::shared_ptr<FEDofEntity_multiIndex> &dofs_view,
531 FEDofEntity_multiIndex::iterator &hint,
532 boost::shared_ptr<FEDofEntity> &&dof) {
533 return dofs_view->emplace_hint(hint, dof);
537 auto data_dofs = boost::make_shared<FEDofEntity_multiIndex>();
544 boost::shared_ptr<std::vector<boost::shared_ptr<FEDofEntity>>>
549 boost::weak_ptr<EntityCacheDofs>
550 operator()(boost::shared_ptr<FieldEntity> &e) {
551 return e->entityCacheDataDofs;
556 using Vec = std::vector<boost::shared_ptr<FEDofEntity>>;
557 using It = Vec::iterator;
558 It operator()(boost::shared_ptr<Vec> &dofs_view, It &hint,
559 boost::shared_ptr<FEDofEntity> &&dof) {
560 dofs_view->emplace_back(dof);
561 return dofs_view->end();
565 auto data_vector_dofs =
566 boost::make_shared<std::vector<boost::shared_ptr<FEDofEntity>>>();
571 return data_vector_dofs;
574 boost::shared_ptr<FENumeredDofEntity_multiIndex>
579 boost::weak_ptr<EntityCacheNumeredDofs>
580 operator()(boost::shared_ptr<FieldEntity> &e) {
581 return e->entityCacheRowDofs;
587 using It = Idx::iterator;
588 It operator()(boost::shared_ptr<Idx> &dofs_view, It &hint,
589 boost::shared_ptr<FENumeredDofEntity> &&dof) {
590 return dofs_view->emplace_hint(hint, dof);
594 auto row_dofs = boost::make_shared<FENumeredDofEntity_multiIndex>();
602 boost::shared_ptr<FENumeredDofEntity_multiIndex>
607 boost::weak_ptr<EntityCacheNumeredDofs>
608 operator()(boost::shared_ptr<FieldEntity> &e) {
609 return e->entityCacheColDofs;
615 using It = Idx::iterator;
616 It operator()(boost::shared_ptr<Idx> &dofs_view, It &hint,
617 boost::shared_ptr<FENumeredDofEntity> &&dof) {
618 return dofs_view->emplace_hint(hint, dof);
622 auto col_dofs = boost::make_shared<FENumeredDofEntity_multiIndex>();