KASKADE 7 development version
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Kaskade::CheckPoint Struct Reference

#include <checkPoint.hh>

Detailed Description

Definition at line 34 of file checkPoint.hh.

Public Member Functions

 CheckPoint ()
 CheckPoint creates a new empty directory with current time stamp as name. Later writes will refer to this dirctory. More...
 
 CheckPoint (std::string const &pathName)
 CheckPoint. If the directory with pathName already exists later reads will refer to this directory. Otherwise a new directory will be created where current time stamp is appended to pathName. This can then be used for writing. More...
 
bool readMode () const
 readMode returns true if this check point was created in read mode (i.e. with existing directory given). More...
 
std::string timeStamp () const
 timeStamp gives the time stamp when directory was created (at construction of this CheckPoint instance), empty when directory already existed. More...
 
template<class Grid >
void writeGrid (GridManager< Grid > const &gridManager, std::string const &gridName) const
 writes grid into file with name gridName. More...
 
template<class Grid >
void writeGrid (Grid const &grid, std::string const &gridName) const
 writes grid into file with name gridName. More...
 
template<class Grid >
std::unique_ptr< Grid > readGrid (std::string const &gridName) const
 reads grid from file with name gridName. More...
 
template<class Index >
void writeRefinementHistory (std::vector< std::vector< std::pair< int, Index > > > const &refHist, std::string const &gridName) const
 writes the refinement history of a grid. More...
 
template<class Index >
void appendRefinementHistory (std::vector< std::pair< int, Index > > const &refStep, std::string const &gridName) const
 appends data of one refinement step of a grid to file. More...
 
template<class Index >
std::vector< std::vector< std::pair< int, Index > > > readRefinementHistory (std::string const &gridName) const
 reads the refinement history of a grid. More...
 
template<template< class, int > class Array, class Scalar , int dim>
void writeData (Dune::BlockVector< Array< Scalar, dim > > const &data, std::string const &dataName) const
 writes data into file with name dataName. Version for BlockVector. More...
 
template<class DataBlocks >
void writeData (DataBlocks const &data, std::string const &dataName) const
 writes data into file with name dataName. Version for LinearProductSpace (of FE-functions or coefficient vectors). More...
 
template<class FeSpace , int m>
void writeData (FunctionSpaceElement< FeSpace, m > const &data, std::string const &dataName) const
 writes data into file with name dataName. Version for FE-function. More...
 
template<template< class, int > class Array, class Scalar , int dim>
void readData (Dune::BlockVector< Array< Scalar, dim > > &data, std::string const &dataName) const
 reads data from file with name dataName. Version for BlockVector. More...
 
template<class DataBlocks >
void readData (DataBlocks &data, std::string const &dataName) const
 reads data from file with name dataName. Version for LinearProductSpace (of FE-functions or coefficient vectors). More...
 
template<class FeSpace , int m>
void readData (FunctionSpaceElement< FeSpace, m > &data, std::string const &dataName) const
 reads data from file with name dataName. Version for FE-function. More...
 

Protected Member Functions

void setTimeStamp ()
 
template<template< class, int > class Array, class Scalar , int dim>
std::ofstream writeData (Dune::BlockVector< Array< Scalar, dim > > const &data, std::ofstream out) const
 
template<class FeSpace , int m>
std::ofstream writeData (FunctionSpaceElement< FeSpace, m > const &data, std::ofstream out) const
 
template<template< class, int > class Array, class Scalar , int dim>
std::ifstream readData (Dune::BlockVector< Array< Scalar, dim > > &data, std::ifstream in) const
 
template<class FeSpace , int m>
std::ifstream readData (FunctionSpaceElement< FeSpace, m > &data, std::ifstream in) const
 

Protected Attributes

std::string timeStamp_
 
boost::filesystem::path directory
 

Constructor & Destructor Documentation

◆ CheckPoint() [1/2]

Kaskade::CheckPoint::CheckPoint ( )

CheckPoint creates a new empty directory with current time stamp as name. Later writes will refer to this dirctory.

◆ CheckPoint() [2/2]

Kaskade::CheckPoint::CheckPoint ( std::string const &  pathName)

CheckPoint. If the directory with pathName already exists later reads will refer to this directory. Otherwise a new directory will be created where current time stamp is appended to pathName. This can then be used for writing.

Parameters
pathNameis the directory which is to be created (if not existing) or where is to be read from (if existing).

Member Function Documentation

◆ appendRefinementHistory()

template<class Index >
void Kaskade::CheckPoint::appendRefinementHistory ( std::vector< std::pair< int, Index > > const &  refStep,
std::string const &  gridName 
) const
inline

appends data of one refinement step of a grid to file.

This is e.g. usefull for check pointing UGGrid, since writeGrid does not work for it. The advantage compared to writeRefinementsHistory is, that if you do a lot of check-pointing and refinement steps, you do not have write the whole history in each step again and again but only to append the update from the last step.

Definition at line 134 of file checkPoint.hh.

◆ readData() [1/5]

template<class DataBlocks >
void Kaskade::CheckPoint::readData ( DataBlocks &  data,
std::string const &  dataName 
) const
inline

reads data from file with name dataName. Version for LinearProductSpace (of FE-functions or coefficient vectors).

Template Parameters
DataBlockshas to be something like LinearProductSpace, i.e. e.g. VariableSet or CoefficientVectorRepresentation.

Definition at line 226 of file checkPoint.hh.

◆ readData() [2/5]

template<template< class, int > class Array, class Scalar , int dim>
std::ifstream Kaskade::CheckPoint::readData ( Dune::BlockVector< Array< Scalar, dim > > &  data,
std::ifstream  in 
) const
inlineprotected

Definition at line 256 of file checkPoint.hh.

◆ readData() [3/5]

template<template< class, int > class Array, class Scalar , int dim>
void Kaskade::CheckPoint::readData ( Dune::BlockVector< Array< Scalar, dim > > &  data,
std::string const &  dataName 
) const
inline

reads data from file with name dataName. Version for BlockVector.

Template Parameters
Arrayis template type, which behaves like an array, e.g. Dune::FieldVector

Definition at line 216 of file checkPoint.hh.

Referenced by readData().

◆ readData() [4/5]

template<class FeSpace , int m>
std::ifstream Kaskade::CheckPoint::readData ( FunctionSpaceElement< FeSpace, m > &  data,
std::ifstream  in 
) const
inlineprotected

Definition at line 262 of file checkPoint.hh.

◆ readData() [5/5]

template<class FeSpace , int m>
void Kaskade::CheckPoint::readData ( FunctionSpaceElement< FeSpace, m > &  data,
std::string const &  dataName 
) const
inline

reads data from file with name dataName. Version for FE-function.

Definition at line 237 of file checkPoint.hh.

◆ readGrid()

template<class Grid >
std::unique_ptr< Grid > Kaskade::CheckPoint::readGrid ( std::string const &  gridName) const
inline

reads grid from file with name gridName.

Does not work for UGGrid.

Returns
pointer to the created grid or nullptr if file did not exist.

Definition at line 98 of file checkPoint.hh.

◆ readMode()

bool Kaskade::CheckPoint::readMode ( ) const
inline

readMode returns true if this check point was created in read mode (i.e. with existing directory given).

Definition at line 53 of file checkPoint.hh.

◆ readRefinementHistory()

template<class Index >
std::vector< std::vector< std::pair< int, Index > > > Kaskade::CheckPoint::readRefinementHistory ( std::string const &  gridName) const
inline

reads the refinement history of a grid.

This is e.g. usefull for check pointing UGGrid, since writeGrid does not work for it. After reading in, the initial grid can be refined step by step in the same manner.

Parameters
refHistis the refinement history. Suggestion for interpretation: Each entry refers to one refinement step. If an entry is an empty vector this means global refinement (once). Otherwise the vector for a refinement step containts pairs of refinement count and cell index (similiar to the usage in the mark() method of the Dune grid interface).

Definition at line 157 of file checkPoint.hh.

◆ setTimeStamp()

void Kaskade::CheckPoint::setTimeStamp ( )
protected

◆ timeStamp()

std::string Kaskade::CheckPoint::timeStamp ( ) const
inline

timeStamp gives the time stamp when directory was created (at construction of this CheckPoint instance), empty when directory already existed.

Returns
time stamp.

Definition at line 61 of file checkPoint.hh.

◆ writeData() [1/5]

template<class DataBlocks >
void Kaskade::CheckPoint::writeData ( DataBlocks const &  data,
std::string const &  dataName 
) const
inline

writes data into file with name dataName. Version for LinearProductSpace (of FE-functions or coefficient vectors).

Template Parameters
DataBlockshas to be something like LinearProductSpace, i.e. e.g. VariableSet or CoefficientVectorRepresentation.

Definition at line 191 of file checkPoint.hh.

◆ writeData() [2/5]

template<template< class, int > class Array, class Scalar , int dim>
std::ofstream Kaskade::CheckPoint::writeData ( Dune::BlockVector< Array< Scalar, dim > > const &  data,
std::ofstream  out 
) const
inlineprotected

Definition at line 245 of file checkPoint.hh.

◆ writeData() [3/5]

template<template< class, int > class Array, class Scalar , int dim>
void Kaskade::CheckPoint::writeData ( Dune::BlockVector< Array< Scalar, dim > > const &  data,
std::string const &  dataName 
) const
inline

writes data into file with name dataName. Version for BlockVector.

Template Parameters
Arrayis template type, which behaves like an array, e.g. Dune::FieldVector

Definition at line 177 of file checkPoint.hh.

Referenced by writeData().

◆ writeData() [4/5]

template<class FeSpace , int m>
std::ofstream Kaskade::CheckPoint::writeData ( FunctionSpaceElement< FeSpace, m > const &  data,
std::ofstream  out 
) const
inlineprotected

Definition at line 251 of file checkPoint.hh.

◆ writeData() [5/5]

template<class FeSpace , int m>
void Kaskade::CheckPoint::writeData ( FunctionSpaceElement< FeSpace, m > const &  data,
std::string const &  dataName 
) const
inline

writes data into file with name dataName. Version for FE-function.

Definition at line 206 of file checkPoint.hh.

◆ writeGrid() [1/2]

template<class Grid >
void Kaskade::CheckPoint::writeGrid ( Grid const &  grid,
std::string const &  gridName 
) const
inline

writes grid into file with name gridName.

Does not work for UGGrid.

Definition at line 81 of file checkPoint.hh.

◆ writeGrid() [2/2]

template<class Grid >
void Kaskade::CheckPoint::writeGrid ( GridManager< Grid > const &  gridManager,
std::string const &  gridName 
) const
inline

writes grid into file with name gridName.

Does not work for UGGrid.

Definition at line 71 of file checkPoint.hh.

Referenced by writeGrid().

◆ writeRefinementHistory()

template<class Index >
void Kaskade::CheckPoint::writeRefinementHistory ( std::vector< std::vector< std::pair< int, Index > > > const &  refHist,
std::string const &  gridName 
) const
inline

writes the refinement history of a grid.

This is e.g. usefull for check pointing UGGrid, since writeGrid does not work for it.

Parameters
refHistis the refinement history. Suggestion for interpretation: Each entry refers to one refinement step. If an entry is an empty vector this means global refinement (once). Otherwise the vector for a refinement step containts pairs of refinement count and cell index (similiar to the usage in the mark() method of the Dune grid interface).

Definition at line 114 of file checkPoint.hh.

Member Data Documentation

◆ directory

boost::filesystem::path Kaskade::CheckPoint::directory
protected

◆ timeStamp_

std::string Kaskade::CheckPoint::timeStamp_
protected

Definition at line 266 of file checkPoint.hh.

Referenced by readMode(), and timeStamp().


The documentation for this struct was generated from the following file: