]> SALOME platform Git repositories - tools/medcoupling.git/blob - src/INTERP_KERNEL/GaussPoints/InterpKernelGaussCoords.hxx
Salome HOME
Updated copyright comment
[tools/medcoupling.git] / src / INTERP_KERNEL / GaussPoints / InterpKernelGaussCoords.hxx
1 // Copyright (C) 2007-2024  CEA, EDF
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 #include "MCIdType.hxx"
27
28 #include <vector>
29
30 namespace INTERP_KERNEL 
31 {
32   typedef std::vector<double> DataVector;
33   typedef std::vector<int>    IndexVector;
34
35   //Class to store Gauss Points information
36   class GaussInfo 
37   {
38   public:
39     INTERPKERNEL_EXPORT GaussInfo( NormalizedCellType theGeometry,
40                                    const DataVector& theGaussCoord,
41                                    int theNbGauss,
42                                    const DataVector& theReferenceCoord,
43                                    int theNbRef
44                                    );
45     INTERPKERNEL_EXPORT ~GaussInfo();
46
47     INTERPKERNEL_EXPORT NormalizedCellType getCellType() const;    
48
49     INTERPKERNEL_EXPORT int getGaussCoordDim() const;
50     INTERPKERNEL_EXPORT int getReferenceCoordDim() const;
51     INTERPKERNEL_EXPORT DataVector getGaussCoords() const { return _my_gauss_coord; }
52     INTERPKERNEL_EXPORT DataVector getRefCoords() const { return _my_reference_coord; }
53     INTERPKERNEL_EXPORT NormalizedCellType getGeoType() const { return _my_geometry; }
54
55     INTERPKERNEL_EXPORT int getNbGauss() const;
56     INTERPKERNEL_EXPORT int getNbRef() const;
57
58     INTERPKERNEL_EXPORT GaussInfo convertToLinear() const;
59
60     INTERPKERNEL_EXPORT const double *getFunctionValues( const int theGaussId ) const;
61     INTERPKERNEL_EXPORT const double *getDerivativeOfShapeFunctionAt( const int theGaussId ) const;
62
63     INTERPKERNEL_EXPORT void initLocalInfo();
64     
65     INTERPKERNEL_EXPORT static std::vector<double> NormalizeCoordinatesIfNecessary(NormalizedCellType ct, int inputDim, const std::vector<double>& inputArray);
66     INTERPKERNEL_EXPORT static std::vector<double> GetDefaultReferenceCoordinatesOf(NormalizedCellType ct);
67     INTERPKERNEL_EXPORT static bool IsInOrOutForReference(NormalizedCellType ct, const double *ptInRefCoo, double eps);
68   public:
69     static const double SEG2A_REF[2];
70     static const double SEG2B_REF[2];
71     static const double SEG3_REF[3];
72     static const double SEG4_REF[4];
73     static const double TRIA3A_REF[6];
74     static const double TRIA3B_REF[6];
75     static const double TRIA6A_REF[12];
76     static const double TRIA6B_REF[12];
77     static const double TRIA7A_REF[14];
78     static const double QUAD4A_REF[8];
79     static const double QUAD4B_REF[8];
80     static const double QUAD8A_REF[16];
81     static const double QUAD8B_REF[16];
82     static const double QUAD9A_REF[18];
83     static const double TETRA4A_REF[12];
84     static const double TETRA4B_REF[12];
85     static const double TETRA10A_REF[30];
86     static const double TETRA10B_REF[30];
87     static const double PYRA5A_REF[15];
88     static const double PYRA5B_REF[15];
89     static const double PYRA13A_REF[39];
90     static const double PYRA13B_REF[39];
91     static const double PENTA6A_REF[18];
92     static const double PENTA6B_REF[18];
93     static const double PENTA15A_REF[45];
94     static const double PENTA15B_REF[45];
95     static const double PENTA18A_REF[54];
96     static const double PENTA18B_REF[54];
97     static const double HEXA8A_REF[24];
98     static const double HEXA8B_REF[24];
99     static const double HEXA20A_REF[60];
100     static const double HEXA20B_REF[60];
101     static const double HEXA27A_REF[81];
102   protected:
103     static bool IsSatisfy(const std::vector<double>& ref1, const std::vector<double>& ref2);
104     bool isSatisfy();
105     
106     void point1Init();
107     
108     //1D
109     void seg2aInit();
110     void seg2bInit();
111     void seg3Init();
112     void seg4Init();
113
114     //2D
115     void tria3aInit();
116     void tria3bInit();
117     void tria6aInit();
118     void tria6bInit();
119     void tria7aInit();
120
121     void quad4aInit();
122     static void Quad4aInit(GaussInfo& obj) { obj.quad4aInit(); }
123     void quad4bInit();
124     static void Quad4bInit(GaussInfo& obj) { obj.quad4bInit(); }
125     void quad4cInit();
126     static void Quad4cInit(GaussInfo& obj) { obj.quad4cInit(); }
127     void quad4DegSeg2Init();
128     static void Quad4DegSeg2Init(GaussInfo& obj) { obj.quad4DegSeg2Init(); }
129     void quad8aInit();
130     void quad8bInit();
131     void quad9aInit();
132
133     //3D
134     void tetra4aInit();
135     void tetra4bInit();
136     void tetra10aInit();
137     void tetra10bInit();
138
139     void pyra5aInit();
140     void pyra5bInit();
141     void pyra13aInit();
142     void pyra13bInit();
143
144     void penta6aInit();
145     static void Penta6aInit(GaussInfo& obj) { obj.penta6aInit(); }
146     void penta6bInit();
147     static void Penta6bInit(GaussInfo& obj) { obj.penta6bInit(); }
148     void penta6DegTria3aInit();
149     static void Penta6DegTria3aInit(GaussInfo& obj) { obj.penta6DegTria3aInit(); }
150     void penta6DegTria3bInit();
151     static void Penta6DegTria3bInit(GaussInfo& obj) { obj.penta6DegTria3bInit(); }
152     
153     void penta15aInit();
154     static void Penta15aInit(GaussInfo& obj) { obj.penta15aInit(); }
155     void penta15bInit();
156     static void Penta15bInit(GaussInfo& obj) { obj.penta15bInit(); }
157     void penta18aInit();
158     static void Penta18aInit(GaussInfo& obj) { obj.penta18aInit(); }
159     void penta18bInit();
160     static void Penta18bInit(GaussInfo& obj) { obj.penta18bInit(); }
161
162     void hexa8aInit();
163     static void Hexa8aInit(GaussInfo& obj) { obj.hexa8aInit(); }
164     void hexa8bInit();
165     static void Hexa8bInit(GaussInfo& obj) { obj.hexa8bInit(); }
166     void hexa8DegQuad4aInit();
167     static void Hexa8DegQuad4aInit(GaussInfo& obj) { obj.hexa8DegQuad4aInit(); }
168     void hexa8DegQuad4bInit();
169     static void Hexa8DegQuad4bInit(GaussInfo& obj) { obj.hexa8DegQuad4bInit(); }
170     void hexa8DegQuad4cInit();
171     static void Hexa8DegQuad4cInit(GaussInfo& obj) { obj.hexa8DegQuad4cInit(); }
172     void hexa20aInit();
173     void hexa20bInit();
174     void hexa27aInit();
175
176   private:
177     //INFORMATION from MEDMEM
178     NormalizedCellType _my_geometry;               //Cell type
179
180     int                _my_nb_gauss;                //Nb of the gauss points for element
181     DataVector         _my_gauss_coord;             //Gauss coordinates
182
183     int                _my_nb_ref;                  //Nb of the nodes for element:
184                                                  //NORM_SEG2 - 2
185                                                  //NORM_SEG3 - 3
186                                                  //NORM_TRI3 - 3
187                                                  //.............
188
189     DataVector         _my_reference_coord;         //Reference coordinates
190
191     //LOCAL INFORMATION
192     DataVector         _my_local_reference_coord;    //Vector to store reference coordinates
193     int                _my_local_ref_dim;            //Dimension of the local reference coordinates:
194                                                  // (x)       - 1D case
195                                                  // (x, y)    - 2D case
196                                                  // (x, y, z) - 3D case
197     int                _my_local_nb_ref;             //Nb of the local reference coordinates
198
199     DataVector         _my_function_value;          //Shape Function values
200     DataVector         _my_derivative_func_value;   //Derivative of the shape function
201   };
202
203
204   //Class for calculation of the coordinates of the gauss points 
205   class GaussCoords 
206   {
207   public:
208
209     INTERPKERNEL_EXPORT GaussCoords();
210     INTERPKERNEL_EXPORT ~GaussCoords();
211
212     INTERPKERNEL_EXPORT void addGaussInfo( NormalizedCellType theGeometry,
213                                            int coordDim,
214                                            const double* theGaussCoord,
215                                            mcIdType theNbGauss,
216                                            const double* theReferenceCoord,
217                                            mcIdType theNbRef);
218
219     INTERPKERNEL_EXPORT double* calculateCoords( NormalizedCellType theGeometry, 
220                                                  const double* theNodeCoords, 
221                                                  const int theSpaceDim,
222                                                  const mcIdType* theIndex);
223
224     INTERPKERNEL_EXPORT void calculateCoords( NormalizedCellType theGeometry, 
225                                               const double* theNodeCoords, 
226                                               const int theSpaceDim,
227                                               const mcIdType* theIndex,
228                                               double *result);
229   private:
230     const GaussInfo *getInfoGivenCellType(NormalizedCellType cellType);
231     void calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const mcIdType *theIndex,
232                             double *result);
233   private:
234     typedef std::vector<GaussInfo*> GaussInfoVector;
235     GaussInfoVector _my_gauss_info;
236   };
237 }
238 #endif //INTERPKERNELGAUSSCOORDS