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

Classes

struct  Fe
 

Public Types

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

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, FunRule fun_rule)
 
MoFEMErrorCode operator() (ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
 

Public Attributes

FunRule funRule = face_rule
 

Private Attributes

boost::shared_ptr< RangefrontNodes
 
boost::shared_ptr< RangefrontEdges
 

Static Private Attributes

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

Detailed Description

Definition at line 664 of file EshelbianPlasticity.cpp.

Member Typedef Documentation

◆ FunRule

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

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

◆ SetIntegrationAtFrontFace() [2/2]

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

Definition at line 673 of file EshelbianPlasticity.cpp.

676 : frontNodes(front_nodes), frontEdges(front_edges), funRule(fun_rule){};

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

679 {
681
682 constexpr bool debug = false;
683
684 constexpr int numNodes = 3;
685 constexpr int numEdges = 3;
686 constexpr int refinementLevels = 6;
687
688 auto &m_field = fe_raw_ptr->mField;
689 auto fe_ptr = static_cast<Fe *>(fe_raw_ptr);
690 auto fe_handle = fe_ptr->getFEEntityHandle();
691
692 auto set_base_quadrature = [&]() {
694 int rule = funRule(order_data);
695 if (rule < QUAD_2D_TABLE_SIZE) {
696 if (QUAD_2D_TABLE[rule]->dim != 2) {
697 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "wrong dimension");
698 }
699 if (QUAD_2D_TABLE[rule]->order < rule) {
700 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
701 "wrong order %d != %d", QUAD_2D_TABLE[rule]->order, rule);
702 }
703 const size_t nb_gauss_pts = QUAD_2D_TABLE[rule]->npoints;
704 fe_ptr->gaussPts.resize(3, nb_gauss_pts, false);
705 cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[1], 3,
706 &fe_ptr->gaussPts(0, 0), 1);
707 cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[2], 3,
708 &fe_ptr->gaussPts(1, 0), 1);
709 cblas_dcopy(nb_gauss_pts, QUAD_2D_TABLE[rule]->weights, 1,
710 &fe_ptr->gaussPts(2, 0), 1);
711 auto &data = fe_ptr->dataOnElement[H1];
712 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 3,
713 false);
714 double *shape_ptr =
715 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
716 cblas_dcopy(3 * nb_gauss_pts, QUAD_2D_TABLE[rule]->points, 1, shape_ptr,
717 1);
718 data->dataOnEntities[MBVERTEX][0].getDiffN(NOBASE).resize(3, 2, false);
719 std::copy(
721 data->dataOnEntities[MBVERTEX][0].getDiffN(NOBASE).data().begin());
722
723 } else {
724 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
725 "rule > quadrature order %d < %d", rule, QUAD_3D_TABLE_SIZE);
726 }
728 };
729
730 CHKERR set_base_quadrature();
731
733
734 auto get_singular_nodes = [&]() {
735 int num_nodes;
736 const EntityHandle *conn;
737 CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
738 true);
739 std::bitset<numNodes> singular_nodes;
740 for (auto nn = 0; nn != numNodes; ++nn) {
741 if (frontNodes->find(conn[nn]) != frontNodes->end()) {
742 singular_nodes.set(nn);
743 } else {
744 singular_nodes.reset(nn);
745 }
746 }
747 return singular_nodes;
748 };
749
750 auto get_singular_edges = [&]() {
751 std::bitset<numEdges> singular_edges;
752 for (int ee = 0; ee != numEdges; ee++) {
753 EntityHandle edge;
754 CHKERR m_field.get_moab().side_element(fe_handle, 1, ee, edge);
755 if (frontEdges->find(edge) != frontEdges->end()) {
756 singular_edges.set(ee);
757 } else {
758 singular_edges.reset(ee);
759 }
760 }
761 return singular_edges;
762 };
763
764 auto set_gauss_pts = [&](auto &ref_gauss_pts) {
766 fe_ptr->gaussPts.swap(ref_gauss_pts);
767 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
768 auto &data = fe_ptr->dataOnElement[H1];
769 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4);
770 double *shape_ptr =
771 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
772 CHKERR ShapeMBTRI(shape_ptr, &fe_ptr->gaussPts(0, 0),
773 &fe_ptr->gaussPts(1, 0), nb_gauss_pts);
775 };
776
777 auto singular_nodes = get_singular_nodes();
778 if (singular_nodes.count()) {
779 auto it_map_ref_coords = mapRefCoords.find(singular_nodes.to_ulong());
780 if (it_map_ref_coords != mapRefCoords.end()) {
781 CHKERR set_gauss_pts(it_map_ref_coords->second);
783 } else {
784
785 auto refine_quadrature = [&]() {
787
788 const int max_level = refinementLevels;
789
790 moab::Core moab_ref;
791 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0};
792 EntityHandle nodes[numNodes];
793 for (int nn = 0; nn != numNodes; nn++)
794 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
795 EntityHandle tri;
796 CHKERR moab_ref.create_element(MBTRI, nodes, numNodes, tri);
797 MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
798 MoFEM::Interface &m_field_ref = mofem_ref_core;
799 {
800 Range tris(tri, tri);
801 Range edges;
802 CHKERR m_field_ref.get_moab().get_adjacencies(
803 tris, 1, true, edges, moab::Interface::UNION);
804 CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevel(
805 tris, BitRefLevel().set(0), false, VERBOSE);
806 }
807
808 Range nodes_at_front;
809 for (int nn = 0; nn != numNodes; nn++) {
810 if (singular_nodes[nn]) {
811 EntityHandle ent;
812 CHKERR moab_ref.side_element(tri, 0, nn, ent);
813 nodes_at_front.insert(ent);
814 }
815 }
816
817 auto singular_edges = get_singular_edges();
818
819 EntityHandle meshset;
820 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
821 for (int ee = 0; ee != numEdges; ee++) {
822 if (singular_edges[ee]) {
823 EntityHandle ent;
824 CHKERR moab_ref.side_element(tri, 1, ee, ent);
825 CHKERR moab_ref.add_entities(meshset, &ent, 1);
826 }
827 }
828
829 // refine mesh
830 auto *m_ref = m_field_ref.getInterface<MeshRefinement>();
831 for (int ll = 0; ll != max_level; ll++) {
832 Range edges;
833 CHKERR m_field_ref.getInterface<BitRefManager>()
834 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
835 BitRefLevel().set(), MBEDGE,
836 edges);
837 Range ref_edges;
838 CHKERR moab_ref.get_adjacencies(
839 nodes_at_front, 1, true, ref_edges, moab::Interface::UNION);
840 ref_edges = intersect(ref_edges, edges);
841 Range ents;
842 CHKERR moab_ref.get_entities_by_type(meshset, MBEDGE, ents, true);
843 ref_edges = intersect(ref_edges, ents);
844 Range tris;
845 CHKERR m_field_ref.getInterface<BitRefManager>()
846 ->getEntitiesByTypeAndRefLevel(
847 BitRefLevel().set(ll), BitRefLevel().set(), MBTRI, tris);
848 CHKERR m_ref->addVerticesInTheMiddleOfEdges(
849 ref_edges, BitRefLevel().set(ll + 1));
850 CHKERR m_ref->refineTris(tris, BitRefLevel().set(ll + 1));
851 CHKERR m_field_ref.getInterface<BitRefManager>()
852 ->updateMeshsetByEntitiesChildren(meshset,
853 BitRefLevel().set(ll + 1),
854 meshset, MBEDGE, true);
855 }
856
857 // get ref coords
858 Range tris;
859 CHKERR m_field_ref.getInterface<BitRefManager>()
860 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(max_level),
861 BitRefLevel().set(), MBTRI,
862 tris);
863
864 if (debug) {
865 CHKERR save_range(moab_ref, "ref_tris.vtk", tris);
866 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "debug");
867 }
868
869 MatrixDouble ref_coords(tris.size(), 9, false);
870 int tt = 0;
871 for (Range::iterator tit = tris.begin(); tit != tris.end();
872 tit++, tt++) {
873 int num_nodes;
874 const EntityHandle *conn;
875 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
876 CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
877 }
878
879 auto &data = fe_ptr->dataOnElement[H1];
880 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
881 MatrixDouble ref_gauss_pts(3, nb_gauss_pts * ref_coords.size1());
882 MatrixDouble &shape_n =
883 data->dataOnEntities[MBVERTEX][0].getN(NOBASE);
884 int gg = 0;
885 for (size_t tt = 0; tt != ref_coords.size1(); tt++) {
886 double *tri_coords = &ref_coords(tt, 0);
888 CHKERR Tools::getTriNormal(tri_coords, &t_normal(0));
889 auto det = t_normal.l2();
890 for (size_t ggg = 0; ggg != nb_gauss_pts; ++ggg, ++gg) {
891 for (int dd = 0; dd != 2; dd++) {
892 ref_gauss_pts(dd, gg) =
893 shape_n(ggg, 0) * tri_coords[3 * 0 + dd] +
894 shape_n(ggg, 1) * tri_coords[3 * 1 + dd] +
895 shape_n(ggg, 2) * tri_coords[3 * 2 + dd];
896 }
897 ref_gauss_pts(2, gg) = fe_ptr->gaussPts(2, ggg) * det;
898 }
899 }
900
901 mapRefCoords[singular_nodes.to_ulong()].swap(ref_gauss_pts);
902 CHKERR set_gauss_pts(mapRefCoords[singular_nodes.to_ulong()]);
903
905 };
906
907 CHKERR refine_quadrature();
908 }
909 }
910 }
911
913 }
@ 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 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
#define QUAD_2D_TABLE_SIZE
Definition quad.h:174
#define QUAD_3D_TABLE_SIZE
Definition quad.h:186
static QUAD *const QUAD_2D_TABLE[]
Definition quad.h:175
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 constexpr std::array< double, 6 > diffShapeFunMBTRI
Definition Tools.hpp:104
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.
int npoints
Definition quad.h:29
auto save_range

Member Data Documentation

◆ frontEdges

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

◆ frontNodes

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

◆ funRule

FunRule EshelbianPlasticity::SetIntegrationAtFrontFace::funRule = face_rule

◆ mapRefCoords

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

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