v0.15.0
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | 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 (boost::shared_ptr< Range > new_els)
 
MoFEMErrorCode operator() (ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
 

Private Attributes

boost::shared_ptr< RangenewEls
 

Static Private Attributes

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

Detailed Description

Examples
SolutionMapping.hpp.

Definition at line 7 of file SolutionMapping.hpp.

Constructor & Destructor Documentation

◆ SetEnrichedIntegration()

SetEnrichedIntegration::SetEnrichedIntegration ( boost::shared_ptr< Range new_els)
Examples
thermoplastic.cpp.

Definition at line 615 of file thermoplastic.cpp.

616 : newEls(new_els) {}
boost::shared_ptr< Range > newEls

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 619 of file thermoplastic.cpp.

621 {
623
624 constexpr int numNodes = 3;
625 constexpr int numEdges = 3;
626
627 auto &m_field = fe_raw_ptr->mField;
628 auto fe_ptr = static_cast<Fe *>(fe_raw_ptr);
629 auto fe_handle = fe_ptr->getFEEntityHandle();
630
631 auto set_base_quadrature = [&]() {
633 int rule = 2 * (order_data + 1);
634 if (rule < QUAD_2D_TABLE_SIZE) {
635 if (QUAD_2D_TABLE[rule]->dim != 2) {
636 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "wrong dimension");
637 }
638 if (QUAD_2D_TABLE[rule]->order < rule) {
639 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
640 "wrong order %d != %d", QUAD_2D_TABLE[rule]->order, rule);
641 }
642 const size_t nb_gauss_pts = QUAD_2D_TABLE[rule]->npoints;
643 fe_ptr->gaussPts.resize(3, nb_gauss_pts, false);
644 cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[1], 3,
645 &fe_ptr->gaussPts(0, 0), 1);
646 cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[2], 3,
647 &fe_ptr->gaussPts(1, 0), 1);
648 cblas_dcopy(nb_gauss_pts, QUAD_2D_TABLE[rule]->weights, 1,
649 &fe_ptr->gaussPts(2, 0), 1);
650 auto &data = fe_ptr->dataOnElement[H1];
651 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 3,
652 false);
653 double *shape_ptr =
654 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
655 cblas_dcopy(3 * nb_gauss_pts, QUAD_2D_TABLE[rule]->points, 1, shape_ptr,
656 1);
657 data->dataOnEntities[MBVERTEX][0].getDiffN(NOBASE).resize(3, 2, false);
658 std::copy(
660 data->dataOnEntities[MBVERTEX][0].getDiffN(NOBASE).data().begin());
661
662 } else {
663 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
664 "rule > quadrature order %d < %d", rule, QUAD_3D_TABLE_SIZE);
665 }
667 };
668
669 CHKERR set_base_quadrature();
670
671 auto set_gauss_pts = [&](auto &ref_gauss_pts) {
673 fe_ptr->gaussPts.swap(ref_gauss_pts);
674 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
675 auto &data = fe_ptr->dataOnElement[H1];
676 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 3);
677 double *shape_ptr =
678 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
679 CHKERR ShapeMBTRI(shape_ptr, &fe_ptr->gaussPts(0, 0),
680 &fe_ptr->gaussPts(1, 0), nb_gauss_pts);
682 };
683
684 auto refine_quadrature = [&]() {
686
687 moab::Core moab_ref;
688 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0};
689 EntityHandle nodes[numNodes];
690 for (int nn = 0; nn != numNodes; nn++)
691 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
692 EntityHandle tri;
693 CHKERR moab_ref.create_element(MBTRI, nodes, numNodes, tri);
694 MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
695 MoFEM::Interface &m_field_ref = mofem_ref_core;
696
697 Range ref_tri(tri, tri);
698 Range edges;
699 CHKERR m_field_ref.get_moab().get_adjacencies(ref_tri, 1, true, edges,
700 moab::Interface::UNION);
701 CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevel(
702 ref_tri, BitRefLevel().set(0), false, VERBOSE);
703
704 Range nodes_at_front;
705 for (int nn = 0; nn != numNodes; nn++) {
706 EntityHandle ent;
707 CHKERR moab_ref.side_element(tri, 0, nn, ent);
708 nodes_at_front.insert(ent);
709 }
710
711 EntityHandle meshset;
712 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
713 for (int ee = 0; ee != numEdges; ee++) {
714 EntityHandle ent;
715 CHKERR moab_ref.side_element(tri, 1, ee, ent);
716 CHKERR moab_ref.add_entities(meshset, &ent, 1);
717 }
718
719 // refine mesh
720 auto *m_ref = m_field_ref.getInterface<MeshRefinement>();
721 Range ref_edges;
722 CHKERR m_field_ref.getInterface<BitRefManager>()
723 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(0),
724 BitRefLevel().set(), MBEDGE, ref_edges);
725
726 // Range tris_to_refine;
727 // CHKERR m_field_ref.getInterface<BitRefManager>()
728 // ->getEntitiesByTypeAndRefLevel(
729 // BitRefLevel().set(0), BitRefLevel().set(), MBTRI,
730 // tris_to_refine);
731 CHKERR m_ref->addVerticesInTheMiddleOfEdges(ref_edges,
732 BitRefLevel().set(1));
733 CHKERR m_ref->addVerticesInTheMiddleOfFaces(ref_tri, BitRefLevel().set(1));
734 CHKERR m_ref->refineTris(ref_tri, BitRefLevel().set(1));
735 CHKERR m_field_ref.getInterface<BitRefManager>()
736 ->updateMeshsetByEntitiesChildren(meshset, BitRefLevel().set(1),
737 meshset, MBEDGE, true);
738 CHKERR m_field_ref.getInterface<BitRefManager>()
739 ->updateMeshsetByEntitiesChildren(meshset, BitRefLevel().set(1),
740 meshset, MBTRI, true);
741
742 // get ref coords
743 Range output_ref_tris;
744 CHKERR m_field_ref.getInterface<BitRefManager>()
745 ->getEntitiesByTypeAndRefLevel(
746 BitRefLevel().set(1), BitRefLevel().set(), MBTRI, output_ref_tris);
747
748#ifndef NDEBUG
749 CHKERR save_range(moab_ref, "ref_tris.vtk", output_ref_tris);
750#endif
751
752 MatrixDouble ref_coords(output_ref_tris.size(), 9, false);
753 int tt = 0;
754 for (Range::iterator tit = output_ref_tris.begin();
755 tit != output_ref_tris.end(); tit++, tt++) {
756 int num_nodes;
757 const EntityHandle *conn;
758 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
759 CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
760 }
761
762 auto &data = fe_ptr->dataOnElement[H1];
763 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
764 MatrixDouble ref_gauss_pts(3, nb_gauss_pts * ref_coords.size1());
765 MatrixDouble &shape_n = data->dataOnEntities[MBVERTEX][0].getN(NOBASE);
766 int gg = 0;
767 for (size_t tt = 0; tt != ref_coords.size1(); tt++) {
768 double *tri_coords = &ref_coords(tt, 0);
770 CHKERR Tools::getTriNormal(tri_coords, &t_normal(0));
771 auto det = t_normal.l2();
772 for (size_t ggg = 0; ggg != nb_gauss_pts; ++ggg, ++gg) {
773 for (int dd = 0; dd != 2; dd++) {
774 ref_gauss_pts(dd, gg) = shape_n(ggg, 0) * tri_coords[3 * 0 + dd] +
775 shape_n(ggg, 1) * tri_coords[3 * 1 + dd] +
776 shape_n(ggg, 2) * tri_coords[3 * 2 + dd];
777 }
778 MOFEM_LOG("REMESHING", Sev::noisy)
779 << ref_gauss_pts(0, gg) << ", " << ref_gauss_pts(1, gg);
780 ref_gauss_pts(2, gg) = fe_ptr->gaussPts(2, ggg) * det;
781 }
782 }
783
784 int num_nodes;
785 const EntityHandle *conn;
786 CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
787 true);
788 std::bitset<numNodes> all_nodes;
789 for (auto nn = 0; nn != numNodes; ++nn) {
790 all_nodes.set(nn);
791 }
792
793 mapRefCoords[all_nodes.to_ulong()].swap(ref_gauss_pts);
794 CHKERR set_gauss_pts(mapRefCoords[all_nodes.to_ulong()]);
795
797 };
798
799 CHKERR refine_quadrature();
800
802}
@ 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
Order displacement.
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.

◆ newEls

boost::shared_ptr<Range> SetEnrichedIntegration::newEls
private
Examples
SolutionMapping.hpp.

Definition at line 22 of file SolutionMapping.hpp.


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