259 {
261
263
264 moab::Core core_ref;
265 moab::Interface &moab_ref = core_ref;
266
267 auto create_reference_element = [&moab_ref]() {
269 constexpr double base_coords[] = {
270
271 0, 0,
272 0,
273
274 1, 0,
275 0,
276
277 0, 1,
278 0
279
280 };
282 for (int nn = 0; nn != 3; ++nn)
283 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
285 CHKERR moab_ref.create_element(MBTRI, nodes, 3, tri);
286
288 CHKERR moab_ref.get_adjacencies(&tri, 1, 1,
true, edges,
289 moab::Interface::UNION);
290
292 };
293
294 CHKERR create_reference_element();
295
298
299 auto refine_ref_triangles = [this, &m_field_ref, max_level]() {
301
302
304 m_field_ref.
getInterface<BitRefManager>()->setBitRefLevelByDim(
306
307 for (int ll = 0; ll != max_level; ++ll) {
309 ll);
312 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
316 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
318
319 auto m_ref = m_field_ref.
getInterface<MeshRefinement>();
320 CHKERR m_ref->addVerticesInTheMiddleOfEdges(edges,
323 }
325 };
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345 auto get_ref_gauss_pts_and_shape_functions = [this, max_level, &moab_ref,
346 &m_field_ref]() {
348 for (int ll = 0; ll != max_level + 1; ++ll) {
349
352 m_field_ref.
getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
354
357 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
358 CHKERR moab_ref.add_entities(meshset, tris);
359 CHKERR moab_ref.convert_entities(meshset,
true,
false,
false);
360 CHKERR moab_ref.delete_entities(&meshset, 1);
361 }
362
364 CHKERR moab_ref.get_connectivity(tris, elem_nodes,
false);
365
367 gauss_pts.resize(elem_nodes.size(), 3, false);
368 std::map<EntityHandle, int> little_map;
369 Range::iterator nit = elem_nodes.begin();
370 for (int gg = 0; nit != elem_nodes.end(); nit++, gg++) {
371 CHKERR moab_ref.get_coords(&*nit, 1, &gauss_pts(gg, 0));
372 little_map[*nit] = gg;
373 }
374 gauss_pts = trans(gauss_pts);
375
377 Range::iterator tit = tris.begin();
378 for (int tt = 0; tit != tris.end(); ++tit, ++tt) {
380 int num_nodes;
381 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes,
false);
382 if (tt == 0) {
383 ref_tris.resize(tris.size(), num_nodes);
384 }
385 for (int nn = 0; nn != num_nodes; ++nn) {
386 ref_tris(tt, nn) = little_map[conn[nn]];
387 }
388 }
389
391 shape_functions.resize(elem_nodes.size(), 3);
393 &gauss_pts(1, 0), elem_nodes.size());
394 }
396 };
397
401
402 CHKERR refine_ref_triangles();
403 CHKERR get_ref_gauss_pts_and_shape_functions();
404
406}
#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 refernce to pointer of interface.