/[escript]/trunk/tools/escriptconvert/escriptconvert.cpp
ViewVC logotype

Diff of /trunk/tools/escriptconvert/escriptconvert.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/tools/libescriptreader/src/escript2silo.cpp revision 2806 by jfenwick, Mon Jul 20 06:20:06 2009 UTC trunk/tools/escriptconvert/escriptconvert.cpp revision 2810 by caltinay, Mon Dec 7 04:13:49 2009 UTC
# Line 11  Line 11 
11  *  *
12  *******************************************************/  *******************************************************/
13    
14  //  #include <escriptexport/EscriptDataset.h>
15  // escript2silo.cpp  #include <escriptexport/FinleyMesh.h>
16  //  #include <escriptexport/DataVar.h>
17  #include <escriptreader/MPDataSet.h>  
18  #include <escriptreader/MeshWithElements.h>  #if USE_SILO
 #include <escriptreader/DataVar.h>  
19  #include <silo.h>  #include <silo.h>
20  #include <netcdf.hh>  #endif
21    
22  #include <cstring>  #include <cstring>
23  #include <fstream>  #include <fstream>
24    
25  using namespace std;  using namespace std;
26  using namespace EscriptReader;  using namespace escriptexport;
27    
28  string insertTimestep(const string& fString, int timeStep, int tsMultiplier)  string insertTimestep(const string& fString, int timeStep, int tsMultiplier)
29  {  {
# Line 43  string insertTimestep(const string& fStr Line 43  string insertTimestep(const string& fStr
43    
44  int main(int argc, char** argv)  int main(int argc, char** argv)
45  {  {
46    #if HAVE_MPI
47        MPI_Init(&argc, &argv);
48    #endif
49    
50    #if USE_SILO
51      // turn off for debugging purposes      // turn off for debugging purposes
52      bool writeMultiMesh = true;      bool writeMultiMesh = true;
53    
# Line 51  int main(int argc, char** argv) Line 56  int main(int argc, char** argv)
56      bool writeMeshOnce = true;      bool writeMeshOnce = true;
57    
58      if (argc < 2) {      if (argc < 2) {
59          cerr << "Usage: " << argv[0] << " <file.esd>" << endl;          cerr << "Usage: " << argv[0] << " <file.esd>" << endl; fflush(stderr);
60          return -1;          return -1;
61      }      }
62    
# Line 134  int main(int argc, char** argv) Line 139  int main(int argc, char** argv)
139          if (nTimesteps > 1)          if (nTimesteps > 1)
140              cout << "T = " << timeStep << endl;              cout << "T = " << timeStep << endl;
141    
142          MPDataSet* ds = new MPDataSet();          EscriptDataset* ds = new EscriptDataset();
143    
144          if (writeMeshOnce && timeStep > 0) {          if (writeMeshOnce && timeStep > 0) {
145              if (!ds->load(meshFromTzero, meshFile, varFilesTS, varNames)) {              if (!ds->loadNetCDF(meshFromTzero, varFilesTS, varNames)) {
146                  delete ds;                  delete ds;
147                  break;                  break;
148              }              }
# Line 148  int main(int argc, char** argv) Line 153  int main(int argc, char** argv)
153              else              else
154                  meshTS.append(".nc");                  meshTS.append(".nc");
155    
156              if (!ds->load(meshTS, varFilesTS, varNames, nParts)) {              if (!ds->loadNetCDF(meshTS, varFilesTS, varNames, nParts)) {
157                  delete ds;                  delete ds;
158                  break;                  break;
159              }              }
# Line 165  int main(int argc, char** argv) Line 170  int main(int argc, char** argv)
170              siloFile << "." << timeStep;              siloFile << "." << timeStep;
171          siloFile << ".silo";          siloFile << ".silo";
172    
173          ds->saveAsSilo(siloFile.str(), writeMultiMesh);          ds->setCycleAndTime(timeStep, (double)timeStep);
174            ds->saveSilo(siloFile.str(), writeMultiMesh);
175    
176          // keep mesh from first timestep if it should be reused          // keep mesh from first timestep if it should be reused
177          if (writeMeshOnce && nTimesteps > 1 && timeStep == 0) {          if (writeMeshOnce && nTimesteps > 1 && timeStep == 0) {
# Line 188  int main(int argc, char** argv) Line 194  int main(int argc, char** argv)
194            
195      // clean up      // clean up
196      MeshBlocks::iterator meshIt;      MeshBlocks::iterator meshIt;
     for (meshIt = meshFromTzero.begin(); meshIt != meshFromTzero.end(); meshIt++)  
         delete *meshIt;  
197    
198      cout << "All done." << endl;      cout << "All done." << endl;
199    #else // !USE_SILO
200        cerr << "Error: escriptconvert was compiled without Silo support! Exiting."
201            << endl;
202    #endif
203    
204    #if HAVE_MPI
205        MPI_Finalize();
206    #endif
207    
208      return 0;      return 0;
209  }  }

Legend:
Removed from v.2806  
changed lines
  Added in v.2810

  ViewVC Help
Powered by ViewVC 1.1.26