261 {
263
265
266 moab::Core core_ref;
267 moab::Interface &moab_ref = core_ref;
268
269 auto create_reference_element = [&moab_ref]() {
271 constexpr double base_coords[] = {
272
273 0, 0,
274 0,
275
276 1, 0,
277 0,
278
279 0, 1,
280 0
281
282 };
284 for (int nn = 0; nn != 3; ++nn)
285 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
287 CHKERR moab_ref.create_element(MBTRI, nodes, 3, tri);
288
290 CHKERR moab_ref.get_adjacencies(&tri, 1, 1,
true, edges,
291 moab::Interface::UNION);
292
294 };
295
296 CHKERR create_reference_element();
297
300
301 auto refine_ref_triangles = [this, &m_field_ref, max_level]() {
303
304
306 m_field_ref.
getInterface<BitRefManager>()->setBitRefLevelByDim(
308
309 for (int ll = 0; ll != max_level; ++ll) {
311 ll);
314 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
318 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
320
321 auto m_ref = m_field_ref.
getInterface<MeshRefinement>();
322 CHKERR m_ref->addVerticesInTheMiddleOfEdges(edges,
325 }
327 };
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347 auto get_ref_gauss_pts_and_shape_functions = [this, max_level, &moab_ref,
348 &m_field_ref]() {
350 for (int ll = 0; ll != max_level + 1; ++ll) {
351
354 m_field_ref.
getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
356
359 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
360 CHKERR moab_ref.add_entities(meshset, tris);
361 CHKERR moab_ref.convert_entities(meshset,
true,
false,
false);
362 CHKERR moab_ref.delete_entities(&meshset, 1);
363 }
364
366 CHKERR moab_ref.get_connectivity(tris, elem_nodes,
false);
367
369 gauss_pts.resize(elem_nodes.size(), 3, false);
370 std::map<EntityHandle, int> little_map;
371 Range::iterator nit = elem_nodes.begin();
372 for (int gg = 0; nit != elem_nodes.end(); nit++, gg++) {
373 CHKERR moab_ref.get_coords(&*nit, 1, &gauss_pts(gg, 0));
374 little_map[*nit] = gg;
375 }
376 gauss_pts = trans(gauss_pts);
377
379 Range::iterator tit = tris.begin();
380 for (int tt = 0; tit != tris.end(); ++tit, ++tt) {
382 int num_nodes;
383 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes,
false);
384 if (tt == 0) {
385 ref_tris.resize(tris.size(), num_nodes);
386 }
387 for (int nn = 0; nn != num_nodes; ++nn) {
388 ref_tris(tt, nn) = little_map[conn[nn]];
389 }
390 }
391
393 shape_functions.resize(elem_nodes.size(), 3);
395 &gauss_pts(1, 0), elem_nodes.size());
396 }
398 };
399
403
404 CHKERR refine_ref_triangles();
405 CHKERR get_ref_gauss_pts_and_shape_functions();
406
408}
#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 getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.