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

Classes

struct  Fe
 

Public Member Functions

 SetIntegrationAtFrontFace (boost::shared_ptr< Range > front_nodes, boost::shared_ptr< Range > front_edges)
 
 SetIntegrationAtFrontFace (boost::shared_ptr< Range > front_nodes, boost::shared_ptr< Range > front_edges, int(*)(int))
 
MoFEMErrorCode operator() (ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
 

Private Attributes

boost::shared_ptr< Range > frontNodes
 
boost::shared_ptr< Range > frontEdges
 

Static Private Attributes

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

Detailed Description

Definition at line 645 of file EshelbianPlasticity.cpp.

Constructor & Destructor Documentation

◆ SetIntegrationAtFrontFace() [1/2]

EshelbianPlasticity::SetIntegrationAtFrontFace::SetIntegrationAtFrontFace ( boost::shared_ptr< Range >  front_nodes,
boost::shared_ptr< Range >  front_edges 
)
inline

Definition at line 647 of file EshelbianPlasticity.cpp.

649 : frontNodes(front_nodes), frontEdges(front_edges) {};

◆ SetIntegrationAtFrontFace() [2/2]

EshelbianPlasticity::SetIntegrationAtFrontFace::SetIntegrationAtFrontFace ( boost::shared_ptr< Range >  front_nodes,
boost::shared_ptr< Range >  front_edges,
int(*)(int)   
)
inline

Definition at line 651 of file EshelbianPlasticity.cpp.

653 : frontNodes(front_nodes), frontEdges(front_edges) {};

Member Function Documentation

◆ operator()()

MoFEMErrorCode EshelbianPlasticity::SetIntegrationAtFrontFace::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 655 of file EshelbianPlasticity.cpp.

656 {
658
659 constexpr bool debug = false;
660
661 constexpr int numNodes = 3;
662 constexpr int numEdges = 3;
663 constexpr int refinementLevels = 6;
664
665 auto &m_field = fe_raw_ptr->mField;
666 auto fe_ptr = static_cast<Fe *>(fe_raw_ptr);
667 auto fe_handle = fe_ptr->getFEEntityHandle();
668
669 auto set_base_quadrature = [&]() {
671 const int rule = face_rule(order_data);
672 const auto xiao_rule = IntRules::XiaoGimbutas::getTriangleRule(rule);
673 if (!xiao_rule) {
674 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
675 "Xiao--Gimbutas triangle rule is available for polynomial "
676 "orders 0 to %d; requested %d",
677 IntRules::XiaoGimbutas::triangleRuleCount, rule);
678 }
679 if (xiao_rule->numBarycentricCoordinates != 3) {
680 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
681 "wrong number of triangle barycentric coordinates");
682 }
683
684 const size_t nb_gauss_pts = xiao_rule->numPoints;
685 auto &gauss_pts = fe_ptr->gaussPts;
686 gauss_pts.resize(3, nb_gauss_pts, false);
687 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[1], 3, &gauss_pts(0, 0), 1);
688 cblas_dcopy(nb_gauss_pts, &xiao_rule->points[2], 3, &gauss_pts(1, 0), 1);
689 cblas_dcopy(nb_gauss_pts, xiao_rule->weights, 1, &gauss_pts(2, 0), 1);
691 };
692
693 CHKERR set_base_quadrature();
694
696
697 auto get_singular_nodes = [&]() {
698 int num_nodes;
699 const EntityHandle *conn;
700 CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
701 true);
702 std::bitset<numNodes> singular_nodes;
703 for (auto nn = 0; nn != numNodes; ++nn) {
704 if (frontNodes->find(conn[nn]) != frontNodes->end()) {
705 singular_nodes.set(nn);
706 } else {
707 singular_nodes.reset(nn);
708 }
709 }
710 return singular_nodes;
711 };
712
713 auto get_singular_edges = [&]() {
714 std::bitset<numEdges> singular_edges;
715 for (int ee = 0; ee != numEdges; ee++) {
716 EntityHandle edge;
717 CHKERR m_field.get_moab().side_element(fe_handle, 1, ee, edge);
718 if (frontEdges->find(edge) != frontEdges->end()) {
719 singular_edges.set(ee);
720 } else {
721 singular_edges.reset(ee);
722 }
723 }
724 return singular_edges;
725 };
726
727 auto set_gauss_pts = [&](auto &ref_gauss_pts) {
729 fe_ptr->gaussPts.swap(ref_gauss_pts);
731 };
732
733 auto singular_nodes = get_singular_nodes();
734 if (singular_nodes.count()) {
735 auto it_map_ref_coords = mapRefCoords.find(singular_nodes.to_ulong());
736 if (it_map_ref_coords != mapRefCoords.end()) {
737 CHKERR set_gauss_pts(it_map_ref_coords->second);
739 } else {
740
741 auto refine_quadrature = [&]() {
743
744 const int max_level = refinementLevels;
745
746 moab::Core moab_ref;
747 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0};
748 EntityHandle nodes[numNodes];
749 for (int nn = 0; nn != numNodes; nn++)
750 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
751 EntityHandle tri;
752 CHKERR moab_ref.create_element(MBTRI, nodes, numNodes, tri);
753 MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
754 MoFEM::Interface &m_field_ref = mofem_ref_core;
755 {
756 Range tris(tri, tri);
757 Range edges;
758 CHKERR m_field_ref.get_moab().get_adjacencies(
759 tris, 1, true, edges, moab::Interface::UNION);
760 CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevel(
761 tris, BitRefLevel().set(0), false, VERBOSE);
762 }
763
764 Range nodes_at_front;
765 for (int nn = 0; nn != numNodes; nn++) {
766 if (singular_nodes[nn]) {
767 EntityHandle ent;
768 CHKERR moab_ref.side_element(tri, 0, nn, ent);
769 nodes_at_front.insert(ent);
770 }
771 }
772
773 auto singular_edges = get_singular_edges();
774
775 EntityHandle meshset;
776 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
777 for (int ee = 0; ee != numEdges; ee++) {
778 if (singular_edges[ee]) {
779 EntityHandle ent;
780 CHKERR moab_ref.side_element(tri, 1, ee, ent);
781 CHKERR moab_ref.add_entities(meshset, &ent, 1);
782 }
783 }
784
785 // refine mesh
786 auto *m_ref = m_field_ref.getInterface<MeshRefinement>();
787 for (int ll = 0; ll != max_level; ll++) {
788 Range edges;
789 CHKERR m_field_ref.getInterface<BitRefManager>()
790 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
791 BitRefLevel().set(), MBEDGE,
792 edges);
793 Range ref_edges;
794 CHKERR moab_ref.get_adjacencies(
795 nodes_at_front, 1, true, ref_edges, moab::Interface::UNION);
796 ref_edges = intersect(ref_edges, edges);
797 Range ents;
798 CHKERR moab_ref.get_entities_by_type(meshset, MBEDGE, ents, true);
799 ref_edges = intersect(ref_edges, ents);
800 Range tris;
801 CHKERR m_field_ref.getInterface<BitRefManager>()
802 ->getEntitiesByTypeAndRefLevel(
803 BitRefLevel().set(ll), BitRefLevel().set(), MBTRI, tris);
804 CHKERR m_ref->addVerticesInTheMiddleOfEdges(
805 ref_edges, BitRefLevel().set(ll + 1));
806 CHKERR m_ref->refineTris(tris, BitRefLevel().set(ll + 1));
807 CHKERR m_field_ref.getInterface<BitRefManager>()
808 ->updateMeshsetByEntitiesChildren(meshset,
809 BitRefLevel().set(ll + 1),
810 meshset, MBEDGE, true);
811 }
812
813 // get ref coords
814 Range tris;
815 CHKERR m_field_ref.getInterface<BitRefManager>()
816 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(max_level),
817 BitRefLevel().set(), MBTRI,
818 tris);
819
820 if (debug) {
821 CHKERR save_range(moab_ref, "ref_tris.vtk", tris);
822 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "debug");
823 }
824
825 MatrixDouble ref_coords(tris.size(), 9, false);
826 int tt = 0;
827 for (Range::iterator tit = tris.begin(); tit != tris.end();
828 tit++, tt++) {
829 int num_nodes;
830 const EntityHandle *conn;
831 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
832 CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
833 }
834
835 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
836 MatrixDouble ref_gauss_pts(3, nb_gauss_pts * ref_coords.size1());
837 MatrixDouble shape_n(nb_gauss_pts, 3, false);
838 CHKERR ShapeMBTRI(&shape_n(0, 0), &fe_ptr->gaussPts(0, 0),
839 &fe_ptr->gaussPts(1, 0), nb_gauss_pts);
840 int gg = 0;
841 for (size_t tt = 0; tt != ref_coords.size1(); tt++) {
842 double *tri_coords = &ref_coords(tt, 0);
844 CHKERR Tools::getTriNormal(tri_coords, &t_normal(0));
845 auto det = t_normal.l2();
846 for (size_t ggg = 0; ggg != nb_gauss_pts; ++ggg, ++gg) {
847 for (int dd = 0; dd != 2; dd++) {
848 ref_gauss_pts(dd, gg) =
849 shape_n(ggg, 0) * tri_coords[3 * 0 + dd] +
850 shape_n(ggg, 1) * tri_coords[3 * 1 + dd] +
851 shape_n(ggg, 2) * tri_coords[3 * 2 + dd];
852 }
853 ref_gauss_pts(2, gg) = fe_ptr->gaussPts(2, ggg) * det;
854 }
855 }
856
857 mapRefCoords[singular_nodes.to_ulong()].swap(ref_gauss_pts);
858 CHKERR set_gauss_pts(mapRefCoords[singular_nodes.to_ulong()]);
859
861 };
862
863 CHKERR refine_quadrature();
864 }
865 }
866 }
867
869 }
@ VERBOSE
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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 ShapeMBTRI(double *N, const double *X, const double *Y, const int G_DIM)
calculate shape functions on triangle
Definition fem_tools.c:182
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 MoFEMErrorCode getTriNormal(const double *coords, double *normal, double *d_normal=nullptr)
Get the Tri Normal objectGet triangle normal.
Definition Tools.cpp:353
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
auto save_range

Member Data Documentation

◆ frontEdges

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

◆ frontNodes

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

◆ mapRefCoords

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

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