Salome HOME
Update copyrights
[modules/smesh.git] / src / MEDWrapper / MED_GaussUtils.hxx
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef MED_GaussUtils_HeaderFile
24 #define MED_GaussUtils_HeaderFile
25
26 #include "MED_WrapperDef.hxx"
27 #include "MED_Structures.hxx"
28
29 namespace MED
30 {
31   //---------------------------------------------------------------
32   typedef TVector<TCCoordSlice> TCCoordSliceArr;
33   typedef TVector<TCoordSlice> TCoordSliceArr;
34
35   //! Define a helper class to handle Gauss Points coordinates
36   class MEDWRAPPER_EXPORT TGaussCoord:
37     virtual TModeSwitchInfo
38   {
39     TInt myNbElem;
40     TInt myNbGauss;
41     TInt myDim;
42
43     TInt myGaussStep;
44
45     TNodeCoord myGaussCoord;
46
47   public:
48
49     TGaussCoord();
50
51     //! To init the class
52     void
53     Init(TInt theNbElem,
54          TInt theNbGauss,
55          TInt theDim,
56          EModeSwitch theMode = eFULL_INTERLACE);
57
58     TInt
59     GetNbElem() const;
60
61     TInt
62     GetNbGauss() const;
63
64     TInt
65     GetDim() const;
66
67     unsigned char*
68     GetValuePtr();
69
70     //! Get slice of the coordinate that corresponds to defined cell (const version)
71     TCCoordSliceArr
72     GetCoordSliceArr(TInt theElemId) const;
73
74     //! Get slice of the coordinate that corresponds to defined cell
75     TCoordSliceArr
76     GetCoordSliceArr(TInt theElemId);
77   };
78   typedef SharedPtr<TGaussCoord> PGaussCoord;
79
80   //---------------------------------------------------------------
81   //! To calculate Gauss Points coordinates
82   MEDWRAPPER_EXPORT
83   bool
84   GetGaussCoord3D(const TGaussInfo& theGaussInfo,
85                   const TCellInfo& theCellInfo,
86                   const TNodeInfo& theNodeInfo,
87                   TGaussCoord& theGaussCoord,
88                   const TElemNum& theElemNum = TElemNum(),
89                   EModeSwitch theMode = eFULL_INTERLACE);
90
91   //---------------------------------------------------------------
92   //! To calculate Gauss Points coordinates for defined TCellInfo as its bary center
93   MEDWRAPPER_EXPORT
94   bool
95   GetBaryCenter(const TCellInfo& theCellInfo,
96                 const TNodeInfo& theNodeInfo,
97                 TGaussCoord& theGaussCoord,
98                 const TElemNum& theElemNum = TElemNum(),
99                 EModeSwitch theMode = eFULL_INTERLACE);
100
101   //! To calculate Gauss Points coordinates for defined TPolygoneInfo as its bary center
102   MEDWRAPPER_EXPORT
103   bool
104   GetBaryCenter(const TPolygoneInfo& thePolygoneInfo,
105                 const TNodeInfo& theNodeInfo,
106                 TGaussCoord& theGaussCoord,
107                 const TElemNum& theElemNum = TElemNum(),
108                 EModeSwitch theMode = eFULL_INTERLACE);
109
110   //! To calculate Gauss Points coordinates for defined TPolyedreInfo as its bary center
111   MEDWRAPPER_EXPORT
112   bool
113   GetBaryCenter(const TPolyedreInfo& thePolyedreInfo,
114                 const TNodeInfo& theNodeInfo,
115                 TGaussCoord& theGaussCoord,
116                 const TElemNum& theElemNum = TElemNum(),
117                 EModeSwitch theMode = eFULL_INTERLACE);
118
119   //---------------------------------------------------------------
120   //! Shape function definitions
121   //---------------------------------------------------------------
122   struct MEDWRAPPER_EXPORT TShapeFun
123   {
124     class TFun;
125
126     TFloatVector myRefCoord;
127     TInt myDim;
128     TInt myNbRef;
129
130     TShapeFun(TInt theDim = 0, TInt theNbRef = 0);
131
132     TInt GetNbRef() const { return myNbRef; }
133
134     TCCoordSlice GetCoord(TInt theRefId) const;
135
136     TCoordSlice GetCoord(TInt theRefId);
137
138     void GetFun(const TCCoordSliceArr& theRef,
139                 const TCCoordSliceArr& theGauss,
140                 TFun& theFun) const;
141     virtual
142     void InitFun(const TCCoordSliceArr& theRef,
143                  const TCCoordSliceArr& theGauss,
144                  TFun& theFun) const = 0;
145     virtual
146     bool IsSatisfy(const TCCoordSliceArr& theRefCoord) const;
147
148     bool Eval(const TCellInfo&       theCellInfo,
149               const TNodeInfo&       theNodeInfo,
150               const TElemNum&        theElemNum,
151               const TCCoordSliceArr& theRef,
152               const TCCoordSliceArr& theGauss,
153               TGaussCoord&           theGaussCoord,
154               EModeSwitch            theMode);
155   };
156   //---------------------------------------------------------------
157   struct TSeg2a: TShapeFun {
158     TSeg2a();
159     virtual void InitFun(const TCCoordSliceArr& theRef,
160                          const TCCoordSliceArr& theGauss,
161                          TFun& theFun) const;
162   };
163   //---------------------------------------------------------------
164   struct TSeg3a: TShapeFun {
165     TSeg3a();
166     virtual void InitFun(const TCCoordSliceArr& theRef,
167                          const TCCoordSliceArr& theGauss,
168                          TFun& theFun) const;
169   };
170   //---------------------------------------------------------------
171   struct TTria3a: TShapeFun {
172     TTria3a();
173     virtual void InitFun(const TCCoordSliceArr& theRef,
174                          const TCCoordSliceArr& theGauss,
175                          TFun& theFun) const;
176   };
177   //---------------------------------------------------------------
178   struct TTria6a: TShapeFun {
179     TTria6a();
180     virtual void InitFun(const TCCoordSliceArr& theRef,
181                          const TCCoordSliceArr& theGauss,
182                          TFun& theFun) const;
183   };
184   //---------------------------------------------------------------
185   struct TTria3b: TShapeFun {
186     TTria3b();
187     virtual void InitFun(const TCCoordSliceArr& theRef,
188                          const TCCoordSliceArr& theGauss,
189                          TFun& theFun) const;
190   };
191   //---------------------------------------------------------------
192   struct TTria6b: TShapeFun {
193     TTria6b();
194     virtual void InitFun(const TCCoordSliceArr& theRef,
195                          const TCCoordSliceArr& theGauss,
196                          TFun& theFun) const;
197   };
198   //---------------------------------------------------------------
199   struct TQuad4a: TShapeFun {
200     TQuad4a();
201     virtual void InitFun(const TCCoordSliceArr& theRef,
202                          const TCCoordSliceArr& theGauss,
203                          TFun& theFun) const;
204   };
205   //---------------------------------------------------------------
206   struct TQuad8a: TShapeFun {
207     TQuad8a();
208     virtual void InitFun(const TCCoordSliceArr& theRef,
209                          const TCCoordSliceArr& theGauss,
210                          TFun& theFun) const;
211   };
212   //---------------------------------------------------------------
213   struct TQuad9a: TShapeFun {
214     TQuad9a();
215     virtual void InitFun(const TCCoordSliceArr& theRef,
216                          const TCCoordSliceArr& theGauss,
217                          TFun& theFun) const;
218   };
219   //---------------------------------------------------------------
220   struct TQuad4b: TShapeFun {
221     TQuad4b();
222     virtual void InitFun(const TCCoordSliceArr& theRef,
223                          const TCCoordSliceArr& theGauss,
224                          TFun& theFun) const;
225   };
226   //---------------------------------------------------------------
227   struct TQuad8b: TShapeFun {
228     TQuad8b();
229     virtual void InitFun(const TCCoordSliceArr& theRef,
230                          const TCCoordSliceArr& theGauss,
231                          TFun& theFun) const;
232   };
233   //---------------------------------------------------------------
234   struct TQuad9b: TShapeFun {
235     TQuad9b();
236     virtual void InitFun(const TCCoordSliceArr& theRef,
237                          const TCCoordSliceArr& theGauss,
238                          TFun& theFun) const;
239   };
240   //---------------------------------------------------------------
241   struct TTetra4a: TShapeFun {
242     TTetra4a();
243     virtual void InitFun(const TCCoordSliceArr& theRef,
244                          const TCCoordSliceArr& theGauss,
245                          TFun& theFun) const;
246   };
247   //---------------------------------------------------------------
248   struct TTetra10a: TShapeFun {
249     TTetra10a();
250     virtual void InitFun(const TCCoordSliceArr& theRef,
251                          const TCCoordSliceArr& theGauss,
252                          TFun& theFun) const;
253   };
254   //---------------------------------------------------------------
255   struct TTetra4b: TShapeFun {
256     TTetra4b();
257     virtual void InitFun(const TCCoordSliceArr& theRef,
258                          const TCCoordSliceArr& theGauss,
259                          TFun& theFun) const;
260   };
261   //---------------------------------------------------------------
262   struct TTetra10b: TShapeFun {
263     TTetra10b();
264     virtual void InitFun(const TCCoordSliceArr& theRef,
265                          const TCCoordSliceArr& theGauss,
266                          TFun& theFun) const;
267   };
268   //---------------------------------------------------------------
269   struct THexa8a: TShapeFun {
270     THexa8a();
271     virtual void InitFun(const TCCoordSliceArr& theRef,
272                          const TCCoordSliceArr& theGauss,
273                          TFun& theFun) const;
274   };
275   //---------------------------------------------------------------
276   struct THexa20a: TShapeFun {
277     THexa20a(TInt theDim = 3, TInt theNbRef = 20);
278     virtual void InitFun(const TCCoordSliceArr& theRef,
279                          const TCCoordSliceArr& theGauss,
280                          TFun& theFun) const;
281   };
282   //---------------------------------------------------------------
283   struct THexa27a: THexa20a {
284     THexa27a();
285     virtual void InitFun(const TCCoordSliceArr& theRef,
286                          const TCCoordSliceArr& theGauss,
287                          TFun& theFun) const;
288   };
289   //---------------------------------------------------------------
290   struct THexa8b: TShapeFun {
291     THexa8b();
292     virtual void InitFun(const TCCoordSliceArr& theRef,
293                          const TCCoordSliceArr& theGauss,
294                          TFun& theFun) const;
295   };
296   //---------------------------------------------------------------
297   struct THexa20b: TShapeFun {
298     THexa20b(TInt theDim = 3, TInt theNbRef = 20);
299     virtual void InitFun(const TCCoordSliceArr& theRef,
300                          const TCCoordSliceArr& theGauss,
301                          TFun& theFun) const;
302   };
303   //---------------------------------------------------------------
304   struct TPenta6a: TShapeFun {
305     TPenta6a();
306     virtual void InitFun(const TCCoordSliceArr& theRef,
307                          const TCCoordSliceArr& theGauss,
308                          TFun& theFun) const;
309   };
310   //---------------------------------------------------------------
311   struct TPenta6b: TShapeFun {
312     TPenta6b();
313     virtual void InitFun(const TCCoordSliceArr& theRef,
314                          const TCCoordSliceArr& theGauss,
315                          TFun& theFun) const;
316   };
317   //---------------------------------------------------------------
318   struct TPenta15a: TShapeFun {
319     TPenta15a();
320     virtual void InitFun(const TCCoordSliceArr& theRef,
321                          const TCCoordSliceArr& theGauss,
322                          TFun& theFun) const;
323   };
324   //---------------------------------------------------------------
325   struct TPenta15b: TShapeFun {
326     TPenta15b();
327     virtual void InitFun(const TCCoordSliceArr& theRef,
328                          const TCCoordSliceArr& theGauss,
329                          TFun& theFun) const;
330   };
331   //---------------------------------------------------------------
332   struct TPyra5a: TShapeFun {
333     TPyra5a();
334     virtual void InitFun(const TCCoordSliceArr& theRef,
335                          const TCCoordSliceArr& theGauss,
336                          TFun& theFun) const;
337   };
338   //---------------------------------------------------------------
339   struct TPyra5b: TShapeFun {
340     TPyra5b();
341     virtual void InitFun(const TCCoordSliceArr& theRef,
342                          const TCCoordSliceArr& theGauss,
343                          TFun& theFun) const;
344   };
345   //---------------------------------------------------------------
346   struct TPyra13a: TShapeFun {
347     TPyra13a();
348     virtual void InitFun(const TCCoordSliceArr& theRef,
349                          const TCCoordSliceArr& theGauss,
350                          TFun& theFun) const;
351   };
352   //---------------------------------------------------------------
353   struct TPyra13b: TShapeFun {
354     TPyra13b();
355     virtual void InitFun(const TCCoordSliceArr& theRef,
356                          const TCCoordSliceArr& theGauss,
357                          TFun& theFun) const;
358   };
359   //---------------------------------------------------------------
360 }
361
362 #endif // MED_GaussUtils_HeaderFile