261 {
263
266
267 moab::Core core_ref;
268 moab::Interface &moab_ref = core_ref;
269
270 auto create_reference_element = [&moab_ref]() {
272 constexpr double base_coords[] = {
273
274 0, 0,
275 0,
276
277 1, 0,
278 0,
279
280 0, 1,
281 0
282
283 };
285 for (int nn = 0; nn != 3; ++nn)
286 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
288 CHKERR moab_ref.create_element(MBTRI, nodes, 3, tri);
289
291 CHKERR moab_ref.get_adjacencies(&tri, 1, 1,
true, edges,
292 moab::Interface::UNION);
293
295 };
296
297 CHKERR create_reference_element();
298
301
302 auto refine_ref_triangles = [this, &m_field_ref, max_level]() {
304
305
307 m_field_ref.
getInterface<BitRefManager>()->setBitRefLevelByDim(
309
310 for (int ll = 0; ll != max_level; ++ll) {
312 ll);
315 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
319 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
321
322 auto m_ref = m_field_ref.
getInterface<MeshRefinement>();
323 CHKERR m_ref->addVerticesInTheMiddleOfEdges(edges,
326 }
328 };
329
330 auto set_gauss_pts = [&](std::map<EntityHandle, int> &little_map) {
333 CHKERR moab_ref.get_entities_by_type(0, MBTRI, faces,
true);
335 CHKERR moab_ref.get_connectivity(faces, faces_nodes,
false);
337 gauss_pts.resize(faces_nodes.size(), 4, false);
338 size_t gg = 0;
339 for (auto node : faces_nodes) {
340 CHKERR moab_ref.get_coords(&node, 1, &gauss_pts(gg, 0));
341 little_map[node] = gg;
342 ++gg;
343 }
344 gauss_pts = trans(gauss_pts);
346 };
347
348 auto get_ref_gauss_pts_and_shape_functions = [this, max_level, &moab_ref,
349 &m_field_ref]() {
351 for (int ll = 0; ll != max_level + 1; ++ll) {
352
355 m_field_ref.
getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
357
360 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
361 CHKERR moab_ref.add_entities(meshset, tris);
362 CHKERR moab_ref.convert_entities(meshset,
true,
false,
false);
363 CHKERR moab_ref.delete_entities(&meshset, 1);
364 }
365
367 CHKERR moab_ref.get_connectivity(tris, elem_nodes,
false);
368
370 gauss_pts.resize(elem_nodes.size(), 3, false);
371 std::map<EntityHandle, int> little_map;
372 Range::iterator nit = elem_nodes.begin();
373 for (int gg = 0; nit != elem_nodes.end(); nit++, gg++) {
374 CHKERR moab_ref.get_coords(&*nit, 1, &gauss_pts(gg, 0));
375 little_map[*nit] = gg;
376 }
377 gauss_pts = trans(gauss_pts);
378
380 Range::iterator tit = tris.begin();
381 for (int tt = 0; tit != tris.end(); ++tit, ++tt) {
383 int num_nodes;
384 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes,
false);
385 if (tt == 0) {
386 ref_tris.resize(tris.size(), num_nodes);
387 }
388 for (int nn = 0; nn != num_nodes; ++nn) {
389 ref_tris(tt, nn) = little_map[conn[nn]];
390 }
391 }
392
394 shape_functions.resize(elem_nodes.size(), 3);
396 &gauss_pts(1, 0), elem_nodes.size());
397 }
399 };
400
404
405 CHKERR refine_ref_triangles();
406 CHKERR get_ref_gauss_pts_and_shape_functions();
407
409}
#define MOFEM_TAG_AND_LOG_C(channel, severity, tag, format,...)
Tag and log in channel.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Deprecated interface functions.
std::vector< ublas::matrix< int > > levelRef
std::vector< MatrixDouble > levelShapeFunctions
std::vector< MatrixDouble > levelGaussPtsOnRefMesh
MoFEMErrorCode getOptions()
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.