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