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

Classes

struct  Fe
 

Public Member Functions

 DGSetIntegration (boost::shared_ptr< Range > edges_ptr, ForcesAndSourcesCore::RuleHookFun fun_rule)
 
MoFEMErrorCode operator() (ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
 

Public Attributes

ForcesAndSourcesCore::RuleHookFun funRule
 

Private Attributes

boost::shared_ptr< RangeedgesPtr
 

Detailed Description

Definition at line 21 of file DGProjection.cpp.

Constructor & Destructor Documentation

◆ DGSetIntegration()

MoFEM::DGSetIntegration::DGSetIntegration ( boost::shared_ptr< Range edges_ptr,
ForcesAndSourcesCore::RuleHookFun  fun_rule 
)
inline

Definition at line 27 of file DGProjection.cpp.

29 : edgesPtr(edges_ptr), funRule(fun_rule) {};
boost::shared_ptr< Range > edgesPtr
ForcesAndSourcesCore::RuleHookFun funRule

Member Function Documentation

◆ operator()()

MoFEMErrorCode MoFEM::DGSetIntegration::operator() ( ForcesAndSourcesCore fe_raw_ptr,
int  order_row,
int  order_col,
int  order_data 
)
inline

Definition at line 31 of file DGProjection.cpp.

32 {
34
35 constexpr bool debug = false;
36
37 constexpr int numNodes = 3;
38 constexpr int numEdges = 3;
39 constexpr int refinementLevels = 1;
40
41 auto &m_field = fe_raw_ptr->mField;
42 auto fe_ptr = static_cast<Fe *>(fe_raw_ptr);
43 auto fe_handle = fe_ptr->getFEEntityHandle();
44 auto type = type_from_handle(fe_handle);
45 if (type != MBTRI) {
46 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
47 "only MBTRI is implemented");
48 }
49
50
51
52 auto set_base_quadrature = [&]() {
54 int rule = funRule(order_row, order_col, order_data);
55 if (rule < QUAD_2D_TABLE_SIZE) {
56 if (QUAD_2D_TABLE[rule]->dim != 2) {
57 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "wrong dimension");
58 }
59 if (QUAD_2D_TABLE[rule]->order < rule) {
60 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
61 "wrong order %d != %d", QUAD_2D_TABLE[rule]->order, rule);
62 }
63 const size_t nb_gauss_pts = QUAD_2D_TABLE[rule]->npoints;
64 fe_ptr->gaussPts.resize(3, nb_gauss_pts, false);
65 cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[1], 3,
66 &fe_ptr->gaussPts(0, 0), 1);
67 cblas_dcopy(nb_gauss_pts, &QUAD_2D_TABLE[rule]->points[2], 3,
68 &fe_ptr->gaussPts(1, 0), 1);
69 cblas_dcopy(nb_gauss_pts, QUAD_2D_TABLE[rule]->weights, 1,
70 &fe_ptr->gaussPts(2, 0), 1);
71 auto &data = fe_ptr->dataOnElement[H1];
72 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 3,
73 false);
74 double *shape_ptr =
75 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
76 cblas_dcopy(3 * nb_gauss_pts, QUAD_2D_TABLE[rule]->points, 1, shape_ptr,
77 1);
78 data->dataOnEntities[MBVERTEX][0].getDiffN(NOBASE).resize(3, 2, false);
79 std::copy(
81 data->dataOnEntities[MBVERTEX][0].getDiffN(NOBASE).data().begin());
82
83 } else {
84 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
85 "rule > quadrature order %d < %d", rule, QUAD_3D_TABLE_SIZE);
86 }
88 };
89
90 CHKERR set_base_quadrature();
91
92 if (edgesPtr) {
93
94 auto get_edges = [&]() {
95 std::bitset<numEdges> edges;
96 for (int ee = 0; ee != numEdges; ee++) {
97 EntityHandle edge;
98 CHKERR m_field.get_moab().side_element(fe_handle, 1, ee, edge);
99 if (edgesPtr->find(edge) != edgesPtr->end()) {
100 edges.set(ee);
101 } else {
102 edges.reset(ee);
103 }
104 }
105 return edges;
106 };
107
108 auto refine_quadrature = [&]() {
110
111 const int max_level = refinementLevels;
112
113 moab::Core moab_ref;
114 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0};
115 EntityHandle nodes[numNodes];
116 for (int nn = 0; nn != numNodes; nn++)
117 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
118 EntityHandle tri;
119 CHKERR moab_ref.create_element(MBTRI, nodes, numNodes, tri);
120 MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
121 MoFEM::Interface &m_field_ref = mofem_ref_core;
122 {
123 Range tris(tri, tri);
124 Range edges;
125 CHKERR m_field_ref.get_moab().get_adjacencies(tris, 1, true, edges,
126 moab::Interface::UNION);
127 CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevel(
128 tris, BitRefLevel().set(0), false, VERBOSE);
129 }
130
131 auto edges = get_edges();
132
133 EntityHandle meshset;
134 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
135 for (int ee = 0; ee != numEdges; ee++) {
136 if (edges[ee]) {
137 EntityHandle ent;
138 CHKERR moab_ref.side_element(tri, 1, ee, ent);
139 CHKERR moab_ref.add_entities(meshset, &ent, 1);
140 }
141 }
142
143 // refine mesh
144 auto *m_ref = m_field_ref.getInterface<MeshRefinement>();
145 for (int ll = 0; ll != max_level; ll++) {
146 Range ref_edges;
147 CHKERR moab_ref.get_entities_by_type(meshset, MBEDGE, ref_edges,
148 true);
149 CHKERR m_field_ref.getInterface<BitRefManager>()
150 ->filterEntitiesByRefLevel(BitRefLevel().set(ll),
151 BitRefLevel().set(), ref_edges);
152
153 Range tris;
154 CHKERR m_field_ref.getInterface<BitRefManager>()
155 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
156 BitRefLevel().set(), MBTRI, tris);
157 CHKERR m_ref->addVerticesInTheMiddleOfEdges(
158 ref_edges, BitRefLevel().set(ll + 1));
159 CHKERR m_ref->refineTris(tris, BitRefLevel().set(ll + 1));
160 CHKERR m_field_ref.getInterface<BitRefManager>()
161 ->updateMeshsetByEntitiesChildren(
162 meshset, BitRefLevel().set(ll + 1), meshset, MBEDGE, true);
163 }
164
165 // get ref coords
166 Range tris;
167 CHKERR m_field_ref.getInterface<BitRefManager>()
168 ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(max_level),
169 BitRefLevel().set(), MBTRI, tris);
170
171 if (debug) {
172 CHKERR dg_save_range(moab_ref, "ref_tris.vtk", tris);
173 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "debug");
174 }
175
176 MatrixDouble ref_coords(tris.size(), 9, false);
177 int tt = 0;
178 for (Range::iterator tit = tris.begin(); tit != tris.end();
179 tit++, tt++) {
180 int num_nodes;
181 const EntityHandle *conn;
182 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
183 CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
184 }
185
186 auto &data = fe_ptr->dataOnElement[H1];
187 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
188 MatrixDouble ref_gauss_pts(3, nb_gauss_pts * ref_coords.size1());
189 MatrixDouble &shape_n = data->dataOnEntities[MBVERTEX][0].getN(NOBASE);
190 int gg = 0;
191 for (size_t tt = 0; tt != ref_coords.size1(); tt++) {
192 double *tri_coords = &ref_coords(tt, 0);
194 CHKERR Tools::getTriNormal(tri_coords, &t_normal(0));
195 auto det = t_normal.l2();
196 for (size_t ggg = 0; ggg != nb_gauss_pts; ++ggg, ++gg) {
197 for (int dd = 0; dd != 2; dd++) {
198 ref_gauss_pts(dd, gg) = shape_n(ggg, 0) * tri_coords[3 * 0 + dd] +
199 shape_n(ggg, 1) * tri_coords[3 * 1 + dd] +
200 shape_n(ggg, 2) * tri_coords[3 * 2 + dd];
201 }
202 ref_gauss_pts(2, gg) = fe_ptr->gaussPts(2, ggg) * det;
203 }
204 }
205
207 };
208
209 CHKERR refine_quadrature();
210 }
211
213 }
std::string type
@ 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
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
constexpr int order
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
UBlasMatrix< double > MatrixDouble
Definition Types.hpp:77
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
auto type_from_handle(const EntityHandle h)
get type from entity handle
static const bool debug
static auto dg_save_range(moab::Interface &moab, const std::string name, const Range r, std::vector< Tag > tags={})
#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
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
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

Member Data Documentation

◆ edgesPtr

boost::shared_ptr<Range> MoFEM::DGSetIntegration::edgesPtr
private

Definition at line 223 of file DGProjection.cpp.

◆ funRule

ForcesAndSourcesCore::RuleHookFun MoFEM::DGSetIntegration::funRule
Initial value:
= [](int, int, int p) {
return 2 * (p + 1);
}

Definition at line 23 of file DGProjection.cpp.

23 {
24 return 2 * (p + 1);
25 };

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