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