]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_PorflowMeshDriver.hxx
Salome HOME
Fix problem of make distcheck
[modules/med.git] / src / MEDMEM / MEDMEM_PorflowMeshDriver.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 #ifndef PORFLOW_MESH_DRIVER_HXX
24 #define PORFLOW_MESH_DRIVER_HXX
25
26 #include "MEDMEM.hxx"
27
28 #include <string>
29 #include <fstream>
30
31 #include "MEDMEM_define.hxx"
32 #include "MEDMEM_GenDriver.hxx"
33 //#include "MEDMEM_DriverTools.hxx"
34
35 #include "MEDMEM_STRING.hxx"
36 #include "MEDMEM_Exception.hxx"
37 #include "MEDMEM_Utilities.hxx"
38
39 #include <vector>
40 #include <set>
41
42 /*!
43
44   Driver PORFLOW for MESH.
45
46   Generic part : implement the readopen and close methods.
47   
48 */
49
50
51 namespace MEDMEM {
52 class GMESH;
53 class MESH;
54 class FAMILY;
55 class GROUP;
56 class CONNECTIVITY;
57 struct _intermediateMED;
58 struct _maille;
59 class MEDMEM_EXPORT PORFLOW_MESH_DRIVER : public GENDRIVER
60 {
61 protected:
62   
63   MESH *          _ptrMesh;
64   // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
65   string          _meshName;    
66   ifstream        _porflow;
67
68   // This enumeration is used to substitude static const
69   // memers data causing link errors on VC7 compiler.
70   enum
71   {
72     nb_geometrie_porflow = 6,
73     nb_nodes_max         = 8, // maximal number of nodes for a porflow geometrie
74     nb_nodes2_max        = 4, // maximal number of nodes for a 2D porflow geometrie
75     nb_faces_max         = 6  // maximal number of faces for a porflow geometrie
76   };
77
78   // tableau de correspondance des types géométriques de PORFLOW -> MED
79   //static const size_t nb_geometrie_porflow = 6;
80   static const MED_EN::medGeometryElement geomPORFLOWtoMED[nb_geometrie_porflow];
81   // indirection table from PORFLOW order to MED one for nodes numerotation in all PORFLOW geometries
82   //static const size_t nb_nodes_max = 8;  // maximal number of nodes for a porflow geometrie
83   //static const size_t nb_nodes2_max = 4; // maximal number of nodes for a 2D porflow geometrie
84   //static const size_t nb_faces_max = 6;  // maximal number of faces for a porflow geometrie
85   static const int numPORFLOWtoMED[nb_geometrie_porflow] [nb_nodes_max];
86   static const int connectivityPORFLOW[nb_geometrie_porflow][nb_faces_max][nb_nodes2_max];
87   inline static int geomMEDtoPorflow(MED_EN::medGeometryElement medGeo);
88
89
90 public :
91
92   /*!
93     Constructor.
94   */
95   PORFLOW_MESH_DRIVER() ;
96   /*!
97     Constructor.
98   */
99   PORFLOW_MESH_DRIVER(const string &         fileName,  
100                       GMESH *                ptrMesh, 
101                       MED_EN::med_mode_acces accessMode) ;
102   /*!
103     Copy constructor.
104   */
105   PORFLOW_MESH_DRIVER(const PORFLOW_MESH_DRIVER & driver) ;
106
107   /*!
108     Destructor.
109   */
110   virtual ~PORFLOW_MESH_DRIVER() ;
111
112   void open() throw (MEDEXCEPTION);
113   void close() throw (MEDEXCEPTION);
114
115   virtual void write( void ) const = 0 ;
116   virtual void read ( void ) = 0 ;
117
118   /*!
119     Set the name of the MESH asked in file.
120
121     It could be different than the name of the MESH object.
122   */
123   void   setMeshName(const string & meshName) ;
124   /*!
125     Get the name of the MESH asked in file.
126   */
127   string getMeshName() const ;
128
129 private:
130   virtual GENDRIVER * copy ( void ) const = 0 ;
131
132 };
133
134
135 class MEDMEM_EXPORT PORFLOW_MESH_RDONLY_DRIVER : public virtual PORFLOW_MESH_DRIVER
136 {
137  
138 public :
139   
140   /*!
141     Constructor.
142   */
143   PORFLOW_MESH_RDONLY_DRIVER() ;
144   /*!
145     Constructor.
146   */
147   PORFLOW_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
148   /*!
149     Copy constructor.
150   */
151   PORFLOW_MESH_RDONLY_DRIVER(const PORFLOW_MESH_RDONLY_DRIVER & driver) ;
152
153   /*!
154     Destructor.
155   */
156   virtual ~PORFLOW_MESH_RDONLY_DRIVER() ;
157   
158   /*!
159     Return a MEDEXCEPTION : it is the read-only driver.
160   */
161   void write( void ) const throw (MEDEXCEPTION);
162   /*!
163     Read MESH in the specified file.
164   */
165   void read ( void ) throw (MEDEXCEPTION);
166
167 private:
168  
169   GENDRIVER * copy ( void ) const ;
170
171   static void readPorflowCoordinateFile(const string & coorFileName,_intermediateMED & medi,const int space_dimension);
172   static void readPorflowConnectivityFile(bool hybride,const string & connecFileName,_intermediateMED & medi,std::vector<set<_maille>::iterator>& p_ma_table,int mesh_dimension);
173
174 };
175
176 /*!
177
178   Driver Med for MESH : Write only.
179
180   Implement write method.
181
182 */
183
184 class MEDMEM_EXPORT PORFLOW_MESH_WRONLY_DRIVER : public virtual PORFLOW_MESH_DRIVER {
185   
186 public :
187   
188   /*!
189     Constructor.
190   */
191   PORFLOW_MESH_WRONLY_DRIVER() ;
192   /*!
193     Constructor.
194   */
195   PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, GMESH * ptrMesh) ;
196   /*!
197     Copy constructor.
198   */
199   PORFLOW_MESH_WRONLY_DRIVER(const PORFLOW_MESH_WRONLY_DRIVER & driver) ;
200
201   /*!
202     Destructor.
203   */
204   virtual ~PORFLOW_MESH_WRONLY_DRIVER() ;
205
206   /*!
207     Write MESH in the specified file.
208   */
209   void write( void ) const throw (MEDEXCEPTION);
210   /*!
211     Return a MEDEXCEPTION : it is the write-only driver.
212   */
213   void read ( void ) throw (MEDEXCEPTION);
214
215 private:
216
217   GENDRIVER * copy ( void ) const ;
218 };
219
220
221 /*!
222
223   Driver PORFLOW for MESH : Read write.
224   - Use read method from PORFLOW_MESH_RDONLY_DRIVER
225   - Use write method from PORFLOW_MESH_WRONLY_DRIVER
226
227 */
228
229 class MEDMEM_EXPORT PORFLOW_MESH_RDWR_DRIVER : public PORFLOW_MESH_RDONLY_DRIVER, public PORFLOW_MESH_WRONLY_DRIVER {
230
231 public :
232
233   /*!
234     Constructor.
235   */
236   PORFLOW_MESH_RDWR_DRIVER() ;
237   /*!
238     Constructor.
239   */
240   PORFLOW_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
241   /*!
242     Copy constructor.
243   */
244   PORFLOW_MESH_RDWR_DRIVER(const PORFLOW_MESH_RDWR_DRIVER & driver) ;
245
246   /*!
247     Destructor.
248   */
249   ~PORFLOW_MESH_RDWR_DRIVER() ;
250
251   /*!
252     Write MESH in the specified file.
253   */
254   void write(void) const throw (MEDEXCEPTION);
255   /*!
256     Read MESH in the specified file.
257   */
258   void read (void) throw (MEDEXCEPTION);
259
260 private:
261   GENDRIVER * copy(void) const ;
262
263 };
264 }
265
266
267 #endif /* PORFLOW_MESH_DRIVER_HXX */