v0.14.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)
 
int getRule (int order)
 
virtual PostProcCommonOnRefMesh::CommonDatagetCommonData ()
 
MoFEMErrorCode generateReferenceElementMesh ()
 Generate reference mesh on single element. More...
 
size_t getMaxLevel () const
 
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)
 
virtual ~PostProcTemplateOnRefineMesh ()
 
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 addFieldValuesGradientPostProc (const std::string field_name, int space_dim, Vec v=PETSC_NULL)
 Add operator to post-process L2 or H1 field gradient. More...
 
MoFEMErrorCode writeFile (const std::string file_name, const char *file_type="MOAB", const char *file_options="PARALLEL=WRITE_PART")
 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
 
boost::shared_ptr< WrapMPIComm > wrapRefMeshComm
 
std::vector< EntityHandlemapGaussPts
 

Private Attributes

std::vector< MatrixDouble > levelShapeFunctionsTets
 
std::vector< MatrixDouble > levelGaussPtsOnRefMeshTets
 
std::vector< ublas::matrix< int > > levelRefTets
 
std::vector< MatrixDouble > levelShapeFunctionsHexes
 
std::vector< MatrixDouble > levelGaussPtsOnRefMeshHexes
 
std::vector< ublas::matrix< int > > levelRefHexes
 
EntityHandle startingVertTetHandle
 
std::vector< double * > verticesOnTetArrays
 
EntityHandle startingEleTetHandle
 
EntityHandletetConn
 
int countTet
 
int countVertTet
 
EntityHandle startingVertHexHandle
 
std::vector< double * > verticesOnHexArrays
 
EntityHandle startingEleHexHandle
 
EntityHandlehexConn
 
int countHex
 
int countVertHex
 

Detailed Description

template<class VOLUME_ELEMENT>
struct PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >

Definition at line 268 of file PostProcOnRefMesh.hpp.

Member Typedef Documentation

◆ CommonData

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

Definition at line 284 of file PostProcOnRefMesh.hpp.

◆ T

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

Definition at line 271 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 
)
inline

Definition at line 276 of file PostProcOnRefMesh.hpp.

280  tenNodesPostProcTets(ten_nodes_post_proc_tets),

Member Function Documentation

◆ addHdivFunctionsPostProc()

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

Add operator to post-process Hdiv field.

Definition at line 863 of file PostProcOnRefMesh.hpp.

863  {
865  T::getOpPtrVector().push_back(
866  new OpHdivFunctions(T::postProcMesh, T::mapGaussPts, field_name));
868  }

◆ clearOperators()

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

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 690 of file PostProcOnRefMesh.hpp.

690  {
692  T::getOpPtrVector().clear();
694  }

◆ generateReferenceElementMesh()

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

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 301 of file PostProcOnRefMesh.hpp.

301  {
303 
304  auto get_nb_of_ref_levels_from_options = [this] {
305  if (nbOfRefLevels == -1) {
306  int max_level = 0;
307  PetscBool flg = PETSC_TRUE;
308  PetscOptionsGetInt(PETSC_NULL, PETSC_NULL,
309  "-my_max_post_proc_ref_level", &max_level, &flg);
310  return max_level;
311  } else {
312  return nbOfRefLevels;
313  }
314  return 0;
315  };
316 
317  auto generate_for_hex = [&]() {
319 
320  moab::Core core_ref;
321  moab::Interface &moab_ref = core_ref;
322 
323  auto create_reference_element = [&moab_ref]() {
325  constexpr double base_coords[] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0,
326  0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1};
327  EntityHandle nodes[8];
328  for (int nn = 0; nn < 8; nn++)
329  CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
330  EntityHandle hex;
331  CHKERR moab_ref.create_element(MBHEX, nodes, 8, hex);
333  };
334 
335  auto add_ho_nodes = [&]() {
337  Range hexes;
338  CHKERR moab_ref.get_entities_by_type(0, MBHEX, hexes, true);
339  EntityHandle meshset;
340  CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
341  CHKERR moab_ref.add_entities(meshset, hexes);
342  CHKERR moab_ref.convert_entities(meshset, true, true, true);
343  CHKERR moab_ref.delete_entities(&meshset, 1);
345  };
346 
347  auto set_gauss_pts = [&](std::map<EntityHandle, int> &little_map) {
349  Range hexes;
350  CHKERR moab_ref.get_entities_by_type(0, MBHEX, hexes, true);
351  Range hexes_nodes;
352  CHKERR moab_ref.get_connectivity(hexes, hexes_nodes, false);
353  auto &gauss_pts = levelGaussPtsOnRefMeshHexes[0];
354  gauss_pts.resize(hexes_nodes.size(), 4, false);
355  size_t gg = 0;
356  for (auto node : hexes_nodes) {
357  CHKERR moab_ref.get_coords(&node, 1, &gauss_pts(gg, 0));
358  little_map[node] = gg;
359  ++gg;
360  }
361  gauss_pts = trans(gauss_pts);
363  };
364 
365  auto set_ref_hexes = [&](std::map<EntityHandle, int> &little_map) {
367  Range hexes;
368  CHKERR moab_ref.get_entities_by_type(0, MBHEX, hexes, true);
369  size_t hh = 0;
370  auto &ref_hexes = levelRefHexes[0];
371  for (auto hex : hexes) {
372  const EntityHandle *conn;
373  int num_nodes;
374  CHKERR moab_ref.get_connectivity(hex, conn, num_nodes, false);
375  if (ref_hexes.size2() != num_nodes) {
376  ref_hexes.resize(hexes.size(), num_nodes);
377  }
378  for (int nn = 0; nn != num_nodes; ++nn) {
379  ref_hexes(hh, nn) = little_map[conn[nn]];
380  }
381  ++hh;
382  }
384  };
385 
386  auto set_shape_functions = [&]() {
388  auto &gauss_pts = levelGaussPtsOnRefMeshHexes[0];
389  auto &shape_functions = levelShapeFunctionsHexes[0];
390  const auto nb_gauss_pts = gauss_pts.size2();
391  shape_functions.resize(nb_gauss_pts, 8);
392  for (int gg = 0; gg != nb_gauss_pts; ++gg) {
393  const double ksi = gauss_pts(0, gg);
394  const double zeta = gauss_pts(1, gg);
395  const double eta = gauss_pts(2, gg);
396  shape_functions(gg, 0) = N_MBHEX0(ksi, zeta, eta);
397  shape_functions(gg, 1) = N_MBHEX1(ksi, zeta, eta);
398  shape_functions(gg, 2) = N_MBHEX2(ksi, zeta, eta);
399  shape_functions(gg, 3) = N_MBHEX3(ksi, zeta, eta);
400  shape_functions(gg, 4) = N_MBHEX4(ksi, zeta, eta);
401  shape_functions(gg, 5) = N_MBHEX5(ksi, zeta, eta);
402  shape_functions(gg, 6) = N_MBHEX6(ksi, zeta, eta);
403  shape_functions(gg, 7) = N_MBHEX7(ksi, zeta, eta);
404  }
406  };
407 
408  levelRefHexes.resize(1);
409  levelGaussPtsOnRefMeshHexes.resize(1);
410  levelShapeFunctionsHexes.resize(1);
411 
412  CHKERR create_reference_element();
414  CHKERR add_ho_nodes();
415  std::map<EntityHandle, int> little_map;
416  CHKERR set_gauss_pts(little_map);
417  CHKERR set_ref_hexes(little_map);
418  CHKERR set_shape_functions();
419 
421  };
422 
423  auto generate_for_tet = [&]() {
425 
426  const int max_level = get_nb_of_ref_levels_from_options();
427 
428  moab::Core core_ref;
429  moab::Interface &moab_ref = core_ref;
430 
431  auto create_reference_element = [&moab_ref]() {
433  constexpr double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
434  EntityHandle nodes[4];
435  for (int nn = 0; nn < 4; nn++) {
436  CHKERR
437  moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
438  }
439  EntityHandle tet;
440  CHKERR moab_ref.create_element(MBTET, nodes, 4, tet);
442  };
443 
444  MoFEM::CoreTmp<-1> m_core_ref(moab_ref, PETSC_COMM_SELF, -2);
445  MoFEM::Interface &m_field_ref = m_core_ref;
446 
447  auto refine_ref_tetrahedron = [this, &m_field_ref, max_level]() {
449  // seed ref mofem database by setting bit ref level to reference
450  // tetrahedron
451  CHKERR
452  m_field_ref.getInterface<BitRefManager>()->setBitRefLevelByDim(
453  0, 3, BitRefLevel().set(0));
454  for (int ll = 0; ll != max_level; ++ll) {
455  MOFEM_TAG_AND_LOG_C("WORLD", Sev::verbose, "PostProc",
456  "Refine Level %d", ll);
457  Range edges;
458  CHKERR m_field_ref.getInterface<BitRefManager>()
459  ->getEntitiesByTypeAndRefLevel(
460  BitRefLevel().set(ll), BitRefLevel().set(), MBEDGE, edges);
461  Range tets;
462  CHKERR m_field_ref.getInterface<BitRefManager>()
463  ->getEntitiesByTypeAndRefLevel(
464  BitRefLevel().set(ll), BitRefLevel(ll).set(), MBTET, tets);
465  // refine mesh
466  MeshRefinement *m_ref;
467  CHKERR m_field_ref.getInterface(m_ref);
468  CHKERR m_ref->addVerticesInTheMiddleOfEdges(
469  edges, BitRefLevel().set(ll + 1));
470  CHKERR m_ref->refineTets(tets, BitRefLevel().set(ll + 1));
471  }
473  };
474 
475  auto get_ref_gauss_pts_and_shape_functions = [this, max_level, &moab_ref,
476  &m_field_ref]() {
478  for (int ll = 0; ll != max_level + 1; ++ll) {
479  Range tets;
480  CHKERR
481  m_field_ref.getInterface<BitRefManager>()
482  ->getEntitiesByTypeAndRefLevel(
483  BitRefLevel().set(ll), BitRefLevel().set(ll), MBTET, tets);
484  if (tenNodesPostProcTets) {
485  EntityHandle meshset;
486  CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
487  CHKERR moab_ref.add_entities(meshset, tets);
488  CHKERR moab_ref.convert_entities(meshset, true, false, false);
489  CHKERR moab_ref.delete_entities(&meshset, 1);
490  }
491  Range elem_nodes;
492  CHKERR moab_ref.get_connectivity(tets, elem_nodes, false);
493 
494  auto &gauss_pts = levelGaussPtsOnRefMeshTets[ll];
495  gauss_pts.resize(elem_nodes.size(), 4, false);
496  std::map<EntityHandle, int> little_map;
497  Range::iterator nit = elem_nodes.begin();
498  for (int gg = 0; nit != elem_nodes.end(); nit++, gg++) {
499  CHKERR moab_ref.get_coords(&*nit, 1, &gauss_pts(gg, 0));
500  little_map[*nit] = gg;
501  }
502  gauss_pts = trans(gauss_pts);
503 
504  auto &ref_tets = levelRefTets[ll];
505  Range::iterator tit = tets.begin();
506  for (int tt = 0; tit != tets.end(); ++tit, ++tt) {
507  const EntityHandle *conn;
508  int num_nodes;
509  CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
510  if (tt == 0) {
511  ref_tets.resize(tets.size(), num_nodes);
512  }
513  for (int nn = 0; nn != num_nodes; ++nn) {
514  ref_tets(tt, nn) = little_map[conn[nn]];
515  }
516  }
517 
518  auto &shape_functions = levelShapeFunctionsTets[ll];
519  shape_functions.resize(elem_nodes.size(), 4);
520  CHKERR ShapeMBTET(&*shape_functions.data().begin(), &gauss_pts(0, 0),
521  &gauss_pts(1, 0), &gauss_pts(2, 0),
522  elem_nodes.size());
523  }
525  };
526 
527  levelRefTets.resize(max_level + 1);
528  levelGaussPtsOnRefMeshTets.resize(max_level + 1);
529  levelShapeFunctionsTets.resize(max_level + 1);
530 
531  CHKERR create_reference_element();
532  CHKERR refine_ref_tetrahedron();
533  CHKERR get_ref_gauss_pts_and_shape_functions();
534 
536  };
537 
538  CHKERR generate_for_hex();
539  CHKERR generate_for_tet();
540 
542  }

◆ getCommonData()

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

Reimplemented from PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >.

Definition at line 289 of file PostProcOnRefMesh.hpp.

289  {
290  return commonData;
291  }

◆ getMaxLevel()

template<class VOLUME_ELEMENT >
size_t PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::getMaxLevel ( ) const
inline

Definition at line 544 of file PostProcOnRefMesh.hpp.

544  {
545  auto get_element_max_dofs_order = [&]() {
546  int max_order = 0;
547  auto dofs_vec = this->getDataVectorDofsPtr();
548  for (auto &dof : *dofs_vec) {
549  const int dof_order = dof->getDofOrder();
550  max_order = (max_order < dof_order) ? dof_order : max_order;
551  };
552  return max_order;
553  };
554  const auto dof_max_order = get_element_max_dofs_order();
555  return (dof_max_order > 0) ? (dof_max_order - 1) / 2 : 0;
556  };

◆ getRule()

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

Definition at line 284 of file PostProcOnRefMesh.hpp.

284 { return -1; };

◆ postProcess()

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

Definition at line 797 of file PostProcOnRefMesh.hpp.

797  {
799 
800  auto update_elements = [&]() {
802  ReadUtilIface *iface;
803  CHKERR this->postProcMesh.query_interface(iface);
804 
805  if (countTet) {
806  MOFEM_TAG_AND_LOG("SELF", Sev::noisy, "PostProc")
807  << "Update tets " << countTet;
808 
809  MOFEM_TAG_AND_LOG("SELF", Sev::noisy, "PostProc")
810  << "Nb nodes on tets " << levelRefTets[0].size2();
811 
812  CHKERR iface->update_adjacencies(startingEleTetHandle, countTet,
813  levelRefTets[0].size2(), tetConn);
814  }
815  if (countHex) {
816  MOFEM_TAG_AND_LOG("SELF", Sev::noisy, "PostProc")
817  << "Update hexes " << countHex;
818  CHKERR iface->update_adjacencies(startingEleHexHandle, countHex,
819  levelRefHexes[0].size2(), hexConn);
820  }
822  };
823 
824  auto resolve_shared_ents = [&]() {
826  ParallelComm *pcomm_post_proc_mesh =
827  ParallelComm::get_pcomm(&(T::postProcMesh), MYPCOMM_INDEX);
828  if (pcomm_post_proc_mesh == NULL) {
829  // T::wrapRefMeshComm =
830  // boost::make_shared<WrapMPIComm>(T::mField.get_comm(), false);
831  pcomm_post_proc_mesh = new ParallelComm(
832  &(T::postProcMesh),
833  PETSC_COMM_WORLD /*(T::wrapRefMeshComm)->get_comm()*/);
834  }
835 
836  Range edges;
837  CHKERR T::postProcMesh.get_entities_by_type(0, MBEDGE, edges, false);
838  CHKERR T::postProcMesh.delete_entities(edges);
839  Range faces;
840  CHKERR T::postProcMesh.get_entities_by_dimension(0, 2, faces, false);
841  CHKERR T::postProcMesh.delete_entities(faces);
842 
843  Range ents;
844  CHKERR T::postProcMesh.get_entities_by_dimension(0, 3, ents, false);
845 
846  int rank = T::mField.get_comm_rank();
847  CHKERR T::postProcMesh.tag_clear_data(pcomm_post_proc_mesh->part_tag(),
848  ents, &rank);
849 
850  CHKERR pcomm_post_proc_mesh->resolve_shared_ents(0);
851 
853  };
854 
855  CHKERR resolve_shared_ents();
856  CHKERR update_elements();
857 
859  }

◆ preProcess()

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

Definition at line 696 of file PostProcOnRefMesh.hpp.

696  {
699  ParallelComm *pcomm_post_proc_mesh =
700  ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
701  if (pcomm_post_proc_mesh != NULL)
702  delete pcomm_post_proc_mesh;
703 
704  CHKERR T::postProcMesh.delete_mesh();
705 
706  auto alloc_vertices_and_elements_on_post_proc_mesh = [&]() {
708 
709  auto fe_ptr = this->problemPtr->numeredFiniteElementsPtr;
710 
711  auto miit =
712  fe_ptr->template get<Composite_Name_And_Part_mi_tag>().lower_bound(
713  boost::make_tuple(this->getFEName(), this->getLoFERank()));
714  auto hi_miit =
715  fe_ptr->template get<Composite_Name_And_Part_mi_tag>().upper_bound(
716  boost::make_tuple(this->getFEName(), this->getHiFERank()));
717 
718  const int number_of_ents_in_the_loop = this->getLoopSize();
719  if (std::distance(miit, hi_miit) != number_of_ents_in_the_loop) {
720  SETERRQ(this->mField.get_comm(), MOFEM_DATA_INCONSISTENCY,
721  "Wrong size of indicices. Inconsistent size number of iterated "
722  "elements iterated by problem and from range.");
723  }
724 
725  int nb_tet_vertices = 0;
726  int nb_tets = 0;
727  int nb_hex_vertices = 0;
728  int nb_hexes = 0;
729 
730  for (; miit != hi_miit; ++miit) {
731  auto type = (*miit)->getEntType();
732 
733  // Set pointer to element. So that getDataVectorDofsPtr in getMaxLevel
734  // can work
735  this->numeredEntFiniteElementPtr = *miit;
736 
737  bool add = true;
738  if (this->exeTestHook) {
739  add = this->exeTestHook(this);
740  }
741 
742  if (add) {
743 
744  auto level = getMaxLevel();
745 
746  switch (type) {
747  case MBTET:
748  level = std::min(level, levelGaussPtsOnRefMeshTets.size() - 1);
749  nb_tet_vertices += levelGaussPtsOnRefMeshTets[level].size2();
750  nb_tets += levelRefTets[level].size1();
751  break;
752  case MBHEX:
753  level = std::min(level, levelGaussPtsOnRefMeshHexes.size() - 1);
754  nb_hex_vertices += levelGaussPtsOnRefMeshHexes[level].size2();
755  nb_hexes += levelRefHexes[level].size1();
756  break;
757  default:
758  SETERRQ(this->mField.get_comm(), MOFEM_DATA_INCONSISTENCY,
759  "Element type not implemented");
760  break;
761  }
762  }
763  }
764 
765  ReadUtilIface *iface;
766  CHKERR this->postProcMesh.query_interface(iface);
767 
768  if (nb_tets) {
769  CHKERR iface->get_node_coords(
770  3, nb_tet_vertices, 0, startingVertTetHandle, verticesOnTetArrays);
771  CHKERR iface->get_element_connect(nb_tets, levelRefTets[0].size2(),
772  MBTET, 0, startingEleTetHandle,
773  tetConn);
774  }
775 
776  if (nb_hexes) {
777  CHKERR iface->get_node_coords(
778  3, nb_hex_vertices, 0, startingVertHexHandle, verticesOnHexArrays);
779  CHKERR iface->get_element_connect(nb_hexes, levelRefHexes[0].size2(),
780  MBHEX, 0, startingEleHexHandle,
781  hexConn);
782  }
783 
784  countTet = 0;
785  countVertTet = 0;
786  countHex = 0;
787  countVertHex = 0;
788 
790  };
791 
792  CHKERR alloc_vertices_and_elements_on_post_proc_mesh();
793 
795  }

◆ setGaussPts()

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

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 565 of file PostProcOnRefMesh.hpp.

565  {
567 
568  auto type = type_from_handle(this->getFEEntityHandle());
569 
570  auto set_gauss_pts = [&](auto &level_gauss_pts_on_ref_mesh, auto &level_ref,
571  auto &level_shape_functions,
572 
573  auto start_vert_handle, auto start_ele_handle,
574  auto &verts_array, auto &conn, auto &ver_count,
575  auto &ele_count
576 
577  ) {
579 
580  auto level =
581  std::min(getMaxLevel(), level_gauss_pts_on_ref_mesh.size() - 1);
582 
583  auto &level_ref_gauss_pts = level_gauss_pts_on_ref_mesh[level];
584  auto &level_ref_ele = level_ref[level];
585  auto &shape_functions = level_shape_functions[level];
586  T::gaussPts.resize(level_ref_gauss_pts.size1(),
587  level_ref_gauss_pts.size2(), false);
588  noalias(T::gaussPts) = level_ref_gauss_pts;
589 
590  EntityHandle fe_ent = T::numeredEntFiniteElementPtr->getEnt();
591  {
592  const EntityHandle *conn;
593  int num_nodes;
594  T::mField.get_moab().get_connectivity(fe_ent, conn, num_nodes, true);
595  T::coords.resize(3 * num_nodes, false);
596  CHKERR T::mField.get_moab().get_coords(conn, num_nodes, &T::coords[0]);
597  }
598 
599  const int num_nodes = level_ref_gauss_pts.size2();
600  T::mapGaussPts.resize(level_ref_gauss_pts.size2());
601 
604  &*shape_functions.data().begin());
606  &verts_array[0][ver_count], &verts_array[1][ver_count],
607  &verts_array[2][ver_count]);
608  for (int gg = 0; gg != num_nodes; ++gg, ++ver_count) {
609 
610  T::mapGaussPts[gg] = start_vert_handle + ver_count;
611 
612  auto set_float_precision = [](const double x) {
613  if (std::abs(x) < std::numeric_limits<float>::epsilon())
614  return 0.;
615  else
616  return x;
617  };
618 
619  t_coords(i) = 0;
620  auto t_ele_coords = getFTensor1FromArray<3, 3>(T::coords);
621  for (int nn = 0; nn != CN::VerticesPerEntity(type); ++nn) {
622  t_coords(i) += t_n * t_ele_coords(i);
623  ++t_ele_coords;
624  ++t_n;
625  }
626 
627  for (auto ii : {0, 1, 2})
628  t_coords(ii) = set_float_precision(t_coords(ii));
629 
630  ++t_coords;
631  }
632 
633  Tag th;
634  int def_in_the_loop = -1;
635  CHKERR T::postProcMesh.tag_get_handle(
636  "NB_IN_THE_LOOP", 1, MB_TYPE_INTEGER, th,
637  MB_TAG_CREAT | MB_TAG_SPARSE, &def_in_the_loop);
638 
639  commonData.tEts.clear();
640  const int num_el = level_ref_ele.size1();
641  const int num_nodes_on_ele = level_ref_ele.size2();
642  auto start_e = start_ele_handle + ele_count;
643  commonData.tEts = Range(start_e, start_e + num_el - 1);
644  for (auto tt = 0; tt != level_ref_ele.size1(); ++tt, ++ele_count) {
645  for (int nn = 0; nn != num_nodes_on_ele; ++nn) {
646  conn[num_nodes_on_ele * ele_count + nn] =
647  T::mapGaussPts[level_ref_ele(tt, nn)];
648  }
649  }
650 
651  const int n_in_the_loop = T::nInTheLoop;
652  CHKERR T::postProcMesh.tag_clear_data(th, commonData.tEts,
653  &n_in_the_loop);
654 
656  };
657 
658  switch (type) {
659  case MBTET:
660  return set_gauss_pts(levelGaussPtsOnRefMeshTets, levelRefTets,
662 
665 
666  );
667  case MBHEX:
668  return set_gauss_pts(levelGaussPtsOnRefMeshHexes, levelRefHexes,
670 
673 
674  );
675  default:
676  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
677  "Element type not implemented");
678  }
679 
681  }

Member Data Documentation

◆ commonData

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

Definition at line 287 of file PostProcOnRefMesh.hpp.

◆ countHex

template<class VOLUME_ELEMENT >
int PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::countHex
private

Definition at line 948 of file PostProcOnRefMesh.hpp.

◆ countTet

template<class VOLUME_ELEMENT >
int PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::countTet
private

Definition at line 941 of file PostProcOnRefMesh.hpp.

◆ countVertHex

template<class VOLUME_ELEMENT >
int PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::countVertHex
private

Definition at line 949 of file PostProcOnRefMesh.hpp.

◆ countVertTet

template<class VOLUME_ELEMENT >
int PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::countVertTet
private

Definition at line 942 of file PostProcOnRefMesh.hpp.

◆ hexConn

template<class VOLUME_ELEMENT >
EntityHandle* PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::hexConn
private

Definition at line 947 of file PostProcOnRefMesh.hpp.

◆ levelGaussPtsOnRefMeshHexes

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

Definition at line 934 of file PostProcOnRefMesh.hpp.

◆ levelGaussPtsOnRefMeshTets

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

Definition at line 931 of file PostProcOnRefMesh.hpp.

◆ levelRefHexes

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

Definition at line 935 of file PostProcOnRefMesh.hpp.

◆ levelRefTets

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

Definition at line 932 of file PostProcOnRefMesh.hpp.

◆ levelShapeFunctionsHexes

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

Definition at line 933 of file PostProcOnRefMesh.hpp.

◆ levelShapeFunctionsTets

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

Definition at line 930 of file PostProcOnRefMesh.hpp.

◆ nbOfRefLevels

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

Definition at line 274 of file PostProcOnRefMesh.hpp.

◆ startingEleHexHandle

template<class VOLUME_ELEMENT >
EntityHandle PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::startingEleHexHandle
private

Definition at line 946 of file PostProcOnRefMesh.hpp.

◆ startingEleTetHandle

template<class VOLUME_ELEMENT >
EntityHandle PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::startingEleTetHandle
private

Definition at line 939 of file PostProcOnRefMesh.hpp.

◆ startingVertHexHandle

template<class VOLUME_ELEMENT >
EntityHandle PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::startingVertHexHandle
private

Definition at line 944 of file PostProcOnRefMesh.hpp.

◆ startingVertTetHandle

template<class VOLUME_ELEMENT >
EntityHandle PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::startingVertTetHandle
private

Definition at line 937 of file PostProcOnRefMesh.hpp.

◆ tenNodesPostProcTets

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

Definition at line 273 of file PostProcOnRefMesh.hpp.

◆ tetConn

template<class VOLUME_ELEMENT >
EntityHandle* PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::tetConn
private

Definition at line 940 of file PostProcOnRefMesh.hpp.

◆ verticesOnHexArrays

template<class VOLUME_ELEMENT >
std::vector<double *> PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::verticesOnHexArrays
private

Definition at line 945 of file PostProcOnRefMesh.hpp.

◆ verticesOnTetArrays

template<class VOLUME_ELEMENT >
std::vector<double *> PostProcTemplateVolumeOnRefinedMesh< VOLUME_ELEMENT >::verticesOnTetArrays
private

Definition at line 938 of file PostProcOnRefMesh.hpp.


The documentation for this struct was generated from the following file:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
PostProcTemplateVolumeOnRefinedMesh::countVertHex
int countVertHex
Definition: PostProcOnRefMesh.hpp:949
PostProcTemplateVolumeOnRefinedMesh::getMaxLevel
size_t getMaxLevel() const
Definition: PostProcOnRefMesh.hpp:544
MYPCOMM_INDEX
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:228
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
EntityHandle
PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >::postProcMesh
moab::Interface & postProcMesh
Definition: PostProcOnRefMesh.hpp:122
PostProcTemplateVolumeOnRefinedMesh::verticesOnHexArrays
std::vector< double * > verticesOnHexArrays
Definition: PostProcOnRefMesh.hpp:945
N_MBHEX5
#define N_MBHEX5(x, y, z)
Definition: fem_tools.h:76
PostProcTemplateVolumeOnRefinedMesh::levelRefHexes
std::vector< ublas::matrix< int > > levelRefHexes
Definition: PostProcOnRefMesh.hpp:935
N_MBHEX0
#define N_MBHEX0(x, y, z)
Definition: fem_tools.h:71
PostProcTemplateVolumeOnRefinedMesh::verticesOnTetArrays
std::vector< double * > verticesOnTetArrays
Definition: PostProcOnRefMesh.hpp:938
PostProcTemplateVolumeOnRefinedMesh::startingVertTetHandle
EntityHandle startingVertTetHandle
Definition: PostProcOnRefMesh.hpp:937
MoFEM::th
Tag th
Definition: Projection10NodeCoordsOnField.cpp:122
PostProcTemplateVolumeOnRefinedMesh::nbOfRefLevels
int nbOfRefLevels
Definition: PostProcOnRefMesh.hpp:274
N_MBHEX7
#define N_MBHEX7(x, y, z)
Definition: fem_tools.h:78
PostProcTemplateVolumeOnRefinedMesh::tenNodesPostProcTets
bool tenNodesPostProcTets
Definition: PostProcOnRefMesh.hpp:273
nb_ref_levels
constexpr int nb_ref_levels
Three levels of refinement.
Definition: hanging_node_approx.cpp:17
zeta
double zeta
Viscous hardening.
Definition: plastic.cpp:126
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::Interface
DeprecatedCoreInterface Interface
Definition: Interface.hpp:2010
PostProcTemplateVolumeOnRefinedMesh::startingVertHexHandle
EntityHandle startingVertHexHandle
Definition: PostProcOnRefMesh.hpp:944
N_MBHEX3
#define N_MBHEX3(x, y, z)
Definition: fem_tools.h:74
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
PostProcTemplateVolumeOnRefinedMesh::hexConn
EntityHandle * hexConn
Definition: PostProcOnRefMesh.hpp:947
MoFEM::CoreTmp
Definition: Core.hpp:36
convert.type
type
Definition: convert.py:64
PostProcTemplateVolumeOnRefinedMesh::commonData
CommonData commonData
Definition: PostProcOnRefMesh.hpp:287
PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >::coreMesh
moab::Core coreMesh
Definition: PostProcOnRefMesh.hpp:120
eta
double eta
Definition: free_surface.cpp:170
PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >
N_MBHEX1
#define N_MBHEX1(x, y, z)
Definition: fem_tools.h:72
PostProcTemplateVolumeOnRefinedMesh::levelRefTets
std::vector< ublas::matrix< int > > levelRefTets
Definition: PostProcOnRefMesh.hpp:932
MoFEM::type_from_handle
auto type_from_handle(const EntityHandle h)
get type from entity handle
Definition: Templates.hpp:1898
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
FTensor::Index< 'i', 3 >
PostProcCommonOnRefMesh::CommonDataForVolume::tEts
Range tEts
Definition: PostProcOnRefMesh.hpp:38
PostProcTemplateVolumeOnRefinedMesh::levelShapeFunctionsHexes
std::vector< MatrixDouble > levelShapeFunctionsHexes
Definition: PostProcOnRefMesh.hpp:933
Range
MOFEM_TAG_AND_LOG
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:362
FTensor::Tensor0
Definition: Tensor0.hpp:16
N_MBHEX2
#define N_MBHEX2(x, y, z)
Definition: fem_tools.h:73
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >::mapGaussPts
std::vector< EntityHandle > mapGaussPts
Definition: PostProcOnRefMesh.hpp:125
MOFEM_TAG_AND_LOG_C
#define MOFEM_TAG_AND_LOG_C(channel, severity, tag, format,...)
Tag and log in channel.
Definition: LogManager.hpp:370
N_MBHEX4
#define N_MBHEX4(x, y, z)
Definition: fem_tools.h:75
PostProcTemplateVolumeOnRefinedMesh::tetConn
EntityHandle * tetConn
Definition: PostProcOnRefMesh.hpp:940
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
PostProcTemplateVolumeOnRefinedMesh::levelShapeFunctionsTets
std::vector< MatrixDouble > levelShapeFunctionsTets
Definition: PostProcOnRefMesh.hpp:930
PostProcTemplateVolumeOnRefinedMesh::startingEleTetHandle
EntityHandle startingEleTetHandle
Definition: PostProcOnRefMesh.hpp:939
PostProcTemplateVolumeOnRefinedMesh::levelGaussPtsOnRefMeshTets
std::vector< MatrixDouble > levelGaussPtsOnRefMeshTets
Definition: PostProcOnRefMesh.hpp:931
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
N_MBHEX6
#define N_MBHEX6(x, y, z)
Definition: fem_tools.h:77
PostProcTemplateVolumeOnRefinedMesh::startingEleHexHandle
EntityHandle startingEleHexHandle
Definition: PostProcOnRefMesh.hpp:946
MoFEM::PetscOptionsGetInt
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
Definition: DeprecatedPetsc.hpp:142
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
PostProcTemplateVolumeOnRefinedMesh::levelGaussPtsOnRefMeshHexes
std::vector< MatrixDouble > levelGaussPtsOnRefMeshHexes
Definition: PostProcOnRefMesh.hpp:934
PostProcTemplateVolumeOnRefinedMesh::countTet
int countTet
Definition: PostProcOnRefMesh.hpp:941
PostProcTemplateVolumeOnRefinedMesh::countHex
int countHex
Definition: PostProcOnRefMesh.hpp:948
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
PostProcTemplateVolumeOnRefinedMesh::countVertTet
int countVertTet
Definition: PostProcOnRefMesh.hpp:942
ShapeMBTET
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:306