Salome HOME
7f010686ccb9f7bff9347a06cec726ae686dccd1
[tools/medcoupling.git] / src / INTERP_KERNEL / GaussPoints / InterpKernelGaussCoords.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __INTERPKERNELGAUSSCOORDS_HXX__
21 #define __INTERPKERNELGAUSSCOORDS_HXX__
22
23 #include "INTERPKERNELDefines.hxx"
24 #include "NormalizedUnstructuredMesh.hxx"
25 #include "InterpKernelException.hxx"
26
27 #include <vector>
28
29 namespace INTERP_KERNEL 
30 {
31   typedef std::vector<double> DataVector;
32   typedef std::vector<int>    IndexVector;
33
34   //Class to store Gauss Points information
35   class GaussInfo 
36   {
37   public:
38     INTERPKERNEL_EXPORT GaussInfo( NormalizedCellType theGeometry,
39                                    const DataVector& theGaussCoord,
40                                    int theNbGauss,
41                                    const DataVector& theReferenceCoord,
42                                    int theNbRef
43                                    );
44     INTERPKERNEL_EXPORT ~GaussInfo();
45
46     INTERPKERNEL_EXPORT NormalizedCellType getCellType() const;    
47
48     INTERPKERNEL_EXPORT int getGaussCoordDim() const;
49     INTERPKERNEL_EXPORT int getReferenceCoordDim() const;
50     INTERPKERNEL_EXPORT DataVector getGaussCoords() const { return _my_gauss_coord; }
51     INTERPKERNEL_EXPORT DataVector getRefCoords() const { return _my_reference_coord; }
52     INTERPKERNEL_EXPORT NormalizedCellType getGeoType() const { return _my_geometry; }
53
54     INTERPKERNEL_EXPORT int getNbGauss() const;
55     INTERPKERNEL_EXPORT int getNbRef() const;
56
57     INTERPKERNEL_EXPORT GaussInfo convertToLinear() const;
58
59     INTERPKERNEL_EXPORT const double* getFunctionValues( const int theGaussId ) const;
60
61     INTERPKERNEL_EXPORT void initLocalInfo();
62     
63     INTERPKERNEL_EXPORT static std::vector<double> NormalizeCoordinatesIfNecessary(NormalizedCellType ct, int inputDim, const std::vector<double>& inputArray);
64
65   public:
66     static const double SEG2_REF[2];
67     static const double SEG3_REF[3];
68     static const double TRIA3A_REF[6];
69     static const double TRIA3B_REF[6];
70     static const double TRIA6A_REF[12];
71     static const double TRIA6B_REF[12];
72     static const double TRIA7A_REF[14];
73     static const double QUAD4A_REF[8];
74     static const double QUAD4B_REF[8];
75     static const double QUAD8A_REF[16];
76     static const double QUAD8B_REF[16];
77     static const double QUAD9A_REF[18];
78     static const double TETRA4A_REF[12];
79     static const double TETRA4B_REF[12];
80     static const double TETRA10A_REF[30];
81     static const double TETRA10B_REF[30];
82     static const double PYRA5A_REF[15];
83     static const double PYRA5B_REF[15];
84     static const double PYRA13A_REF[39];
85     static const double PYRA13B_REF[39];
86     static const double PENTA6A_REF[18];
87     static const double PENTA6B_REF[18];
88     static const double PENTA15A_REF[45];
89     static const double PENTA15B_REF[45];
90     static const double HEXA8A_REF[24];
91     static const double HEXA8B_REF[24];
92     static const double HEXA20A_REF[60];
93     static const double HEXA20B_REF[60];
94     static const double HEXA27A_REF[81];
95   protected:
96     static bool IsSatisfy(const std::vector<double>& ref1, const std::vector<double>& ref2);
97     bool isSatisfy();
98     
99     void point1Init();
100     
101     //1D
102     void seg2Init();
103     void seg3Init();
104
105     //2D
106     void tria3aInit();
107     void tria3bInit();
108     void tria6aInit();
109     void tria6bInit();
110     void tria7aInit();
111
112     void quad4aInit();
113     static void Quad4aInit(GaussInfo& obj) { obj.quad4aInit(); }
114     void quad4bInit();
115     static void Quad4bInit(GaussInfo& obj) { obj.quad4bInit(); }
116     void quad4cInit();
117     static void Quad4cInit(GaussInfo& obj) { obj.quad4cInit(); }
118     void quad4DegSeg2Init();
119     static void Quad4DegSeg2Init(GaussInfo& obj) { obj.quad4DegSeg2Init(); }
120     void quad8aInit();
121     void quad8bInit();
122     void quad9aInit();
123
124     //3D
125     void tetra4aInit();
126     void tetra4bInit();
127     void tetra10aInit();
128     void tetra10bInit();
129
130     void pyra5aInit();
131     void pyra5bInit();
132     void pyra13aInit();
133     void pyra13bInit();
134
135     void penta6aInit();
136     static void Penta6aInit(GaussInfo& obj) { obj.penta6aInit(); }
137     void penta6bInit();
138     static void Penta6bInit(GaussInfo& obj) { obj.penta6bInit(); }
139     void penta6DegTria3aInit();
140     static void Penta6DegTria3aInit(GaussInfo& obj) { obj.penta6DegTria3aInit(); }
141     void penta6DegTria3bInit();
142     static void Penta6DegTria3bInit(GaussInfo& obj) { obj.penta6DegTria3bInit(); }
143     
144     void penta15aInit();
145     static void Penta15aInit(GaussInfo& obj) { obj.penta15aInit(); }
146     void penta15bInit();
147     static void Penta15bInit(GaussInfo& obj) { obj.penta15bInit(); }
148
149     void hexa8aInit();
150     static void Hexa8aInit(GaussInfo& obj) { obj.hexa8aInit(); }
151     void hexa8bInit();
152     static void Hexa8bInit(GaussInfo& obj) { obj.hexa8bInit(); }
153     void hexa8DegQuad4aInit();
154     static void Hexa8DegQuad4aInit(GaussInfo& obj) { obj.hexa8DegQuad4aInit(); }
155     void hexa8DegQuad4bInit();
156     static void Hexa8DegQuad4bInit(GaussInfo& obj) { obj.hexa8DegQuad4bInit(); }
157     void hexa8DegQuad4cInit();
158     static void Hexa8DegQuad4cInit(GaussInfo& obj) { obj.hexa8DegQuad4cInit(); }
159     void hexa20aInit();
160     void hexa20bInit();
161     void hexa27aInit();
162
163   private:
164     //INFORMATION from MEDMEM
165     NormalizedCellType _my_geometry;               //Cell type
166
167     int                _my_nb_gauss;                //Nb of the gauss points for element
168     DataVector         _my_gauss_coord;             //Gauss coordinates
169
170     int                _my_nb_ref;                  //Nb of the nodes for element:
171                                                  //NORM_SEG2 - 2
172                                                  //NORM_SEG3 - 3
173                                                  //NORM_TRI3 - 3
174                                                  //.............
175
176     DataVector         _my_reference_coord;         //Reference coordinates
177
178     //LOCAL INFORMATION
179     DataVector         _my_local_reference_coord;    //Vector to store reference coordinates
180     int                _my_local_ref_dim;            //Dimension of the local reference coordinates:
181                                                  // (x)       - 1D case
182                                                  // (x, y)    - 2D case
183                                                  // (x, y, z) - 3D case
184     int                _my_local_nb_ref;             //Nb of the local reference coordinates
185
186     DataVector         _my_function_value;          //Shape Function values
187   };
188
189
190   //Class for calculation of the coordinates of the gauss points 
191   class GaussCoords 
192   {
193   public:
194
195     INTERPKERNEL_EXPORT GaussCoords();
196     INTERPKERNEL_EXPORT ~GaussCoords();
197
198     INTERPKERNEL_EXPORT void addGaussInfo( NormalizedCellType theGeometry,
199                                            int coordDim,
200                                            const double* theGaussCoord,
201                                            int theNbGauss,
202                                            const double* theReferenceCoord,
203                                            int theNbRef);
204
205     INTERPKERNEL_EXPORT double* calculateCoords( NormalizedCellType theGeometry, 
206                                                  const double* theNodeCoords, 
207                                                  const int theSpaceDim,
208                                                  const int* theIndex);
209
210     INTERPKERNEL_EXPORT void calculateCoords( NormalizedCellType theGeometry, 
211                                               const double* theNodeCoords, 
212                                               const int theSpaceDim,
213                                               const int* theIndex,
214                                               double *result);
215   private:
216     const GaussInfo *getInfoGivenCellType(NormalizedCellType cellType);
217     void calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const int *theIndex,
218                             double *result);
219   private:
220     typedef std::vector<GaussInfo*> GaussInfoVector;
221     GaussInfoVector _my_gauss_info;
222   };
223 }
224 #endif //INTERPKERNELGAUSSCOORDS