dune-fem  2.4.1-rc
datawriter.hh
Go to the documentation of this file.
1 #ifndef DUNE_FEM_DATAWRITER_HH
2 #define DUNE_FEM_DATAWRITER_HH
3 
4 #include <string>
5 
18 #include <dune/grid/common/backuprestore.hh>
19 
20 #if USE_GRAPE
21 #include <dune/grid/io/visual/grapedatadisplay.hh>
22 #endif
23 
24 namespace Dune
25 {
26 
27  namespace Fem
28  {
29 
31  {
32  explicit DataWriterParameters ( std::string keyPrefix, const ParameterReader &parameter = Parameter::container() )
33  : DataOutputParameters( keyPrefix, parameter )
34  {}
35 
38  {}
39 
41  virtual std::string macroGridName (const int dim) const
42  {
43  return parameter().getValue< std::string >( IOInterface::defaultGridKey( dim, parameter() ) );
44  }
45 
47  virtual bool separateRankPath () const
48  {
49  return false;
50  }
51  };
52 
60  template <class GridImp,
61  class DataImp>
62  class DataWriter : public DataOutput< GridImp, DataImp >
63  {
64  protected:
66  typedef GridImp GridType;
68  typedef DataImp OutPutDataType;
69 
72 
74 
75  using BaseType :: grid_;
76  using BaseType :: data_;
77 
78  using BaseType :: path_;
79  using BaseType :: datapref_;
80  using BaseType :: writeStep_;
81  using BaseType :: outputFormat_ ;
82 
83  friend class DataOutput< GridImp, DataImp >;
84  mutable std::stringstream macroGrid_;
85  const bool separateRankPath_ ;
86 
87  public:
88 
95  DataWriter(const GridType & grid,
96  OutPutDataType& data,
98  : BaseType( grid, data, parameter ),
99  separateRankPath_( parameter.separateRankPath() )
100  {
101  }
102 
110  DataWriter(const GridType & grid,
111  OutPutDataType& data,
112  const TimeProviderBase& tp,
114  : BaseType( grid, data, tp, parameter ),
115  separateRankPath_( parameter.separateRankPath() )
116  {
117  }
118 
120  virtual ~DataWriter() {}
121 
122  protected:
124  virtual const char* myClassName() const { return "DataWriter"; }
125 
127  virtual void writeBinaryData(const double sequenceStamp) const
128  {
129  writeMyBinaryData( sequenceStamp, writeStep_ , data_ );
130  }
131 
132  template< class OutputTuple >
133  std::string writeMyBinaryData ( const double sequenceStamp, const int step,
134  OutputTuple &data ) const
135  {
136  // create new path for time step output
137  std::string timeStepPath = IOInterface::createPath( grid_.comm(), path_, datapref_, step, separateRankPath_ );
138 
139  typedef IOTuple< OutputTuple > IOTupleType ;
140 
141  // if data is given, use BinaryDataIO to write it
142  if( IOTupleType :: length > 0 )
143  {
144  // call output of IOTuple
145  IOTupleType :: output( grid_, sequenceStamp, timeStepPath, datapref_, data );
146  }
147 
148  return timeStepPath;
149  }
150  }; // end class DataWriter
151 
153  //
154  // Checkpointer
155  //
157 
166  {
167  protected:
169 
170  public:
171  CheckPointerParameters( const bool writeMode, const std::string keyPrefix = "fem.io." ) :
172  DataWriterParameters( keyPrefix, Parameter::container() ),
173  writeMode_( writeMode )
174  {}
175 
176  explicit CheckPointerParameters( const std::string keyPrefix = "fem.io." ) :
177  DataWriterParameters( keyPrefix, Parameter::container() ),
178  writeMode_( true )
179  {}
180 
182  virtual std::string prefix () const
183  {
184  return checkPointPrefix();
185  }
186 
188  virtual int checkPointStep() const
189  {
190  return parameter().getValue< int > ( keyPrefix_ + "checkpointstep", 500 );
191  }
192 
194  virtual int maxNumberOfCheckPoints() const
195  {
196  return parameter().getValue< int > ( keyPrefix_ + "checkpointmax", 2 );
197  }
198 
200  virtual std::string checkPointPrefix() const
201  {
202  return parameter().getValue< std::string > ( keyPrefix_ + "checkpointfile", "checkpoint" );
203  }
204 
206  virtual bool writeMode() const
207  {
208  return writeMode_;
209  }
210 
212  virtual bool separateRankPath () const
213  {
214  return false;
215  }
216 
217  virtual int outputformat() const
218  {
219  return 5; // i.e. none
220  }
221  };
222 
238  template< class GridImp, class DataImp = tuple<> >
240  : public DataWriter< GridImp, DataImp >
241  {
242  protected:
244  typedef GridImp GridType;
245 
247 
250  {
251  const GridType& grid_ ;
252  const std::string name_;
253 
255  GridPersistentObject( const GridType& grid )
256  : grid_( grid ),
257  name_( Fem :: gridName( grid_ ) )
258  {
259  // we need to push the grid at the
260  // front position of the PersistenceManager list
261  // since we have to read it first on restore
262  const bool pushFront = true ;
263  // add grid at first position
264  PersistenceManager::insert( *this, pushFront );
265  }
266 
269  {
270  // remove myself
272  }
273 
275  virtual void backup() const
276  {
277  // this feature is available in dune-grid 2.3.x and later
278 
279  // try backup using stream method first
280  try
281  {
282  std::ostream& stream = PersistenceManager :: backupStream().stream();
283  Dune::BackupRestoreFacility< GridType > :: backup( grid_, stream );
284  }
285  catch ( Dune :: NotImplemented )
286  {
287 #ifndef NDEBUG
288  if( Parameter :: verbose () )
289  std::cerr << "GridPersistentObject::backup: cannot use stream backup." << std::endl;
290 #endif
291 
292  // try method given a filename
293  try {
294  std::string filename( PersistenceManager :: uniqueFileName( name_ ) );
295  Dune::BackupRestoreFacility< GridType > :: backup( grid_, filename );
296  }
297  catch ( Dune :: NotImplemented )
298  {
299  std::cerr << "ERROR: GridPersistentObject::backup: not possible!" << std::endl;
300  }
301  }
302 
303  // backup dof manager
304  DofManagerType :: instance( grid_ ).backup();
305  }
306 
308  virtual void restore ()
309  {
310  // restore of the grid is done below in method restoreGrid
311  // here we only need to restore the DofManager
312  DofManagerType :: instance( grid_ ).restore();
313  }
314  };
315 
318 
319  using BaseType :: grid_;
320  using BaseType :: data_;
321 
322  using BaseType :: path_;
323  using BaseType :: datapref_;
324  using BaseType :: writeStep_;
325  using BaseType :: outputFormat_ ;
326  using BaseType :: grapeDisplay_;
327  using BaseType :: separateRankPath_;
328 
329  // friendship for restoreData calls
330  friend class CheckPointer< GridImp >;
331 
334 
336  typedef DataImp OutPutDataType;
337 
339  PersistentGridObjectType* persistentGridObject_ ;
340 
341  OutPutDataType* dataPtr_ ;
342 
343  const int checkPointStep_;
345  int myRank_;
346 
347  std::string checkPointFile_;
348 
350 
351  public:
359  CheckPointer(const GridType & grid,
360  OutPutDataType& data,
361  const TimeProviderBase& tp,
363  : BaseType(grid,data,tp,parameter)
364  , persistentGridObject_( new PersistentGridObjectType( grid_ ) )
365  , dataPtr_ ( 0 )
366  , checkPointStep_( parameter.checkPointStep() )
367  , maxCheckPointNumber_( parameter.maxNumberOfCheckPoints() )
368  , myRank_( grid.comm().rank() )
369  , takeCareOfPersistenceManager_( true )
370  {
371  initialize( parameter );
372  }
373 
380  CheckPointer( const GridType & grid,
381  const TimeProviderBase& tp,
383  : BaseType(grid, *( new OutPutDataType () ), tp, parameter )
384  , persistentGridObject_( new PersistentGridObjectType( grid_ ) )
385  , dataPtr_ ( &data_ )
386  , checkPointStep_( parameter.checkPointStep() )
387  , maxCheckPointNumber_( parameter.maxNumberOfCheckPoints() )
388  , myRank_( grid.comm().rank() )
389  , takeCareOfPersistenceManager_( true )
390  {
391  initialize( parameter );
392  }
393 
395  {
396  // remove persistent grid object from PersistenceManager
397  delete persistentGridObject_;
398  persistentGridObject_ = 0;
399 
400  // if data_ was created inside this class
401  // we have also to delete it
402  if( dataPtr_ )
403  {
404  delete dataPtr_;
405  dataPtr_ = 0 ;
406  }
407  }
408 
409  protected:
411  {
412  // output format can only be binary
413  outputFormat_ = BaseType :: binary;
414  // do not display
415  grapeDisplay_ = false ;
416 
417  checkPointFile_ = path_;
418  checkPointFile_ += "/";
419  checkPointFile_ += parameter.prefix();
420 
421  // write parameter file
422  Parameter::write("parameter.log");
423  }
424 
425  protected:
443  CheckPointer(const GridType & grid,
444  const int myRank,
445  OutPutDataType& data,
446  const char * checkFile,
447  const bool takeCareOfPersistenceManager = true,
448  const int writeStep = 0 )
449  : BaseType(grid, data, CheckPointerParameters( checkFile == 0 ) ) // checkFile != 0 means read mode
450  , persistentGridObject_( 0 ) // do not create a persistent object here, since we are in read mode
451  , dataPtr_ ( 0 )
452  , checkPointStep_( 0 )
453  , maxCheckPointNumber_( writeStep + 1 )
454  , myRank_( myRank )
455  , takeCareOfPersistenceManager_( takeCareOfPersistenceManager )
456  {
457  // output format can oinly be binary
458  outputFormat_ = BaseType :: binary;
459  // do not display
460  grapeDisplay_ = false ;
461 
462  CheckPointerParameters parameter( checkFile == 0 );
463  datapref_ = parameter.checkPointPrefix();
464 
465  if( checkFile )
466  {
467  // try to read given check point file
468  checkPointFile_ = checkFile;
469  // read last counter
470  bool ok = readCheckPoint();
471 
472  // if check point couldn't be opened, try again with default
473  if(!ok)
474  {
475  // read name of check point file
476  checkPointFile_ = path_;
477  checkPointFile_ += "/";
478  checkPointFile_ += parameter.checkPointPrefix();
479 
480  ok = readCheckPoint();
481  if( ! ok )
482  {
483  std::cerr <<"ERROR: unable to open checkpoint file! \n";
484  exit(1);
485  }
486  }
487  }
488  else
489  {
490  initialize( CheckPointerParameters( checkFile == 0 ) );
491  }
492 
493  // set write step counter to value given in constructor
494  writeStep_ = writeStep ;
495  }
496 
497  public:
506  static GridType* restoreGrid(const std::string checkFile,
507  const int givenRank = -1,
509  {
510  const int rank = ( givenRank < 0 ) ? MPIManager :: rank() : givenRank ;
511  std::string datapref( parameter.checkPointPrefix() );
512  std::string path;
513 
514  const bool verbose = (rank == 0);
515 
516  int checkPointNumber = 0;
517  // if given checkpointfile is not valid use default checkpoint file
518  if( ! readParameter(checkFile,"LastCheckPoint",checkPointNumber,verbose ) )
519  {
520  // read default path
521  path = IOInterface::readPath();
522  // set checkpointfile
523  std::string checkPointFile = path;
524  // try out default checkpoint file
525  checkPointFile += "/";
526  checkPointFile += parameter.checkPointPrefix();
527  readParameter(checkPointFile,"LastCheckPoint",checkPointNumber, verbose);
528  }
529  else
530  {
531  if( ! readParameter(checkFile,"RecoverPath",path,verbose) )
532  {
533  // read default path
534  path = IOInterface::readPath();
535  }
536  }
537 
538  // now add timestamp (and rank)
540  path, rank, datapref, checkPointNumber, parameter.separateRankPath() );
541 
542  // initialize PersistenceManager
544 
545  GridType* grid = 0;
546  // this is only available in dune-grid 2.3.x and later
547  try
548  {
549  std::istream& stream = PersistenceManager :: restoreStream().stream();
550  grid = Dune::BackupRestoreFacility< GridType > :: restore( stream );
551  }
552  catch ( Dune :: NotImplemented )
553  {
554 #ifndef NDEBUG
555  if( Parameter :: verbose () )
556  std::cerr << "GridPersistentObject::restore: cannot use stream restore." << std::endl;
557 #endif
558  try {
559  std::string name ( Fem :: gridName( *grid ) );
560  std::string filename( PersistenceManager :: uniqueFileName( name ) );
561  grid = Dune::BackupRestoreFacility< GridType > :: restore( filename );
562  }
563  catch ( Dune :: NotImplemented )
564  {
565  std::cerr << "ERROR: GridPersistentObject::restore: not possible!" << std::endl;
566  }
567  }
568 
569  if( grid == 0 )
570  {
571  DUNE_THROW(InvalidStateException,"Could not recover grid");
572  }
573 
574  return grid;
575  }
576 
583  static inline
584  void restoreData ( const GridType &grid, const std::string checkFile )
585  {
586  tuple<> fakeData;
587  restoreData( grid, fakeData, checkFile );
588  }
589 
598  template <class InputTupleType>
599  static inline
600  void restoreData(const GridType& grid,
601  InputTupleType& data,
602  const std::string checkFile,
603  const int rank = -1 )
604  {
605  // make rank exchangable
606  const int myRank = ( rank < 0 ) ? grid.comm().rank() : rank ;
607 
608  // check that check point is not empty
609  if( checkFile == "" )
610  {
611  DUNE_THROW(InvalidStateException,"Checkpoint file empty!");
612  }
613 
614  // create temporary check pointer
615  CheckPointer<GridType, InputTupleType> checker( grid, myRank, data, checkFile.c_str() );
616 
617  // restore data
618  checker.restoreData();
619  }
620 
621  protected:
625  std::string restorePersistentData()
626  {
627  // now add timestamp and rank
628  std::string path = IOInterface::createRecoverPath(
629  path_, myRank_ , datapref_, writeStep_, separateRankPath_ );
630 
631  // if true also restore PersistenceManager
632  if( takeCareOfPersistenceManager_ )
633  {
634  // restore all persistent values kept by PersistenceManager
636  }
637 
638  return path;
639  }
640 
641  template< class InputTuple >
642  void restoreUserData ( InputTuple &data )
643  {
644  // restore persistent data
645  std::string path = restorePersistentData( );
646 
647  typedef IOTuple< InputTuple > IOTupleType ;
648 
649  // restore user data
650  if( IOTupleType :: length > 0 )
651  {
652  IOTupleType :: restoreData( data, grid_, path , datapref_ );
653  }
654 
655  // make data consecutive at the end of the restore process
656  DofManagerType :: instance( grid_ ).compress();
657  }
658 
659  void restoreData( )
660  {
661  restoreUserData( data_ );
662  }
663 
664  public:
666  virtual const char* myClassName() const { return "CheckPointer"; }
667 
668  using BaseType :: willWrite ;
671  bool willWrite(const TimeProviderBase& tp) const
672  {
673  const int timestep = tp.timeStep();
674  // only write data time > saveTime
675  return ( (checkPointStep_ > 0) && (((timestep % checkPointStep_) == 0) && timestep > 0) );
676  }
677 
678  template <class OutputTuple>
679  static void writeSingleCheckPoint(const GridType& grid,
680  OutputTuple& data,
681  const double time,
682  const bool storePersistenceManager,
683  const int writeStep = 0 )
684  {
685  CheckPointer< GridType, OutputTuple > checkPointer( grid, grid.comm().rank(),
686  data, 0, storePersistenceManager, writeStep );
687  checkPointer.writeBinaryData( time );
688  }
689 
690  virtual void writeBinaryData(const double time) const
691  {
692  // reset writeStep_ when maxCheckPointNumber_ is reached
693  if( writeStep_ >= maxCheckPointNumber_ ) writeStep_ = 0;
694 
695  // write data
696  std::string path = this->writeMyBinaryData( time, writeStep_, data_ );
697 
698  // if true also backup PersistenceManager
699  if( takeCareOfPersistenceManager_ )
700  {
701  // backup all persistent values kept by PersistenceManager
703  }
704 
705  // write checkpoint info
706  writeCheckPoint(path, time,
707  writeStep_ );
708 
709  return;
710  }
711 
712  protected:
714  bool readCheckPoint(const bool warn = true)
715  {
716  const bool verbose = Parameter::verbose();
717 
718  // read Checkpiont file
719  if( readParameter(checkPointFile_,"LastCheckPoint",writeStep_, verbose, warn ) )
720  {
721  std::string recoverPath;
722  // try to read recover path
723  if( ! readParameter(checkPointFile_,"RecoverPath", recoverPath, verbose) )
724  {
725  // default value is output path
726  recoverPath = path_;
727  }
728 
729  int storedPersistentManager = 0;
730  if( readParameter(checkPointFile_,"PersistenceManager", storedPersistentManager, verbose) )
731  {
732  takeCareOfPersistenceManager_ = ( storedPersistentManager > 0 );
733  }
734 
735  // overwrite path with recover path
736  path_ = recoverPath;
737 
738  return true;
739  }
740  return false;
741  }
742 
743  // write some info for checkpointing
744  void writeCheckPoint (const std::string& path,
745  const double time,
746  const int savestep ) const
747  {
748  // write some needed informantion to current checkpoint file
749  // only proc 0 writes the global checkpoint file
750  if( myRank_ <= 0 )
751  {
752  std::string checkpointstr ;
753  {
754  std::stringstream checkpoint;
755  checkpoint << "LastCheckPoint: " << savestep << std::endl;
756  checkpoint.precision( 16 );
757  checkpoint << "Time: " << std::scientific << time << std::endl;
758  checkpoint << "SaveCount: " << savestep << std::endl;
759  checkpoint << "PersistenceManager: " << takeCareOfPersistenceManager_ << std::endl;
760  checkpoint << "NumberProcessors: " << grid_.comm().size() << std::endl;
761  checkpoint << "# RecoverPath can be edited by hand if data has been moved!" << std::endl;
762  checkpoint << "RecoverPath: " << path_ << std::endl;
763  checkpointstr = checkpoint.str();
764  }
765 
766  // overwrite the last checkpoint file
767  {
768  std::ofstream file (checkPointFile_.c_str());
769  if( file.is_open() )
770  {
771  file << checkpointstr;
772  }
773  }
774 
775  // write check point file for this checkpoint
776  {
777  std::string checkPointStepFile( path );
778  checkPointStepFile += "/" + datapref_;
779 
780  std::ofstream file ( checkPointStepFile.c_str() );
781  if( file.is_open() )
782  {
783  file << checkpointstr;
784  }
785  }
786  }
787  }
788 
789  }; // end class CheckPointer
790 
791  } // end namespace Fem
792 
793 } // namespace Dune
794 
795 #endif // #ifndef DUNE_FEM_DATAWRITER_HH
DataWriter(const GridType &grid, OutPutDataType &data, const TimeProviderBase &tp, const DataWriterParameters &parameter=DataWriterParameters())
Constructor creating data writer.
Definition: datawriter.hh:110
std::stringstream macroGrid_
Definition: datawriter.hh:84
std::string restorePersistentData()
restores data, assumes that all objects have been created before this method is called ...
Definition: datawriter.hh:625
void writeCheckPoint(const std::string &path, const double time, const int savestep) const
Definition: datawriter.hh:744
virtual std::string prefix() const
base of file name for data file (fem.io.datafileprefix)
Definition: datawriter.hh:182
void backup(const std::string &token, const T &value)
Definition: persistencemanager.hh:308
CheckPointer< GridImp, DataImp > ThisType
type of this class
Definition: datawriter.hh:333
virtual bool writeMode() const
writeMode, true when checkpointer is in backup mode
Definition: datawriter.hh:206
virtual bool separateRankPath() const
return true if all data should be written to a spearate path per rank
Definition: datawriter.hh:47
virtual const char * myClassName() const
print class name
Definition: datawriter.hh:666
PersistentGridObjectType * persistentGridObject_
Definition: datawriter.hh:339
static int rank()
Definition: mpimanager.hh:116
Implementation of the IOInterface. This class manages checkpointing.
Definition: datawriter.hh:239
CheckPointer(const GridType &grid, const TimeProviderBase &tp, const CheckPointerParameters &parameter=CheckPointerParameters())
Constructor generating a checkpointer.
Definition: datawriter.hh:380
Container for User Specified Parameters.
Definition: io/parameter.hh:187
int timeStep() const
obtain number of the current time step
Definition: timeprovider.hh:103
static std::string uniqueFileName(const std::string &tag="")
Definition: persistencemanager.hh:368
const ParameterReader & parameter() const noexcept
Definition: dataoutput.hh:170
static void startRestore(const std::string &path)
Definition: persistencemanager.hh:363
static RestoreStreamType & restoreStream()
Definition: persistencemanager.hh:338
virtual void writeBinaryData(const double sequenceStamp) const
write binary data
Definition: datawriter.hh:127
bool willWrite(const TimeProviderBase &tp) const
returns true if data will be written on next write call
Definition: datawriter.hh:671
Implementation of the Dune::IOInterface. This class manages data output. Available output formats are...
Definition: datawriter.hh:62
static void insert(PersistentObject &object, const bool pushFront=false)
Definition: persistencemanager.hh:343
static std::string readPath()
Definition: iointerface.hh:260
std::ostream & stream()
Definition: standardstreams.hh:85
Implementation of the Dune::Fem::IOInterface. This class manages data output. Available output format...
Definition: dataoutput.hh:183
GridImp GridType
type of grid used
Definition: datawriter.hh:66
Definition: datacollector.hh:45
static void writeSingleCheckPoint(const GridType &grid, OutputTuple &data, const double time, const bool storePersistenceManager, const int writeStep=0)
Definition: datawriter.hh:679
std::string writeMyBinaryData(const double sequenceStamp, const int step, OutputTuple &data) const
Definition: datawriter.hh:133
CheckPointerParameters(const std::string keyPrefix="fem.io.")
Definition: datawriter.hh:176
static bool readParameter(std::istream &file, const std::string keyword, T &data, bool verbose=true, bool warn=true)
Definition: asciiparser.hh:18
CheckPointerParameters(const bool writeMode, const std::string keyPrefix="fem.io.")
Definition: datawriter.hh:171
static std::string defaultGridKey(int dimension, bool check=true)
return FEM key for macro grid reading
Definition: iointerface.hh:186
DataWriter< GridImp, DataImp > BaseType
type of base class
Definition: datawriter.hh:317
DataWriterParameters(const ParameterReader &parameter=Parameter::container())
Definition: datawriter.hh:36
Parameter class for Dune::Fem::DataOutput.
Definition: dataoutput.hh:57
void initialize(const CheckPointerParameters &parameter)
Definition: datawriter.hh:410
general base for time providers
Definition: timeprovider.hh:35
static void restoreData(const GridType &grid, const std::string checkFile)
restores data, assumes that all objects have been created and inserted to PersistenceManager before t...
Definition: datawriter.hh:584
DataWriter(const GridType &grid, OutPutDataType &data, const DataWriterParameters &parameter=DataWriterParameters())
Constructor creating data writer.
Definition: datawriter.hh:95
void restore(const std::string &token, T &value)
Definition: persistencemanager.hh:315
const std::string name_
Definition: datawriter.hh:252
CheckPointer(const GridType &grid, const int myRank, OutPutDataType &data, const char *checkFile, const bool takeCareOfPersistenceManager=true, const int writeStep=0)
Constructor generating a checkpointer to restore data.
Definition: datawriter.hh:443
call appropriate backup and restore methods on the grid class
Definition: datawriter.hh:249
static const std::string & gridName()
Definition: gridname.hh:33
virtual bool separateRankPath() const
return true if all data should be written to a spearate path per rank
Definition: datawriter.hh:212
static BackupStreamType & backupStream()
Definition: persistencemanager.hh:333
bool writeMode_
Definition: datawriter.hh:168
Definition: coordinate.hh:4
Definition: iotuple.hh:155
virtual void writeBinaryData(const double time) const
write binary data
Definition: datawriter.hh:690
OutPutDataType * dataPtr_
Definition: datawriter.hh:341
const int maxCheckPointNumber_
Definition: datawriter.hh:344
const int checkPointStep_
Definition: datawriter.hh:343
DataOutput< GridImp, DataImp > BaseType
Definition: datawriter.hh:73
virtual std::string checkPointPrefix() const
return default value for check point prefix
Definition: datawriter.hh:200
GridPersistentObject(const GridType &grid)
constructor storing grid
Definition: datawriter.hh:255
GridImp GridType
used grid type
Definition: datawriter.hh:244
const GridType & grid_
Definition: datawriter.hh:251
virtual void restore()
restore grid
Definition: datawriter.hh:308
~CheckPointer()
Definition: datawriter.hh:394
std::istream & stream()
Definition: standardstreams.hh:220
static ParameterContainer & container()
Definition: io/parameter.hh:190
static void write(const std::string &filename, const std::string &fileextension="", bool writeAll=true)
write the parameter database to a file
Definition: io/parameter.hh:515
void restoreData()
Definition: datawriter.hh:659
static void remove(PersistentObject &object)
Definition: persistencemanager.hh:348
base class for persistent objects
Definition: persistencemanager.hh:96
static GridType * restoreGrid(const std::string checkFile, const int givenRank=-1, const CheckPointerParameters &parameter=CheckPointerParameters())
restore grid from previous runs
Definition: datawriter.hh:506
bool readCheckPoint(const bool warn=true)
read checkpoint file
Definition: datawriter.hh:714
virtual int maxNumberOfCheckPoints() const
maximal number of checkpoint stages written (default = 2)
Definition: datawriter.hh:194
static bool verbose()
obtain the cached value for fem.verbose
Definition: io/parameter.hh:444
DofManager< GridType > DofManagerType
Definition: datawriter.hh:246
DataWriter< GridImp, DataImp > ThisType
type of this class
Definition: datawriter.hh:71
local parameter collection for CheckPointer
Definition: datawriter.hh:165
virtual std::string path() const
path where the data is stored (always relative to fem.prefix)
Definition: dataoutput.hh:76
GridPersistentObject PersistentGridObjectType
Definition: datawriter.hh:338
void restoreUserData(InputTuple &data)
Definition: datawriter.hh:642
virtual int checkPointStep() const
return number of timestep to be passed until next checkpoint in written
Definition: datawriter.hh:188
CheckPointer(const GridType &grid, OutPutDataType &data, const TimeProviderBase &tp, const CheckPointerParameters &parameter=CheckPointerParameters())
Constructor generating a checkpointer.
Definition: datawriter.hh:359
T getValue(const std::string &key) const
get mandatory parameter
Definition: reader.hh:149
const std::string keyPrefix_
Definition: dataoutput.hh:63
static void restoreData(const GridType &grid, InputTupleType &data, const std::string checkFile, const int rank=-1)
restores data, assumes that all objects have been created and inserted to PersistenceManager before t...
Definition: datawriter.hh:600
std::string checkPointFile_
Definition: datawriter.hh:347
virtual std::string macroGridName(const int dim) const
base of file name for data file (fem.io.macroGridFile)
Definition: datawriter.hh:41
virtual int outputformat() const
format of output (fem.io.outputformat)
Definition: datawriter.hh:217
Definition: datawriter.hh:30
DataImp OutPutDataType
type of data tuple
Definition: datawriter.hh:68
static void createPath(const std::string &path)
create given path in combination with rank
Definition: iointerface.hh:237
DataImp OutPutDataType
used data tuple
Definition: datawriter.hh:336
virtual void backup() const
backup grid
Definition: datawriter.hh:275
virtual ~DataWriter()
destructor
Definition: datawriter.hh:120
int myRank_
Definition: datawriter.hh:345
~GridPersistentObject()
destructor removing grid object
Definition: datawriter.hh:268
virtual const char * myClassName() const
print class name
Definition: datawriter.hh:124
bool takeCareOfPersistenceManager_
Definition: datawriter.hh:349
virtual double savestep() const
save data every savestep interval (fem.io.savestep)
Definition: dataoutput.hh:121
virtual bool writeMode() const
Definition: dataoutput.hh:165
static std::string createRecoverPath(const std::string &pathPrefix, const int rank, const std::string &dataPrefix, const int step, const bool alsoUseRankPath=true)
Definition: iointerface.hh:331
DataWriterParameters(std::string keyPrefix, const ParameterReader &parameter=Parameter::container())
Definition: datawriter.hh:32
const bool separateRankPath_
Definition: datawriter.hh:85