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