v0.15.4
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 = [](int p) { return 2 * p + 1; }
 

Private Attributes

boost::shared_ptr< RangefrontNodes
 
boost::shared_ptr< RangefrontEdges
 
boost::shared_ptr< CGGUserPolynomialBase::CachePhicachePhi
 

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.

379 : frontNodes(front_nodes), frontEdges(front_edges), cachePhi(cache_phi){};
boost::shared_ptr< CGGUserPolynomialBase::CachePhi > cachePhi

◆ 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 381 of file EshelbianPlasticity.cpp.

385 : frontNodes(front_nodes), frontEdges(front_edges), funRule(fun_rule),
386 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 388 of file EshelbianPlasticity.cpp.

389 {
391
392 constexpr bool debug = false;
393
394 constexpr int numNodes = 4;
395 constexpr int numEdges = 6;
396 constexpr int refinementLevels = 6;
397
398 auto &m_field = fe_raw_ptr->mField;
399 auto fe_ptr = static_cast<Fe *>(fe_raw_ptr);
400 auto fe_handle = fe_ptr->getFEEntityHandle();
401
402 auto set_base_quadrature = [&]() {
404 int rule = funRule(order_data);
405 if (rule < QUAD_3D_TABLE_SIZE) {
406 if (QUAD_3D_TABLE[rule]->dim != 3) {
407 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
408 "wrong dimension");
409 }
410 if (QUAD_3D_TABLE[rule]->order < rule) {
411 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
412 "wrong order %d != %d", QUAD_3D_TABLE[rule]->order, rule);
413 }
414 const size_t nb_gauss_pts = QUAD_3D_TABLE[rule]->npoints;
415 auto &gauss_pts = fe_ptr->gaussPts;
416 gauss_pts.resize(4, nb_gauss_pts, false);
417 cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[1], 4,
418 &gauss_pts(0, 0), 1);
419 cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[2], 4,
420 &gauss_pts(1, 0), 1);
421 cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[3], 4,
422 &gauss_pts(2, 0), 1);
423 cblas_dcopy(nb_gauss_pts, QUAD_3D_TABLE[rule]->weights, 1,
424 &gauss_pts(3, 0), 1);
425 auto &data = fe_ptr->dataOnElement[H1];
426 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4,
427 false);
428 double *shape_ptr =
429 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
430 cblas_dcopy(4 * nb_gauss_pts, QUAD_3D_TABLE[rule]->points, 1, shape_ptr,
431 1);
432 } else {
433 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
434 "rule > quadrature order %d < %d", rule, QUAD_3D_TABLE_SIZE);
435 }
437 };
438
439 CHKERR set_base_quadrature();
440
442
443 auto get_singular_nodes = [&]() {
444 int num_nodes;
445 const EntityHandle *conn;
446 CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
447 true);
448 std::bitset<numNodes> singular_nodes;
449 for (auto nn = 0; nn != numNodes; ++nn) {
450 if (frontNodes->find(conn[nn]) != frontNodes->end()) {
451 singular_nodes.set(nn);
452 } else {
453 singular_nodes.reset(nn);
454 }
455 }
456 return singular_nodes;
457 };
458
459 auto get_singular_edges = [&]() {
460 std::bitset<numEdges> singular_edges;
461 for (int ee = 0; ee != numEdges; ee++) {
462 EntityHandle edge;
463 CHKERR m_field.get_moab().side_element(fe_handle, 1, ee, edge);
464 if (frontEdges->find(edge) != frontEdges->end()) {
465 singular_edges.set(ee);
466 } else {
467 singular_edges.reset(ee);
468 }
469 }
470 return singular_edges;
471 };
472
473 auto set_gauss_pts = [&](auto &ref_gauss_pts) {
475 fe_ptr->gaussPts.swap(ref_gauss_pts);
476 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
477 auto &data = fe_ptr->dataOnElement[H1];
478 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4);
479 double *shape_ptr =
480 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
481 CHKERR ShapeMBTET(shape_ptr, &fe_ptr->gaussPts(0, 0),
482 &fe_ptr->gaussPts(1, 0), &fe_ptr->gaussPts(2, 0),
483 nb_gauss_pts);
485 };
486
487 auto singular_nodes = get_singular_nodes();
488 if (singular_nodes.count()) {
489 auto it_map_ref_coords = mapRefCoords.find(singular_nodes.to_ulong());
490 if (it_map_ref_coords != mapRefCoords.end()) {
491 CHKERR set_gauss_pts(it_map_ref_coords->second);
493 } else {
494
495 auto refine_quadrature = [&]() {
497
498 const int max_level = refinementLevels;
499 EntityHandle tet;
500
501 moab::Core moab_ref;
502 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
503 EntityHandle nodes[4];
504 for (int nn = 0; nn != 4; nn++)
505 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
506 CHKERR moab_ref.create_element(MBTET, nodes, 4, tet);
507 MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
508 MoFEM::Interface &m_field_ref = mofem_ref_core;
509 {
510 Range tets(tet, tet);
511 Range edges;
512 CHKERR m_field_ref.get_moab().get_adjacencies(
513 tets, 1, true, edges, moab::Interface::UNION);
514 CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevel(
515 tets, BitRefLevel().set(0), false, VERBOSE);
516 }
517
518 Range nodes_at_front;
519 for (int nn = 0; nn != numNodes; nn++) {
520 if (singular_nodes[nn]) {
521 EntityHandle ent;
522 CHKERR moab_ref.side_element(tet, 0, nn, ent);
523 nodes_at_front.insert(ent);
524 }
525 }
526
527 auto singular_edges = get_singular_edges();
528
529 EntityHandle meshset;
530 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
531 for (int ee = 0; ee != numEdges; ee++) {
532 if (singular_edges[ee]) {
533 EntityHandle ent;
534 CHKERR moab_ref.side_element(tet, 1, ee, ent);
535 CHKERR moab_ref.add_entities(meshset, &ent, 1);
536 }
537 }
538
539 // refine mesh
540 auto *m_ref = m_field_ref.getInterface<MeshRefinement>();
541 for (int ll = 0; ll != max_level; ll++) {
542 Range edges;
543 CHKERR m_field_ref.getInterface<BitRefManager>()
544 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
545 BitRefLevel().set(), MBEDGE,
546 edges);
547 Range ref_edges;
548 CHKERR moab_ref.get_adjacencies(
549 nodes_at_front, 1, true, ref_edges, moab::Interface::UNION);
550 ref_edges = intersect(ref_edges, edges);
551 Range ents;
552 CHKERR moab_ref.get_entities_by_type(meshset, MBEDGE, ents, true);
553 ref_edges = intersect(ref_edges, ents);
554 Range tets;
555 CHKERR m_field_ref.getInterface<BitRefManager>()
556 ->getEntitiesByTypeAndRefLevel(
557 BitRefLevel().set(ll), BitRefLevel().set(), MBTET, tets);
558 CHKERR m_ref->addVerticesInTheMiddleOfEdges(
559 ref_edges, BitRefLevel().set(ll + 1));
560 CHKERR m_ref->refineTets(tets, BitRefLevel().set(ll + 1));
561 CHKERR m_field_ref.getInterface<BitRefManager>()
562 ->updateMeshsetByEntitiesChildren(meshset,
563 BitRefLevel().set(ll + 1),
564 meshset, MBEDGE, true);
565 }
566
567 // get ref coords
568 Range tets;
569 CHKERR m_field_ref.getInterface<BitRefManager>()
570 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(max_level),
571 BitRefLevel().set(), MBTET,
572 tets);
573
574 if (debug) {
575 CHKERR save_range(moab_ref, "ref_tets.vtk", tets);
576 }
577
578 MatrixDouble ref_coords(tets.size(), 12, false);
579 int tt = 0;
580 for (Range::iterator tit = tets.begin(); tit != tets.end();
581 tit++, tt++) {
582 int num_nodes;
583 const EntityHandle *conn;
584 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
585 CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
586 }
587
588 auto &data = fe_ptr->dataOnElement[H1];
589 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
590 MatrixDouble ref_gauss_pts(4, nb_gauss_pts * ref_coords.size1());
591 MatrixDouble &shape_n =
592 data->dataOnEntities[MBVERTEX][0].getN(NOBASE);
593 int gg = 0;
594 for (size_t tt = 0; tt != ref_coords.size1(); tt++) {
595 double *tet_coords = &ref_coords(tt, 0);
596 double det = Tools::tetVolume(tet_coords);
597 det *= 6;
598 for (size_t ggg = 0; ggg != nb_gauss_pts; ++ggg, ++gg) {
599 for (int dd = 0; dd != 3; dd++) {
600 ref_gauss_pts(dd, gg) =
601 shape_n(ggg, 0) * tet_coords[3 * 0 + dd] +
602 shape_n(ggg, 1) * tet_coords[3 * 1 + dd] +
603 shape_n(ggg, 2) * tet_coords[3 * 2 + dd] +
604 shape_n(ggg, 3) * tet_coords[3 * 3 + dd];
605 }
606 ref_gauss_pts(3, gg) = fe_ptr->gaussPts(3, ggg) * det;
607 }
608 }
609
610 mapRefCoords[singular_nodes.to_ulong()].swap(ref_gauss_pts);
611 CHKERR set_gauss_pts(mapRefCoords[singular_nodes.to_ulong()]);
612
613 // clear cache bubble
614 cachePhi->get<0>() = 0;
615 cachePhi->get<1>() = 0;
616 // tet base cache
617 TetPolynomialBase::switchCacheBaseOff<HDIV>({fe_raw_ptr});
618 TetPolynomialBase::switchCacheBaseOn<HDIV>({fe_raw_ptr});
619
621 };
622
623 CHKERR refine_quadrature();
624 }
625 }
626 }
627
629 }
@ 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.
constexpr int order
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
#define QUAD_3D_TABLE_SIZE
Definition quad.h:186
static QUAD *const QUAD_3D_TABLE[]
Definition quad.h:187
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.
int order
Definition quad.h:28
int npoints
Definition quad.h:29
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 = [](int p) { return 2 * p + 1; }

◆ mapRefCoords

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

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