]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/test_porflow_driver.cxx
Salome HOME
DCQ:prepare 2.0.0
[modules/med.git] / src / MEDMEM / test_porflow_driver.cxx
1 using namespace std;
2
3 #include "MEDMEM_PorflowMeshDriver.hxx"
4 #include "MEDMEM_Mesh.hxx"
5 using namespace MEDMEM;
6 int main (int argc, char ** argv)
7 {
8     /* process the arguments */
9     if (argc != 2) 
10     {
11         cerr << "Usage : " << argv[0] 
12         << " Porflowfilename" << endl << endl
13         << "-> lit le fichier Porflowfilename ,crée 2 fichiers : MED et VTK" << endl;
14         exit(-1);
15     }
16     string porflowfilename  = argv[1];
17
18     // Construction des noms de fichier
19     const string ext=".inp";
20     string::size_type pos=porflowfilename.find(ext,0);
21     string basename (porflowfilename, 0, pos); // nom sans extension
22     string medfile=basename+".med"; // nom fichier med à creer
23     string vtkfile=basename+".vtk"; // nom fichier vtk à creer
24     string::size_type pos1=porflowfilename.rfind('/');
25     string meshName (porflowfilename,pos1+1,pos-pos1-1); //get rid of directory & extension
26     cout << meshName << endl;
27
28     // lecture du fichier porflow
29     MESH * myMesh= new MESH() ; 
30     PORFLOW_MESH_RDONLY_DRIVER myPorflowMeshDriver(porflowfilename, myMesh) ;
31     myPorflowMeshDriver.open() ;
32     myPorflowMeshDriver.read() ;
33     myPorflowMeshDriver.close() ;
34     
35     cout << "Impression de MESH : " << endl;
36     cout << *myMesh;
37
38     // creation d'un fichier med
39     cout << "creation d'un fichier med : " << endl;
40     int idMed = myMesh->addDriver(MED_DRIVER, medfile, meshName);
41     myMesh->write(idMed) ;
42
43     // creation d'un fichier vtk
44     cout << "creation d'un fichier vtk : " << endl;
45     int idVtk = myMesh->addDriver(VTK_DRIVER, vtkfile, meshName);
46     myMesh->write(idVtk) ;
47
48
49     int SpaceDimension = myMesh->getSpaceDimension() ;
50     int MeshDimension  = myMesh->getMeshDimension() ;
51     int NumberOfNodes  = myMesh->getNumberOfNodes() ;
52
53     cout << "Space Dimension : " << SpaceDimension << endl << endl ; 
54
55     cout << "Mesh Dimension : " << MeshDimension << endl << endl ; 
56
57     const double * Coordinates = myMesh->getCoordinates(MED_FULL_INTERLACE) ;
58
59     cout << "Show Nodes Coordinates : " << endl ;
60
61     cout << "Name :" << endl ;
62     const string * CoordinatesNames = myMesh->getCoordinatesNames() ;
63     for(int i=0; i<SpaceDimension ; i++) {
64       cout << " - " << CoordinatesNames[i] << endl ;
65     }
66     cout << "Unit :" << endl ;
67     const string * CoordinatesUnits = myMesh->getCoordinatesUnits() ;
68     for(int i=0; i<SpaceDimension ; i++) {
69       cout << " - " << CoordinatesUnits[i] << endl ;
70     }
71     for(int i=0; i<NumberOfNodes ; i++) {
72       cout << "Nodes " << i+1 << " : " ;
73       for (int j=0; j<SpaceDimension ; j++)
74         cout << Coordinates[i*SpaceDimension+j] << " " ;
75       cout << endl ;
76     }
77
78     cout << "The END" << endl;
79     delete myMesh;
80
81     // remontée du fichier med en mémoire
82     myMesh= new MESH(MED_DRIVER,medfile,meshName);
83     delete myMesh;
84
85 }