v0.14.0
Public Member Functions | Public Attributes | List of all members
Op< OP > Struct Template Reference
Inheritance diagram for Op< OP >:
[legend]
Collaboration diagram for Op< OP >:
[legend]

Public Member Functions

 Op (moab::Interface &post_proc, MapCoords &map_coords, EntityHandle prism)
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 

Public Attributes

moab::Interface & postProc
 
MapCoordsmapCoords
 
EntityHandle prism
 
std::vector< EntityHandlenodeHandles
 

Detailed Description

template<typename OP>
struct Op< OP >

Examples
build_large_problem.cpp, and prism_elements_from_surface.cpp.

Definition at line 78 of file prism_elements_from_surface.cpp.

Constructor & Destructor Documentation

◆ Op()

template<typename OP >
Op< OP >::Op ( moab::Interface &  post_proc,
MapCoords map_coords,
EntityHandle  prism 
)
Examples
prism_elements_from_surface.cpp.

Definition at line 579 of file prism_elements_from_surface.cpp.

581  : OP("FIELD1", "FIELD1", ForcesAndSourcesCore::UserDataOperator::OPROW),
582  postProc(post_proc), mapCoords(map_coords), prism(prism) {}

Member Function Documentation

◆ doWork()

template<typename OP >
MoFEMErrorCode Op< OP >::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData data 
)
Examples
prism_elements_from_surface.cpp.

Definition at line 585 of file prism_elements_from_surface.cpp.

586  {
587  constexpr double def_val[] = {0, 0, 0};
589  switch (type) {
590  case MBVERTEX:
591  case MBEDGE:
592  case MBTRI:
593  case MBQUAD:
594  break;
595  default:
597  }
598 
599  const int nb_dofs = data.getIndices().size();
600  for (int dd = 0; dd != nb_dofs; ++dd)
601  if (data.getFieldData()[dd] != data.getIndices()[dd]) {
602  std::cerr << "Indices: " << data.getIndices() << std::endl;
603  std::cerr << "Local indices: " << data.getLocalIndices() << std::endl;
604  std::cerr << "Data: " << data.getFieldData() << std::endl;
605  SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
606  "Indicices/data inconsistency %3.1f != %d",
607  data.getFieldData()[dd], data.getIndices()[dd]);
608  }
609 
610  const EntityHandle fe_ent = OP::getFEEntityHandle();
611  const EntityHandle ent = OP::getSideEntity(side, type);
612  int side_prism, sense, offset;
613  if (type == MBVERTEX) {
614  CHKERR postProc.side_number(prism, fe_ent, side_prism, sense, offset);
615  } else
616  CHKERR postProc.side_number(prism, ent, side_prism, sense, offset);
617 
618  if (type == MBVERTEX) {
619  auto &coords_at_pts = OP::getCoordsAtGaussPts();
620  const size_t nb_gauss_pts = coords_at_pts.size1();
621 
622  nodeHandles.reserve(nb_gauss_pts);
623  nodeHandles.clear();
624  for (size_t gg = 0; gg != nb_gauss_pts; ++gg) {
625  auto t = boost::make_tuple(CoordsAndHandle::getArg(coords_at_pts(gg, 0)),
626  CoordsAndHandle::getArg(coords_at_pts(gg, 1)),
627  CoordsAndHandle::getArg(coords_at_pts(gg, 2)));
628 
629  auto it = mapCoords.find(t);
630  if (it != mapCoords.end())
631  nodeHandles.emplace_back(it->node);
632  else
633  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Vertex not found");
634  }
635  }
636 
637  auto to_str = [](auto i) { return boost::lexical_cast<std::string>(i); };
638  std::string tag_name_base =
639  "FEType" + to_str(OP::getNumeredEntFiniteElementPtr()->getEntType()) +
640  "Type" + to_str(type) + "Side" + to_str(side_prism);
641 
642  std::string tag_prism_name_base =
643  "PrismType" + to_str(type) + "Side" + to_str(side_prism);
644 
645  MatrixDouble trans_base = trans(data.getN());
646  MatrixDouble prism_base(trans_base.size1(), trans_base.size2());
647  if (trans_base.size2() != nodeHandles.size())
648  SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID, "wrong size %d != %d",
649  trans_base.size2(), nodeHandles.size());
650 
651  for (size_t rr = 0; rr != trans_base.size1(); ++rr) {
652 
653  std::string tag_name = tag_name_base + "Base";
654  if (type == MBVERTEX) {
655  EntityHandle node = data.getFieldDofs()[rr]->getEnt();
656  int prism_mode_side;
657  CHKERR postProc.side_number(prism, node, prism_mode_side, sense, offset);
658  tag_name += to_str(prism_mode_side);
659  } else {
660  tag_name += to_str(rr);
661  }
662 
663  std::cout << tag_name << endl;
664 
665  Tag th;
666  CHKERR postProc.tag_get_handle(tag_name.c_str(), 1, MB_TYPE_DOUBLE, th,
667  MB_TAG_CREAT | MB_TAG_DENSE, def_val);
668  CHKERR postProc.tag_set_data(th, &nodeHandles[0], nodeHandles.size(),
669  &trans_base(rr, 0));
670 
671  if (type != MBVERTEX) {
672  auto tag_prism_name = tag_prism_name_base + "Base" + to_str(rr);
673  Tag th_prism;
674  CHKERR postProc.tag_get_handle(tag_prism_name.c_str(), th_prism);
675  CHKERR postProc.tag_get_data(th_prism, &nodeHandles[0],
676  nodeHandles.size(), &prism_base(rr, 0));
677  }
678  }
679 
680  auto sum_matrix = [](MatrixDouble &m) {
681  double s = 0;
682  for (unsigned int ii = 0; ii < m.size1(); ii++) {
683  for (unsigned int jj = 0; jj < m.size2(); jj++) {
684  s += std::abs(m(ii, jj));
685  }
686  }
687  return s;
688  };
689 
690  if (type != MBVERTEX) {
691  prism_base -= trans_base;
692  double sum = sum_matrix(prism_base);
693  constexpr double eps = 1e-6;
694 
695  if (std::abs(sum) > eps)
696  cout << "Inconsistent base " << tag_prism_name_base << " "
697  << tag_name_base << " sum " << sum << endl;
698 
699  if (std::abs(sum) > eps)
700  SETERRQ2(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
701  "Inconsistent base %s sum %6.4e", tag_prism_name_base.c_str(),
702  sum);
703  }
704 
706 }

Member Data Documentation

◆ mapCoords

template<typename OP >
MapCoords& Op< OP >::mapCoords

Definition at line 86 of file prism_elements_from_surface.cpp.

◆ nodeHandles

template<typename OP >
std::vector<EntityHandle> Op< OP >::nodeHandles

Definition at line 88 of file prism_elements_from_surface.cpp.

◆ postProc

template<typename OP >
moab::Interface& Op< OP >::postProc

Definition at line 85 of file prism_elements_from_surface.cpp.

◆ prism

template<typename OP >
EntityHandle Op< OP >::prism

Definition at line 87 of file prism_elements_from_surface.cpp.


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:447
EntityHandle
MoFEM::EntitiesFieldData::EntData::getLocalIndices
const VectorInt & getLocalIndices() const
get local indices of dofs on entity
Definition: EntitiesFieldData.hpp:1216
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
MoFEM::th
Tag th
Definition: Projection10NodeCoordsOnField.cpp:122
MoFEM::EntitiesFieldData::EntData::getFieldData
const VectorDouble & getFieldData() const
get dofs values
Definition: EntitiesFieldData.hpp:1241
CoordsAndHandle::getArg
static double getArg(double x)
Definition: prism_elements_from_surface.cpp:27
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
convert.type
type
Definition: convert.py:64
MoFEM::EntitiesFieldData::EntData::getIndices
const VectorInt & getIndices() const
Get global indices of dofs on entity.
Definition: EntitiesFieldData.hpp:1201
MoFEM::EntitiesFieldData::EntData::getFieldDofs
const VectorDofs & getFieldDofs() const
get dofs data stature FEDofEntity
Definition: EntitiesFieldData.hpp:1256
t
constexpr double t
plate stiffness
Definition: plate.cpp:59
Op::postProc
moab::Interface & postProc
Definition: prism_elements_from_surface.cpp:85
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
Op::nodeHandles
std::vector< EntityHandle > nodeHandles
Definition: prism_elements_from_surface.cpp:88
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
MoFEM::EntitiesFieldData::EntData::getN
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
Definition: EntitiesFieldData.hpp:1305
eps
static const double eps
Definition: check_base_functions_derivatives_on_tet.cpp:11
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
m
FTensor::Index< 'm', 3 > m
Definition: shallow_wave.cpp:80
MOFEM_ATOM_TEST_INVALID
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
sum_matrix
static double sum_matrix(MatrixDouble &m)
Definition: edge_and_bubble_shape_functions_on_quad.cpp:12
OP
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
Op::prism
EntityHandle prism
Definition: prism_elements_from_surface.cpp:87
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
Op::mapCoords
MapCoords & mapCoords
Definition: prism_elements_from_surface.cpp:86