v0.16.3
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | Static Private Attributes | List of all members
EshelbianPlasticity::SetIntegrationAtFrontVolume Struct Reference
Collaboration diagram for EshelbianPlasticity::SetIntegrationAtFrontVolume:
[legend]

Classes

struct  Fe
 

Public Types

using FunRule = boost::function< int(int)>
 

Public Member Functions

 SetIntegrationAtFrontVolume (boost::shared_ptr< Range > front_nodes, boost::shared_ptr< Range > front_edges, boost::shared_ptr< CGGUserPolynomialBase::CachePhi > cache_phi=nullptr)
 
 SetIntegrationAtFrontVolume (boost::shared_ptr< Range > front_nodes, boost::shared_ptr< Range > front_edges, FunRule fun_rule, boost::shared_ptr< CGGUserPolynomialBase::CachePhi > cache_phi=nullptr)
 
MoFEMErrorCode operator() (ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
 

Public Attributes

FunRule funRule
 

Private Attributes

boost::shared_ptr< Range > frontNodes
 
boost::shared_ptr< Range > frontEdges
 
boost::shared_ptr< CGGUserPolynomialBase::CachePhi > cachePhi
 

Static Private Attributes

static std::map< long int, MatrixDouble > mapRefCoords
 

Detailed Description

Definition at line 370 of file EshelbianPlasticity.cpp.

Member Typedef Documentation

◆ FunRule

Constructor & Destructor Documentation

◆ SetIntegrationAtFrontVolume() [1/2]

EshelbianPlasticity::SetIntegrationAtFrontVolume::SetIntegrationAtFrontVolume ( boost::shared_ptr< Range >  front_nodes,
boost::shared_ptr< Range >  front_edges,
boost::shared_ptr< CGGUserPolynomialBase::CachePhi >  cache_phi = nullptr 
)
inline

Definition at line 375 of file EshelbianPlasticity.cpp.

◆ SetIntegrationAtFrontVolume() [2/2]

EshelbianPlasticity::SetIntegrationAtFrontVolume::SetIntegrationAtFrontVolume ( boost::shared_ptr< Range >  front_nodes,
boost::shared_ptr< Range >  front_edges,
FunRule  fun_rule,
boost::shared_ptr< CGGUserPolynomialBase::CachePhi >  cache_phi = nullptr 
)
inline

Definition at line 382 of file EshelbianPlasticity.cpp.

386 : funRule(fun_rule), frontNodes(front_nodes), frontEdges(front_edges),
387 cachePhi(cache_phi) {};

Member Function Documentation

◆ operator()()

MoFEMErrorCode EshelbianPlasticity::SetIntegrationAtFrontVolume::operator() ( ForcesAndSourcesCore *  fe_raw_ptr,
int  order_row,
int  order_col,
int  order_data 
)
inline
Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 389 of file EshelbianPlasticity.cpp.

390 {
392
393 constexpr bool debug = false;
394
395 constexpr int numNodes = 4;
396 constexpr int numEdges = 6;
397 constexpr int refinementLevels = 6;
398
399 auto &m_field = fe_raw_ptr->mField;
400 auto fe_ptr = static_cast<Fe *>(fe_raw_ptr);
401 auto fe_handle = fe_ptr->getFEEntityHandle();
402
403 auto set_base_quadrature = [&]() {
405 if (!funRule) {
407 }
408 const int rule = funRule(order_data);
409 const auto xiao_rule = IntRules::XiaoGimbutas::getTetrahedronRule(rule);
410 if (!xiao_rule) {
411 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
412 "Xiao--Gimbutas tetrahedron rule is available for polynomial "
413 "orders 0 to %d; requested %d",
414 IntRules::XiaoGimbutas::tetrahedronRuleCount, rule);
415 }
416 if (xiao_rule->numBarycentricCoordinates != 4) {
417 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
418 "wrong number of tetrahedron barycentric coordinates");
419 }
420
421 const size_t nb_gauss_pts = xiao_rule->numPoints;
422 auto &gauss_pts = fe_ptr->gaussPts;
423 gauss_pts.resize(4, nb_gauss_pts, false);
424 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[1], 4, &gauss_pts(0, 0), 1);
425 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[2], 4, &gauss_pts(1, 0), 1);
426 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[3], 4, &gauss_pts(2, 0), 1);
427 cblas_dcopy(nb_gauss_pts, xiao_rule->weights, 1, &gauss_pts(3, 0), 1);
428 auto &data = fe_ptr->dataOnElement[H1];
429 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4,
430 false);
431 double *shape_ptr =
432 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
433 cblas_dcopy(4 * nb_gauss_pts, xiao_rule->points, 1, shape_ptr, 1);
435 };
436
437 CHKERR set_base_quadrature();
438
440
441 auto get_singular_nodes = [&]() {
442 int num_nodes;
443 const EntityHandle *conn;
444 CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
445 true);
446 std::bitset<numNodes> singular_nodes;
447 for (auto nn = 0; nn != numNodes; ++nn) {
448 if (frontNodes->find(conn[nn]) != frontNodes->end()) {
449 singular_nodes.set(nn);
450 } else {
451 singular_nodes.reset(nn);
452 }
453 }
454 return singular_nodes;
455 };
456
457 auto get_singular_edges = [&]() {
458 std::bitset<numEdges> singular_edges;
459 for (int ee = 0; ee != numEdges; ee++) {
460 EntityHandle edge;
461 CHKERR m_field.get_moab().side_element(fe_handle, 1, ee, edge);
462 if (frontEdges->find(edge) != frontEdges->end()) {
463 singular_edges.set(ee);
464 } else {
465 singular_edges.reset(ee);
466 }
467 }
468 return singular_edges;
469 };
470
471 auto set_gauss_pts = [&](auto &ref_gauss_pts) {
473 fe_ptr->gaussPts.swap(ref_gauss_pts);
474 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
475 auto &data = fe_ptr->dataOnElement[H1];
476 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4);
477 double *shape_ptr =
478 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
479 CHKERR ShapeMBTET(shape_ptr, &fe_ptr->gaussPts(0, 0),
480 &fe_ptr->gaussPts(1, 0), &fe_ptr->gaussPts(2, 0),
481 nb_gauss_pts);
483 };
484
485 auto singular_nodes = get_singular_nodes();
486 if (singular_nodes.count()) {
487 auto it_map_ref_coords = mapRefCoords.find(singular_nodes.to_ulong());
488 if (it_map_ref_coords != mapRefCoords.end()) {
489 CHKERR set_gauss_pts(it_map_ref_coords->second);
491 } else {
492
493 auto refine_quadrature = [&]() {
495
496 const int max_level = refinementLevels;
497 EntityHandle tet;
498
499 moab::Core moab_ref;
500 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
501 EntityHandle nodes[4];
502 for (int nn = 0; nn != 4; nn++)
503 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
504 CHKERR moab_ref.create_element(MBTET, nodes, 4, tet);
505 MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
506 MoFEM::Interface &m_field_ref = mofem_ref_core;
507 {
508 Range tets(tet, tet);
509 Range edges;
510 CHKERR m_field_ref.get_moab().get_adjacencies(
511 tets, 1, true, edges, moab::Interface::UNION);
512 CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevel(
513 tets, BitRefLevel().set(0), false, VERBOSE);
514 }
515
516 Range nodes_at_front;
517 for (int nn = 0; nn != numNodes; nn++) {
518 if (singular_nodes[nn]) {
519 EntityHandle ent;
520 CHKERR moab_ref.side_element(tet, 0, nn, ent);
521 nodes_at_front.insert(ent);
522 }
523 }
524
525 auto singular_edges = get_singular_edges();
526
527 EntityHandle meshset;
528 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
529 for (int ee = 0; ee != numEdges; ee++) {
530 if (singular_edges[ee]) {
531 EntityHandle ent;
532 CHKERR moab_ref.side_element(tet, 1, ee, ent);
533 CHKERR moab_ref.add_entities(meshset, &ent, 1);
534 }
535 }
536
537 // refine mesh
538 auto *m_ref = m_field_ref.getInterface<MeshRefinement>();
539 for (int ll = 0; ll != max_level; ll++) {
540 Range edges;
541 CHKERR m_field_ref.getInterface<BitRefManager>()
542 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
543 BitRefLevel().set(), MBEDGE,
544 edges);
545 Range ref_edges;
546 CHKERR moab_ref.get_adjacencies(
547 nodes_at_front, 1, true, ref_edges, moab::Interface::UNION);
548 ref_edges = intersect(ref_edges, edges);
549 Range ents;
550 CHKERR moab_ref.get_entities_by_type(meshset, MBEDGE, ents, true);
551 ref_edges = intersect(ref_edges, ents);
552 Range tets;
553 CHKERR m_field_ref.getInterface<BitRefManager>()
554 ->getEntitiesByTypeAndRefLevel(
555 BitRefLevel().set(ll), BitRefLevel().set(), MBTET, tets);
556 CHKERR m_ref->addVerticesInTheMiddleOfEdges(
557 ref_edges, BitRefLevel().set(ll + 1));
558 CHKERR m_ref->refineTets(tets, BitRefLevel().set(ll + 1));
559 CHKERR m_field_ref.getInterface<BitRefManager>()
560 ->updateMeshsetByEntitiesChildren(meshset,
561 BitRefLevel().set(ll + 1),
562 meshset, MBEDGE, true);
563 }
564
565 // get ref coords
566 Range tets;
567 CHKERR m_field_ref.getInterface<BitRefManager>()
568 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(max_level),
569 BitRefLevel().set(), MBTET,
570 tets);
571
572 if (debug) {
573 CHKERR save_range(moab_ref, "ref_tets.vtk", tets);
574 }
575
576 MatrixDouble ref_coords(tets.size(), 12, false);
577 int tt = 0;
578 for (Range::iterator tit = tets.begin(); tit != tets.end();
579 tit++, tt++) {
580 int num_nodes;
581 const EntityHandle *conn;
582 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
583 CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
584 }
585
586 auto &data = fe_ptr->dataOnElement[H1];
587 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
588 MatrixDouble ref_gauss_pts(4, nb_gauss_pts * ref_coords.size1());
589 MatrixDouble &shape_n =
590 data->dataOnEntities[MBVERTEX][0].getN(NOBASE);
591 int gg = 0;
592 for (size_t tt = 0; tt != ref_coords.size1(); tt++) {
593 double *tet_coords = &ref_coords(tt, 0);
594 double det = Tools::tetVolume(tet_coords);
595 det *= 6;
596 for (size_t ggg = 0; ggg != nb_gauss_pts; ++ggg, ++gg) {
597 for (int dd = 0; dd != 3; dd++) {
598 ref_gauss_pts(dd, gg) =
599 shape_n(ggg, 0) * tet_coords[3 * 0 + dd] +
600 shape_n(ggg, 1) * tet_coords[3 * 1 + dd] +
601 shape_n(ggg, 2) * tet_coords[3 * 2 + dd] +
602 shape_n(ggg, 3) * tet_coords[3 * 3 + dd];
603 }
604 ref_gauss_pts(3, gg) = fe_ptr->gaussPts(3, ggg) * det;
605 }
606 }
607
608 mapRefCoords[singular_nodes.to_ulong()].swap(ref_gauss_pts);
609 CHKERR set_gauss_pts(mapRefCoords[singular_nodes.to_ulong()]);
610
611 // clear cache bubble
612 cachePhi->get<0>() = 0;
613 cachePhi->get<1>() = 0;
614 // tet base cache
615 TetPolynomialBase::switchCacheBaseOff<HDIV>({fe_raw_ptr});
616 TetPolynomialBase::switchCacheBaseOn<HDIV>({fe_raw_ptr});
617
619 };
620
621 CHKERR refine_quadrature();
622 }
623 }
624 }
625
627 }
@ VERBOSE
@ NOBASE
Definition definitions.h:59
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ H1
continuous field
Definition definitions.h:85
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
static const bool debug
PetscErrorCode ShapeMBTET(double *N, const double *G_X, const double *G_Y, const double *G_Z, int DIM)
calculate shape functions
Definition fem_tools.c:306
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition ddTensor0.hpp:33
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
static PetscBool setSingularity
static std::map< long int, MatrixDouble > mapRefCoords
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
Mesh refinement interface.
static double tetVolume(const double *coords)
Calculate volume of tetrahedron.
Definition Tools.cpp:30
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
auto save_range

Member Data Documentation

◆ cachePhi

boost::shared_ptr<CGGUserPolynomialBase::CachePhi> EshelbianPlasticity::SetIntegrationAtFrontVolume::cachePhi
private

◆ frontEdges

boost::shared_ptr<Range> EshelbianPlasticity::SetIntegrationAtFrontVolume::frontEdges
private

◆ frontNodes

boost::shared_ptr<Range> EshelbianPlasticity::SetIntegrationAtFrontVolume::frontNodes
private

◆ funRule

FunRule EshelbianPlasticity::SetIntegrationAtFrontVolume::funRule

◆ mapRefCoords

std::map<long int, MatrixDouble> EshelbianPlasticity::SetIntegrationAtFrontVolume::mapRefCoords
inlinestaticprivate

The documentation for this struct was generated from the following file: