v0.14.0
VolumeElementForcesAndSourcesCoreOnSide.hpp
Go to the documentation of this file.
1 /** \file VolumeElementForcesAndSourcesCoreOnSide.hpp
2  \brief Volume element.
3 
4  Those element are inherited by user to implement specific implementation of
5  particular problem.
6 
7 */
8 
9 
10 
11 #ifndef __VOLUMEELEMENTFORCESANDSOURCESCORE_ONSIDE_HPP__
12 #define __VOLUMEELEMENTFORCESANDSOURCESCORE_ONSIDE_HPP__
13 
14 using namespace boost::numeric;
15 
16 namespace MoFEM {
17 
18 /**
19  * \brief Base volume element used to integrate on skeleton
20  * \ingroup mofem_forces_and_sources_volume_element
21  */
24 
25  using VolumeElementForcesAndSourcesCore::VolumeElementForcesAndSourcesCore;
26 
27  /**
28  * @brief Get the face nodes mapped on volume element
29  *
30  * \todo That this is not general, e.g., for quad number of nodes is 4.
31  *
32  * @return const std::array<int, 4>&
33  */
34  inline const std::array<int, 4> &getFaceConnMap() const;
35 
36  /**
37  * @brief Get face nodes maped on volume
38  *
39  * \todo That this is not general, e.g., for prism or hex, size of fixed array
40  * is wrong.
41  *
42  * @return const sdt::array<int, 4>&
43  */
44  inline const std::array<int, 8> &getTetConnMap() const;
45 
46  /**
47  * @brief Get node on volume opposite to volume element
48  *
49  * \todo That this is not general, e.g., for prism or hex, opoosite node is
50  * not unique.
51  *
52  * @return int
53  */
54  inline int getOppositeNode() const;
55 
56  /**
57  * @brief Sense face on volume
58  * @deprecated use getSkeletonSense()
59  *
60  * @return int
61  */
62  DEPRECATED inline int getFaceSense() const;
63 
64  /**
65  * @brief Sense face on volume
66  *
67  * @return int
68  */
69  inline int getSkeletonSense() const;
70 
71  /**
72  * @brief Face number on the volume
73  *
74  * @return int
75  */
76  inline int getFaceSideNumber() const;
77 
78  /** \brief default operator for TET element
79  * \ingroup mofem_forces_and_sources_volume_element
80  */
81  struct UserDataOperator;
82 
83  int getRule(int order);
84  MoFEMErrorCode setGaussPts(int order);
85 
86  /**
87  * \brief Get side and sense and call operator from derived class
88  */
89  MoFEMErrorCode operator()();
90 
91 private:
92 
93  MoFEMErrorCode operatorImpl();
94 
95  int faceSense; ///< Sense of face, could be 1 or -1
96  int faceSideNumber; ///< Face side number
97  int nbNodesOnFace; ///< Number of nodes on face
98  std::array<int, 4> faceConnMap;
99  std::array<int, 8> tetConnMap;
101  bool operatorImplCalled = false; ///< flag to check if operatorImpl was called
102 };
103 
104 /** \brief default operator for TET element
105  * \ingroup mofem_forces_and_sources_volume_element
106  */
109 
111 
112  inline VolumeElementForcesAndSourcesCoreOnSide *getVolumeFE() const;
113 
114  inline FaceElementForcesAndSourcesCore *getFaceFE() const;
115 
116  /**
117  * \brief get face sense in respect to volume
118  * \deprecated use getSkeletonSense
119  * @return error code
120  */
121  DEPRECATED inline int getFaceSense() const;
122 
123  /**
124  * @brief Get the skeleton sense
125  *
126  * calls getFaceSense()
127  *
128  * @return int
129  */
130  inline int getSkeletonSense() const;
131 
132  /**
133  * \brief get face side number in respect to volume
134  * @return error code
135  */
136  inline int getFaceSideNumber() const;
137 
138  inline bool getEdgeFace(const int ee) const;
139 
140  /**
141  * get face normal on side which is this element
142  * @return face normal
143  */
144  inline VectorDouble &getNormal();
145 
146  /** \brief get triangle tangent 1
147  */
148  inline VectorDouble &getTangent1();
149 
150  /** \brief get triangle tangent 2
151  */
152  inline VectorDouble &getTangent2();
153 
154  /** \brief get normal as tensor
155  */
156  inline auto getFTensor1Normal();
157 
158  /** \brief get tangentOne as tensor
159  */
160  inline auto getFTensor1Tangent1();
161 
162  /** \brief get tangentTwo as tensor
163  */
164  inline auto getFTensor1Tangent2();
165 
166  /** \brief if higher order geometry return normals at Gauss pts.
167 
168  Note: returned matrix has size 0 in rows and columns if no HO approximation
169  of geometry is available.
170 
171  */
172  inline MatrixDouble &getNormalsAtGaussPts();
173 
174  /** \brief if higher order geometry return normals at Gauss pts.
175  *
176  * \param gg gauss point number
177  */
178  inline ublas::matrix_row<MatrixDouble> getNormalsAtGaussPts(const int gg);
179 
180  /** \brief get normal at integration points
181 
182  Example:
183  \code
184  double nrm2;
185  FTensor::Index<'i',3> i;
186  auto t_normal = getFTensor1NormalsAtGaussPts();
187  for(int gg = gg!=data.getN().size1();gg++) {
188  nrm2 = sqrt(t_normal(i)*t_normal(i));
189  ++t_normal;
190  }
191  \endcode
192 
193  */
194  inline auto getFTensor1NormalsAtGaussPts();
195 
196  /** \brief get face coordinates at Gauss pts.
197 
198  \note Coordinates should be the same what function getCoordsAtGaussPts
199  on tets is returning. If both coordinates are different it is error, or you
200  do something very unusual.
201 
202  */
203  inline MatrixDouble &getFaceCoordsAtGaussPts();
204 
205 protected:
206  MoFEMErrorCode setPtrFE(ForcesAndSourcesCore *ptr);
207 };
208 
209 const std::array<int, 4> &
210 VolumeElementForcesAndSourcesCoreOnSide::getFaceConnMap() const {
211  return faceConnMap;
212 }
213 
214 const std::array<int, 8> &
215 VolumeElementForcesAndSourcesCoreOnSide::getTetConnMap() const {
216  return tetConnMap;
217 }
218 
219 int VolumeElementForcesAndSourcesCoreOnSide::getOppositeNode() const {
220  return oppositeNode;
221 }
222 
223 int VolumeElementForcesAndSourcesCoreOnSide::getFaceSense() const {
224  return getSkeletonSense();
225 }
226 
227 int VolumeElementForcesAndSourcesCoreOnSide::getSkeletonSense() const {
228  return faceSense;
229 }
230 
231 int VolumeElementForcesAndSourcesCoreOnSide::getFaceSideNumber() const {
232  return faceSideNumber;
233 }
234 
236 VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::getFaceFE()
237  const {
238  return static_cast<FaceElementForcesAndSourcesCore *>(
239  getVolumeFE()->sidePtrFE);
240 }
241 
242 VectorDouble &
243 VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::getNormal() {
244  return getFaceFE()->nOrmal;
245 }
246 
247 VectorDouble &
248 VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::getTangent1() {
249  return getFaceFE()->tangentOne;
250 }
251 
252 VectorDouble &
253 VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::getTangent2() {
254  return getFaceFE()->tangentTwo;
255 }
256 
258 VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::getVolumeFE()
259  const {
260  return static_cast<VolumeElementForcesAndSourcesCoreOnSide *>(ptrFE);
261 }
262 
263 int VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
264  getFaceSense() const {
265  return getSkeletonSense();
266 }
267 
268 int VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
269  getSkeletonSense() const {
270  return getVolumeFE()->faceSense;
271 }
272 
273 auto VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
274  getFTensor1Normal() {
275  double *ptr = &*getNormal().data().begin();
276  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
277 }
278 
279 auto VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
280  getFTensor1Tangent1() {
281  double *ptr = &*getTangent1().data().begin();
282  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
283 }
284 
285 auto VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
286  getFTensor1Tangent2() {
287  double *ptr = &*getTangent2().data().begin();
288  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
289 }
290 
291 inline auto VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
292  getFTensor1NormalsAtGaussPts() {
293  double *ptr = &*getNormalsAtGaussPts().data().begin();
294  return FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3>(ptr, &ptr[1],
295  &ptr[2]);
296 }
297 
298 int VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
299  getFaceSideNumber() const {
300  return getVolumeFE()->faceSideNumber;
301 }
302 
303 MatrixDouble &VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
304  getNormalsAtGaussPts() {
305  return getFaceFE()->normalsAtGaussPts;
306 }
307 
308 MatrixDouble &VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::
309  getFaceCoordsAtGaussPts() {
310  return getFaceFE()->coordsAtGaussPts;
311 }
312 
313 bool VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator::getEdgeFace(
314  const int ee) const {
315  constexpr bool edges_on_faces[6][4] = {{true, false, false, true}, // e0
316  {false, true, false, true}, // e1
317  {false, false, true, true}, // e2
318  {true, false, true, false}, // e3
319  {true, true, false, false}, // e4
320  {false, true, true, false}};
321  return edges_on_faces[ee][getFaceSideNumber()];
322 }
323 
324 ublas::matrix_row<MatrixDouble> VolumeElementForcesAndSourcesCoreOnSide::
325  UserDataOperator::getNormalsAtGaussPts(const int gg) {
326  return ublas::matrix_row<MatrixDouble>(getNormalsAtGaussPts(), gg);
327 }
328 
329 /**
330  * @deprecated use VolumeElementForcesAndSourcesCore
331  *
332  */
335 
336 /**
337  * @deprecated do not use this template, it is obsolete
338  */
339 template <int SWITCH>
342  using VolumeElementForcesAndSourcesCoreOnSide::
343  VolumeElementForcesAndSourcesCoreOnSide;
344  using UserDataOperator =
346 };
347 
348 
349 
350 } // namespace MoFEM
351 
352 #endif //__VOLUMEELEMENTFORCESANDSOURCESCORE_ONSIDE_HPP__
UBlasMatrix< double >
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::UserDataOperator
default operator for TET element
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:107
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::faceConnMap
std::array< int, 4 > faceConnMap
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:98
DEPRECATED
#define DEPRECATED
Definition: definitions.h:17
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::nbNodesOnFace
int nbNodesOnFace
Number of nodes on face.
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:97
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::tetConnMap
std::array< int, 8 > tetConnMap
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:99
order
constexpr int order
Definition: dg_projection.cpp:18
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::oppositeNode
int oppositeNode
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:100
MoFEM::VolumeElementForcesAndSourcesCoreOnSideBase
DEPRECATED typedef VolumeElementForcesAndSourcesCoreOnSide VolumeElementForcesAndSourcesCoreOnSideBase
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:334
MoFEM::VolumeElementForcesAndSourcesCoreOnSideSwitch
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:340
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::VolumeElementForcesAndSourcesCoreOnSide::faceSideNumber
int faceSideNumber
Face side number.
Definition: VolumeElementForcesAndSourcesCoreOnSide.hpp:96
MoFEM::FaceElementForcesAndSourcesCore
Face finite element.
Definition: FaceElementForcesAndSourcesCore.hpp:23
MoFEM::VolumeElementForcesAndSourcesCore
Volume finite element base.
Definition: VolumeElementForcesAndSourcesCore.hpp:26
MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
Definition: VolumeElementForcesAndSourcesCore.hpp:109
MoFEM::ForcesAndSourcesCore
structure to get information form mofem into EntitiesFieldData
Definition: ForcesAndSourcesCore.hpp:22
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
UBlasVector< double >
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:95