371 {
373
375
376 moab::Core core_ref;
377 moab::Interface &moab_ref = core_ref;
378
379 auto create_reference_element = [&moab_ref]() {
381 constexpr double base_coords[] = {
382
383 0, 0,
384 0,
385
386 1, 0,
387 0,
388
389 0, 1,
390 0
391
392 };
394 for (int nn = 0; nn != 3; ++nn)
395 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
397 CHKERR moab_ref.create_element(MBTRI, nodes, 3, tri);
398
400 CHKERR moab_ref.get_adjacencies(&tri, 1, 1,
true, edges,
401 moab::Interface::UNION);
402
404 };
405
406 CHKERR create_reference_element();
407
410
411 auto refine_ref_triangles = [this, &m_field_ref, max_level]() {
413
414
416 m_field_ref.
getInterface<BitRefManager>()->setBitRefLevelByDim(
418
419 for (int ll = 0; ll != max_level; ++ll) {
421 ll);
424 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
428 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
430
431 auto m_ref = m_field_ref.
getInterface<MeshRefinement>();
432 CHKERR m_ref->addVerticesInTheMiddleOfEdges(edges,
435 }
437 };
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457 auto get_ref_gauss_pts_and_shape_functions = [this, max_level, &moab_ref,
458 &m_field_ref]() {
460 for (int ll = 0; ll != max_level + 1; ++ll) {
461
464 m_field_ref.
getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
466
469 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
470 CHKERR moab_ref.add_entities(meshset, tris);
471 CHKERR moab_ref.convert_entities(meshset,
true,
false,
false);
472 CHKERR moab_ref.delete_entities(&meshset, 1);
473 }
474
476 CHKERR moab_ref.get_connectivity(tris, elem_nodes,
false);
477
479 gauss_pts.resize(elem_nodes.size(), 3, false);
480 std::map<EntityHandle, int> little_map;
481 Range::iterator nit = elem_nodes.begin();
482 for (int gg = 0; nit != elem_nodes.end(); nit++, gg++) {
483 CHKERR moab_ref.get_coords(&*nit, 1, &gauss_pts(gg, 0));
484 little_map[*nit] = gg;
485 }
486 gauss_pts = trans(gauss_pts);
487
489 Range::iterator tit = tris.begin();
490 for (int tt = 0; tit != tris.end(); ++tit, ++tt) {
492 int num_nodes;
493 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes,
false);
494 if (tt == 0) {
495 ref_tris.resize(tris.size(), num_nodes);
496 }
497 for (int nn = 0; nn != num_nodes; ++nn) {
498 ref_tris(tt, nn) = little_map[conn[nn]];
499 }
500 }
501
503 shape_functions.resize(elem_nodes.size(), 3);
505 &gauss_pts(1, 0), elem_nodes.size());
506 }
508 };
509
513
514 CHKERR refine_ref_triangles();
515 CHKERR get_ref_gauss_pts_and_shape_functions();
516
518}
#define MOFEM_TAG_AND_LOG_C(channel, severity, tag, format,...)
Tag and log in channel.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Deprecated interface functions.
std::vector< ublas::matrix< int > > levelRef
std::vector< MatrixDouble > levelShapeFunctions
std::vector< MatrixDouble > levelGaussPtsOnRefMesh
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.