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