v0.14.0
VolumeElementForcesAndSourcesCoreOnSide.cpp
Go to the documentation of this file.
1 /** \file VolumeElementForcesAndSourcesCoreOnSide.cpp
2 
3 \brief Implementation of volume element on side
4 
5 */
6 
7 
8 
9 namespace MoFEM {
10 
12  return -1;
13 };
14 
18 
19  if (!sidePtrFE)
20  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "Side element not set");
21 
22  const auto type = numeredEntFiniteElementPtr->getEntType();
23  const auto nb_nodes_on_ele = CN::VerticesPerEntity(type);
24 
25  auto face_ptr_fe =
27 
28  const auto face_entity = sidePtrFE->numeredEntFiniteElementPtr->getEnt();
29  auto &side_table = const_cast<SideNumber_multiIndex &>(
30  numeredEntFiniteElementPtr->getSideNumberTable());
31  auto sit = side_table.get<0>().find(face_entity);
32  if (sit == side_table.get<0>().end())
33  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
34  "Face can not be found on volume element");
35 
36  const auto nb_nodes_on_face = CN::VerticesPerEntity((*sit)->getEntType());
37 
38  faceSense = (*sit)->sense;
39  faceSideNumber = (*sit)->side_number;
40  fill(&tetConnMap[0], &tetConnMap[nb_nodes_on_ele], -1);
41  for (int nn = 0; nn != nb_nodes_on_face; ++nn) {
42  faceConnMap[nn] = std::distance(
43  conn, find(conn, &conn[nb_nodes_on_ele], face_ptr_fe->conn[nn]));
44  tetConnMap[faceConnMap[nn]] = nn;
45  if (faceConnMap[nn] >= nb_nodes_on_ele)
46  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
47  "No common node on face and element can not be found");
48  }
49 
50  oppositeNode = std::distance(
51  &tetConnMap[0], find(&tetConnMap[0], &tetConnMap[nb_nodes_on_ele], -1));
52 
53  const int nb_gauss_pts = face_ptr_fe->gaussPts.size2();
54  gaussPts.resize(4, nb_gauss_pts, false);
55  gaussPts.clear();
56 
57  constexpr double tet_coords[12] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
58  constexpr double hex_coords[24] = {0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0,
59  0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1};
60 
61  auto set_gauss = [&](auto &coords) {
64  auto &data = *face_ptr_fe->dataOnElement[H1];
65  auto t_base = data.dataOnEntities[MBVERTEX][0].getFTensor0N(NOBASE);
67  &gaussPts(0, 0), &gaussPts(1, 0), &gaussPts(2, 0)};
68  for (int gg = 0; gg != nb_gauss_pts; ++gg) {
69  for (int bb = 0; bb != nb_nodes_on_face; ++bb) {
70  const int shift = 3 * faceConnMap[bb];
72  coords[shift + 0], coords[shift + 1], coords[shift + 2]};
73  t_gauss_coords(i) += t_base * t_coords(i);
74  ++t_base;
75  }
76  ++t_gauss_coords;
77  gaussPts(3, gg) = face_ptr_fe->gaussPts(2, gg);
78  }
80  };
81 
82  switch (type) {
83  case MBTET:
84  CHKERR set_gauss(tet_coords);
85  break;
86  case MBHEX:
87  CHKERR set_gauss(hex_coords);
88  break;
89  default:
90  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
91  "Element type not implemented: %d", type);
92  }
93 
95 }
96 
99  ForcesAndSourcesCore *ptr) {
101  if (!(ptrFE =
102  dynamic_cast<VolumeElementForcesAndSourcesCoreOnSide *>(ptr)))
103  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
104  "User operator and finite element do not work together");
106 }
107 
108 } // namespace MoFEM
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::faceConnMap
std::array< int, 4 > faceConnMap
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:89
H1
@ H1
continuous field
Definition: definitions.h:85
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::setPtrFE
MoFEMErrorCode setPtrFE(ForcesAndSourcesCore *ptr)
Definition: VolumeElementForcesAndSourcesCoreOnSide.cpp:98
NOBASE
@ NOBASE
Definition: definitions.h:59
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::ForcesAndSourcesCore::sidePtrFE
ForcesAndSourcesCore * sidePtrFE
Element to integrate on the sides.
Definition: ForcesAndSourcesCore.hpp:507
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::tetConnMap
std::array< int, 8 > tetConnMap
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:90
order
constexpr int order
Definition: dg_projection.cpp:18
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::getRule
int getRule(int order)
Definition: VolumeElementForcesAndSourcesCoreOnSide.cpp:11
MoFEM::VolumeElementForcesAndSourcesCore::coords
VectorDouble coords
Definition: VolumeElementForcesAndSourcesCore.hpp:89
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::oppositeNode
int oppositeNode
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:91
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
convert.type
type
Definition: convert.py:64
SideNumber_multiIndex
multi_index_container< boost::shared_ptr< SideNumber >, indexed_by< ordered_unique< member< SideNumber, EntityHandle, &SideNumber::ent > >, ordered_non_unique< composite_key< SideNumber, const_mem_fun< SideNumber, EntityType, &SideNumber::getEntType >, member< SideNumber, signed char, &SideNumber::side_number > > > > > SideNumber_multiIndex
SideNumber_multiIndex for SideNumber.
Definition: RefEntsMultiIndices.hpp:101
MoFEM::VolumeElementForcesAndSourcesCore::conn
const EntityHandle * conn
Definition: VolumeElementForcesAndSourcesCore.hpp:101
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::faceSideNumber
int faceSideNumber
Face side number.
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:88
MoFEM::FaceElementForcesAndSourcesCore
Face finite element.
Definition: FaceElementForcesAndSourcesCore.hpp:23
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::setGaussPts
MoFEMErrorCode setGaussPts(int order)
Definition: VolumeElementForcesAndSourcesCoreOnSide.cpp:16
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index< 'i', 3 >
MoFEM::ForcesAndSourcesCore
structure to get information form mofem into EntitiesFieldData
Definition: ForcesAndSourcesCore.hpp:22
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::ForcesAndSourcesCore::gaussPts
MatrixDouble gaussPts
Matrix of integration points.
Definition: ForcesAndSourcesCore.hpp:109
MoFEM::FEMethod::numeredEntFiniteElementPtr
boost::shared_ptr< const NumeredEntFiniteElement > numeredEntFiniteElementPtr
Definition: LoopMethods.hpp:383
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
MoFEM::VolumeElementForcesAndSourcesCoreOnSide
Base volume element used to integrate on skeleton.
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:22
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::faceSense
int faceSense
Sense of face, could be 1 or -1.
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:87
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
MoFEM::ForcesAndSourcesCore::UserDataOperator::ptrFE
ForcesAndSourcesCore * ptrFE
Definition: ForcesAndSourcesCore.hpp:985
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359