v0.13.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)
 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 280 of file PostProcOnRefMesh.hpp.

Member Typedef Documentation

◆ CommonData

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

Definition at line 298 of file PostProcOnRefMesh.hpp.

◆ T

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

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

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

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

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

716  {
718  T::getOpPtrVector().clear();
720  }

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

313  {
315 
316  auto get_nb_of_ref_levels_from_options = [this] {
317  if (nbOfRefLevels == -1) {
318  int max_level = 0;
319  PetscBool flg = PETSC_TRUE;
320  PetscOptionsGetInt(PETSC_NULL, PETSC_NULL,
321  "-my_max_post_proc_ref_level", &max_level, &flg);
322  return max_level;
323  } else {
324  return nbOfRefLevels;
325  }
326  return 0;
327  };
328 
329  auto generate_for_hex = [&]() {
331 
332  moab::Core core_ref;
333  moab::Interface &moab_ref = core_ref;
334 
335  auto create_reference_element = [&moab_ref]() {
337  constexpr double base_coords[] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0,
338  0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1};
339  EntityHandle nodes[8];
340  for (int nn = 0; nn < 8; nn++)
341  CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
342  EntityHandle hex;
343  CHKERR moab_ref.create_element(MBHEX, nodes, 8, hex);
345  };
346 
347  auto add_ho_nodes = [&]() {
349  Range hexes;
350  CHKERR moab_ref.get_entities_by_type(0, MBHEX, hexes, true);
351  EntityHandle meshset;
352  CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
353  CHKERR moab_ref.add_entities(meshset, hexes);
354  CHKERR moab_ref.convert_entities(meshset, true, true, true);
355  CHKERR moab_ref.delete_entities(&meshset, 1);
357  };
358 
359  auto set_gauss_pts = [&](std::map<EntityHandle, int> &little_map) {
361  Range hexes;
362  CHKERR moab_ref.get_entities_by_type(0, MBHEX, hexes, true);
363  Range hexes_nodes;
364  CHKERR moab_ref.get_connectivity(hexes, hexes_nodes, false);
365  auto &gauss_pts = levelGaussPtsOnRefMeshHexes[0];
366  gauss_pts.resize(hexes_nodes.size(), 4, false);
367  size_t gg = 0;
368  for (auto node : hexes_nodes) {
369  CHKERR moab_ref.get_coords(&node, 1, &gauss_pts(gg, 0));
370  little_map[node] = gg;
371  ++gg;
372  }
373  gauss_pts = trans(gauss_pts);
375  };
376 
377  auto set_ref_hexes = [&](std::map<EntityHandle, int> &little_map) {
379  Range hexes;
380  CHKERR moab_ref.get_entities_by_type(0, MBHEX, hexes, true);
381  size_t hh = 0;
382  auto &ref_hexes = levelRefHexes[0];
383  for (auto hex : hexes) {
384  const EntityHandle *conn;
385  int num_nodes;
386  CHKERR moab_ref.get_connectivity(hex, conn, num_nodes, false);
387  if (ref_hexes.size2() != num_nodes) {
388  ref_hexes.resize(hexes.size(), num_nodes);
389  }
390  for (int nn = 0; nn != num_nodes; ++nn) {
391  ref_hexes(hh, nn) = little_map[conn[nn]];
392  }
393  ++hh;
394  }
396  };
397 
398  auto set_shape_functions = [&]() {
400  auto &gauss_pts = levelGaussPtsOnRefMeshHexes[0];
401  auto &shape_functions = levelShapeFunctionsHexes[0];
402  const auto nb_gauss_pts = gauss_pts.size2();
403  shape_functions.resize(nb_gauss_pts, 8);
404  for (int gg = 0; gg != nb_gauss_pts; ++gg) {
405  const double ksi = gauss_pts(0, gg);
406  const double zeta = gauss_pts(1, gg);
407  const double eta = gauss_pts(2, gg);
408  shape_functions(gg, 0) = N_MBHEX0(ksi, zeta, eta);
409  shape_functions(gg, 1) = N_MBHEX1(ksi, zeta, eta);
410  shape_functions(gg, 2) = N_MBHEX2(ksi, zeta, eta);
411  shape_functions(gg, 3) = N_MBHEX3(ksi, zeta, eta);
412  shape_functions(gg, 4) = N_MBHEX4(ksi, zeta, eta);
413  shape_functions(gg, 5) = N_MBHEX5(ksi, zeta, eta);
414  shape_functions(gg, 6) = N_MBHEX6(ksi, zeta, eta);
415  shape_functions(gg, 7) = N_MBHEX7(ksi, zeta, eta);
416  }
418  };
419 
420  levelRefHexes.resize(1);
421  levelGaussPtsOnRefMeshHexes.resize(1);
422  levelShapeFunctionsHexes.resize(1);
423 
424  CHKERR create_reference_element();
426  CHKERR add_ho_nodes();
427  std::map<EntityHandle, int> little_map;
428  CHKERR set_gauss_pts(little_map);
429  CHKERR set_ref_hexes(little_map);
430  CHKERR set_shape_functions();
431 
433  };
434 
435  auto generate_for_tet = [&]() {
437 
438  const int max_level = get_nb_of_ref_levels_from_options();
439 
440  moab::Core core_ref;
441  moab::Interface &moab_ref = core_ref;
442 
443  auto create_reference_element = [&moab_ref]() {
445  constexpr double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
446  EntityHandle nodes[4];
447  for (int nn = 0; nn < 4; nn++) {
448  CHKERR
449  moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
450  }
451  EntityHandle tet;
452  CHKERR moab_ref.create_element(MBTET, nodes, 4, tet);
454  };
455 
456  MoFEM::CoreTmp<-1> m_core_ref(moab_ref, PETSC_COMM_SELF, -2);
457  MoFEM::Interface &m_field_ref = m_core_ref;
458 
459  auto refine_ref_tetrahedron = [this, &m_field_ref, max_level]() {
461  // seed ref mofem database by setting bit ref level to reference
462  // tetrahedron
463  CHKERR
464  m_field_ref.getInterface<BitRefManager>()->setBitRefLevelByDim(
465  0, 3, BitRefLevel().set(0));
466  for (int ll = 0; ll != max_level; ++ll) {
467  MOFEM_TAG_AND_LOG_C("WORLD", Sev::verbose, "PostProc",
468  "Refine Level %d", ll);
469  Range edges;
470  CHKERR m_field_ref.getInterface<BitRefManager>()
471  ->getEntitiesByTypeAndRefLevel(
472  BitRefLevel().set(ll), BitRefLevel().set(), MBEDGE, edges);
473  Range tets;
474  CHKERR m_field_ref.getInterface<BitRefManager>()
475  ->getEntitiesByTypeAndRefLevel(
476  BitRefLevel().set(ll), BitRefLevel(ll).set(), MBTET, tets);
477  // refine mesh
478  MeshRefinement *m_ref;
479  CHKERR m_field_ref.getInterface(m_ref);
480  CHKERR m_ref->addVerticesInTheMiddleOfEdges(
481  edges, BitRefLevel().set(ll + 1));
482  CHKERR m_ref->refineTets(tets, BitRefLevel().set(ll + 1));
483  }
485  };
486 
487  auto get_ref_gauss_pts_and_shape_functions = [this, max_level, &moab_ref,
488  &m_field_ref]() {
490  for (int ll = 0; ll != max_level + 1; ++ll) {
491  Range tets;
492  CHKERR
493  m_field_ref.getInterface<BitRefManager>()
494  ->getEntitiesByTypeAndRefLevel(
495  BitRefLevel().set(ll), BitRefLevel().set(ll), MBTET, tets);
496  if (tenNodesPostProcTets) {
497  EntityHandle meshset;
498  CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
499  CHKERR moab_ref.add_entities(meshset, tets);
500  CHKERR moab_ref.convert_entities(meshset, true, false, false);
501  CHKERR moab_ref.delete_entities(&meshset, 1);
502  }
503  Range elem_nodes;
504  CHKERR moab_ref.get_connectivity(tets, elem_nodes, false);
505 
506  auto &gauss_pts = levelGaussPtsOnRefMeshTets[ll];
507  gauss_pts.resize(elem_nodes.size(), 4, false);
508  std::map<EntityHandle, int> little_map;
509  Range::iterator nit = elem_nodes.begin();
510  for (int gg = 0; nit != elem_nodes.end(); nit++, gg++) {
511  CHKERR moab_ref.get_coords(&*nit, 1, &gauss_pts(gg, 0));
512  little_map[*nit] = gg;
513  }
514  gauss_pts = trans(gauss_pts);
515 
516  auto &ref_tets = levelRefTets[ll];
517  Range::iterator tit = tets.begin();
518  for (int tt = 0; tit != tets.end(); ++tit, ++tt) {
519  const EntityHandle *conn;
520  int num_nodes;
521  CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
522  if (tt == 0) {
523  ref_tets.resize(tets.size(), num_nodes);
524  }
525  for (int nn = 0; nn != num_nodes; ++nn) {
526  ref_tets(tt, nn) = little_map[conn[nn]];
527  }
528  }
529 
530  auto &shape_functions = levelShapeFunctionsTets[ll];
531  shape_functions.resize(elem_nodes.size(), 4);
532  CHKERR ShapeMBTET(&*shape_functions.data().begin(), &gauss_pts(0, 0),
533  &gauss_pts(1, 0), &gauss_pts(2, 0),
534  elem_nodes.size());
535  }
537  };
538 
539  levelRefTets.resize(max_level + 1);
540  levelGaussPtsOnRefMeshTets.resize(max_level + 1);
541  levelShapeFunctionsTets.resize(max_level + 1);
542 
543  CHKERR create_reference_element();
544  CHKERR refine_ref_tetrahedron();
545  CHKERR get_ref_gauss_pts_and_shape_functions();
546 
548  };
549 
550  CHKERR generate_for_hex();
551  CHKERR generate_for_tet();
552 
554  }
#define MOFEM_TAG_AND_LOG_C(channel, severity, tag, format,...)
Tag and log in channel.
Definition: LogManager.hpp:363
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
#define CHKERR
Inline error check.
Definition: definitions.h:548
#define N_MBHEX7(x, y, z)
Definition: fem_tools.h:88
#define N_MBHEX3(x, y, z)
Definition: fem_tools.h:84
#define N_MBHEX5(x, y, z)
Definition: fem_tools.h:86
#define N_MBHEX4(x, y, z)
Definition: fem_tools.h:85
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 N_MBHEX0(x, y, z)
Definition: fem_tools.h:81
#define N_MBHEX6(x, y, z)
Definition: fem_tools.h:87
#define N_MBHEX2(x, y, z)
Definition: fem_tools.h:83
#define N_MBHEX1(x, y, z)
Definition: fem_tools.h:82
constexpr double eta
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
CoreTmp< 0 > Core
Definition: Core.hpp:1096
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1965
Deprecated interface functions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
std::vector< MatrixDouble > levelGaussPtsOnRefMeshTets
std::vector< ublas::matrix< int > > levelRefTets
std::vector< MatrixDouble > levelShapeFunctionsHexes
std::vector< MatrixDouble > levelGaussPtsOnRefMeshHexes
std::vector< MatrixDouble > levelShapeFunctionsTets
std::vector< ublas::matrix< int > > levelRefHexes

◆ getCommonData()

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

Reimplemented from PostProcTemplateOnRefineMesh< VOLUME_ELEMENT >.

Definition at line 301 of file PostProcOnRefMesh.hpp.

301  {
302  return commonData;
303  }
CommonData commonData

◆ getMaxLevel()

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

Definition at line 556 of file PostProcOnRefMesh.hpp.

556  {
557  auto get_element_max_dofs_order = [&]() {
558  int max_order = 0;
559  auto dofs_vec = this->getDataVectorDofsPtr();
560  for (auto &dof : *dofs_vec) {
561  const int dof_order = dof->getDofOrder();
562  max_order = (max_order < dof_order) ? dof_order : max_order;
563  };
564  return max_order;
565  };
566  const auto dof_max_order = get_element_max_dofs_order();
567  return (dof_max_order > 0) ? (dof_max_order - 1) / 2 : 0;
568  };

◆ getRule()

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

Definition at line 296 of file PostProcOnRefMesh.hpp.

296 { return -1; };

◆ postProcess()

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

Definition at line 816 of file PostProcOnRefMesh.hpp.

816  {
818 
819  auto update_elements = [&]() {
821  ReadUtilIface *iface;
822  CHKERR this->postProcMesh.query_interface(iface);
823 
824  if (countTet) {
825  MOFEM_TAG_AND_LOG("SELF", Sev::noisy, "PostProc")
826  << "Update tets " << countTet;
827 
828  MOFEM_TAG_AND_LOG("SELF", Sev::noisy, "PostProc")
829  << "Nb nodes on tets " << levelRefTets[0].size2();
830 
831  CHKERR iface->update_adjacencies(startingEleTetHandle, countTet,
832  levelRefTets[0].size2(), tetConn);
833 
834  }
835  if (countHex) {
836  MOFEM_TAG_AND_LOG("SELF", Sev::noisy, "PostProc")
837  << "Update hexes " << countHex;
838  CHKERR iface->update_adjacencies(startingEleHexHandle, countHex,
839  levelRefHexes[0].size2(), hexConn);
840  }
842  };
843 
844  auto resolve_shared_ents = [&]() {
846  ParallelComm *pcomm_post_proc_mesh =
847  ParallelComm::get_pcomm(&(T::postProcMesh), MYPCOMM_INDEX);
848  if (pcomm_post_proc_mesh == NULL) {
850  boost::make_shared<WrapMPIComm>(T::mField.get_comm(), false);
851  pcomm_post_proc_mesh = new ParallelComm(
852  &(T::postProcMesh), (T::wrapRefMeshComm)->get_comm());
853  }
854 
855  Range edges;
856  CHKERR T::postProcMesh.get_entities_by_type(0, MBEDGE, edges, false);
857  CHKERR T::postProcMesh.delete_entities(edges);
858  Range faces;
859  CHKERR T::postProcMesh.get_entities_by_dimension(0, 2, faces, false);
860  CHKERR T::postProcMesh.delete_entities(faces);
861 
862  Range ents;
863  CHKERR T::postProcMesh.get_entities_by_dimension(0, 3, ents, false);
864 
865  int rank = T::mField.get_comm_rank();
866  CHKERR T::postProcMesh.tag_clear_data(pcomm_post_proc_mesh->part_tag(),
867  ents, &rank);
868 
869  CHKERR pcomm_post_proc_mesh->resolve_shared_ents(0);
870 
872  };
873 
874  CHKERR resolve_shared_ents();
875  CHKERR update_elements();
876 
878  }
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
Definition: LogManager.hpp:355
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:228
boost::shared_ptr< WrapMPIComm > wrapRefMeshComm
EntityHandle startingEleHexHandle
int countHex
EntityHandle * hexConn
EntityHandle * tetConn
int countTet
EntityHandle startingEleTetHandle

◆ preProcess()

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

Definition at line 722 of file PostProcOnRefMesh.hpp.

722  {
725  ParallelComm *pcomm_post_proc_mesh =
726  ParallelComm::get_pcomm(&moab, MYPCOMM_INDEX);
727  if (pcomm_post_proc_mesh != NULL)
728  delete pcomm_post_proc_mesh;
729 
730  CHKERR T::postProcMesh.delete_mesh();
731 
732  auto alloc_vertives_and_elements_on_post_proc_mesh = [&]() {
734 
735  auto fe_name = this->feName;
736  auto fe_ptr = this->problemPtr->numeredFiniteElementsPtr;
737 
738  auto miit =
739  fe_ptr->template get<Composite_Name_And_Part_mi_tag>().lower_bound(
740  boost::make_tuple(fe_name, this->getLoFERank()));
741  auto hi_miit =
742  fe_ptr->template get<Composite_Name_And_Part_mi_tag>().upper_bound(
743  boost::make_tuple(fe_name, this->getHiFERank()));
744 
745  const int number_of_ents_in_the_loop = this->getLoopSize();
746  if (std::distance(miit, hi_miit) != number_of_ents_in_the_loop) {
747  SETERRQ(this->mField.get_comm(), MOFEM_DATA_INCONSISTENCY,
748  "Wrong size of indicices. Inconsistent size number of iterated "
749  "elements iterated by problem and from range.");
750  }
751 
752  int nb_tet_vertices = 0;
753  int nb_tets = 0;
754  int nb_hex_vertices = 0;
755  int nb_hexes = 0;
756 
757  for (; miit != hi_miit; ++miit) {
758  auto type = (*miit)->getEntType();
759 
760  // Set pointer to element. So that getDataVectorDofsPtr in getMaxLevel
761  // can work
762  this->numeredEntFiniteElementPtr = *miit;
763  auto level = getMaxLevel();
764 
765  switch (type) {
766  case MBTET:
767  level = std::min(level, levelGaussPtsOnRefMeshTets.size() - 1);
768  nb_tet_vertices += levelGaussPtsOnRefMeshTets[level].size2();
769  nb_tets += levelRefTets[level].size1();
770  break;
771  case MBHEX:
772  level = std::min(level, levelGaussPtsOnRefMeshHexes.size() - 1);
773  nb_hex_vertices += levelGaussPtsOnRefMeshHexes[level].size2();
774  nb_hexes += levelRefHexes[level].size1();
775  break;
776  default:
777  SETERRQ(this->mField.get_comm(), MOFEM_DATA_INCONSISTENCY,
778  "Element type not implemented");
779  break;
780  }
781  }
782 
783  ReadUtilIface *iface;
784  CHKERR this->postProcMesh.query_interface(iface);
785 
786  if (nb_tets) {
787  CHKERR iface->get_node_coords(3, nb_tet_vertices, 0,
790  CHKERR iface->get_element_connect(nb_tets, levelRefTets[0].size2(),
791  MBTET, 0, startingEleTetHandle,
792  tetConn);
793  }
794 
795  if (nb_hexes) {
796  CHKERR iface->get_node_coords(
797  3, nb_hex_vertices, 0, startingVertHexHandle, verticesOnHexArrays);
798  CHKERR iface->get_element_connect(nb_hexes, levelRefHexes[0].size2(),
799  MBHEX, 0, startingEleHexHandle,
800  hexConn);
801  }
802 
803  countTet = 0;
804  countVertTet = 0;
805  countHex = 0;
806  countVertHex = 0;
807 
809  };
810 
811  CHKERR alloc_vertives_and_elements_on_post_proc_mesh();
812 
814  }
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:44
moab::Core coreMesh
int countVertHex
size_t getMaxLevel() const
EntityHandle startingVertHexHandle
int countVertTet
std::vector< double * > verticesOnHexArrays
std::vector< double * > verticesOnTetArrays
EntityHandle startingVertTetHandle

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

577  {
579 
580  auto type = type_from_handle(this->getFEEntityHandle());
581 
582  auto set_gauss_pts = [&](auto &level_gauss_pts_on_ref_mesh, auto &level_ref,
583  auto &level_shape_functions,
584 
585  auto start_vert_handle,
586  auto start_ele_handle,
587  auto &verts_array,
588  auto &conn,
589  auto &ver_count,
590  auto &ele_count
591 
592  ) {
594 
595  auto level =
596  std::min(getMaxLevel(), level_gauss_pts_on_ref_mesh.size() - 1);
597 
598  auto &level_ref_gauss_pts = level_gauss_pts_on_ref_mesh[level];
599  auto &level_ref_ele = level_ref[level];
600  auto &shape_functions = level_shape_functions[level];
601  T::gaussPts.resize(level_ref_gauss_pts.size1(),
602  level_ref_gauss_pts.size2(), false);
603  noalias(T::gaussPts) = level_ref_gauss_pts;
604 
605  EntityHandle fe_ent = T::numeredEntFiniteElementPtr->getEnt();
606  {
607  const EntityHandle *conn;
608  int num_nodes;
609  T::mField.get_moab().get_connectivity(fe_ent, conn, num_nodes, true);
610  T::coords.resize(3 * num_nodes, false);
611  CHKERR T::mField.get_moab().get_coords(conn, num_nodes, &T::coords[0]);
612  }
613 
614  const int num_nodes = level_ref_gauss_pts.size2();
615  T::mapGaussPts.resize(level_ref_gauss_pts.size2());
616 
619  &*shape_functions.data().begin());
621  &verts_array[0][ver_count], &verts_array[1][ver_count],
622  &verts_array[2][ver_count]);
623  for (int gg = 0; gg != num_nodes; ++gg, ++ver_count) {
624 
625  T::mapGaussPts[gg] = start_vert_handle + ver_count;
626 
627  auto set_float_precision = [](const double x) {
628  if (std::abs(x) < std::numeric_limits<float>::epsilon())
629  return 0.;
630  else
631  return x;
632  };
633 
634  t_coords(i) = 0;
635  auto t_ele_coords = getFTensor1FromArray<3, 3>(T::coords);
636  for (int nn = 0; nn != CN::VerticesPerEntity(type); ++nn) {
637  t_coords(i) += t_n * t_ele_coords(i);
638  ++t_ele_coords;
639  ++t_n;
640  }
641 
642  for (auto ii : {0, 1, 2})
643  t_coords(ii) = set_float_precision(t_coords(ii));
644 
645  ++t_coords;
646  }
647 
648  Tag th;
649  int def_in_the_loop = -1;
650  CHKERR T::postProcMesh.tag_get_handle(
651  "NB_IN_THE_LOOP", 1, MB_TYPE_INTEGER, th,
652  MB_TAG_CREAT | MB_TAG_SPARSE, &def_in_the_loop);
653 
654  commonData.tEts.clear();
655  const int num_el = level_ref_ele.size1();
656  const int num_nodes_on_ele = level_ref_ele.size2();
657  auto start_e = start_ele_handle + ele_count;
658  commonData.tEts = Range(start_e, start_e + num_el - 1);
659  for (auto tt = 0; tt != level_ref_ele.size1(); ++tt, ++ele_count) {
660  for (int nn = 0; nn != num_nodes_on_ele; ++nn) {
661  conn[num_nodes_on_ele * ele_count + nn] =
662  T::mapGaussPts[level_ref_ele(tt, nn)];
663  }
664  }
665 
666  const int n_in_the_loop = T::nInTheLoop;
667  CHKERR T::postProcMesh.tag_clear_data(th, commonData.tEts,
668  &n_in_the_loop);
669 
671  };
672 
673  switch (type) {
674  case MBTET:
675  return set_gauss_pts(levelGaussPtsOnRefMeshTets, levelRefTets,
677 
681  tetConn,
682  countVertTet,
683  countTet
684 
685 
686 
687 
688  );
689  case MBHEX:
690  return set_gauss_pts(levelGaussPtsOnRefMeshHexes, levelRefHexes,
692 
696  hexConn,
697  countVertHex,
698  countHex
699 
700  );
701  default:
702  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
703  "Element type not implemented");
704  }
705 
707  }
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:45
FTensor::Index< 'i', SPACE_DIM > i
auto type_from_handle
get type from entity handle
Definition: Templates.hpp:1441
Range tEts

Member Data Documentation

◆ commonData

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

Definition at line 299 of file PostProcOnRefMesh.hpp.

◆ countHex

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

Definition at line 967 of file PostProcOnRefMesh.hpp.

◆ countTet

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

Definition at line 960 of file PostProcOnRefMesh.hpp.

◆ countVertHex

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

Definition at line 968 of file PostProcOnRefMesh.hpp.

◆ countVertTet

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

Definition at line 961 of file PostProcOnRefMesh.hpp.

◆ hexConn

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

Definition at line 966 of file PostProcOnRefMesh.hpp.

◆ levelGaussPtsOnRefMeshHexes

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

Definition at line 953 of file PostProcOnRefMesh.hpp.

◆ levelGaussPtsOnRefMeshTets

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

Definition at line 950 of file PostProcOnRefMesh.hpp.

◆ levelRefHexes

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

Definition at line 954 of file PostProcOnRefMesh.hpp.

◆ levelRefTets

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

Definition at line 951 of file PostProcOnRefMesh.hpp.

◆ levelShapeFunctionsHexes

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

Definition at line 952 of file PostProcOnRefMesh.hpp.

◆ levelShapeFunctionsTets

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

Definition at line 949 of file PostProcOnRefMesh.hpp.

◆ nbOfRefLevels

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

Definition at line 286 of file PostProcOnRefMesh.hpp.

◆ startingEleHexHandle

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

Definition at line 965 of file PostProcOnRefMesh.hpp.

◆ startingEleTetHandle

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

Definition at line 958 of file PostProcOnRefMesh.hpp.

◆ startingVertHexHandle

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

Definition at line 963 of file PostProcOnRefMesh.hpp.

◆ startingVertTetHandle

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

Definition at line 956 of file PostProcOnRefMesh.hpp.

◆ tenNodesPostProcTets

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

Definition at line 285 of file PostProcOnRefMesh.hpp.

◆ tetConn

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

Definition at line 959 of file PostProcOnRefMesh.hpp.

◆ verticesOnHexArrays

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

Definition at line 964 of file PostProcOnRefMesh.hpp.

◆ verticesOnTetArrays

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

Definition at line 957 of file PostProcOnRefMesh.hpp.


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