v0.13.2
Loading...
Searching...
No Matches
Simple.cpp
Go to the documentation of this file.
1/** \file Simple.cpp
2 * \brief Implementation of simple interface
3 * \ingroup mofem_simple_interface
4 */
5
6namespace MoFEM {
7
8MoFEMErrorCode Simple::query_interface(boost::typeindex::type_index type_index,
9 UnknownInterface **iface) const {
10 *iface = const_cast<Simple *>(this);
11 return 0;
12}
13
14template <int DIM>
16 static_assert(DIM == 2 || DIM == 3, "not implemented");
18}
19
20template <>
21MoFEMErrorCode Simple::setSkeletonAdjacency<2>(std::string fe_name) {
22 Interface &m_field = cOre;
24
26 boost::make_shared<ParentFiniteElementAdjacencyFunctionSkeleton<1>>(
29 fe_name, MBEDGE, *parentAdjSkeletonFunctionDim1);
30
32}
33
34template <>
35MoFEMErrorCode Simple::setSkeletonAdjacency<3>(std::string fe_name) {
36 Interface &m_field = cOre;
38
40 boost::make_shared<ParentFiniteElementAdjacencyFunctionSkeleton<2>>(
42
44 fe_name, MBTRI, *parentAdjSkeletonFunctionDim2);
46 fe_name, MBQUAD, *parentAdjSkeletonFunctionDim2);
47
49}
50
51template <>
54
55 switch (getDim()) {
56 case 1:
57 THROW_MESSAGE("Not implemented");
58 case 2:
59 return setSkeletonAdjacency<2>(fe_name);
60 case 3:
61 return setSkeletonAdjacency<3>(fe_name);
62 default:
63 THROW_MESSAGE("Not implemented");
64 }
66}
68 static_assert(DIM == 2 || DIM == 3, "not implemented");
70}
71
72template <> MoFEMErrorCode Simple::setParentAdjacency<3>() {
73 Interface &m_field = cOre;
75
77 boost::make_shared<ParentFiniteElementAdjacencyFunction<3>>(
80 boost::make_shared<ParentFiniteElementAdjacencyFunction<2>>(
82
87 if (addBoundaryFE || !boundaryFields.empty()) {
92 }
93 if (addSkeletonFE || !skeletonFields.empty()) {
98 }
99
101}
102
103template <> MoFEMErrorCode Simple::setParentAdjacency<2>() {
104 Interface &m_field = cOre;
106
108 boost::make_shared<ParentFiniteElementAdjacencyFunction<2>>(
111 boost::make_shared<ParentFiniteElementAdjacencyFunction<1>>(
113
118 if (addBoundaryFE || !boundaryFields.empty())
121 if (addSkeletonFE || !skeletonFields.empty())
124
126}
127
130 switch (getDim()) {
131 case 1:
132 THROW_MESSAGE("Not implemented");
133 case 2:
134 return setParentAdjacency<2>();
135 case 3:
136 return setParentAdjacency<3>();
137 default:
138 THROW_MESSAGE("Not implemented");
139 }
141}
142
145 if (dim == -1)
146 dim = getDim();
147
148 if (fe_name.empty())
149 fe_name = skeletonFE;
150
151 switch (dim) {
152 case 2:
153 return setSkeletonAdjacency<2>(fe_name);
154 case 3:
155 return setSkeletonAdjacency<3>(fe_name);
156 default:
157 SETERRQ(PETSC_COMM_WORLD, MOFEM_NOT_IMPLEMENTED, "Not implemented");
158 }
160}
161
163 : cOre(const_cast<Core &>(core)), bitLevel(BitRefLevel().set(0)),
164 bitLevelMask(BitRefLevel().set()), meshSet(0), boundaryMeshset(0),
165 skeletonMeshset(0), nameOfProblem("SimpleProblem"), domainFE("dFE"),
166 boundaryFE("bFE"), skeletonFE("sFE"), dIm(-1), addSkeletonFE(false),
167 addBoundaryFE(false), addParentAdjacencies(false),
168 bitAdjParent(BitRefLevel().set()), bitAdjParentMask(BitRefLevel().set()),
169 bitAdjEnt(BitRefLevel().set()), bitAdjEntMask(BitRefLevel().set()) {
170 PetscLogEventRegister("SimpleSetUp", 0, &MOFEM_EVENT_SimpleSetUP);
171 PetscLogEventRegister("SimpleLoadMesh", 0, &MOFEM_EVENT_SimpleLoadMesh);
172 PetscLogEventRegister("SimpleBuildFields", 0, &MOFEM_EVENT_SimpleBuildFields);
173 PetscLogEventRegister("SimpleBuildFiniteElements", 0,
175 PetscLogEventRegister("SimpleSetUp", 0, &MOFEM_EVENT_SimpleBuildProblem);
176 PetscLogEventRegister("SimpleKSPSolve", 0, &MOFEM_EVENT_SimpleKSPSolve);
177 strcpy(meshFileName, "mesh.h5m");
178}
179
181 PetscBool flg = PETSC_TRUE;
183 ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "", "Simple interface options",
184 "none");
185 CHKERRG(ierr);
186 ierr = PetscOptionsString("-file_name", "file name", "", "mesh.h5m",
187 meshFileName, 255, &flg);
188 CHKERRG(ierr);
189 ierr = PetscOptionsEnd();
190 CHKERRG(ierr);
192}
193
194MoFEMErrorCode Simple::loadFile(const std::string options,
195 const std::string mesh_file_name) {
196 Interface &m_field = cOre;
198 PetscLogEventBegin(MOFEM_EVENT_SimpleLoadMesh, 0, 0, 0, 0);
199
200 if (!mesh_file_name.empty())
201 strcpy(meshFileName, mesh_file_name.c_str());
202
203 // This is a case of distributed mesh and algebra. In that case each processor
204 // keep only part of the problem.
205 CHKERR m_field.get_moab().load_file(meshFileName, 0, options.c_str());
206 CHKERR m_field.rebuild_database();
207
208 // determine problem dimension
209 if (dIm == -1) {
210 int nb_ents_3d;
211 CHKERR m_field.get_moab().get_number_entities_by_dimension(
212 meshSet, 3, nb_ents_3d, true);
213 if (nb_ents_3d > 0) {
214 dIm = 3;
215 } else {
216 int nb_ents_2d;
217 CHKERR m_field.get_moab().get_number_entities_by_dimension(
218 meshSet, 2, nb_ents_2d, true);
219 if (nb_ents_2d > 0) {
220 dIm = 2;
221 } else {
222 dIm = 1;
223 }
224 }
225 }
226
227 if (!boundaryMeshset)
229 if (!skeletonMeshset)
231 if (addSkeletonFE)
233
234 if (bitLevel.any()) {
235 Range ents;
236 CHKERR m_field.get_moab().get_entities_by_dimension(meshSet, dIm, ents,
237 true);
238 CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevel(ents, bitLevel,
239 false);
240 } else {
241 MOFEM_LOG("WORLD", Sev::warning) << "BitRefLevel is none and not set";
242 CHKERR m_field.getInterface<BitRefManager>()->addToDatabaseBitRefLevelByDim(
243 dIm, BitRefLevel().set(), BitRefLevel().set());
244 }
245
246 PetscLogEventEnd(MOFEM_EVENT_SimpleLoadMesh, 0, 0, 0, 0);
248}
249
252 Interface &m_field = cOre;
253 if (m_field.get_comm_size() == 1)
255 else
256 CHKERR loadFile("PARALLEL=READ_PART;"
257 "PARALLEL_RESOLVE_SHARED_ENTS;"
258 "PARTITION=PARALLEL_PARTITION;",
261}
262
264Simple::addDomainField(const std::string &name, const FieldSpace space,
265 const FieldApproximationBase base,
266 const FieldCoefficientsNumber nb_of_cooficients,
267 const TagType tag_type, const enum MoFEMTypes bh,
268 int verb) {
269
270 Interface &m_field = cOre;
272 CHKERR m_field.add_field(name, space, base, nb_of_cooficients, tag_type, bh,
273 verb);
274 if (space == NOFIELD)
275 noFieldFields.push_back(name);
276 else
277 domainFields.push_back(name);
279}
280
282Simple::addBoundaryField(const std::string &name, const FieldSpace space,
283 const FieldApproximationBase base,
284 const FieldCoefficientsNumber nb_of_cooficients,
285 const TagType tag_type, const enum MoFEMTypes bh,
286 int verb) {
287 Interface &m_field = cOre;
289 CHKERR m_field.add_field(name, space, base, nb_of_cooficients, tag_type, bh,
290 verb);
291 boundaryFields.push_back(name);
292 if (space == NOFIELD)
293 SETERRQ(
294 PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
295 "NOFIELD space for boundary filed not implemented in Simple interface");
297}
298
300Simple::addSkeletonField(const std::string &name, const FieldSpace space,
301 const FieldApproximationBase base,
302 const FieldCoefficientsNumber nb_of_cooficients,
303 const TagType tag_type, const enum MoFEMTypes bh,
304 int verb) {
305
306 Interface &m_field = cOre;
308 CHKERR m_field.add_field(name, space, base, nb_of_cooficients, tag_type, bh,
309 verb);
310 skeletonFields.push_back(name);
311 if (space == NOFIELD)
312 SETERRQ(
313 PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
314 "NOFIELD space for boundary filed not implemented in Simple interface");
315
317}
318
320Simple::addDataField(const std::string &name, const FieldSpace space,
321 const FieldApproximationBase base,
322 const FieldCoefficientsNumber nb_of_cooficients,
323 const TagType tag_type, const enum MoFEMTypes bh,
324 int verb) {
325
326 Interface &m_field = cOre;
328 CHKERR m_field.add_field(name, space, base, nb_of_cooficients, tag_type, bh,
329 verb);
330 if (space == NOFIELD)
331 noFieldDataFields.push_back(name);
332 else
333 dataFields.push_back(name);
335}
336
338 Interface &m_field = cOre;
340
341 auto remove_field_from_list = [&](auto &vec) {
342 auto it = std::find(vec.begin(), vec.end(), name);
343 if (it != vec.end())
344 vec.erase(it);
345 };
346
347 remove_field_from_list(noFieldFields);
348 remove_field_from_list(domainFields);
349
351}
352
354 Interface &m_field = cOre;
356
357 auto remove_field_from_list = [&](auto &vec) {
358 auto it = std::find(vec.begin(), vec.end(), name);
359 if (it != vec.end())
360 vec.erase(it);
361 };
362
363 remove_field_from_list(boundaryFields);
364
366}
367
369 Interface &m_field = cOre;
371
372 auto remove_field_from_list = [&](auto &vec) {
373 auto it = std::find(vec.begin(), vec.end(), name);
374 if (it != vec.end())
375 vec.erase(it);
376 };
377
378 remove_field_from_list(skeletonFields);
379
381}
382
384 Interface &m_field = cOre;
386
387 auto clear_rows_and_cols = [&](auto &fe_name) {
389 auto fe_ptr = m_field.get_finite_elements();
390 auto &fe_by_name = const_cast<FiniteElement_multiIndex *>(fe_ptr)
391 ->get<FiniteElement_name_mi_tag>();
392 auto it_fe = fe_by_name.find(fe_name);
393 if (it_fe != fe_by_name.end()) {
394
395 if (!fe_by_name.modify(it_fe, FiniteElement_row_change_bit_reset()))
396 SETERRQ(m_field.get_comm(), MOFEM_OPERATION_UNSUCCESSFUL,
397 "modification unsuccessful");
398
399 if (!fe_by_name.modify(it_fe, FiniteElement_col_change_bit_reset()))
400 SETERRQ(m_field.get_comm(), MOFEM_OPERATION_UNSUCCESSFUL,
401 "modification unsuccessful");
402 }
404 };
405 CHKERR clear_rows_and_cols(domainFE);
406 CHKERR clear_rows_and_cols(boundaryFE);
407 CHKERR clear_rows_and_cols(skeletonFE);
408
409 // Define finite elements
411
412 auto add_fields = [&](auto &fe_name, auto &fields) {
414 for (auto &field : fields) {
415 CHKERR m_field.modify_finite_element_add_field_row(fe_name, field);
416 CHKERR m_field.modify_finite_element_add_field_col(fe_name, field);
417 CHKERR m_field.modify_finite_element_add_field_data(fe_name, field);
418 }
420 };
421
422 auto add_data_fields = [&](auto &fe_name, auto &fields) {
424 for (auto &field : fields)
425 CHKERR m_field.modify_finite_element_add_field_data(fe_name, field);
427 };
428
429 CHKERR add_fields(domainFE, domainFields);
430 CHKERR add_data_fields(domainFE, dataFields);
431 CHKERR add_fields(domainFE, noFieldFields);
432 CHKERR add_data_fields(domainFE, noFieldDataFields);
433
434 if (addBoundaryFE || !boundaryFields.empty()) {
436 CHKERR add_fields(boundaryFE, domainFields);
437 if (!boundaryFields.empty())
438 CHKERR add_fields(boundaryFE, boundaryFields);
439 CHKERR add_data_fields(boundaryFE, dataFields);
440 CHKERR add_data_fields(boundaryFE, noFieldDataFields);
441 CHKERR add_fields(boundaryFE, noFieldFields);
442 }
443 if (addSkeletonFE || !skeletonFields.empty()) {
445 CHKERR add_fields(skeletonFE, domainFields);
446 if (!skeletonFields.empty())
447 CHKERR add_fields(skeletonFE, skeletonFields);
448 CHKERR add_data_fields(skeletonFE, dataFields);
449 CHKERR add_data_fields(skeletonFE, noFieldDataFields);
450 CHKERR add_fields(skeletonFE, noFieldFields);
451 }
453}
454
455MoFEMErrorCode Simple::defineProblem(const PetscBool is_partitioned) {
456 Interface &m_field = cOre;
458 // Create dm instance
459 dM = createSmartDM(m_field.get_comm(), "DMMOFEM");
460 // set dm data structure which created mofem data structures
463 CHKERR DMSetFromOptions(dM);
465 if (addBoundaryFE || !boundaryFields.empty()) {
467 }
468 if (addSkeletonFE || !skeletonFields.empty()) {
470 }
472 CHKERR DMMoFEMSetIsPartitioned(dM, is_partitioned);
474}
475
477 const int order, const Range *ents) {
479 fieldsOrder.emplace_back(field_name, order,
480 ents == NULL ? Range() : Range(*ents));
482}
483
485 Interface &m_field = cOre;
487 PetscLogEventBegin(MOFEM_EVENT_SimpleBuildFields, 0, 0, 0, 0);
488
489 auto comm_interface_ptr = m_field.getInterface<CommInterface>();
490 auto bit_ref_ptr = m_field.getInterface<BitRefManager>();
491
492 // Add entities to the fields
493 auto add_ents_to_field = [&](auto meshset, auto dim, auto &fields) {
495 for (auto &field : fields) {
496 CHKERR m_field.add_ents_to_field_by_dim(meshset, dim, field);
497 CHKERR comm_interface_ptr->synchroniseFieldEntities(field, 0);
498 }
500 };
501
502 auto make_no_field_ents = [&](auto &fields) {
504 for (auto &field : fields) {
505 std::array<double, 6> coords = {0, 0, 0, 0, 0, 0};
506 CHKERR m_field.create_vertices_and_add_to_field(field, coords.data(), 1);
507 CHKERR comm_interface_ptr->makeFieldEntitiesMultishared(field, 0);
508 CHKERR bit_ref_ptr->setFieldEntitiesBitRefLevel(field, bitLevel);
509 }
511 };
512
513 CHKERR add_ents_to_field(meshSet, dIm, domainFields);
514 CHKERR add_ents_to_field(meshSet, dIm, dataFields);
515 CHKERR add_ents_to_field(boundaryMeshset, dIm - 1, boundaryFields);
516 CHKERR add_ents_to_field(skeletonMeshset, dIm - 1, skeletonFields);
517
518 std::set<std::string> nofield_fields;
519 for (auto &f : noFieldFields)
520 nofield_fields.insert(f);
521 for (auto &f : noFieldDataFields)
522 nofield_fields.insert(f);
523
524 CHKERR make_no_field_ents(nofield_fields);
525
526 // Set order
527
528 auto get_field_ptr = [&](auto &f) { return m_field.get_field_structure(f); };
529 for (auto &t : fieldsOrder) {
530 const auto f = std::get<0>(t);
531 const auto order = std::get<1>(t);
532
533 MOFEM_TAG_AND_LOG("WORLD", Sev::inform, "Simple")
534 << "Set order to field " << f << " order " << order;
535 if (!std::get<2>(t).empty()) {
536 MOFEM_LOG_CHANNEL("SYNC");
537 MOFEM_TAG_AND_LOG("SYNC", Sev::verbose, "Simple")
538 << "To ents: " << std::endl
539 << std::get<2>(t) << std::endl;
541 }
542
543 if (std::get<2>(t).empty()) {
544 auto f_ptr = get_field_ptr(f);
545
546 if (f_ptr->getSpace() == H1) {
547 if (f_ptr->getApproxBase() == AINSWORTH_BERNSTEIN_BEZIER_BASE) {
548 CHKERR m_field.set_field_order(meshSet, MBVERTEX, f, order);
549 } else {
550 CHKERR m_field.set_field_order(meshSet, MBVERTEX, f, 1);
551 }
552 }
553
554 for (auto d = 1; d <= dIm; ++d) {
555 for (EntityType t = CN::TypeDimensionMap[d].first;
556 t <= CN::TypeDimensionMap[d].second; ++t) {
557 CHKERR m_field.set_field_order(meshSet, t, f, order);
558 }
559 }
560 } else {
561 CHKERR m_field.set_field_order(std::get<2>(t), f, order);
562 }
563 }
564 MOFEM_LOG_CHANNEL("WORLD");
565 // Build fields
566 CHKERR m_field.build_fields();
567 PetscLogEventEnd(MOFEM_EVENT_SimpleBuildFields, 0, 0, 0, 0);
569}
570
572 Interface &m_field = cOre;
574 PetscLogEventBegin(MOFEM_EVENT_SimpleBuildFiniteElements, 0, 0, 0, 0);
575 // Add finite elements
577 true);
579 if (addBoundaryFE || !boundaryFields.empty()) {
581 boundaryFE, true);
583 }
584 if (addSkeletonFE || !skeletonFields.empty()) {
586 skeletonFE, true);
588 }
589 for (std::vector<std::string>::iterator fit = otherFEs.begin();
590 fit != otherFEs.end(); ++fit) {
591 CHKERR m_field.build_finite_elements(*fit);
592 }
593 PetscLogEventEnd(MOFEM_EVENT_SimpleBuildFiniteElements, 0, 0, 0, 0);
595}
596
598 Interface &m_field = cOre;
600 PetscLogEventBegin(MOFEM_EVENT_SimpleBuildProblem, 0, 0, 0, 0);
602 // Set problem by the DOFs on the fields rather that by adding DOFs on the
603 // elements
604 m_field.getInterface<ProblemsManager>()->buildProblemFromFields = PETSC_TRUE;
606 m_field.getInterface<ProblemsManager>()->buildProblemFromFields = PETSC_FALSE;
607 PetscLogEventEnd(MOFEM_EVENT_SimpleBuildProblem, 0, 0, 0, 0);
609}
610
611MoFEMErrorCode Simple::setUp(const PetscBool is_partitioned) {
612 Interface &m_field = cOre;
614
615 PetscLogEventBegin(MOFEM_EVENT_SimpleSetUP, 0, 0, 0, 0);
616
618
619 if (addSkeletonFE || !skeletonFields.empty())
621
624
625 CHKERR defineProblem(is_partitioned);
629
630 PetscLogEventEnd(MOFEM_EVENT_SimpleSetUP, 0, 0, 0, 0);
632}
633
635 Interface &m_field = cOre;
637 PetscLogEventBegin(MOFEM_EVENT_SimpleBuildProblem, 0, 0, 0, 0);
638
639 if (!only_dm) {
642 if (addSkeletonFE || !skeletonFields.empty())
647 }
648
650
651 const Problem *problem_ptr;
652 CHKERR DMMoFEMGetProblemPtr(dM, &problem_ptr);
653 const auto problem_name = problem_ptr->getName();
654 CHKERR m_field.modify_problem_ref_level_set_bit(problem_name, bitLevel);
657
658 // Set problem by the DOFs on the fields rather that by adding DOFs on the
659 // elements
660 m_field.getInterface<ProblemsManager>()->buildProblemFromFields = PETSC_TRUE;
662 m_field.getInterface<ProblemsManager>()->buildProblemFromFields = PETSC_FALSE;
663
664 PetscLogEventEnd(MOFEM_EVENT_SimpleBuildProblem, 0, 0, 0, 0);
666}
667
670 CHKERR PetscObjectReference(getPetscObject(dM.get()));
671 *dm = dM.get();
673}
674
675/**
676 * @brief Delete dm
677 *
678 * @return MoFEMErrorCode
679 */
682 dM.reset();
684}
685
686/**
687 * @brief Delete finite elements
688 *
689 * @return MoFEMErrorCode
690 */
692 Interface &m_field = cOre;
694 for (auto fe : {domainFE, boundaryFE, skeletonFE}) {
695 if (m_field.check_finite_element(fe)) {
696 CHKERR m_field.delete_finite_element(fe);
697 }
698 }
700}
701
703Simple::addFieldToEmptyFieldBlocks(const std::string row_field,
704 const std::string col_field) const {
705 Interface &m_field = cOre;
708 getProblemName(), row_field, col_field);
710}
711
713 Interface &m_field = cOre;
715 ParallelComm *pcomm =
716 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
717
718 auto get_skin = [&](auto meshset) {
719 // filter not owned entities, those are not on boundary
720
721 Range domain_ents;
722 CHKERR m_field.get_moab().get_entities_by_dimension(meshset, dIm,
723 domain_ents, true);
724 CHKERR pcomm->filter_pstatus(domain_ents,
725 PSTATUS_SHARED | PSTATUS_MULTISHARED,
726 PSTATUS_NOT, -1, nullptr);
727
728 Skinner skin(&m_field.get_moab());
729 Range domain_skin;
730 CHKERR skin.find_skin(0, domain_ents, false, domain_skin);
731 CHKERR pcomm->filter_pstatus(domain_skin,
732 PSTATUS_SHARED | PSTATUS_MULTISHARED,
733 PSTATUS_NOT, -1, nullptr);
734 return domain_skin;
735 };
736
737 auto create_boundary_meshset = [&](auto &&domain_skin) {
739 // create boundary meshset
740 if (boundaryMeshset != 0) {
742 }
743 CHKERR m_field.get_moab().create_meshset(MESHSET_SET, boundaryMeshset);
744 CHKERR m_field.get_moab().add_entities(boundaryMeshset, domain_skin);
745 for (int dd = 0; dd != dIm - 1; dd++) {
746 Range adj;
747 CHKERR m_field.get_moab().get_adjacencies(domain_skin, dd, false, adj,
748 moab::Interface::UNION);
749 CHKERR m_field.get_moab().add_entities(boundaryMeshset, adj);
750 }
752 };
753
754 CHKERR create_boundary_meshset(get_skin(meshSet));
755
757}
758
760 Interface &m_field = cOre;
762
763 ParallelComm *pcomm =
764 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
765
766 auto create_skeleton_meshset = [&](auto meshset) {
768 // create boundary meshset
769 if (skeletonMeshset != 0) {
771 }
772 Range boundary_ents, skeleton_ents;
773 CHKERR m_field.get_moab().get_entities_by_dimension(boundaryMeshset,
774 dIm - 1, boundary_ents);
775 Range domain_ents;
776 CHKERR m_field.get_moab().get_entities_by_dimension(meshset, dIm,
777 domain_ents, true);
778 CHKERR m_field.get_moab().get_adjacencies(
779 domain_ents, dIm - 1, false, skeleton_ents, moab::Interface::UNION);
780 skeleton_ents = subtract(skeleton_ents, boundary_ents);
781 CHKERR pcomm->filter_pstatus(skeleton_ents, PSTATUS_NOT_OWNED, PSTATUS_NOT,
782 -1, nullptr);
783 CHKERR m_field.get_moab().create_meshset(MESHSET_SET, skeletonMeshset);
784 CHKERR m_field.get_moab().add_entities(skeletonMeshset, skeleton_ents);
786 };
787
788 CHKERR create_skeleton_meshset(meshSet);
789
791}
792
794 Interface &m_field = cOre;
796 MOFEM_LOG("WORLD", Sev::verbose) << "Exchange ghost cells";
797
798 ParallelComm *pcomm =
799 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
800 if (pcomm == NULL)
801 pcomm = new ParallelComm(&m_field.get_moab(), m_field.get_comm());
802
803 CHKERR pcomm->exchange_ghost_cells(getDim(), getDim() - 1, 1,
804 3 /**get all adjacent ghosted entities */,
805 true, false, meshSet ? &meshSet : nullptr);
806
807 Range shared;
808 CHKERR m_field.get_moab().get_entities_by_dimension(0, dIm, shared);
809 for (auto d = dIm - 1; d >= 0; --d) {
810 CHKERR m_field.get_moab().get_adjacencies(shared, d, false, shared,
811 moab::Interface::UNION);
812 }
813 CHKERR pcomm->filter_pstatus(shared, PSTATUS_SHARED | PSTATUS_MULTISHARED,
814 PSTATUS_OR, -1, &shared);
815 Tag part_tag = pcomm->part_tag();
816 CHKERR pcomm->exchange_tags(part_tag, shared);
817 CHKERR m_field.getInterface<CommInterface>()->resolveParentEntities(shared,
818 VERBOSE);
819
821}
822
823} // namespace MoFEM
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
Definition: LogManager.hpp:338
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:345
@ VERBOSE
Definition: definitions.h:209
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
Definition: definitions.h:97
@ MF_ZERO
Definition: definitions.h:98
FieldApproximationBase
approximation base
Definition: definitions.h:58
@ AINSWORTH_BERNSTEIN_BEZIER_BASE
Definition: definitions.h:64
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
FieldSpace
approximation spaces
Definition: definitions.h:82
@ NOFIELD
scalar or vector of scalars describe (no true field)
Definition: definitions.h:84
@ H1
continuous field
Definition: definitions.h:85
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition: definitions.h:34
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:561
const int dim
PetscErrorCode DMMoFEMSetIsPartitioned(DM dm, PetscBool is_partitioned)
Definition: DMMoFEM.cpp:1091
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition: DMMoFEM.cpp:465
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
Definition: DMMoFEM.cpp:118
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
Definition: DMMoFEM.cpp:394
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition: DMMoFEM.cpp:1249
multi_index_container< boost::shared_ptr< FiniteElement >, indexed_by< hashed_unique< tag< FiniteElement_Meshset_mi_tag >, member< FiniteElement, EntityHandle, &FiniteElement::meshset > >, hashed_unique< tag< BitFEId_mi_tag >, const_mem_fun< FiniteElement, BitFEId, &FiniteElement::getId >, HashBit< BitFEId >, EqBit< BitFEId > >, ordered_unique< tag< FiniteElement_name_mi_tag >, const_mem_fun< FiniteElement, boost::string_ref, &FiniteElement::getNameRef > > > > FiniteElement_multiIndex
MultiIndex for entities for FiniteElement.
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
virtual MoFEMErrorCode add_ents_to_finite_element_by_dim(const EntityHandle entities, const int dim, const std::string &name, const bool recursive=true)=0
add entities to finite element
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
virtual MoFEMErrorCode modify_finite_element_adjacency_table(const std::string &fe_name, const EntityType type, ElementAdjacencyFunct function)=0
modify finite element table, only for advanced user
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
virtual const Field * get_field_structure(const std::string &name, enum MoFEMTypes bh=MF_EXIST) const =0
get field structure
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode add_ents_to_field_by_dim(const Range &ents, const int dim, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:301
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:277
virtual MoFEMErrorCode modify_problem_mask_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set dof mask ref level for problem
virtual MoFEMErrorCode modify_problem_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set ref level for problem
char mesh_file_name[255]
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
int FieldCoefficientsNumber
Number of field coefficients.
Definition: Types.hpp:27
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
auto createSmartDM(MPI_Comm comm, const std::string dm_type_name)
Creates smart DM object.
PetscObject getPetscObject(T obj)
constexpr double t
plate stiffness
Definition: plate.cpp:59
constexpr auto field_name
Managing BitRefLevels.
Managing BitRefLevels.
virtual int get_comm_size() const =0
virtual moab::Interface & get_moab()=0
virtual bool check_finite_element(const std::string &name) const =0
Check if finite element is in database.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
virtual MPI_Comm & get_comm() const =0
virtual MoFEMErrorCode delete_finite_element(const std::string name, int verb=DEFAULT_VERBOSITY)=0
delete finite element from mofem database
virtual MoFEMErrorCode add_field(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
virtual MoFEMErrorCode rebuild_database(int verb=DEFAULT_VERBOSITY)=0
Clear database and initialize it once again.
virtual MoFEMErrorCode create_vertices_and_add_to_field(const std::string name, const double coords[], int size, int verb=DEFAULT_VERBOSITY)=0
Create a vertices and add to field object.
Core (interface) class.
Definition: Core.hpp:82
Deprecated interface functions.
keeps basic data about problem
Problem manager is used to build and partition problems.
Simple interface for fast problem set-up.
Definition: Simple.hpp:27
boost::shared_ptr< ParentFiniteElementAdjacencyFunction< 2 > > parentAdjFunctionDim2
Definition: Simple.hpp:531
EntityHandle boundaryMeshset
meshset with boundary
Definition: Simple.hpp:484
MoFEMErrorCode buildProblem()
Build problem.
Definition: Simple.cpp:597
std::vector< std::string > dataFields
Data fields.
Definition: Simple.hpp:499
MoFEMErrorCode setParentAdjacency()
Definition: Simple.cpp:67
std::vector< std::string > domainFields
domain fields
Definition: Simple.hpp:496
MoFEMErrorCode removeDomainField(const std::string &name)
Remove field form domain.
Definition: Simple.cpp:337
MoFEMErrorCode defineFiniteElements()
Define finite elements.
Definition: Simple.cpp:383
MoFEM::Core & cOre
Definition: Simple.hpp:471
BitRefLevel bitAdjEnt
bit ref level for parent
Definition: Simple.hpp:493
char meshFileName[255]
mesh file name
Definition: Simple.hpp:513
EntityHandle meshSet
domain meshset
Definition: Simple.hpp:483
int getDim() const
Get the problem dimension.
Definition: Simple.hpp:271
std::vector< std::string > otherFEs
Other finite elements.
Definition: Simple.hpp:511
MoFEMErrorCode buildFiniteElements()
Build finite elements.
Definition: Simple.cpp:571
boost::shared_ptr< ParentFiniteElementAdjacencyFunctionSkeleton< 2 > > parentAdjSkeletonFunctionDim2
Definition: Simple.hpp:536
MoFEMErrorCode addDataField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
Definition: Simple.cpp:320
MoFEMErrorCode exchangeGhostCells()
Definition: Simple.cpp:793
PetscLogEvent MOFEM_EVENT_SimpleBuildFields
Definition: Simple.hpp:478
PetscLogEvent MOFEM_EVENT_SimpleLoadMesh
Definition: Simple.hpp:477
MoFEMErrorCode addDomainField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
Definition: Simple.cpp:264
MoFEMErrorCode reSetUp(bool only_dm=false)
Rebuild internal MoFEM data structures.
Definition: Simple.cpp:634
std::vector< std::string > noFieldFields
NOFIELD field name.
Definition: Simple.hpp:500
bool addSkeletonFE
Add skeleton FE.
Definition: Simple.hpp:487
BitRefLevel bitAdjParent
bit ref level for parent
Definition: Simple.hpp:491
bool addBoundaryFE
Add boundary FE.
Definition: Simple.hpp:488
MoFEMErrorCode addFieldToEmptyFieldBlocks(const std::string row_field, const std::string col_field) const
add empty block to problem
Definition: Simple.cpp:703
std::string skeletonFE
skeleton finite element
Definition: Simple.hpp:509
std::vector< std::string > noFieldDataFields
NOFIELD field name.
Definition: Simple.hpp:501
std::string boundaryFE
boundary finite element
Definition: Simple.hpp:508
std::string nameOfProblem
problem name
Definition: Simple.hpp:506
boost::shared_ptr< ParentFiniteElementAdjacencyFunction< 3 > > parentAdjFunctionDim3
Definition: Simple.hpp:529
MoFEMErrorCode getOptions()
get options
Definition: Simple.cpp:180
std::string domainFE
domain finite element
Definition: Simple.hpp:507
std::vector< std::string > boundaryFields
boundary fields
Definition: Simple.hpp:497
boost::shared_ptr< ParentFiniteElementAdjacencyFunctionSkeleton< 1 > > parentAdjSkeletonFunctionDim1
Definition: Simple.hpp:538
BitRefLevel bitAdjEntMask
bit ref level for parent parent
Definition: Simple.hpp:494
SmartPetscObj< DM > dM
Discrete manager (interface to PETSc/MoFEM functions)
Definition: Simple.hpp:517
std::list< std::tuple< std::string, int, Range > > fieldsOrder
fields order
Definition: Simple.hpp:504
MoFEMErrorCode buildFields()
Build fields.
Definition: Simple.cpp:484
SmartPetscObj< DM > getDM()
Return smart DM object.
Definition: Simple.hpp:261
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name)
Load mesh file.
Definition: Simple.cpp:194
BitRefLevel bitLevel
BitRefLevel of the problem.
Definition: Simple.hpp:473
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
Definition: Simple.cpp:476
MoFEMErrorCode addBoundaryField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on boundary.
Definition: Simple.cpp:282
MoFEMErrorCode defineProblem(const PetscBool is_partitioned=PETSC_TRUE)
define problem
Definition: Simple.cpp:455
std::vector< std::string > skeletonFields
fields on the skeleton
Definition: Simple.hpp:498
MoFEMErrorCode addSkeletonField(const std::string &name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on skeleton.
Definition: Simple.cpp:300
MoFEMErrorCode removeSkeletonField(const std::string &name)
Remove field form skeleton.
Definition: Simple.cpp:368
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: Simple.cpp:8
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
Definition: Simple.cpp:611
MoFEMErrorCode removeBoundaryField(const std::string &name)
Remove field form boundary.
Definition: Simple.cpp:353
const std::string getProblemName() const
Get the Problem Name.
Definition: Simple.hpp:341
int dIm
dimension of problem
Definition: Simple.hpp:514
MoFEMErrorCode setSkeletonAdjacency(int dim=-1, std::string fe_name="")
Set the skeleton adjacency object.
Definition: Simple.cpp:143
MoFEMErrorCode deleteDM()
Delete dm.
Definition: Simple.cpp:680
PetscLogEvent MOFEM_EVENT_SimpleSetUP
Definition: Simple.hpp:476
PetscLogEvent MOFEM_EVENT_SimpleKSPSolve
Definition: Simple.hpp:481
MoFEMErrorCode createBoundaryMeshset()
Definition: Simple.cpp:712
PetscLogEvent MOFEM_EVENT_SimpleBuildFiniteElements
Definition: Simple.hpp:479
BitRefLevel bitLevelMask
BitRefLevel of the problem.
Definition: Simple.hpp:474
BitRefLevel bitAdjParentMask
bit ref level for parent parent
Definition: Simple.hpp:492
PetscLogEvent MOFEM_EVENT_SimpleBuildProblem
Definition: Simple.hpp:480
boost::shared_ptr< ParentFiniteElementAdjacencyFunction< 1 > > parentAdjFunctionDim1
Definition: Simple.hpp:533
MoFEMErrorCode deleteFiniteElements()
Delete finite elements.
Definition: Simple.cpp:691
Simple(const MoFEM::Core &core)
Definition: Simple.cpp:162
EntityHandle skeletonMeshset
skeleton meshset with boundary
Definition: Simple.hpp:485
MoFEMErrorCode createSkeletonMeshset()
Definition: Simple.cpp:759
bool addParentAdjacencies
If set to true parent adjacencies are build.
Definition: Simple.hpp:489
base class for all interface classes
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.