Salome HOME
CoTech decision: move MEDWrapper from MED to SMESH
[modules/smesh.git] / src / MEDWrapper / Base / MED_GaussUtils.hxx
1 // Copyright (C) 2007-2013  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.
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_WrapperBase.hxx"
27
28 #include "MED_Structures.hxx"
29
30 namespace MED
31 {
32   //---------------------------------------------------------------
33   typedef TVector<TCCoordSlice> TCCoordSliceArr;
34   typedef TVector<TCoordSlice> TCoordSliceArr;
35
36   //! Define a helper class to handle Gauss Points coordinates
37   class MEDWRAPPER_EXPORT TGaussCoord:
38     virtual TModeSwitchInfo 
39   {
40     TInt myNbElem;
41     TInt myNbGauss;
42     TInt myDim;
43
44     TInt myGaussStep;
45
46     TNodeCoord myGaussCoord;
47
48   public:
49     
50     TGaussCoord();
51
52     //! To init the class
53     void
54     Init(TInt theNbElem,
55          TInt theNbGauss,
56          TInt theDim,
57          EModeSwitch theMode = eFULL_INTERLACE);
58
59     TInt
60     GetNbElem() const;
61
62     TInt
63     GetNbGauss() const;
64
65     TInt
66     GetDim() const;
67
68     unsigned char*
69     GetValuePtr();
70
71     //! Get slice of the coordinate that corresponds to defined cell (const version)
72     TCCoordSliceArr
73     GetCoordSliceArr(TInt theElemId) const;
74
75     //! Get slice of the coordinate that corresponds to defined cell
76     TCoordSliceArr 
77     GetCoordSliceArr(TInt theElemId);
78   };
79   typedef SharedPtr<TGaussCoord> PGaussCoord;
80
81
82   //---------------------------------------------------------------
83   //! To calculate Gauss Points coordinates
84   MEDWRAPPER_EXPORT 
85   bool
86   GetGaussCoord3D(const TGaussInfo& theGaussInfo, 
87                   const TCellInfo& theCellInfo,
88                   const TNodeInfo& theNodeInfo,
89                   TGaussCoord& theGaussCoord,
90                   const TElemNum& theElemNum = TElemNum(),
91                   EModeSwitch theMode = eFULL_INTERLACE);
92
93
94   //---------------------------------------------------------------
95   //! To calculate Gauss Points coordinates for defined TCellInfo as its bary center
96   MEDWRAPPER_EXPORT 
97   bool
98   GetBaryCenter(const TCellInfo& theCellInfo,
99                 const TNodeInfo& theNodeInfo,
100                 TGaussCoord& theGaussCoord,
101                 const TElemNum& theElemNum = TElemNum(),
102                 EModeSwitch theMode = eFULL_INTERLACE);
103
104   //! To calculate Gauss Points coordinates for defined TPolygoneInfo as its bary center
105   MEDWRAPPER_EXPORT 
106   bool
107   GetBaryCenter(const TPolygoneInfo& thePolygoneInfo,
108                 const TNodeInfo& theNodeInfo,
109                 TGaussCoord& theGaussCoord,
110                 const TElemNum& theElemNum = TElemNum(),
111                 EModeSwitch theMode = eFULL_INTERLACE);
112
113   //! To calculate Gauss Points coordinates for defined TPolyedreInfo as its bary center
114   MEDWRAPPER_EXPORT 
115   bool
116   GetBaryCenter(const TPolyedreInfo& thePolyedreInfo,
117                 const TNodeInfo& theNodeInfo,
118                 TGaussCoord& theGaussCoord,
119                 const TElemNum& theElemNum = TElemNum(),
120                 EModeSwitch theMode = eFULL_INTERLACE);
121
122   //---------------------------------------------------------------
123   //! Shape function definitions
124   //---------------------------------------------------------------
125   struct MEDWRAPPER_EXPORT TShapeFun
126   {
127     class TFun;
128     
129     TFloatVector myRefCoord;
130     TInt myDim;
131     TInt myNbRef;
132
133     TShapeFun(TInt theDim = 0, TInt theNbRef = 0);
134
135     TInt GetNbRef() const { return myNbRef; }
136
137     TCCoordSlice GetCoord(TInt theRefId) const;
138
139     TCoordSlice GetCoord(TInt theRefId);
140
141     void GetFun(const TCCoordSliceArr& theRef,
142                 const TCCoordSliceArr& theGauss,
143                 TFun& theFun) const;
144     virtual 
145     void InitFun(const TCCoordSliceArr& theRef,
146                  const TCCoordSliceArr& theGauss,
147                  TFun& theFun) const = 0;
148     virtual
149     bool IsSatisfy(const TCCoordSliceArr& theRefCoord) const;
150
151     bool Eval(const TCellInfo&       theCellInfo,
152               const TNodeInfo&       theNodeInfo,
153               const TElemNum&        theElemNum,
154               const TCCoordSliceArr& theRef,
155               const TCCoordSliceArr& theGauss,
156               TGaussCoord&           theGaussCoord,
157               EModeSwitch            theMode);
158   };
159   //---------------------------------------------------------------
160   struct TSeg2a: TShapeFun {
161     TSeg2a();
162     virtual void InitFun(const TCCoordSliceArr& theRef,
163                          const TCCoordSliceArr& theGauss,
164                          TFun& theFun) const;
165   };
166   //---------------------------------------------------------------
167   struct TSeg3a: TShapeFun {
168     TSeg3a();
169     virtual void InitFun(const TCCoordSliceArr& theRef,
170                          const TCCoordSliceArr& theGauss,
171                          TFun& theFun) const;
172   };
173   //---------------------------------------------------------------
174   struct TTria3a: TShapeFun {
175     TTria3a();
176     virtual void InitFun(const TCCoordSliceArr& theRef,
177                          const TCCoordSliceArr& theGauss,
178                          TFun& theFun) const;
179   };
180   //---------------------------------------------------------------
181   struct TTria6a: TShapeFun {
182     TTria6a();
183     virtual void InitFun(const TCCoordSliceArr& theRef,
184                          const TCCoordSliceArr& theGauss,
185                          TFun& theFun) const;
186   };
187   //---------------------------------------------------------------
188   struct TTria3b: TShapeFun {
189     TTria3b();
190     virtual void InitFun(const TCCoordSliceArr& theRef,
191                          const TCCoordSliceArr& theGauss,
192                          TFun& theFun) const;
193   };
194   //---------------------------------------------------------------
195   struct TTria6b: TShapeFun {
196     TTria6b();
197     virtual void InitFun(const TCCoordSliceArr& theRef,
198                          const TCCoordSliceArr& theGauss,
199                          TFun& theFun) const;
200   };
201   //---------------------------------------------------------------
202   struct TQuad4a: TShapeFun {
203     TQuad4a();
204     virtual void InitFun(const TCCoordSliceArr& theRef,
205                          const TCCoordSliceArr& theGauss,
206                          TFun& theFun) const;
207   };
208   //---------------------------------------------------------------
209   struct TQuad8a: TShapeFun {
210     TQuad8a();
211     virtual void InitFun(const TCCoordSliceArr& theRef,
212                          const TCCoordSliceArr& theGauss,
213                          TFun& theFun) const;
214   };
215   //---------------------------------------------------------------
216   struct TQuad9a: TShapeFun {
217     TQuad9a();
218     virtual void InitFun(const TCCoordSliceArr& theRef,
219                          const TCCoordSliceArr& theGauss,
220                          TFun& theFun) const;
221   };
222   //---------------------------------------------------------------
223   struct TQuad4b: TShapeFun {
224     TQuad4b();
225     virtual void InitFun(const TCCoordSliceArr& theRef,
226                          const TCCoordSliceArr& theGauss,
227                          TFun& theFun) const;
228   };
229   //---------------------------------------------------------------
230   struct TQuad8b: TShapeFun {
231     TQuad8b();
232     virtual void InitFun(const TCCoordSliceArr& theRef,
233                          const TCCoordSliceArr& theGauss,
234                          TFun& theFun) const;
235   };
236   //---------------------------------------------------------------
237   struct TQuad9b: TShapeFun {
238     TQuad9b();
239     virtual void InitFun(const TCCoordSliceArr& theRef,
240                          const TCCoordSliceArr& theGauss,
241                          TFun& theFun) const;
242   };
243   //---------------------------------------------------------------
244   struct TTetra4a: TShapeFun {
245     TTetra4a();
246     virtual void InitFun(const TCCoordSliceArr& theRef,
247                          const TCCoordSliceArr& theGauss,
248                          TFun& theFun) const;
249   };
250   //---------------------------------------------------------------
251   struct TTetra10a: TShapeFun {
252     TTetra10a();
253     virtual void InitFun(const TCCoordSliceArr& theRef,
254                          const TCCoordSliceArr& theGauss,
255                          TFun& theFun) const;
256   };
257   //---------------------------------------------------------------
258   struct TTetra4b: TShapeFun {
259     TTetra4b();
260     virtual void InitFun(const TCCoordSliceArr& theRef,
261                          const TCCoordSliceArr& theGauss,
262                          TFun& theFun) const;
263   };
264   //---------------------------------------------------------------
265   struct TTetra10b: TShapeFun {
266     TTetra10b();
267     virtual void InitFun(const TCCoordSliceArr& theRef,
268                          const TCCoordSliceArr& theGauss,
269                          TFun& theFun) const;
270   };
271   //---------------------------------------------------------------
272   struct THexa8a: TShapeFun {
273     THexa8a();
274     virtual void InitFun(const TCCoordSliceArr& theRef,
275                          const TCCoordSliceArr& theGauss,
276                          TFun& theFun) const;
277   };
278   //---------------------------------------------------------------
279   struct THexa20a: TShapeFun {
280     THexa20a(TInt theDim = 3, TInt theNbRef = 20);
281     virtual void InitFun(const TCCoordSliceArr& theRef,
282                          const TCCoordSliceArr& theGauss,
283                          TFun& theFun) const;
284   };
285   //---------------------------------------------------------------
286   struct THexa27a: THexa20a {
287     THexa27a();
288     virtual void InitFun(const TCCoordSliceArr& theRef,
289                          const TCCoordSliceArr& theGauss,
290                          TFun& theFun) const;
291   };
292   //---------------------------------------------------------------
293   struct THexa8b: TShapeFun {
294     THexa8b();
295     virtual void InitFun(const TCCoordSliceArr& theRef,
296                          const TCCoordSliceArr& theGauss,
297                          TFun& theFun) const;
298   };
299   //---------------------------------------------------------------
300   struct THexa20b: TShapeFun {
301     THexa20b(TInt theDim = 3, TInt theNbRef = 20);
302     virtual void InitFun(const TCCoordSliceArr& theRef,
303                          const TCCoordSliceArr& theGauss,
304                          TFun& theFun) const;
305   };
306   //---------------------------------------------------------------
307   struct TPenta6a: TShapeFun {
308     TPenta6a();
309     virtual void InitFun(const TCCoordSliceArr& theRef,
310                          const TCCoordSliceArr& theGauss,
311                          TFun& theFun) const;
312   };
313   //---------------------------------------------------------------
314   struct TPenta6b: TShapeFun {
315     TPenta6b();
316     virtual void InitFun(const TCCoordSliceArr& theRef,
317                          const TCCoordSliceArr& theGauss,
318                          TFun& theFun) const;
319   };
320   //---------------------------------------------------------------
321   struct TPenta15a: TShapeFun {
322     TPenta15a();
323     virtual void InitFun(const TCCoordSliceArr& theRef,
324                          const TCCoordSliceArr& theGauss,
325                          TFun& theFun) const;
326   };
327   //---------------------------------------------------------------
328   struct TPenta15b: TShapeFun {
329     TPenta15b();
330     virtual void InitFun(const TCCoordSliceArr& theRef,
331                          const TCCoordSliceArr& theGauss,
332                          TFun& theFun) const;
333   };
334   //---------------------------------------------------------------
335   struct TPyra5a: TShapeFun {
336     TPyra5a();
337     virtual void InitFun(const TCCoordSliceArr& theRef,
338                          const TCCoordSliceArr& theGauss,
339                          TFun& theFun) const;
340   };
341   //---------------------------------------------------------------
342   struct TPyra5b: TShapeFun {
343     TPyra5b();
344     virtual void InitFun(const TCCoordSliceArr& theRef,
345                          const TCCoordSliceArr& theGauss,
346                          TFun& theFun) const;
347   };
348   //---------------------------------------------------------------
349   struct TPyra13a: TShapeFun {
350     TPyra13a();
351     virtual void InitFun(const TCCoordSliceArr& theRef,
352                          const TCCoordSliceArr& theGauss,
353                          TFun& theFun) const;
354   };
355   //---------------------------------------------------------------
356   struct TPyra13b: TShapeFun {
357     TPyra13b();
358     virtual void InitFun(const TCCoordSliceArr& theRef,
359                          const TCCoordSliceArr& theGauss,
360                          TFun& theFun) const;
361   };
362   //---------------------------------------------------------------
363
364 }
365
366 #endif