dune-fem  2.8-git
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 #include <tuple>
6 #include <limits>
7 #include <memory>
8 
12 #include <dune/fem/io/parameter.hh>
21 #include <dune/grid/common/backuprestore.hh>
22 
23 #if USE_GRAPE
24 #include <dune/grid/io/visual/grapedatadisplay.hh>
25 #endif
26 
27 namespace Dune
28 {
29 
30  namespace Fem
31  {
32 
34  {
35  explicit DataWriterParameters ( std::string keyPrefix, const ParameterReader &parameter = Parameter::container() )
36  : DataOutputParameters( keyPrefix, parameter )
37  {}
38 
41  {}
42 
44  virtual std::string macroGridName (const int dim) const
45  {
46  return parameter().getValue< std::string >( IOInterface::defaultGridKey( dim, parameter() ) );
47  }
48 
50  virtual bool separateRankPath () const
51  {
52  return false;
53  }
54  };
55 
63  template <class GridImp,
64  class DataImp>
65  class DataWriter : public DataOutput< GridImp, DataImp >
66  {
67  protected:
69  typedef GridImp GridType;
71  typedef DataImp OutPutDataType;
72 
75 
77 
78  using BaseType :: grid_;
79  using BaseType :: data_;
80 
81  using BaseType :: path_;
85 
86  friend class DataOutput< GridImp, DataImp >;
87  mutable std::stringstream macroGrid_;
88  const bool separateRankPath_ ;
89 
90  public:
91 
98  DataWriter(const GridType & grid,
99  OutPutDataType& data,
100  const DataWriterParameters& parameter = DataWriterParameters() )
101  : BaseType( grid, data, parameter ),
102  separateRankPath_( parameter.separateRankPath() )
103  {
104  }
105 
113  DataWriter(const GridType & grid,
114  OutPutDataType& data,
115  const TimeProviderBase& tp,
116  const DataWriterParameters& parameter = DataWriterParameters() )
117  : BaseType( grid, data, tp, parameter ),
118  separateRankPath_( parameter.separateRankPath() )
119  {
120  }
121 
123  virtual ~DataWriter() {}
124 
125  protected:
127  virtual const char* myClassName() const { return "DataWriter"; }
128 
130  virtual void writeBinaryData(const double sequenceStamp) const
131  {
132  writeMyBinaryData( sequenceStamp, writeStep_ , data_ );
133  }
134 
135  template< class OutputTuple >
136  std::string writeMyBinaryData ( const double sequenceStamp, const int step,
137  OutputTuple &data ) const
138  {
139  // create new path for time step output
140  std::string timeStepPath = IOInterface::createPath( grid_.comm(), path_, datapref_, step, separateRankPath_ );
141 
142  typedef IOTuple< OutputTuple > IOTupleType ;
143 
144  // if data is given, use BinaryDataIO to write it
145  if( IOTupleType :: length > 0 )
146  {
147  // call output of IOTuple
148  IOTupleType :: output( grid_, sequenceStamp, timeStepPath, datapref_, data );
149  }
150 
151  return timeStepPath;
152  }
153  }; // end class DataWriter
154 
156  //
157  // Checkpointer
158  //
160 
169  {
170  protected:
172 
173  public:
174  CheckPointerParameters( const bool writeMode, const std::string keyPrefix = "fem.io." ) :
175  DataWriterParameters( keyPrefix, Parameter::container() ),
177  {}
178 
179  explicit CheckPointerParameters( const std::string keyPrefix = "fem.io." ) :
180  DataWriterParameters( keyPrefix, Parameter::container() ),
181  writeMode_( true )
182  {}
183 
185  virtual std::string prefix () const
186  {
187  return checkPointPrefix();
188  }
189 
191  virtual int checkPointStep() const
192  {
193  return parameter().getValue< int > ( keyPrefix_ + "checkpointstep", 500 );
194  }
195 
197  virtual int maxNumberOfCheckPoints() const
198  {
199  return parameter().getValue< int > ( keyPrefix_ + "checkpointmax", 2 );
200  }
201 
203  virtual std::string checkPointPrefix() const
204  {
205  return parameter().getValue< std::string > ( keyPrefix_ + "checkpointfile", "checkpoint" );
206  }
207 
209  virtual bool writeMode() const
210  {
211  return writeMode_;
212  }
213 
215  virtual bool separateRankPath () const
216  {
217  return false;
218  }
219 
220  virtual int outputformat() const
221  {
222  return 5; // i.e. none
223  }
224  };
225 
235  template< class GridImp >
237  : public DataWriter< GridImp, std::tuple<> >
238  {
239  typedef std::tuple<> DataImp;
240  protected:
242  typedef GridImp GridType;
243 
245 
248  {
249  const GridType& grid_ ;
250  const std::string name_;
251 
254  : grid_( grid ),
255  name_( Fem :: gridName( grid_ ) )
256  {
257  // we need to push the grid at the
258  // front position of the PersistenceManager list
259  // since we have to read it first on restore
260  const bool pushFront = true ;
261  // add grid at first position
262  PersistenceManager::insert( *this, pushFront );
263  }
264 
267  {
268  // remove myself
270  }
271 
273  virtual void backup() const
274  {
275  // this feature is available in dune-grid 2.3.x and later
276 
277  // try backup using stream method first
278  try
279  {
280  std::string gridBackup ;
281  // get backup stream from grid facility
282  {
283  std::stringstream gridBackupStream;
284  Dune::BackupRestoreFacility< GridType > :: backup( grid_, gridBackupStream );
285  gridBackup = gridBackupStream.str();
286  }
287  PersistenceManager :: backupStream() << gridBackup;
288  }
289  catch ( const Dune :: NotImplemented& )
290  {
291 #ifndef NDEBUG
292  if( Parameter :: verbose () )
293  std::cerr << "GridPersistentObject::backup: cannot use stream backup." << std::endl;
294 #endif
295 
296  // try method given a filename
297  try {
298  std::string filename( PersistenceManager :: uniqueFileName( name_ ) );
299  Dune::BackupRestoreFacility< GridType > :: backup( grid_, filename );
300  }
301  catch ( const Dune :: NotImplemented& )
302  {
303  std::cerr << "ERROR: GridPersistentObject::backup: not possible!" << std::endl;
304  }
305  }
306 
307  // backup dof manager
309  }
310 
312  virtual void restore ()
313  {
314  }
315  };
316 
319 
320  using BaseType :: grid_;
321  using BaseType :: data_;
322 
323  using BaseType :: path_;
324  using BaseType :: datapref_;
329 
332 
334  typedef DataImp OutPutDataType;
335  OutPutDataType fakeData_; // empty tuple
336 
338  std::unique_ptr< PersistentGridObjectType > persistentGridObject_ ;
339 
341 
342  const int checkPointStep_;
344  int myRank_;
345 
346  std::string checkPointFile_;
347 
349 
350  public:
356  CheckPointer(const GridType & grid,
357  const CheckPointerParameters& parameter = CheckPointerParameters() )
358  : BaseType(grid, fakeData_, parameter)
360  , dataPtr_ ( 0 )
361  , checkPointStep_( parameter.checkPointStep() )
362  , maxCheckPointNumber_( parameter.maxNumberOfCheckPoints() )
363  , myRank_( grid.comm().rank() )
365  {
366  initialize( parameter );
367  }
368 
376  CheckPointer(const GridType & grid,
377  const TimeProviderBase& tp,
378  const CheckPointerParameters& parameter = CheckPointerParameters() )
379  : BaseType(grid, fakeData_,tp,parameter)
381  , checkPointStep_( parameter.checkPointStep() )
382  , maxCheckPointNumber_( parameter.maxNumberOfCheckPoints() )
383  , myRank_( grid.comm().rank() )
385  {
386  initialize( parameter );
387  }
388 
389  protected:
390  void initialize( const CheckPointerParameters& parameter )
391  {
392  // output format can only be binary
394  // do not display
395  grapeDisplay_ = false ;
396 
398  checkPointFile_ += "/";
399  checkPointFile_ += parameter.prefix();
400 
401  // write parameter file
402  Parameter::write("parameter.log");
403  }
404 
405  protected:
423  CheckPointer(const GridType & grid,
424  const int myRank,
425  const char * checkFile,
426  const bool takeCareOfPersistenceManager = true,
427  const int writeStep = 0 )
428  : BaseType(grid, fakeData_, CheckPointerParameters( checkFile == 0 ) ) // checkFile != 0 means read mode
429  , persistentGridObject_( ) // do not create a persistent object here, since we are in read mode
430  , checkPointStep_( 0 )
432  , myRank_( myRank )
433  , takeCareOfPersistenceManager_( takeCareOfPersistenceManager )
434  {
435  // output format can oinly be binary
437  // do not display
438  grapeDisplay_ = false ;
439 
440  CheckPointerParameters parameter( checkFile == 0 );
441  datapref_ = parameter.checkPointPrefix();
442 
443  if( checkFile )
444  {
445  // try to read given check point file
446  checkPointFile_ = checkFile;
447 
448  // read last counter, don't issue warning
449  bool ok = readCheckPoint( false );
450 
451  // if check point couldn't be opened, try again with default
452  if(!ok)
453  {
454 
455  // read name of check point file
457  checkPointFile_ += "/";
458  checkPointFile_ += parameter.checkPointPrefix();
459 
460  const bool warn = (myRank == 0);
461  if( warn )
462  {
463  std::cerr << "WARNING: Coudn't open file `" << checkFile << "' trying file `" << checkPointFile_ << "' instead!" << std::endl;
464  }
465 
466  ok = readCheckPoint();
467  if( ! ok )
468  {
469  std::cerr <<"ERROR: unable to open checkpoint file! \n";
470  exit(1);
471  }
472  }
473  }
474  else
475  {
476  initialize( CheckPointerParameters( checkFile == 0 ) );
477  }
478 
479  // set write step counter to value given in constructor
481  }
482 
483  public:
492  static GridType* restoreGrid(const std::string checkFile,
493  const int givenRank = -1,
494  const CheckPointerParameters& parameter = CheckPointerParameters() )
495  {
496  const int rank = ( givenRank < 0 ) ? MPIManager :: rank() : givenRank ;
497  std::string datapref( parameter.checkPointPrefix() );
498  std::string path;
499 
500  const bool verbose = (rank == 0);
501 
502  int checkPointNumber = 0;
503  // if given checkpointfile is not valid use default checkpoint file
504  if( ! readParameter(checkFile,"LastCheckPoint",checkPointNumber, verbose, false ) )
505  {
506  // read default path
508  // set checkpointfile
509  std::string checkPointFile = path;
510  // try out default checkpoint file
511  checkPointFile += "/";
512  checkPointFile += parameter.checkPointPrefix();
513  if ( verbose )
514  {
515  std::cerr << "WARNING: Coudn't open file `" << checkFile << "' trying file `" << checkPointFile << "' instead!" << std::endl;
516  }
517  readParameter(checkPointFile,"LastCheckPoint",checkPointNumber, verbose);
518  }
519  else
520  {
521  if( ! readParameter(checkFile,"RecoverPath",path,verbose) )
522  {
523  // read default path
525  }
526  }
527 
528  // now add timestamp (and rank)
530  path, rank, datapref, checkPointNumber, parameter.separateRankPath() );
531 
532  // initialize PersistenceManager
534 
535  GridType* grid = 0;
536  // this is only available in dune-grid 2.3.x and later
537  try
538  {
539  std::string gridData;
541 
542  // copy data to stream
543  std::stringstream gridStream( gridData );
544  // clear grid data
545  gridData = std::string();
546 
547  // perform restore using grid stream only
548  grid = Dune::BackupRestoreFacility< GridType > :: restore( gridStream );
549  }
550  catch ( const Dune :: NotImplemented& )
551  {
552 #ifndef NDEBUG
553  if( Parameter :: verbose () )
554  std::cerr << "GridPersistentObject::restore: cannot use stream restore." << std::endl;
555 #endif
556  try {
557  std::string name ( Fem :: gridName( *grid ) );
558  std::string filename( PersistenceManager :: uniqueFileName( name ) );
559  grid = Dune::BackupRestoreFacility< GridType > :: restore( filename );
560  }
561  catch ( const Dune :: NotImplemented& )
562  {
563  std::cerr << "ERROR: GridPersistentObject::restore: not possible!" << std::endl;
564  }
565  }
566 
567  if( grid == 0 )
568  {
569  DUNE_THROW(InvalidStateException,"Could not recover grid");
570  }
571 
572  return grid;
573  }
574 
581  static inline
582  void restoreData ( const GridType &grid, const std::string checkFile, const int rank=-1 )
583  {
584  // make rank exchangable
585  const int myRank = ( rank < 0 ) ? grid.comm().rank() : rank ;
586 
587  // check that check point is not empty
588  if( checkFile == "" )
589  {
590  DUNE_THROW(InvalidStateException,"Checkpoint file empty!");
591  }
592 
593  // create temporary check pointer
594  CheckPointer<GridType> checker( grid, myRank, checkFile.c_str() );
595 
596  // restore data
597  checker.restoreData();
598  }
599 
600  protected:
604  std::string restorePersistentData()
605  {
606  // now add timestamp and rank
607  std::string path = IOInterface::createRecoverPath(
609 
610  // if true also restore PersistenceManager
612  {
613  // restore all persistent values kept by PersistenceManager
615  }
616 
617  return path;
618  }
619 
620  template< class InputTuple >
621  void restoreUserData ( InputTuple &data )
622  {
623  // restore of the grid is done in method restoreGrid
624  // here we only need to restore the DofManager since now
625  // all spaces and index sets have been created
626  DofManagerType :: instance( grid_ ).restore();
627 
628  // restore persistent data
629  std::string path = restorePersistentData( );
630 
631  // make data consecutive at the end of the restore process
632  // and communicate data
633  DofManagerType :: instance( grid_ ).compress();
634  }
635 
636  void restoreData( )
637  {
639  }
640 
641  public:
643  virtual const char* myClassName() const { return "CheckPointer"; }
644 
645  using BaseType :: willWrite ;
648  bool willWrite(const TimeProviderBase& tp) const
649  {
650  const int timestep = tp.timeStep();
651  // only write data time > saveTime
652  return ( (checkPointStep_ > 0) && (((timestep % checkPointStep_) == 0) && timestep > 0) );
653  }
654 
655  static void writeSingleCheckPoint(const GridType& grid,
656  const double time,
657  const bool storePersistenceManager,
658  const int writeStep = 0 )
659  {
660  CheckPointer< GridType > checkPointer( grid );
661  checkPointer.writeBinaryData( time );
662  }
663 
664  virtual void writeBinaryData(const double time) const
665  {
666  // reset writeStep_ when maxCheckPointNumber_ is reached
668 
669  // write data
670  std::string path = this->writeMyBinaryData( time, writeStep_, data_ );
671 
672  // if true also backup PersistenceManager
674  {
675  // backup all persistent values kept by PersistenceManager
677  }
678 
679  // write checkpoint info
680  writeCheckPoint(path, time,
681  writeStep_ );
682 
683  return;
684  }
685 
686  protected:
688  bool readCheckPoint(const bool warn = true)
689  {
690  const bool verbose = Parameter::verbose();
691 
692  // read Checkpiont file
693  if( readParameter(checkPointFile_,"LastCheckPoint",writeStep_, verbose, warn ) )
694  {
695  std::string recoverPath;
696  // try to read recover path
697  if( ! readParameter(checkPointFile_,"RecoverPath", recoverPath, verbose) )
698  {
699  // default value is output path
700  recoverPath = path_;
701  }
702 
703  int storedPersistentManager = 0;
704  if( readParameter(checkPointFile_,"PersistenceManager", storedPersistentManager, verbose) )
705  {
706  takeCareOfPersistenceManager_ = ( storedPersistentManager > 0 );
707  }
708 
709  // overwrite path with recover path
710  path_ = recoverPath;
711 
712  return true;
713  }
714  return false;
715  }
716 
717  // write some info for checkpointing
718  void writeCheckPoint (const std::string& path,
719  const double time,
720  const int savestep ) const
721  {
722  // write some needed informantion to current checkpoint file
723  // only proc 0 writes the global checkpoint file
724  if( myRank_ <= 0 )
725  {
726  std::string checkpointstr ;
727  {
728  std::stringstream checkpoint;
729  checkpoint << "LastCheckPoint: " << savestep << std::endl;
730  checkpoint.precision( 16 );
731  checkpoint << "Time: " << std::scientific << time << std::endl;
732  checkpoint << "SaveCount: " << savestep << std::endl;
733  checkpoint << "PersistenceManager: " << takeCareOfPersistenceManager_ << std::endl;
734  checkpoint << "NumberProcessors: " << grid_.comm().size() << std::endl;
735  checkpoint << "# RecoverPath can be edited by hand if data has been moved!" << std::endl;
736  checkpoint << "RecoverPath: " << path_ << std::endl;
737  checkpointstr = checkpoint.str();
738  }
739 
740  // overwrite the last checkpoint file
741  {
742  std::ofstream file (checkPointFile_.c_str());
743  if( file.is_open() )
744  {
745  file << checkpointstr;
746  }
747  }
748 
749  // write check point file for this checkpoint
750  {
751  std::string checkPointStepFile( path );
752  checkPointStepFile += "/" + datapref_;
753 
754  std::ofstream file ( checkPointStepFile.c_str() );
755  if( file.is_open() )
756  {
757  file << checkpointstr;
758  }
759  }
760  }
761  }
762 
763  }; // end class CheckPointer
764 
765  } // end namespace Fem
766 
767 } // namespace Dune
768 
769 #endif // #ifndef DUNE_FEM_DATAWRITER_HH
static ThisType & instance(const GridType &grid)
obtain a reference to the DofManager for a given grid
Definition: dofmanager.hh:1216
Definition: bindguard.hh:11
static bool readParameter(std::istream &file, const std::string keyword, T &data, bool verbose=true, bool warn=true)
Definition: asciiparser.hh:18
static const std::string & gridName()
Definition: gridname.hh:33
Parameter class for Dune::Fem::DataOutput.
Definition: dataoutput.hh:73
const ParameterReader & parameter() const noexcept
Definition: dataoutput.hh:182
const std::string keyPrefix_
Definition: dataoutput.hh:75
Implementation of the Dune::Fem::IOInterface. This class manages data output. Available output format...
Definition: dataoutput.hh:197
int writeStep_
Definition: dataoutput.hh:488
GridImp GridType
type of grid used
Definition: dataoutput.hh:279
@ binary
Definition: dataoutput.hh:276
std::string path_
Definition: dataoutput.hh:482
DataImp OutPutDataType
type of data tuple
Definition: dataoutput.hh:281
int writeStep() const
return write step
Definition: dataoutput.hh:419
bool grapeDisplay_
Definition: dataoutput.hh:485
OutputFormat outputFormat_
Definition: dataoutput.hh:498
OutPutDataType data_
Definition: dataoutput.hh:479
virtual bool willWrite() const
returns true if data will be written on next write call
Definition: dataoutput.hh:350
const std::string & path() const
return output path name
Definition: dataoutput.hh:413
const GridType & grid_
type of this class
Definition: dataoutput.hh:478
std::string datapref_
Definition: dataoutput.hh:483
Definition: datawriter.hh:34
virtual bool separateRankPath() const
return true if all data should be written to a spearate path per rank
Definition: datawriter.hh:50
DataWriterParameters(std::string keyPrefix, const ParameterReader &parameter=Parameter::container())
Definition: datawriter.hh:35
virtual std::string macroGridName(const int dim) const
base of file name for data file (fem.io.macroGridFile)
Definition: datawriter.hh:44
DataWriterParameters(const ParameterReader &parameter=Parameter::container())
Definition: datawriter.hh:39
Implementation of the Dune::IOInterface. This class manages data output. Available output formats are...
Definition: datawriter.hh:66
DataWriter(const GridType &grid, OutPutDataType &data, const TimeProviderBase &tp, const DataWriterParameters &parameter=DataWriterParameters())
Constructor creating data writer.
Definition: datawriter.hh:113
const bool separateRankPath_
Definition: datawriter.hh:88
virtual void writeBinaryData(const double sequenceStamp) const
write binary data
Definition: datawriter.hh:130
DataOutput< GridImp, DataImp > BaseType
Definition: datawriter.hh:76
virtual ~DataWriter()
destructor
Definition: datawriter.hh:123
std::stringstream macroGrid_
Definition: datawriter.hh:87
virtual const char * myClassName() const
print class name
Definition: datawriter.hh:127
GridImp GridType
type of grid used
Definition: datawriter.hh:69
DataImp OutPutDataType
type of data tuple
Definition: datawriter.hh:71
DataWriter< GridImp, DataImp > ThisType
type of this class
Definition: datawriter.hh:74
std::string writeMyBinaryData(const double sequenceStamp, const int step, OutputTuple &data) const
Definition: datawriter.hh:136
DataWriter(const GridType &grid, OutPutDataType &data, const DataWriterParameters &parameter=DataWriterParameters())
Constructor creating data writer.
Definition: datawriter.hh:98
local parameter collection for CheckPointer
Definition: datawriter.hh:169
virtual int outputformat() const
format of output (fem.io.outputformat)
Definition: datawriter.hh:220
virtual std::string checkPointPrefix() const
return default value for check point prefix
Definition: datawriter.hh:203
virtual int checkPointStep() const
return number of timestep to be passed until next checkpoint in written
Definition: datawriter.hh:191
virtual int maxNumberOfCheckPoints() const
maximal number of checkpoint stages written (default = 2)
Definition: datawriter.hh:197
bool writeMode_
Definition: datawriter.hh:171
virtual bool writeMode() const
writeMode, true when checkpointer is in backup mode
Definition: datawriter.hh:209
virtual std::string prefix() const
base of file name for data file (fem.io.datafileprefix)
Definition: datawriter.hh:185
virtual bool separateRankPath() const
return true if all data should be written to a spearate path per rank
Definition: datawriter.hh:215
CheckPointerParameters(const bool writeMode, const std::string keyPrefix="fem.io.")
Definition: datawriter.hh:174
CheckPointerParameters(const std::string keyPrefix="fem.io.")
Definition: datawriter.hh:179
Implementation of the IOInterface. This class manages checkpointing.
Definition: datawriter.hh:238
std::string checkPointFile_
Definition: datawriter.hh:346
virtual const char * myClassName() const
print class name
Definition: datawriter.hh:643
static void restoreData(const GridType &grid, 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:582
std::unique_ptr< PersistentGridObjectType > persistentGridObject_
Definition: datawriter.hh:338
CheckPointer(const GridType &grid, const CheckPointerParameters &parameter=CheckPointerParameters())
Constructor generating a checkpointer.
Definition: datawriter.hh:356
DofManager< GridType > DofManagerType
Definition: datawriter.hh:244
GridPersistentObject PersistentGridObjectType
Definition: datawriter.hh:337
const int checkPointStep_
Definition: datawriter.hh:342
const int maxCheckPointNumber_
Definition: datawriter.hh:343
bool readCheckPoint(const bool warn=true)
read checkpoint file
Definition: datawriter.hh:688
void restoreUserData(InputTuple &data)
Definition: datawriter.hh:621
bool willWrite(const TimeProviderBase &tp) const
returns true if data will be written on next write call
Definition: datawriter.hh:648
int myRank_
Definition: datawriter.hh:344
OutPutDataType fakeData_
Definition: datawriter.hh:335
OutPutDataType * dataPtr_
Definition: datawriter.hh:340
DataWriter< GridImp, DataImp > BaseType
type of base class
Definition: datawriter.hh:318
static void writeSingleCheckPoint(const GridType &grid, const double time, const bool storePersistenceManager, const int writeStep=0)
Definition: datawriter.hh:655
void writeCheckPoint(const std::string &path, const double time, const int savestep) const
Definition: datawriter.hh:718
GridImp GridType
used grid type
Definition: datawriter.hh:242
DataImp OutPutDataType
used data tuple
Definition: datawriter.hh:334
CheckPointer(const GridType &grid, const TimeProviderBase &tp, const CheckPointerParameters &parameter=CheckPointerParameters())
Constructor generating a checkpointer.
Definition: datawriter.hh:376
void initialize(const CheckPointerParameters &parameter)
Definition: datawriter.hh:390
void restoreData()
Definition: datawriter.hh:636
CheckPointer(const GridType &grid, const int myRank, const char *checkFile, const bool takeCareOfPersistenceManager=true, const int writeStep=0)
Constructor generating a checkpointer to restore data.
Definition: datawriter.hh:423
CheckPointer< GridImp > ThisType
type of this class
Definition: datawriter.hh:331
static GridType * restoreGrid(const std::string checkFile, const int givenRank=-1, const CheckPointerParameters &parameter=CheckPointerParameters())
restore grid from previous runs
Definition: datawriter.hh:492
std::string restorePersistentData()
restores data, assumes that all objects have been created before this method is called
Definition: datawriter.hh:604
bool takeCareOfPersistenceManager_
Definition: datawriter.hh:348
virtual void writeBinaryData(const double time) const
write binary data
Definition: datawriter.hh:664
call appropriate backup and restore methods on the grid class
Definition: datawriter.hh:248
virtual void restore()
restore grid
Definition: datawriter.hh:312
virtual void backup() const
backup grid
Definition: datawriter.hh:273
const std::string name_
Definition: datawriter.hh:250
GridPersistentObject(const GridType &grid)
constructor storing grid
Definition: datawriter.hh:253
const GridType & grid_
Definition: datawriter.hh:249
~GridPersistentObject()
destructor removing grid object
Definition: datawriter.hh:266
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
static std::string defaultGridKey(int dimension, bool check=true)
return FEM key for macro grid reading
Definition: iointerface.hh:186
static void createPath(const std::string &path)
create given path in combination with rank
Definition: iointerface.hh:237
static std::string readPath()
Definition: iointerface.hh:260
Definition: iotuple.hh:153
base class for persistent objects
Definition: persistencemanager.hh:101
virtual void backup() const =0
backup persistent object
static void remove(PersistentObject &object)
Definition: persistencemanager.hh:364
void backup(const std::string &token, const T &value)
Definition: persistencemanager.hh:312
void restore(const std::string &token, T &value)
Definition: persistencemanager.hh:319
static std::string uniqueFileName(const std::string &tag="")
Definition: persistencemanager.hh:384
static void insert(PersistentObject &object, const bool pushFront=false)
Definition: persistencemanager.hh:359
static void startRestore(const std::string &path)
Definition: persistencemanager.hh:379
static RestoreStreamType & restoreStream()
Definition: persistencemanager.hh:354
static BackupStreamType & backupStream()
Definition: persistencemanager.hh:349
T getValue(const std::string &key) const
get mandatory parameter
Definition: reader.hh:159
Container for User Specified Parameters.
Definition: io/parameter.hh:191
static bool verbose()
obtain the cached value for fem.verbose
Definition: io/parameter.hh:445
static ParameterContainer & container()
Definition: io/parameter.hh:193
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:516
static int rank()
Definition: mpimanager.hh:155
general base for time providers
Definition: timeprovider.hh:36
int timeStep() const
obtain number of the current time step
Definition: timeprovider.hh:103
Definition: dofmanager.hh:762