Salome HOME
Merge from V6_main 28/02/2013
[tools/medcoupling.git] / src / INTERP_KERNEL / GaussPoints / InterpKernelGaussCoords.hxx
1 // Copyright (C) 2007-2012  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.
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 INTERPKERNEL_EXPORT GaussInfo 
36   {
37   public:
38     GaussInfo( NormalizedCellType theGeometry,
39                const DataVector& theGaussCoord,
40                int theNbGauss,
41                const DataVector& theReferenceCoord,
42                int theNbRef
43                );
44     ~GaussInfo();
45
46     NormalizedCellType getCellType() const;    
47
48     int getGaussCoordDim() const;
49     int getReferenceCoordDim() const;
50
51     int getNbGauss() const;
52     int getNbRef() const;
53
54     const double* getFunctionValues( const int theGaussId ) const;
55
56     void initLocalInfo() throw (INTERP_KERNEL::Exception);
57
58   protected:
59
60     bool isSatisfy();
61
62     //1D
63     void seg2Init();
64     void seg3Init();
65
66     //2D
67     void tria3aInit();
68     void tria3bInit();
69     void tria6aInit();
70     void tria6bInit();
71
72     void quad4aInit();
73     void quad4bInit();
74     void quad8aInit();
75     void quad8bInit();
76
77     //3D
78     void tetra4aInit();
79     void tetra4bInit();
80     void tetra10aInit();
81     void tetra10bInit();
82
83     void pyra5aInit();
84     void pyra5bInit();
85     void pyra13aInit();
86     void pyra13bInit();
87
88     void penta6aInit();
89     void penta6bInit();
90     void penta15aInit();
91     void penta15bInit();
92
93     void hexa8aInit();
94     void hexa8bInit();
95     void hexa20aInit();
96     void hexa20bInit();
97
98
99   private:
100     //INFORMATION from MEDMEM
101     NormalizedCellType _my_geometry;               //Cell type
102
103     int                _my_nb_gauss;                //Nb of the gauss points for element
104     DataVector         _my_gauss_coord;             //Gauss coordinates
105
106     int                _my_nb_ref;                  //Nb of the nodes for element:
107                                                  //NORM_SEG2 - 2
108                                                  //NORM_SEG3 - 3
109                                                  //NORM_TRI3 - 3
110                                                  //.............
111
112     DataVector         _my_reference_coord;         //Reference coordinates
113
114     //LOCAL INFORMATION
115     DataVector         _my_local_reference_coord;    //Vector to store reference coordinates
116     int                _my_local_ref_dim;            //Dimension of the local reference coordinates:
117                                                  // (x)       - 1D case
118                                                  // (x, y)    - 2D case
119                                                  // (x, y, z) - 3D case
120     int                _my_local_nb_ref;             //Nb of the local reference coordinates
121
122     DataVector         _my_function_value;          //Shape Function values
123   };
124
125
126   //Class for calculation of the coordinates of the gauss points 
127   class INTERPKERNEL_EXPORT GaussCoords 
128   {
129   public:
130
131     GaussCoords();
132     ~GaussCoords();
133
134     void addGaussInfo( NormalizedCellType theGeometry,
135                        int coordDim,
136                        const double* theGaussCoord,
137                        int theNbGauss,
138                        const double* theReferenceCoord,
139                        int theNbRef) throw (INTERP_KERNEL::Exception);
140
141     double* calculateCoords( NormalizedCellType theGeometry, 
142                              const double* theNodeCoords, 
143                              const int theSpaceDim,
144                              const int* theIndex) throw(INTERP_KERNEL::Exception);
145
146     void calculateCoords( NormalizedCellType theGeometry, 
147                           const double* theNodeCoords, 
148                           const int theSpaceDim,
149                           const int* theIndex,
150                           double *result) throw(INTERP_KERNEL::Exception);
151   private:
152     const GaussInfo *getInfoGivenCellType(NormalizedCellType cellType);
153     void calculateCoordsAlg(const GaussInfo *info, const double* theNodeCoords, const int theSpaceDim, const int *theIndex,
154                             double *result);
155   private:
156     typedef std::vector<GaussInfo*> GaussInfoVector;
157     GaussInfoVector _my_gauss_info;
158   };
159 }
160 #endif //INTERPKERNELGAUSSCOORDS