21 #define DeleteCoreFunctionBegin \
23 MOFEM_LOG_CHANNEL("WORLD"); \
24 MOFEM_LOG_FUNCTION(); \
25 MOFEM_LOG_TAG("WORLD", "DeleteCore");
34 for (DofEntity_multiIndex::iterator dit = dofsField.begin();
35 dit != dofsField.end();) {
36 if (!dit->get()->getActive()) {
37 dit = dofsField.erase(dit);
53 CHKERR clear_dofs_fields(ents, verb);
62 for (Range::const_pair_iterator p_eit = ents.pair_begin();
63 p_eit != ents.pair_end(); p_eit++) {
67 DofEntityByEnt::iterator dit, hi_dit;
68 dit = dofsField.get<
Ent_mi_tag>().lower_bound(first);
71 hi_dit = dofsField.get<
Ent_mi_tag>().upper_bound(second);
73 dofsField.get<
Ent_mi_tag>().erase(dit, hi_dit);
84 const auto bit_number = get_field_bit_number(name);
86 for (Range::const_pair_iterator p_eit = ents.pair_begin();
87 p_eit != ents.pair_end(); p_eit++) {
88 const auto first = p_eit->first;
89 const auto second = p_eit->second;
92 auto dit = dofsField.get<
Unique_mi_tag>().lower_bound(lo_uid);
93 auto hi_dit = dofsField.get<
Unique_mi_tag>().upper_bound(hi_uid);
107 CHKERR clear_dofs_fields(ents, verb);
108 CHKERR clear_adjacencies_entities(ents, verb);
109 CHKERR clear_ents_fields(ents, verb);
117 CHKERR clear_dofs_fields(ents, verb);
118 CHKERR clear_adjacencies_entities(ents, verb);
119 for (Range::const_pair_iterator p_eit = ents.pair_begin();
120 p_eit != ents.pair_end(); p_eit++) {
123 FieldEntity_multiIndex::index<Ent_mi_tag>::type::iterator dit, hi_dit;
124 dit = entsFields.get<
Ent_mi_tag>().lower_bound(first);
125 hi_dit = entsFields.get<
Ent_mi_tag>().upper_bound(second);
126 entsFields.get<
Ent_mi_tag>().erase(dit, hi_dit);
136 const auto bit_number = get_field_bit_number(name);
137 CHKERR clear_dofs_fields(name, ents, verb);
138 CHKERR clear_adjacencies_entities(name, ents, verb);
139 for (Range::const_pair_iterator p_eit = ents.pair_begin();
140 p_eit != ents.pair_end(); p_eit++) {
141 const auto first = p_eit->first;
142 const auto second = p_eit->second;
154 const EntityType
type,
int verb) {
159 CHKERR get_moab().get_entities_by_type(meshset,
type, ents);
160 CHKERR remove_ents_from_field(name, ents, verb);
165 const Range ents,
int verb) {
170 meshset = get_field_meshset(name);
171 CHKERR clear_ents_fields(name, ents, verb);
172 CHKERR get_moab().remove_entities(meshset, ents);
180 CHKERR clear_ents_fields(ents, verb);
181 for (Field_multiIndex::iterator fit = fIelds.begin(); fit != fIelds.end();
184 CHKERR get_moab().remove_entities(meshset, ents);
197 CHKERR remove_ents_from_field(ents, verb);
209 CHKERR clear_adjacencies_entities(ents, verb);
217 for (Range::const_pair_iterator p_eit = ents.pair_begin();
218 p_eit != ents.pair_end(); ++p_eit) {
221 FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index<
224 ait = entFEAdjacencies.get<
Ent_mi_tag>().lower_bound(first);
225 hi_ait = entFEAdjacencies.get<
Ent_mi_tag>().upper_bound(second);
226 entFEAdjacencies.get<
Ent_mi_tag>().erase(ait, hi_ait);
232 const Range ents,
int verb) {
237 const Field *field_ptr = get_field_structure(name);
240 for (Range::const_pair_iterator p_eit = ents.pair_begin();
241 p_eit != ents.pair_end(); p_eit++) {
254 auto ait = entFEAdjacencies.get<
Unique_mi_tag>().lower_bound(first_uid);
255 auto hi_ait = entFEAdjacencies.get<
Unique_mi_tag>().upper_bound(second_uid);
269 CHKERR clear_finite_elements(ents, verb);
277 CHKERR clear_adjacencies_finite_elements(ents, verb);
278 for (Range::const_pair_iterator p_eit = ents.pair_begin();
279 p_eit != ents.pair_end(); p_eit++) {
282 EntFiniteElement_multiIndex::index<Ent_mi_tag>::type::iterator fit, hi_fit;
283 fit = entsFiniteElements.get<
Ent_mi_tag>().lower_bound(first);
284 hi_fit = entsFiniteElements.get<
Ent_mi_tag>().upper_bound(second);
285 entsFiniteElements.get<
Ent_mi_tag>().erase(fit, hi_fit);
291 const Range &ents,
int verb) {
295 CHKERR clear_adjacencies_finite_elements(fe_name, ents, verb);
298 for (Range::const_pair_iterator p_eit = ents.pair_begin();
299 p_eit != ents.pair_end(); p_eit++) {
300 auto fit = entsFiniteElements.get<
Unique_mi_tag>().lower_bound(
302 (*fe_miit)->getFEUId()));
303 auto hi_fit = entsFiniteElements.get<
Unique_mi_tag>().upper_bound(
305 (*fe_miit)->getFEUId()));
306 fit = entsFiniteElements.get<
Unique_mi_tag>().erase(fit, hi_fit);
318 CHKERR clear_adjacencies_finite_elements(ents, verb);
327 for (Range::const_pair_iterator p_eit = ents.pair_begin();
328 p_eit != ents.pair_end(); p_eit++) {
331 FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index<
334 ait = entFEAdjacencies.get<
FEEnt_mi_tag>().lower_bound(first);
335 hi_ait = entFEAdjacencies.get<
FEEnt_mi_tag>().upper_bound(second);
336 entFEAdjacencies.get<
FEEnt_mi_tag>().erase(ait, hi_ait);
348 FiniteElement_multiIndex::index<FiniteElement_name_mi_tag>::type::iterator
352 const auto fe_uid = (*it_fe)->getFEUId();
354 for (Range::const_pair_iterator p_eit = ents.pair_begin();
355 p_eit != ents.pair_end(); p_eit++) {
368 FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index<
381 const EntityType
type,
387 CHKERR get_moab().get_entities_by_type(meshset,
type, ents,
false);
388 CHKERR remove_ents_from_finite_element(name, ents, verb);
398 CHKERR clear_finite_elements(name, ents, verb);
399 const EntityHandle idm = get_finite_element_meshset(name);
400 CHKERR get_moab().remove_entities(idm, ents);
409 CHKERR clear_finite_elements(ents, verb);
410 for (FiniteElement_multiIndex::iterator fe_it = finiteElements.begin();
411 fe_it != finiteElements.end(); fe_it++) {
413 CHKERR get_moab().remove_entities(meshset, ents);
425 CHKERR remove_ents_from_finite_element(ents, verb);
433 CHKERR remove_ents_from_finite_element(ents, verb);
434 CHKERR remove_ents_from_field(ents, verb);
436 for (Range::const_pair_iterator p_eit = ents.pair_begin();
437 p_eit != ents.pair_end(); ++p_eit) {
439 RefElement_multiIndex::index<Ent_mi_tag>::type::iterator frit, hi_frit;
440 frit = refinedFiniteElements.get<
Ent_mi_tag>().lower_bound(p_eit->first);
442 refinedFiniteElements.get<
Ent_mi_tag>().upper_bound(p_eit->second);
443 refinedFiniteElements.get<
Ent_mi_tag>().erase(frit, hi_frit);
445 RefEntity_multiIndex::index<Ent_mi_tag>::type::iterator rit, hi_rit;
446 rit = refinedEntities.get<
Ent_mi_tag>().lower_bound(p_eit->first);
447 hi_rit = refinedEntities.get<
Ent_mi_tag>().upper_bound(p_eit->second);
448 refinedEntities.get<
Ent_mi_tag>().erase(rit, hi_rit);
461 CHKERR remove_ents(ents, verb);
473 CHKERR remove_parents_by_ents(ents, verb);
480 std::vector<EntityHandle> leftovers_ents;
481 leftovers_ents.reserve(ents.size());
483 for (
auto pit = ents.pair_begin(); pit != ents.pair_end(); ++pit) {
487 auto lo = refinedEntities.lower_bound(
f);
488 for (;
f <= s; ++
f) {
490 auto check = [
this](
auto lo,
auto f) {
491 if (lo == refinedEntities.end())
493 if ((*lo)->getEnt() ==
f)
502 "Operation of removing parent unsuccessful");
505 leftovers_ents.emplace_back(
f);
509 if (!leftovers_ents.empty()) {
510 std::vector<EntityHandle> zero_parents(leftovers_ents.size());
511 CHKERR get_moab().tag_set_data(th_RefParentHandle, &leftovers_ents[0],
512 leftovers_ents.size(),
513 &*zero_parents.begin());
520 for (Range::iterator eit = ents.begin(); eit != ents.end(); ++eit) {
521 RefEntity_multiIndex::index<Ent_Ent_mi_tag>::type::iterator it;
528 "Operation of removing parent unsuccessful");
537 const bool remove_parent,
int verb,
545 Range ents_meshsets = ents.subset_by_type(MBENTITYSET);
546 ents = subtract(ents, ents_meshsets);
549 MOFEM_LOG(
"WORLD", Sev::verbose) <<
"Nb. of deleted entities 0";
554 MOFEM_LOG(
"WORLD", Sev::noisy) <<
"Deleted ents:\n" << ents;
556 CHKERR remove_ents(ents, verb);
560 CHKERR remove_parents_by_parents(ents);
564 CHKERR get_moab().get_entities_by_type(0, MBENTITYSET, meshsets,
true);
565 for (
auto m : meshsets) {
566 CHKERR get_moab().remove_entities(
m, ents);
570 rval = get_moab().delete_entities(ents);
571 if (
rval != MB_SUCCESS) {
574 MOFEM_LOG(
"SELF", Sev::noisy) <<
"Problem deleting:\n" << ents;
576 MOFEM_LOG(
"SELF", Sev::warning) <<
"Problem deleting:\n" << ents;
587 MOFEM_LOG_C(
"SELF", Sev::noisy,
"Nb. of deleted entities %d", ents.size());
595 auto mit = fe.find(name);
596 if (mit == fe.end()) {
598 "Finite element <%s> not found", name.c_str());
602 CHKERR get_moab().get_entities_by_handle(meshset, ents,
false);
603 CHKERR remove_ents_from_finite_element(name, ents, verb);
605 CHKERR get_moab().delete_entities(&meshset, 1);
612 auto mit =
f.find(name);
613 if (mit ==
f.end()) {
615 "Finite element <%s> not found", name.c_str());
619 CHKERR get_moab().get_entities_by_handle(meshset, ents,
false);
620 CHKERR remove_ents_from_field(name, ents, verb);
621 CHKERR get_moab().tag_delete((*mit)->th_FieldDataVerts);
622 CHKERR get_moab().tag_delete((*mit)->th_FieldData);
623 CHKERR get_moab().tag_delete((*mit)->th_AppOrder);
625 CHKERR get_moab().delete_entities(&meshset, 1);