Back to index

salome-med  6.5.0
MEDMEM_PorflowMeshDriver.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef PORFLOW_MESH_DRIVER_HXX
00024 #define PORFLOW_MESH_DRIVER_HXX
00025 
00026 #include "MEDMEM.hxx"
00027 
00028 #include <string>
00029 #include <fstream>
00030 
00031 #include "MEDMEM_define.hxx"
00032 #include "MEDMEM_GenDriver.hxx"
00033 //#include "MEDMEM_DriverTools.hxx"
00034 
00035 #include "MEDMEM_STRING.hxx"
00036 #include "MEDMEM_Exception.hxx"
00037 #include "MEDMEM_Utilities.hxx"
00038 
00039 #include <vector>
00040 #include <set>
00041 
00051 namespace MEDMEM {
00052 class GMESH;
00053 class MESH;
00054 class FAMILY;
00055 class GROUP;
00056 class CONNECTIVITY;
00057 struct _intermediateMED;
00058 struct _maille;
00059 class MEDMEM_EXPORT PORFLOW_MESH_DRIVER : public GENDRIVER
00060 {
00061 protected:
00062   
00063   MESH *          _ptrMesh;
00064   // A VOIR FILE DESCRIPTEUR ? MED_FR::med_idt _medIdt;
00065   string          _meshName;    
00066   ifstream        _porflow;
00067 
00068   // This enumeration is used to substitude static const
00069   // memers data causing link errors on VC7 compiler.
00070   enum
00071   {
00072     nb_geometrie_porflow = 6,
00073     nb_nodes_max         = 8, // maximal number of nodes for a porflow geometrie
00074     nb_nodes2_max        = 4, // maximal number of nodes for a 2D porflow geometrie
00075     nb_faces_max         = 6  // maximal number of faces for a porflow geometrie
00076   };
00077 
00078   // tableau de correspondance des types géométriques de PORFLOW -> MED
00079   //static const size_t nb_geometrie_porflow = 6;
00080   static const MED_EN::medGeometryElement geomPORFLOWtoMED[nb_geometrie_porflow];
00081   // indirection table from PORFLOW order to MED one for nodes numerotation in all PORFLOW geometries
00082   //static const size_t nb_nodes_max = 8;  // maximal number of nodes for a porflow geometrie
00083   //static const size_t nb_nodes2_max = 4; // maximal number of nodes for a 2D porflow geometrie
00084   //static const size_t nb_faces_max = 6;  // maximal number of faces for a porflow geometrie
00085   static const int numPORFLOWtoMED[nb_geometrie_porflow] [nb_nodes_max];
00086   static const int connectivityPORFLOW[nb_geometrie_porflow][nb_faces_max][nb_nodes2_max];
00087   inline static int geomMEDtoPorflow(MED_EN::medGeometryElement medGeo);
00088 
00089 
00090 public :
00091 
00095   PORFLOW_MESH_DRIVER() ;
00099   PORFLOW_MESH_DRIVER(const string &         fileName,  
00100                       GMESH *                ptrMesh, 
00101                       MED_EN::med_mode_acces accessMode) ;
00105   PORFLOW_MESH_DRIVER(const PORFLOW_MESH_DRIVER & driver) ;
00106 
00110   virtual ~PORFLOW_MESH_DRIVER() ;
00111 
00112   void open() throw (MEDEXCEPTION);
00113   void close() throw (MEDEXCEPTION);
00114 
00115   virtual void write( void ) const = 0 ;
00116   virtual void read ( void ) = 0 ;
00117 
00123   void   setMeshName(const string & meshName) ;
00127   string getMeshName() const ;
00128 
00129 private:
00130   virtual GENDRIVER * copy ( void ) const = 0 ;
00131 
00132 };
00133 
00134 
00135 class MEDMEM_EXPORT PORFLOW_MESH_RDONLY_DRIVER : public virtual PORFLOW_MESH_DRIVER
00136 {
00137  
00138 public :
00139   
00143   PORFLOW_MESH_RDONLY_DRIVER() ;
00147   PORFLOW_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh) ;
00151   PORFLOW_MESH_RDONLY_DRIVER(const PORFLOW_MESH_RDONLY_DRIVER & driver) ;
00152 
00156   virtual ~PORFLOW_MESH_RDONLY_DRIVER() ;
00157   
00161   void write( void ) const throw (MEDEXCEPTION);
00165   void read ( void ) throw (MEDEXCEPTION);
00166 
00167 private:
00168  
00169   GENDRIVER * copy ( void ) const ;
00170 
00171   static void readPorflowCoordinateFile(const string & coorFileName,_intermediateMED & medi,const int space_dimension);
00172   static void readPorflowConnectivityFile(bool hybride,const string & connecFileName,_intermediateMED & medi,std::vector<set<_maille>::iterator>& p_ma_table,int mesh_dimension);
00173 
00174 };
00175 
00184 class MEDMEM_EXPORT PORFLOW_MESH_WRONLY_DRIVER : public virtual PORFLOW_MESH_DRIVER {
00185   
00186 public :
00187   
00191   PORFLOW_MESH_WRONLY_DRIVER() ;
00195   PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, GMESH * ptrMesh) ;
00199   PORFLOW_MESH_WRONLY_DRIVER(const PORFLOW_MESH_WRONLY_DRIVER & driver) ;
00200 
00204   virtual ~PORFLOW_MESH_WRONLY_DRIVER() ;
00205 
00209   void write( void ) const throw (MEDEXCEPTION);
00213   void read ( void ) throw (MEDEXCEPTION);
00214 
00215 private:
00216 
00217   GENDRIVER * copy ( void ) const ;
00218 };
00219 
00220 
00229 class MEDMEM_EXPORT PORFLOW_MESH_RDWR_DRIVER : public PORFLOW_MESH_RDONLY_DRIVER, public PORFLOW_MESH_WRONLY_DRIVER {
00230 
00231 public :
00232 
00236   PORFLOW_MESH_RDWR_DRIVER() ;
00240   PORFLOW_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh) ;
00244   PORFLOW_MESH_RDWR_DRIVER(const PORFLOW_MESH_RDWR_DRIVER & driver) ;
00245 
00249   ~PORFLOW_MESH_RDWR_DRIVER() ;
00250 
00254   void write(void) const throw (MEDEXCEPTION);
00258   void read (void) throw (MEDEXCEPTION);
00259 
00260 private:
00261   GENDRIVER * copy(void) const ;
00262 
00263 };
00264 }
00265 
00266 
00267 #endif /* PORFLOW_MESH_DRIVER_HXX */