v0.14.0
FaceElementForcesAndSourcesCore.hpp
Go to the documentation of this file.
1 /** \file FaceElementForcesAndSourcesCore.hpp
2  \brief Implementation of face element.
3 
4 */
5 
6 #ifndef __FACEELEMENTFORCESANDSOURCESCORE_HPP__
7 #define __FACEELEMENTFORCESANDSOURCESCORE_HPP__
8 
9 using namespace boost::numeric;
10 
11 namespace MoFEM {
12 
14 
15 /** \brief Face finite element
16  \ingroup mofem_forces_and_sources_tri_element
17 
18  User is implementing own operator at Gauss point level, by own object
19  derived from FaceElementForcesAndSourcesCoreL::UserDataOperator. Arbitrary
20  number of operator added pushing objects to OpPtrVector
21 
22  */
24 
25  /**
26  * @deprecated not used anymore, will be removed in next versions
27  *
28  */
30 
31  /** \brief default operator for TRI element
32  * \ingroup mofem_forces_and_sources_tri_element
33  */
34  struct UserDataOperator;
35 
36  MoFEMErrorCode operator()();
37 
39 
40 protected:
41  /**
42  * \brief Calculate element area and normal of the face at integration points
43  *
44  * @return Error code
45  */
46  virtual MoFEMErrorCode calculateAreaAndNormalAtIntegrationPts();
47 
48  /**
49  * \brief Calculate element area and normal of the face
50  *
51  * Note that at that point is assumed that geometry is exclusively defined
52  * by corner nodes.
53  *
54  * @return Error code
55  */
56  virtual MoFEMErrorCode calculateAreaAndNormal();
57 
58  /**
59  * \brief Set integration points
60  * @return Error code
61  */
62  virtual MoFEMErrorCode setIntegrationPts();
63 
64  /**
65  * \brief Determine approximation space and order of base functions
66  * @return Error code
67  */
68  virtual MoFEMErrorCode getSpaceBaseAndOrderOnElement();
69 
70  /**
71  * \brief Calculate coordinate at integration points
72  * @return Error code
73  */
74  virtual MoFEMErrorCode calculateCoordinatesAtGaussPts();
75 
76  double &aRea;
77  int num_nodes;
79  VectorDouble nOrmal, tangentOne, tangentTwo;
81 
85 
86  friend class UserDataOperator;
88  template <int DIM> friend struct OpCopyGeomDataToE;
89 };
90 
91 /** \brief default operator for TRI element
92  * \ingroup mofem_forces_and_sources_tri_element
93  */
96 
98 
99  /**
100  * \brief get area of face
101  * @return area of face
102  */
103  inline double getArea();
104 
105  /** \brief get triangle normal
106  */
107  inline VectorDouble &getNormal();
108 
109  /** \brief get triangle tangent 1
110  */
111  inline VectorDouble &getTangent1();
112 
113  /** \brief get triangle tangent 2
114  */
115  inline VectorDouble &getTangent2();
116 
117  /** \brief get normal as tensor
118  */
119  inline auto getFTensor1Normal();
120 
121  /** \brief get tangentOne as tensor
122  */
123  inline auto getFTensor1Tangent1();
124 
125  /** \brief get tangentTwo as tensor
126  */
127  inline auto getFTensor1Tangent2();
128 
129  /** \brief get element number of nodes
130  */
131  inline int getNumNodes();
132 
133  /** \brief get element connectivity
134  */
135  inline const EntityHandle *getConn();
136 
137  /** \brief get triangle coordinates
138  */
139  inline VectorDouble &getCoords();
140 
141  /**
142  * \brief get get coords at gauss points
143 
144  \code
145  FTensor::Index<'i',3> i;
146  FTensor::Tensor1<double,3> t_center;
147  auto t_coords = getFTensor1Coords();
148  t_center(i) = 0;
149  for(int nn = 0;nn!=3;nn++) {
150  t_center(i) += t_coords(i);
151  ++t_coords;
152  }
153  t_center(i) /= 3;
154  \endcode
155 
156  */
157  inline auto getFTensor1Coords();
158 
159  /** \brief if higher order geometry return normals at Gauss pts.
160 
161  Note: returned matrix has size 0 in rows and columns if no HO approximation
162  of geometry is available.
163 
164  */
165  inline MatrixDouble &getNormalsAtGaussPts();
166 
167  /** \brief if higher order geometry return normals at Gauss pts.
168  *
169  * \param gg gauss point number
170  */
171  inline ublas::matrix_row<MatrixDouble> getNormalsAtGaussPts(const int gg);
172 
173  /** \brief if higher order geometry return tangent vector to triangle at
174  Gauss pts.
175 
176  Note: returned matrix has size 0 in rows and columns if no HO approximation
177  of geometry is avaliable.
178 
179  */
180  inline MatrixDouble &getTangent1AtGaussPts();
181 
182  /** \brief if higher order geometry return tangent vector to triangle at
183  Gauss pts.
184 
185  Note: returned matrix has size 0 in rows and columns if no HO approximation
186  of geometry is avaliable.
187 
188  */
189  inline MatrixDouble &getTangent2AtGaussPts();
190 
191  /** \brief get normal at integration points
192 
193  Example:
194  \code
195  double nrm2;
196  FTensor::Index<'i',3> i;
197  auto t_normal = getFTensor1NormalsAtGaussPts();
198  for(int gg = gg!=data.getN().size1();gg++) {
199  nrm2 = sqrt(t_normal(i)*t_normal(i));
200  ++t_normal;
201  }
202  \endcode
203 
204  */
205  inline auto getFTensor1NormalsAtGaussPts();
206 
207  /** \brief get tangent 1 at integration points
208 
209  */
210  inline auto getFTensor1Tangent1AtGaussPts();
211 
212  /** \brief get tangent 2 at integration points
213 
214  */
215  inline auto getFTensor1Tangent2AtGaussPts();
216 
217  /** \brief return pointer to Generic Triangle Finite Element object
218  */
219  inline FaceElementForcesAndSourcesCore *getFaceFE();
220 
221  /**
222  *
223  * User call this function to loop over elements on the side of face. This
224  * function calls MoFEM::VolumeElementForcesAndSourcesCoreOnSide with is
225  * operator to do calculations.
226  *
227  * @param fe_name Name of the element
228  * @param method Finite element object
229  * @return error code
230  */
232  loopSideVolumes(const string fe_name,
234 
235 private:
236  MoFEMErrorCode setPtrFE(ForcesAndSourcesCore *ptr);
237 };
238 
239 double FaceElementForcesAndSourcesCore::UserDataOperator::getArea() {
240  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->aRea;
241 }
242 
243 VectorDouble &FaceElementForcesAndSourcesCore::UserDataOperator::getNormal() {
244  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->nOrmal;
245 }
246 
247 VectorDouble &FaceElementForcesAndSourcesCore::UserDataOperator::getTangent1() {
248  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->tangentOne;
249 }
250 
251 VectorDouble &FaceElementForcesAndSourcesCore::UserDataOperator::getTangent2() {
252  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->tangentTwo;
253 }
254 
255 auto FaceElementForcesAndSourcesCore::UserDataOperator::getFTensor1Normal() {
256  double *ptr = &*getNormal().data().begin();
257  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
258 }
259 
260 auto FaceElementForcesAndSourcesCore::UserDataOperator::getFTensor1Tangent1() {
261  double *ptr = &*getTangent1().data().begin();
262  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
263 }
264 
265 auto FaceElementForcesAndSourcesCore::UserDataOperator::getFTensor1Tangent2() {
266  double *ptr = &*getTangent2().data().begin();
267  return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
268 }
269 
270 int FaceElementForcesAndSourcesCore::UserDataOperator::getNumNodes() {
271  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->num_nodes;
272 }
273 
274 const EntityHandle *
275 FaceElementForcesAndSourcesCore::UserDataOperator::getConn() {
276  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->conn;
277 }
278 
279 VectorDouble &FaceElementForcesAndSourcesCore::UserDataOperator::getCoords() {
280  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->coords;
281 }
282 
283 auto FaceElementForcesAndSourcesCore::UserDataOperator::getFTensor1Coords() {
284  double *ptr = &*getCoords().data().begin();
285  return FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3>(ptr, &ptr[1],
286  &ptr[2]);
287 }
288 
289 MatrixDouble &
290 FaceElementForcesAndSourcesCore::UserDataOperator::getNormalsAtGaussPts() {
291  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)
292  ->normalsAtGaussPts;
293 }
294 
295 ublas::matrix_row<MatrixDouble>
296 FaceElementForcesAndSourcesCore::UserDataOperator::getNormalsAtGaussPts(
297  const int gg) {
298  return ublas::matrix_row<MatrixDouble>(
299  static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->normalsAtGaussPts,
300  gg);
301 }
302 
303 MatrixDouble &
304 FaceElementForcesAndSourcesCore::UserDataOperator::getTangent1AtGaussPts() {
305  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)
306  ->tangentOneAtGaussPts;
307 }
308 
309 MatrixDouble &
310 FaceElementForcesAndSourcesCore::UserDataOperator::getTangent2AtGaussPts() {
311  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)
312  ->tangentTwoAtGaussPts;
313 }
314 
315 auto FaceElementForcesAndSourcesCore::UserDataOperator::
316  getFTensor1NormalsAtGaussPts() {
317  double *ptr = &*getNormalsAtGaussPts().data().begin();
318  return FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3>(ptr, &ptr[1],
319  &ptr[2]);
320 }
321 
322 auto FaceElementForcesAndSourcesCore::UserDataOperator::
323  getFTensor1Tangent1AtGaussPts() {
324  double *ptr = &*getTangent1AtGaussPts().data().begin();
325  return FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3>(ptr, &ptr[1],
326  &ptr[2]);
327 }
328 
329 auto FaceElementForcesAndSourcesCore::UserDataOperator::
330  getFTensor1Tangent2AtGaussPts() {
331  double *ptr = &*getTangent2AtGaussPts().data().begin();
332  return FTensor::Tensor1<FTensor::PackPtr<double *, 3>, 3>(ptr, &ptr[1],
333  &ptr[2]);
334 }
335 
337 FaceElementForcesAndSourcesCore::UserDataOperator::getFaceFE() {
338  return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE);
339 }
340 
341 /** \deprecated use FaceElementForcesAndSourcesCore
342  */
345 
346 /**
347  * \brief Copy geometry-related data from one element to other
348  *
349  * That can be used to copy high order geometry data from coarse element to
350  * children. That is often a case when higher order geometry is defined only on
351  * coarse elements.
352  *
353  * \note Element have to share the same integration points, i.e. number of
354  * integration points has to be the same, and geometric location.
355  *
356  */
357 template <>
360 
361  template <typename E>
362  OpCopyGeomDataToE(boost::shared_ptr<E> to_ele_ptr)
364  toElePtr(boost::dynamic_pointer_cast<FaceElementForcesAndSourcesCore>(
365  to_ele_ptr)) {}
366 
367  MoFEMErrorCode doWork(int side, EntityType type,
369 
370 protected:
371  boost::shared_ptr<FaceElementForcesAndSourcesCore> toElePtr;
372 };
373 
374 } // namespace MoFEM
375 
376 #endif //__FACEELEMENTFORCESANDSOURCESCORE_HPP__
377 
378 /**
379  * \defgroup mofem_forces_and_sources_tri_element Face Element
380  * \brief Implementation of face element
381  *
382  * \ingroup mofem_forces_and_sources
383  **/
NOSPACE
@ NOSPACE
Definition: definitions.h:83
MoFEM::EntitiesFieldData::EntData
Data on single entity (This is passed as argument to DataOperator::doWork)
Definition: EntitiesFieldData.hpp:127
MoFEM::FaceElementForcesAndSourcesCore::tangentTwo
VectorDouble tangentTwo
Definition: FaceElementForcesAndSourcesCore.hpp:79
DEPRECATED
#define DEPRECATED
Definition: definitions.h:17
FTensor::Tensor1
Definition: Tensor1_value.hpp:8
EntityHandle
MoFEM::OpCopyGeomDataToE< 2 >::OpCopyGeomDataToE
OpCopyGeomDataToE(boost::shared_ptr< E > to_ele_ptr)
Definition: FaceElementForcesAndSourcesCore.hpp:362
MoFEM::FaceElementForcesAndSourcesCore::meshPositionsFieldName
std::string meshPositionsFieldName
Definition: FaceElementForcesAndSourcesCore.hpp:29
MoFEM::FaceElementForcesAndSourcesCore::tangentTwoAtGaussPts
MatrixDouble tangentTwoAtGaussPts
Definition: FaceElementForcesAndSourcesCore.hpp:84
VolumeElementForcesAndSourcesCoreOnSide
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
MoFEM::OpCopyGeomDataToE< 2 >::toElePtr
boost::shared_ptr< FaceElementForcesAndSourcesCore > toElePtr
Definition: FaceElementForcesAndSourcesCore.hpp:371
MoFEM::FaceElementForcesAndSourcesCore::aRea
double & aRea
Definition: FaceElementForcesAndSourcesCore.hpp:76
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
FTensor::Tensor1::data
T data[Tensor_Dim]
Definition: Tensor1_value.hpp:10
MoFEM::FaceElementForcesAndSourcesCore::conn
const EntityHandle * conn
Definition: FaceElementForcesAndSourcesCore.hpp:78
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::FaceElementForcesAndSourcesCore::num_nodes
int num_nodes
Definition: FaceElementForcesAndSourcesCore.hpp:77
MoFEM::ForcesAndSourcesCore::UserDataOperator
Definition: ForcesAndSourcesCore.hpp:549
MoFEM::OpCopyGeomDataToE
Copy geometry-related data from one element to other.
Definition: ForcesAndSourcesCore.hpp:1341
MoFEM::FaceElementForcesAndSourcesCore::UserDataOperator
default operator for TRI element
Definition: FaceElementForcesAndSourcesCore.hpp:94
convert.type
type
Definition: convert.py:64
MoFEM::FaceElementForcesAndSourcesCoreBase
DEPRECATED typedef FaceElementForcesAndSourcesCore FaceElementForcesAndSourcesCoreBase
Definition: FaceElementForcesAndSourcesCore.hpp:344
MoFEM::FaceElementForcesAndSourcesCore
Face finite element.
Definition: FaceElementForcesAndSourcesCore.hpp:23
MoFEM::ForcesAndSourcesCore
structure to get information form mofem into EntitiesFieldData
Definition: ForcesAndSourcesCore.hpp:22
MoFEM::ForcesAndSourcesCore::UserDataOperator::FaceElementForcesAndSourcesCore
friend class FaceElementForcesAndSourcesCore
Definition: ForcesAndSourcesCore.hpp:991
MoFEM::FaceElementForcesAndSourcesCore::tangentOneAtGaussPts
MatrixDouble tangentOneAtGaussPts
Definition: FaceElementForcesAndSourcesCore.hpp:83
MoFEM::FaceElementForcesAndSourcesCore::coords
VectorDouble coords
Definition: FaceElementForcesAndSourcesCore.hpp:80
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::FaceElementForcesAndSourcesCore::normalsAtGaussPts
MatrixDouble normalsAtGaussPts
Definition: FaceElementForcesAndSourcesCore.hpp:82