Salome HOME
Copyrights update 2015.
[tools/medcoupling.git] / src / INTERP_KERNEL / GaussPoints / InterpKernelGaussCoords.hxx
1 // Copyright (C) 2007-2015  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
51     INTERPKERNEL_EXPORT int getNbGauss() const;
52     INTERPKERNEL_EXPORT int getNbRef() const;
53
54     INTERPKERNEL_EXPORT const double* getFunctionValues( const int theGaussId ) const;
55
56     INTERPKERNEL_EXPORT void initLocalInfo();
57     
58     INTERPKERNEL_EXPORT static std::vector<double> NormalizeCoordinatesIfNecessary(NormalizedCellType ct, int inputDim, const std::vector<double>& inputArray);
59
60   protected:
61
62     bool isSatisfy();
63     
64     void point1Init();
65     
66     //1D
67     void seg2Init();
68     void seg3Init();
69
70     //2D
71     void tria3aInit();
72     void tria3bInit();
73     void tria6aInit();
74     void tria6bInit();
75     void tria7aInit();
76
77     void quad4aInit();
78     static void Quad4aInit(GaussInfo& obj) { obj.quad4aInit(); }
79     void quad4bInit();
80     static void Quad4bInit(GaussInfo& obj) { obj.quad4bInit(); }
81     void quad4cInit();
82     static void Quad4cInit(GaussInfo& obj) { obj.quad4cInit(); }
83     void quad4DegSeg2Init();
84     static void Quad4DegSeg2Init(GaussInfo& obj) { obj.quad4DegSeg2Init(); }
85     void quad8aInit();
86     void quad8bInit();
87     void quad9aInit();
88
89     //3D
90     void tetra4aInit();
91     void tetra4bInit();
92     void tetra10aInit();
93     void tetra10bInit();
94
95     void pyra5aInit();
96     void pyra5bInit();
97     void pyra13aInit();
98     void pyra13bInit();
99
100     void penta6aInit();
101     static void Penta6aInit(GaussInfo& obj) { obj.penta6aInit(); }
102     void penta6bInit();
103     static void Penta6bInit(GaussInfo& obj) { obj.penta6bInit(); }
104     void penta6DegTria3aInit();
105     static void Penta6DegTria3aInit(GaussInfo& obj) { obj.penta6DegTria3aInit(); }
106     void penta6DegTria3bInit();
107     static void Penta6DegTria3bInit(GaussInfo& obj) { obj.penta6DegTria3bInit(); }
108     
109     void penta15aInit();
110     static void Penta15aInit(GaussInfo& obj) { obj.penta15aInit(); }
111     void penta15bInit();
112     static void Penta15bInit(GaussInfo& obj) { obj.penta15bInit(); }
113
114     void hexa8aInit();
115     static void Hexa8aInit(GaussInfo& obj) { obj.hexa8aInit(); }
116     void hexa8bInit();
117     static void Hexa8bInit(GaussInfo& obj) { obj.hexa8bInit(); }
118     void hexa8DegQuad4aInit();
119     static void Hexa8DegQuad4aInit(GaussInfo& obj) { obj.hexa8DegQuad4aInit(); }
120     void hexa8DegQuad4bInit();
121     static void Hexa8DegQuad4bInit(GaussInfo& obj) { obj.hexa8DegQuad4bInit(); }
122     void hexa8DegQuad4cInit();
123     static void Hexa8DegQuad4cInit(GaussInfo& obj) { obj.hexa8DegQuad4cInit(); }
124     void hexa20aInit();
125     void hexa20bInit();
126     void hexa27aInit();
127
128   private:
129     //INFORMATION from MEDMEM
130     NormalizedCellType _my_geometry;               //Cell type
131
132     int                _my_nb_gauss;                //Nb of the gauss points for element
133     DataVector         _my_gauss_coord;             //Gauss coordinates
134
135     int                _my_nb_ref;                  //Nb of the nodes for element:
136                                                  //NORM_SEG2 - 2
137                                                  //NORM_SEG3 - 3
138                                                  //NORM_TRI3 - 3
139                                                  //.............
140
141     DataVector         _my_reference_coord;         //Reference coordinates
142
143     //LOCAL INFORMATION
144     DataVector         _my_local_reference_coord;    //Vector to store reference coordinates
145     int                _my_local_ref_dim;            //Dimension of the local reference coordinates:
146                                                  // (x)       - 1D case
147                                                  // (x, y)    - 2D case
148                                                  // (x, y, z) - 3D case
149     int                _my_local_nb_ref;             //Nb of the local reference coordinates
150
151     DataVector         _my_function_value;          //Shape Function values
152   };
153
154
155   //Class for calculation of the coordinates of the gauss points 
156   class GaussCoords 
157   {
158   public:
159
160     INTERPKERNEL_EXPORT GaussCoords();
161     INTERPKERNEL_EXPORT ~GaussCoords();
162
163     INTERPKERNEL_EXPORT void addGaussInfo( NormalizedCellType theGeometry,
164                                            int coordDim,
165                                            const double* theGaussCoord,
166                                            int theNbGauss,
167                                            const double* theReferenceCoord,
168                                            int theNbRef);
169
170     INTERPKERNEL_EXPORT double* calculateCoords( NormalizedCellType theGeometry, 
171                                                  const double* theNodeCoords, 
172                                                  const int theSpaceDim,
173                                                  const int* theIndex);
174
175     INTERPKERNEL_EXPORT void calculateCoords( NormalizedCellType theGeometry, 
176                                               const double* theNodeCoords, 
177                                               const int theSpaceDim,
178                                               const int* theIndex,
179                                               double *result);
180   private:
181     const GaussInfo *getInfoGivenCellType(NormalizedCellType cellType);
182     void calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const int *theIndex,
183                             double *result);
184   private:
185     typedef std::vector<GaussInfo*> GaussInfoVector;
186     GaussInfoVector _my_gauss_info;
187   };
188 }
189 #endif //INTERPKERNELGAUSSCOORDS