v0.9.0
Classes | Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT > Struct Template Reference

#include <users_modules/basic_finite_elements/src/PostProcOnRefMesh.hpp>

Inheritance diagram for PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >:
[legend]
Collaboration diagram for PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >:
[legend]

Classes

struct  OpHdivFunctions
 

Public Types

typedef PostProcTemplateOnRefineMesh< VOLUME_ELEMENT > T
 
typedef PostProcCommonOnRefMesh::CommonDataForVolume CommonData
 

Public Member Functions

 PostProcTemplateVolumeOnRefinedMesh (MoFEM::Interface &m_field, bool ten_nodes_post_proc_tets=true, int nb_ref_levels=-1)
 
virtual ~PostProcTemplateVolumeOnRefinedMesh ()
 
int getRule (int order)
 
virtual PostProcCommonOnRefMesh::CommonDatagetCommonData ()
 
MoFEMErrorCode generateReferenceElementMesh ()
 Generate reference mesh on single element. More...
 
MoFEMErrorCode setGaussPts (int order)
 Set integration points. More...
 
MoFEMErrorCode clearOperators ()
 Clear operators list. More...
 
MoFEMErrorCode preProcess ()
 
MoFEMErrorCode postProcess ()
 
MoFEMErrorCode addHdivFunctionsPostProc (const std::string field_name)
 Add operator to post-process Hdiv field. More...
 
- Public Member Functions inherited from PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >
 PostProcTemplateOnRefineMesh (MoFEM::Interface &m_field)
 
MoFEMErrorCode addFieldValuesPostProc (const std::string field_name, Vec v=PETSC_NULL)
 Add operator to post-process L2, H1, Hdiv, Hcurl field value. More...
 
MoFEMErrorCode addFieldValuesPostProc (const std::string field_name, const std::string tag_name, Vec v=PETSC_NULL)
 Add operator to post-process L2 or H1 field value. More...
 
MoFEMErrorCode addFieldValuesGradientPostProc (const std::string field_name, Vec v=PETSC_NULL)
 Add operator to post-process L2 or H1 field gradient. More...
 
MoFEMErrorCode addFieldValuesGradientPostProc (const std::string field_name, const std::string tag_name, Vec v=PETSC_NULL)
 Add operator to post-process L2 or H1 field gradient. More...
 
MoFEMErrorCode writeFile (const std::string file_name)
 wrote results in (MOAB) format, use "file_name.h5m" More...
 

Public Attributes

bool tenNodesPostProcTets
 
int nbOfRefLevels
 
CommonData commonData
 
- Public Attributes inherited from PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >
moab::Core coreMesh
 
moab::Interface & postProcMesh
 
std::vector< EntityHandlemapGaussPts
 

Private Attributes

std::vector< MatrixDouble > levelShapeFunctions
 
std::vector< MatrixDouble > levelGaussPtsOnRefMesh
 
std::vector< ublas::matrix< int > > levelRefTets
 

Detailed Description

template<class VOLUME_ELEMENT>
struct PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >

Definition at line 249 of file PostProcOnRefMesh.hpp.

Member Typedef Documentation

◆ CommonData

template<class VOLUME_ELEMENT>
typedef PostProcCommonOnRefMesh::CommonDataForVolume PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::CommonData

Definition at line 274 of file PostProcOnRefMesh.hpp.

◆ T

template<class VOLUME_ELEMENT>
typedef PostProcTemplateOnRefineMesh<VOLUME_ELEMENT> PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::T

Definition at line 252 of file PostProcOnRefMesh.hpp.

Constructor & Destructor Documentation

◆ PostProcTemplateVolumeOnRefinedMesh()

template<class VOLUME_ELEMENT>
PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::PostProcTemplateVolumeOnRefinedMesh ( MoFEM::Interface m_field,
bool  ten_nodes_post_proc_tets = true,
int  nb_ref_levels = -1 
)

◆ ~PostProcTemplateVolumeOnRefinedMesh()

template<class VOLUME_ELEMENT>
virtual PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::~PostProcTemplateVolumeOnRefinedMesh ( )
virtual

Definition at line 264 of file PostProcOnRefMesh.hpp.

264  {
265  moab::Interface &moab = T::coreMesh;
266  ParallelComm *pcomm_post_proc_mesh =
267  ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
268  if (pcomm_post_proc_mesh != NULL) {
269  delete pcomm_post_proc_mesh;
270  }
271  }
moab::Core coreMesh
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:285

Member Function Documentation

◆ addHdivFunctionsPostProc()

template<class VOLUME_ELEMENT>
MoFEMErrorCode PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::addHdivFunctionsPostProc ( const std::string  field_name)

Add operator to post-process Hdiv field.

Definition at line 575 of file PostProcOnRefMesh.hpp.

575  {
577  T::getOpPtrVector().push_back(
578  new OpHdivFunctions(T::postProcMesh, T::mapGaussPts, field_name));
580  }
moab::Interface & postProcMesh
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
std::vector< EntityHandle > mapGaussPts

◆ clearOperators()

template<class VOLUME_ELEMENT>
MoFEMErrorCode PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::clearOperators ( )

Clear operators list.

Clear operators list, user can use the same mesh instance to post-process different problem or the same problem with different set of post-processed fields.

Definition at line 521 of file PostProcOnRefMesh.hpp.

521  {
523  T::getOpPtrVector().clear();
525  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508

◆ generateReferenceElementMesh()

template<class VOLUME_ELEMENT>
MoFEMErrorCode PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::generateReferenceElementMesh ( )

Generate reference mesh on single element.

Each element is subdivided on smaller elements, i.e. a reference mesh on single element is created. Nodes of such reference mesh are used as integration points at which field values are calculated and to each node a "moab" tag is attached to store those values.

Definition at line 291 of file PostProcOnRefMesh.hpp.

291  {
293 
294  auto get_nb_of_ref_levels_from_options = [this] {
295  if (nbOfRefLevels == -1) {
296  int max_level = 0;
297  PetscBool flg = PETSC_TRUE;
298  PetscOptionsGetInt(PETSC_NULL, PETSC_NULL,
299  "-my_max_post_proc_ref_level", &max_level, &flg);
300  return max_level;
301  } else {
302  return nbOfRefLevels;
303  }
304  return 0;
305  };
306  const int max_level = get_nb_of_ref_levels_from_options();
307 
308  moab::Core core_ref;
309  moab::Interface &moab_ref = core_ref;
310 
311  auto create_reference_element = [&moab_ref]() {
313  const double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
314  EntityHandle nodes[4];
315  for (int nn = 0; nn < 4; nn++) {
316  CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
317  }
318  EntityHandle tet;
319  CHKERR moab_ref.create_element(MBTET, nodes, 4, tet);
321  };
322 
323  MoFEM::Core m_core_ref(moab_ref, PETSC_COMM_SELF, -2);
324  MoFEM::Interface &m_field_ref = m_core_ref;
325 
326  auto refine_ref_tetrahedron = [this, &m_field_ref, max_level]() {
328  // seed ref mofem database by setting bit ref level to reference
329  // tetrahedron
330  CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevelByDim(
331  0, 3, BitRefLevel().set(0));
332  for (int ll = 0; ll != max_level; ++ll) {
333  PetscPrintf(T::mField.get_comm(), "Refine Level %d\n", ll);
334  Range edges;
335  CHKERR m_field_ref.getInterface<BitRefManager>()
336  ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
337  BitRefLevel().set(), MBEDGE, edges);
338  Range tets;
339  CHKERR m_field_ref.getInterface<BitRefManager>()
340  ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
341  BitRefLevel(ll).set(), MBTET, tets);
342  // refine mesh
343  MeshRefinement *m_ref;
344  CHKERR m_field_ref.getInterface(m_ref);
345  CHKERR m_ref->add_vertices_in_the_middle_of_edges(
346  edges, BitRefLevel().set(ll + 1));
347  CHKERR m_ref->refine_TET(tets, BitRefLevel().set(ll + 1));
348  }
350  };
351 
352  auto get_ref_gauss_pts_and_shape_functions = [this, max_level, &moab_ref,
353  &m_field_ref]() {
355  for (int ll = 0; ll != max_level + 1; ++ll) {
356  Range tets;
357  CHKERR m_field_ref.getInterface<BitRefManager>()
358  ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
359  BitRefLevel().set(ll), MBTET, tets);
360  if (tenNodesPostProcTets) {
361  EntityHandle meshset;
362  CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
363  CHKERR moab_ref.add_entities(meshset, tets);
364  CHKERR moab_ref.convert_entities(meshset, true, false, false);
365  CHKERR moab_ref.delete_entities(&meshset, 1);
366  }
367  Range elem_nodes;
368  CHKERR moab_ref.get_connectivity(tets, elem_nodes, false);
369 
370  auto &gauss_pts = levelGaussPtsOnRefMesh[ll];
371  gauss_pts.resize(elem_nodes.size(), 4, false);
372  std::map<EntityHandle, int> little_map;
373  Range::iterator nit = elem_nodes.begin();
374  for (int gg = 0; nit != elem_nodes.end(); nit++, gg++) {
375  CHKERR moab_ref.get_coords(&*nit, 1, &gauss_pts(gg, 0));
376  little_map[*nit] = gg;
377  }
378  gauss_pts = trans(gauss_pts);
379 
380  auto &ref_tets = levelRefTets[ll];
381  Range::iterator tit = tets.begin();
382  for (int tt = 0; tit != tets.end(); ++tit, ++tt) {
383  const EntityHandle *conn;
384  int num_nodes;
385  CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
386  if (tt == 0) {
387  // Ref tets has number of rows equal to number of tets on element,
388  // columns are number of gauss points
389  ref_tets.resize(tets.size(), num_nodes);
390  }
391  for (int nn = 0; nn != num_nodes; ++nn) {
392  ref_tets(tt, nn) = little_map[conn[nn]];
393  }
394  }
395 
396  auto &shape_functions = levelShapeFunctions[ll];
397  shape_functions.resize(elem_nodes.size(), 4);
398  CHKERR ShapeMBTET(&*shape_functions.data().begin(), &gauss_pts(0, 0),
399  &gauss_pts(1, 0), &gauss_pts(2, 0),
400  elem_nodes.size());
401  }
403  };
404 
405  levelRefTets.resize(max_level + 1);
406  levelGaussPtsOnRefMesh.resize(max_level + 1);
407  levelShapeFunctions.resize(max_level + 1);
408 
409  CHKERR create_reference_element();
410  CHKERR refine_ref_tetrahedron();
411  CHKERR get_ref_gauss_pts_and_shape_functions();
412 
414  }
PetscErrorCode ShapeMBTET(double *N, const double *G_X, const double *G_Y, const double *G_Z, int DIM)
calculate shape functions
Definition: fem_tools.c:318
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
Core (interface) class.
Definition: Core.hpp:50
std::vector< ublas::matrix< int > > levelRefTets
bool tenNodesPostProcTets
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
int nbOfRefLevels
std::vector< MatrixDouble > levelShapeFunctions
std::vector< MatrixDouble > levelGaussPtsOnRefMesh
#define CHKERR
Inline error check.
Definition: definitions.h:596
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ getCommonData()

template<class VOLUME_ELEMENT>
virtual PostProcCommonOnRefMesh::CommonData& PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::getCommonData ( )
virtual

Reimplemented from PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >.

Definition at line 279 of file PostProcOnRefMesh.hpp.

279  {
280  return commonData;
281  }
CommonData commonData

◆ getRule()

template<class VOLUME_ELEMENT>
int PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::getRule ( int  order)

Definition at line 274 of file PostProcOnRefMesh.hpp.

274 { return -1; };

◆ postProcess()

template<class VOLUME_ELEMENT>
MoFEMErrorCode PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::postProcess ( )

Definition at line 539 of file PostProcOnRefMesh.hpp.

539  {
541 
542  moab::Interface &moab = T::coreMesh;
543  ParallelComm *pcomm =
544  ParallelComm::get_pcomm(&T::mField.get_moab(), MYPCOMM_INDEX);
545  ParallelComm *pcomm_post_proc_mesh =
546  ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
547  if (pcomm_post_proc_mesh == NULL) {
548  pcomm_post_proc_mesh = new ParallelComm(&moab, T::mField.get_comm());
549  }
550 
551  Range edges;
552  CHKERR T::postProcMesh.get_entities_by_type(0, MBEDGE, edges, false);
553  CHKERR T::postProcMesh.delete_entities(edges);
554  Range tris;
555  CHKERR T::postProcMesh.get_entities_by_type(0, MBTRI, tris, false);
556  CHKERR T::postProcMesh.delete_entities(tris);
557 
558  Range tets;
559  CHKERR T::postProcMesh.get_entities_by_type(0, MBTET, tets, false);
560 
561  int rank = pcomm->rank();
562  Range::iterator tit = tets.begin();
563  for (; tit != tets.end(); tit++) {
564  CHKERR T::postProcMesh.tag_set_data(pcomm_post_proc_mesh->part_tag(),
565  &*tit, 1, &rank);
566  }
567 
568  CHKERR pcomm_post_proc_mesh->resolve_shared_ents(0);
569 
571  }
moab::Interface & postProcMesh
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
moab::Core coreMesh
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:285

◆ preProcess()

template<class VOLUME_ELEMENT>
MoFEMErrorCode PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::preProcess ( )

Definition at line 527 of file PostProcOnRefMesh.hpp.

527  {
529  moab::Interface &moab = T::coreMesh;
530  ParallelComm *pcomm_post_proc_mesh =
531  ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
532  if (pcomm_post_proc_mesh != NULL) {
533  delete pcomm_post_proc_mesh;
534  }
535  CHKERR T::postProcMesh.delete_mesh();
537  }
moab::Interface & postProcMesh
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
moab::Core coreMesh
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:285

◆ setGaussPts()

template<class VOLUME_ELEMENT>
MoFEMErrorCode PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::setGaussPts ( int  order)

Set integration points.

If reference mesh is generated on single elements. This function maps reference coordinates into physical coordinates and create element on post-processing mesh.

Definition at line 423 of file PostProcOnRefMesh.hpp.

423  {
425 
426  auto get_element_max_dofs_order = [this]() {
427  int max_order = 0;
428  auto &dofs_multi_index = *this->dataPtr;
429  for (auto &dof : dofs_multi_index) {
430  const int dof_order = dof->getDofOrder();
431  max_order = (max_order < dof_order) ? dof_order : max_order;
432  };
433  return max_order;
434  };
435 
436  const int dof_max_order = get_element_max_dofs_order();
437  size_t level = (dof_max_order > 0) ? (dof_max_order - 1) / 2 : 0;
438  if (level > (levelGaussPtsOnRefMesh.size() - 1))
439  level = levelGaussPtsOnRefMesh.size() - 1;
440 
441  auto &level_ref_gauss_pts = levelGaussPtsOnRefMesh[level];
442  auto &level_ref_tets = levelRefTets[level];
443  auto &shape_functions = levelShapeFunctions[level];
444  T::gaussPts.resize(level_ref_gauss_pts.size1(), level_ref_gauss_pts.size2(),
445  false);
446  noalias(T::gaussPts) = level_ref_gauss_pts;
447 
448  ReadUtilIface *iface;
449  CHKERR T::postProcMesh.query_interface(iface);
450 
451  const int num_nodes = level_ref_gauss_pts.size2();
452  std::vector<double *> arrays;
453  EntityHandle startv;
454  CHKERR iface->get_node_coords(3, num_nodes, 0, startv, arrays);
455  T::mapGaussPts.resize(level_ref_gauss_pts.size2());
456  for (int gg = 0; gg != num_nodes; ++gg)
457  T::mapGaussPts[gg] = startv + gg;
458 
459  Tag th;
460  int def_in_the_loop = -1;
461  CHKERR T::postProcMesh.tag_get_handle("NB_IN_THE_LOOP", 1, MB_TYPE_INTEGER,
462  th, MB_TAG_CREAT | MB_TAG_SPARSE,
463  &def_in_the_loop);
464 
465  commonData.tEts.clear();
466  const int num_el = level_ref_tets.size1();
467  const int num_nodes_on_ele = level_ref_tets.size2();
468  EntityHandle starte;
469  EntityHandle *conn;
470  CHKERR iface->get_element_connect(num_el, num_nodes_on_ele, MBTET, 0,
471  starte, conn);
472  for (unsigned int tt = 0; tt != level_ref_tets.size1(); ++tt) {
473  for (int nn = 0; nn != num_nodes_on_ele; ++nn)
474  conn[num_nodes_on_ele * tt + nn] =
475  T::mapGaussPts[level_ref_tets(tt, nn)];
476  }
477  CHKERR iface->update_adjacencies(starte, num_el, num_nodes_on_ele, conn);
478  commonData.tEts = Range(starte, starte + num_el - 1);
479  CHKERR T::postProcMesh.tag_clear_data(th, commonData.tEts,
480  &(T::nInTheLoop));
481 
482  EntityHandle fe_ent = T::numeredEntFiniteElementPtr->getEnt();
483  T::coords.resize(12, false);
484  {
485  const EntityHandle *conn;
486  int num_nodes;
487  T::mField.get_moab().get_connectivity(fe_ent, conn, num_nodes, true);
488  CHKERR T::mField.get_moab().get_coords(conn, num_nodes, &T::coords[0]);
489  }
490 
493  &*shape_functions.data().begin());
495  arrays[0], arrays[1], arrays[2]);
496  const double *t_coords_ele_x = &T::coords[0];
497  const double *t_coords_ele_y = &T::coords[1];
498  const double *t_coords_ele_z = &T::coords[2];
499  for (int gg = 0; gg != num_nodes; ++gg) {
501  t_coords_ele_x, t_coords_ele_y, t_coords_ele_z);
502  t_coords(i) = 0;
503  for (int nn = 0; nn != 4; ++nn) {
504  t_coords(i) += t_n * t_ele_coords(i);
505  ++t_ele_coords;
506  ++t_n;
507  }
508  ++t_coords;
509  }
510 
512  }
CommonData commonData
Range tEts
moab::Interface & postProcMesh
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
std::vector< ublas::matrix< int > > levelRefTets
std::vector< MatrixDouble > levelShapeFunctions
std::vector< MatrixDouble > levelGaussPtsOnRefMesh
#define CHKERR
Inline error check.
Definition: definitions.h:596
std::vector< EntityHandle > mapGaussPts
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

Member Data Documentation

◆ commonData

template<class VOLUME_ELEMENT>
CommonData PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::commonData

Definition at line 277 of file PostProcOnRefMesh.hpp.

◆ levelGaussPtsOnRefMesh

template<class VOLUME_ELEMENT>
std::vector<MatrixDouble> PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::levelGaussPtsOnRefMesh
private

Definition at line 643 of file PostProcOnRefMesh.hpp.

◆ levelRefTets

template<class VOLUME_ELEMENT>
std::vector<ublas::matrix<int> > PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::levelRefTets
private

Definition at line 644 of file PostProcOnRefMesh.hpp.

◆ levelShapeFunctions

template<class VOLUME_ELEMENT>
std::vector<MatrixDouble> PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::levelShapeFunctions
private

Definition at line 642 of file PostProcOnRefMesh.hpp.

◆ nbOfRefLevels

template<class VOLUME_ELEMENT>
int PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::nbOfRefLevels

Definition at line 255 of file PostProcOnRefMesh.hpp.

◆ tenNodesPostProcTets

template<class VOLUME_ELEMENT>
bool PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::tenNodesPostProcTets

Definition at line 254 of file PostProcOnRefMesh.hpp.


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