v0.16.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Private Attributes | List of all members
SetEnrichedIntegration Struct Reference

#include "users_modules/multifield-thermoplasticity-private/src/SolutionMapping.hpp"

Collaboration diagram for SetEnrichedIntegration:
[legend]

Classes

struct  Fe
 

Public Member Functions

 SetEnrichedIntegration ()
 
MoFEMErrorCode operator() (ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
 

Static Private Attributes

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

Detailed Description

Examples
SolutionMapping.hpp.

Definition at line 8 of file SolutionMapping.hpp.

Constructor & Destructor Documentation

◆ SetEnrichedIntegration()

SetEnrichedIntegration::SetEnrichedIntegration ( )
Examples
SolutionMapping.hpp, and thermoplastic.cpp.

Definition at line 705 of file thermoplastic.cpp.

705{}

Member Function Documentation

◆ operator()()

MoFEMErrorCode SetEnrichedIntegration::operator() ( ForcesAndSourcesCore fe_raw_ptr,
int  order_row,
int  order_col,
int  order_data 
)
Examples
SolutionMapping.hpp, and thermoplastic.cpp.

Definition at line 708 of file thermoplastic.cpp.

710 {
712
713 constexpr int numNodes = 3;
714 constexpr int numEdges = 3;
715
716 auto &m_field = fe_raw_ptr->mField;
717 auto fe_ptr = static_cast<Fe *>(fe_raw_ptr);
718 auto fe_handle = fe_ptr->getFEEntityHandle();
719
720 auto set_base_quadrature = [&]() {
722 int rule = 2 * (order_data + 1);
723 if (rule < QUAD_2D_TABLE_SIZE) {
724 if (QUAD_2D_TABLE[rule]->dim != 2) {
725 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "wrong dimension");
726 }
727 if (QUAD_2D_TABLE[rule]->order < rule) {
728 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
729 "wrong order %d != %d", QUAD_2D_TABLE[rule]->order, rule);
730 }
731 const size_t nb_gauss_pts = QUAD_2D_TABLE[rule]->npoints;
732 fe_ptr->gaussPts.resize(3, nb_gauss_pts, false);
733 cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[1], 3,
734 &fe_ptr->gaussPts(0, 0), 1);
735 cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[2], 3,
736 &fe_ptr->gaussPts(1, 0), 1);
737 cblas_dcopy(nb_gauss_pts, QUAD_2D_TABLE[rule]->weights, 1,
738 &fe_ptr->gaussPts(2, 0), 1);
739 auto &data = fe_ptr->dataOnElement[H1];
740 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 3,
741 false);
742 double *shape_ptr =
743 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
744 cblas_dcopy(3 * nb_gauss_pts, QUAD_2D_TABLE[rule]->points, 1, shape_ptr,
745 1);
746 data->dataOnEntities[MBVERTEX][0].getDiffN(NOBASE).resize(3, 2, false);
747 std::copy(
749 data->dataOnEntities[MBVERTEX][0].getDiffN(NOBASE).data().begin());
750
751 } else {
752 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
753 "rule > quadrature order %d < %d", rule, QUAD_3D_TABLE_SIZE);
754 }
756 };
757
758 CHKERR set_base_quadrature();
759
760 auto set_gauss_pts = [&](auto &ref_gauss_pts) {
762 fe_ptr->gaussPts.swap(ref_gauss_pts);
763 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
764 auto &data = fe_ptr->dataOnElement[H1];
765 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 3);
766 double *shape_ptr =
767 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
768 CHKERR ShapeMBTRI(shape_ptr, &fe_ptr->gaussPts(0, 0),
769 &fe_ptr->gaussPts(1, 0), nb_gauss_pts);
771 };
772
773 auto refine_quadrature = [&]() {
775
776 moab::Core moab_ref;
777 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0};
778 EntityHandle nodes[numNodes];
779 for (int nn = 0; nn != numNodes; nn++)
780 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
781 EntityHandle tri;
782 CHKERR moab_ref.create_element(MBTRI, nodes, numNodes, tri);
783 MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
784 MoFEM::Interface &m_field_ref = mofem_ref_core;
785
786 Range ref_tri(tri, tri);
787 Range edges;
788 CHKERR m_field_ref.get_moab().get_adjacencies(ref_tri, 1, true, edges,
789 moab::Interface::UNION);
790 CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevel(
791 ref_tri, BitRefLevel().set(0), false, VERBOSE);
792
793 Range nodes_at_front;
794 for (int nn = 0; nn != numNodes; nn++) {
795 EntityHandle ent;
796 CHKERR moab_ref.side_element(tri, 0, nn, ent);
797 nodes_at_front.insert(ent);
798 }
799
800 EntityHandle meshset;
801 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
802 for (int ee = 0; ee != numEdges; ee++) {
803 EntityHandle ent;
804 CHKERR moab_ref.side_element(tri, 1, ee, ent);
805 CHKERR moab_ref.add_entities(meshset, &ent, 1);
806 }
807
808 // refine mesh
809 auto *m_ref = m_field_ref.getInterface<MeshRefinement>();
810 Range ref_edges;
811 CHKERR m_field_ref.getInterface<BitRefManager>()
812 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(0),
813 BitRefLevel().set(), MBEDGE, ref_edges);
814
815 // Range tris_to_refine;
816 // CHKERR m_field_ref.getInterface<BitRefManager>()
817 // ->getEntitiesByTypeAndRefLevel(
818 // BitRefLevel().set(0), BitRefLevel().set(), MBTRI,
819 // tris_to_refine);
820 CHKERR m_ref->addVerticesInTheMiddleOfEdges(ref_edges,
821 BitRefLevel().set(1));
822 CHKERR m_ref->refineTris(ref_tri, BitRefLevel().set(1));
823 CHKERR m_field_ref.getInterface<BitRefManager>()
824 ->updateMeshsetByEntitiesChildren(meshset, BitRefLevel().set(1),
825 meshset, MBEDGE, true);
826 CHKERR m_field_ref.getInterface<BitRefManager>()
827 ->updateMeshsetByEntitiesChildren(meshset, BitRefLevel().set(1),
828 meshset, MBTRI, true);
829
830 // get ref coords
831 Range output_ref_tris;
832 CHKERR m_field_ref.getInterface<BitRefManager>()
833 ->getEntitiesByTypeAndRefLevel(
834 BitRefLevel().set(1), BitRefLevel().set(), MBTRI, output_ref_tris);
835
836#ifndef NDEBUG
837 CHKERR save_range(moab_ref, "ref_tris.vtk", output_ref_tris);
838#endif
839
840 MatrixDouble ref_coords(output_ref_tris.size(), 9, false);
841 int tt = 0;
842 for (Range::iterator tit = output_ref_tris.begin();
843 tit != output_ref_tris.end(); tit++, tt++) {
844 int num_nodes;
845 const EntityHandle *conn;
846 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
847 CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
848 }
849
850 auto &data = fe_ptr->dataOnElement[H1];
851 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
852 MatrixDouble ref_gauss_pts(3, nb_gauss_pts * ref_coords.size1());
853 MatrixDouble &shape_n = data->dataOnEntities[MBVERTEX][0].getN(NOBASE);
854 int gg = 0;
855 for (size_t tt = 0; tt != ref_coords.size1(); tt++) {
856 double *tri_coords = &ref_coords(tt, 0);
858 CHKERR Tools::getTriNormal(tri_coords, &t_normal(0));
859 auto det = t_normal.l2();
860 for (size_t ggg = 0; ggg != nb_gauss_pts; ++ggg, ++gg) {
861 for (int dd = 0; dd != 2; dd++) {
862 ref_gauss_pts(dd, gg) = shape_n(ggg, 0) * tri_coords[3 * 0 + dd] +
863 shape_n(ggg, 1) * tri_coords[3 * 1 + dd] +
864 shape_n(ggg, 2) * tri_coords[3 * 2 + dd];
865 }
866 MOFEM_LOG("REMESHING", Sev::noisy)
867 << ref_gauss_pts(0, gg) << ", " << ref_gauss_pts(1, gg);
868 ref_gauss_pts(2, gg) = fe_ptr->gaussPts(2, ggg) * det;
869 }
870 }
871
872 int num_nodes;
873 const EntityHandle *conn;
874 CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
875 true);
876 std::bitset<numNodes> all_nodes;
877 for (auto nn = 0; nn != numNodes; ++nn) {
878 all_nodes.set(nn);
879 }
880
881 mapRefCoords[all_nodes.to_ulong()].swap(ref_gauss_pts);
882 CHKERR set_gauss_pts(mapRefCoords[all_nodes.to_ulong()]);
883
885 };
886
887 CHKERR refine_quadrature();
888
890}
@ VERBOSE
@ NOBASE
Definition definitions.h:59
@ 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
PetscErrorCode ShapeMBTRI(double *N, const double *X, const double *Y, const int G_DIM)
calculate shape functions on triangle
Definition fem_tools.c:182
#define MOFEM_LOG(channel, severity)
Log.
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
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
static std::map< long int, MatrixDouble > mapRefCoords
auto save_range

Member Data Documentation

◆ mapRefCoords

std::map<long int, MatrixDouble> SetEnrichedIntegration::mapRefCoords
inlinestaticprivate
Examples
SolutionMapping.hpp, and thermoplastic.cpp.

Definition at line 23 of file SolutionMapping.hpp.


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