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