v0.14.0
Loading...
Searching...
No Matches
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
9using namespace boost::numeric;
10
11namespace MoFEM {
12
13struct VolumeElementForcesAndSourcesCoreOnSide;
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
37
39
40protected:
41 /**
42 * \brief Calculate element area and normal of the face at integration points
43 *
44 * @return Error code
45 */
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 */
57
58 /**
59 * \brief Set integration points
60 * @return Error code
61 */
63
64 /**
65 * \brief Determine approximation space and order of base functions
66 * @return Error code
67 */
69
70 /**
71 * \brief Calculate coordinate at integration points
72 * @return Error code
73 */
75
76 double &aRea;
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
97 using ForcesAndSourcesCore::UserDataOperator::UserDataOperator;
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 */
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 */
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 */
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 */
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
235private:
237};
238
239double FaceElementForcesAndSourcesCore::UserDataOperator::getArea() {
240 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->aRea;
241}
242
243VectorDouble &FaceElementForcesAndSourcesCore::UserDataOperator::getNormal() {
244 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->nOrmal;
245}
246
247VectorDouble &FaceElementForcesAndSourcesCore::UserDataOperator::getTangent1() {
248 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->tangentOne;
249}
250
251VectorDouble &FaceElementForcesAndSourcesCore::UserDataOperator::getTangent2() {
252 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->tangentTwo;
253}
254
255auto FaceElementForcesAndSourcesCore::UserDataOperator::getFTensor1Normal() {
256 double *ptr = &*getNormal().data().begin();
257 return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
258}
259
260auto FaceElementForcesAndSourcesCore::UserDataOperator::getFTensor1Tangent1() {
261 double *ptr = &*getTangent1().data().begin();
262 return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
263}
264
265auto FaceElementForcesAndSourcesCore::UserDataOperator::getFTensor1Tangent2() {
266 double *ptr = &*getTangent2().data().begin();
267 return FTensor::Tensor1<double *, 3>(ptr, &ptr[1], &ptr[2]);
268}
269
270int FaceElementForcesAndSourcesCore::UserDataOperator::getNumNodes() {
271 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->num_nodes;
272}
273
274const EntityHandle *
275FaceElementForcesAndSourcesCore::UserDataOperator::getConn() {
276 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->conn;
277}
278
279VectorDouble &FaceElementForcesAndSourcesCore::UserDataOperator::getCoords() {
280 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)->coords;
281}
282
283auto FaceElementForcesAndSourcesCore::UserDataOperator::getFTensor1Coords() {
284 double *ptr = &*getCoords().data().begin();
286 &ptr[2]);
287}
288
290FaceElementForcesAndSourcesCore::UserDataOperator::getNormalsAtGaussPts() {
291 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)
293}
294
295ublas::matrix_row<MatrixDouble>
296FaceElementForcesAndSourcesCore::UserDataOperator::getNormalsAtGaussPts(
297 const int gg) {
298 return ublas::matrix_row<MatrixDouble>(
300 gg);
301}
302
304FaceElementForcesAndSourcesCore::UserDataOperator::getTangent1AtGaussPts() {
305 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)
307}
308
310FaceElementForcesAndSourcesCore::UserDataOperator::getTangent2AtGaussPts() {
311 return static_cast<FaceElementForcesAndSourcesCore *>(ptrFE)
313}
314
315auto FaceElementForcesAndSourcesCore::UserDataOperator::
316 getFTensor1NormalsAtGaussPts() {
317 double *ptr = &*getNormalsAtGaussPts().data().begin();
319 &ptr[2]);
320}
321
322auto FaceElementForcesAndSourcesCore::UserDataOperator::
323 getFTensor1Tangent1AtGaussPts() {
324 double *ptr = &*getTangent1AtGaussPts().data().begin();
326 &ptr[2]);
327}
328
329auto FaceElementForcesAndSourcesCore::UserDataOperator::
330 getFTensor1Tangent2AtGaussPts() {
331 double *ptr = &*getTangent2AtGaussPts().data().begin();
333 &ptr[2]);
334}
335
337FaceElementForcesAndSourcesCore::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 */
357template <>
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
370protected:
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 **/
ForcesAndSourcesCore::UserDataOperator UserDataOperator
T data[Tensor_Dim]
@ NOSPACE
Definition definitions.h:83
#define DEPRECATED
Definition definitions.h:17
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
Definition Common.hpp:10
DEPRECATED typedef FaceElementForcesAndSourcesCore FaceElementForcesAndSourcesCoreBase
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
MatrixDouble & getNormalsAtGaussPts()
if higher order geometry return normals at Gauss pts.
MoFEMErrorCode loopSideVolumes(const string fe_name, VolumeElementForcesAndSourcesCoreOnSide &fe_method)
FaceElementForcesAndSourcesCore * getFaceFE()
return pointer to Generic Triangle Finite Element object
MatrixDouble & getTangent2AtGaussPts()
if higher order geometry return tangent vector to triangle at Gauss pts.
MatrixDouble & getTangent1AtGaussPts()
if higher order geometry return tangent vector to triangle at Gauss pts.
virtual MoFEMErrorCode calculateAreaAndNormal()
Calculate element area and normal of the face.
MoFEMErrorCode operator()()
function is run for every finite element
virtual MoFEMErrorCode getSpaceBaseAndOrderOnElement()
Determine approximation space and order of base functions.
virtual MoFEMErrorCode calculateAreaAndNormalAtIntegrationPts()
Calculate element area and normal of the face at integration points.
virtual MoFEMErrorCode setIntegrationPts()
Set integration points.
virtual MoFEMErrorCode calculateCoordinatesAtGaussPts()
Calculate coordinate at integration points.
structure to get information form mofem into EntitiesFieldData
boost::shared_ptr< FaceElementForcesAndSourcesCore > toElePtr
OpCopyGeomDataToE(boost::shared_ptr< E > to_ele_ptr)
Copy geometry-related data from one element to other.