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