revision: v0.14
File Class Reference

#include <File.h>

Public Member Functions

 File ()
 constructor More...
 
 File (const File &)
 default copy constructor More...
 
virtual ~File ()
 destructor More...
 
std::fstream & getFstream ()
 Allows to access the member variable File::fstream_. More...
 
const std::string & getName () const
 Allows to access the file name, e.g., "problem.data". More...
 
const std::string getFullName () const
 Also allows to access the file name, however with additional information which is the file counter, e.g., "problem.data.0000". More...
 
const std::string getFullName (unsigned) const
 Allows to access the file name, however with additional information which is the file counter, e.g., "problem.data.0000". More...
 
void setName (const std::string &name)
 Sets the file name, e.g. "Name.data". More...
 
FileType getFileType () const
 Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_. More...
 
void setFileType (FileType fileType)
 Sets the type of file needed to write into or read from. File::fileType_. More...
 
unsigned int getCounter () const
 In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next file i.e. to be opened for reading or writing; NOTE: needed only if FILE::fileType_ is multiple files. More...
 
void setCounter (unsigned int counter)
 Allows the user to set the file counter according to his need. Sets File::counter_. More...
 
void increaseCounter ()
 
void decreaseCounter ()
 
std::fstream::openmode getOpenMode () const
 Allows the user to know the file mode i.e. gets File::openMode_. More...
 
void setOpenMode (std::fstream::openmode openMode)
 Allows the user to Sets File::openMode_. More...
 
unsigned int getSaveCount () const
 Gets File::saveCount_. More...
 
void writeFirstAndLastTimeStep ()
 Sets File::saveCount_ to the highest possible value such that only the first and last time step is written. More...
 
void setSaveCount (unsigned int saveCount)
 Sets File::saveCount_. More...
 
unsigned int getLastSavedTimeStep () const
 Gets File::nextSavedTimeStep_. More...
 
void setLastSavedTimeStep (unsigned int lastSavedTimeStep)
 Sets File::nextSavedTimeStep_. More...
 
bool saveCurrentTimeStep (unsigned int ntimeSteps)
 determined if this time step has to be written; if so, opens the output file More...
 
bool saveCurrentTimeStepNoFileTypeCheck (unsigned int ntimeSteps)
 
void read (std::istream &is)
 read function, which accepts an input stream std::istream. More...
 
void write (std::ostream &os) const
 print function, which accepts an std::stringstream as input. More...
 
bool open ()
 Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the nextSavedTimeStep and the counter. the counter is useful when the fileType_ is set to Multiple or Multiple with padded. More...
 
bool openWrite (unsigned)
 First sets openmode to write (and append in some cases), then calls open(). More...
 
bool openWriteNoAppend (unsigned)
 
bool open (std::fstream::openmode openMode)
 First calls setOpenMode(openMode), then calls open(). More...
 
void close ()
 Closes the file by calling fstream_.close() More...
 
void setlogarithmicSaveCount (const Mdouble logarithmicSaveCountBase)
 the function to set the user input base of logarithmic saving count More...
 

Private Attributes

std::string name_
 name of the file. More...
 
std::fstream fstream_
 Stream object used to read/write data files. More...
 
FileType fileType_
 fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as described in the description of the class. More...
 
unsigned int counter_
 counts the number of already opened files, i.e. counter=1 means .0000 exists More...
 
std::fstream::openmode openMode_
 A variable to indicate how the file should be opened i.e. in, out, ... see http://en.cppreference.com (std::fstream::out by default) More...
 
unsigned int saveCount_
 Allows one to define the number of time steps to be skipped to make a snap shot. E.g. TMax = 100, saveCount_ = 10, timeStep = 1; It stores data at t={0,10,20,30,40...100}. And if TMax =101, it stores data at t={0,10,20,30,...100,101}. More...
 
Mdouble logarithmicSaveCountBase_
 the switch allow user to set saveCount in logarithmic timescale with equal distance , the number is the base of log scale from user input More...
 
unsigned int lastSavedTimeStep_
 the time step at which the next write or read operation has to happen. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const File &o)
 Operator overloading used to write data obtained from an object of class File into an output stream. It also returns a reference to the output stream. More...
 
std::istream & operator>> (std::istream &is, File &o)
 Operator overloading used to read data from the input stream into member variables of an object of class File. It also returns a reference of type std::istream&. More...
 

Detailed Description

The instance of class File, for e.g. member variables of class Files (objects of type File) in Files.h, allows to manipulate the the input and output stream. In layman terms: In MercuryDPM, in order to read and write data into or from files we use the methods defined in Files.h. These methods implicitly calls the methods of class File and thereby allowing us to write or read data.

Constructor & Destructor Documentation

◆ File() [1/2]

File::File ( )

constructor

A File constructor which initialises FILE::saveCount_=0, sets the default filename as FILE::name_ = "", sets the default FileType to be as FileType::ONE_FILE and few other variables as listed below.

102 {
103  //sets the default for the number of time steps to be skipped
104  //in between each saved "snapshot" of the system to zero
105  //(i.e. records every time step by default)
106  saveCount_ = 0;
107 
108  // file name has to be set by the user
109  name_ = "out";
110 
111  // output into a single file by default
112  fileType_ = FileType::ONE_FILE;
113 
114  // counter of currently open file set to 0 by default
115  counter_ = 0;
116 
117  //stores the time step of the last write/read operation; NEVER by default
119 
120  //sets the default openMode to "out"
121  //i.e. files will by default be written to, not read from.
122  openMode_ = std::fstream::out;
123 
124  //sets the default logarithmicSaveCount to zero
126 }

References counter_, fileType_, lastSavedTimeStep_, logarithmicSaveCountBase_, name_, NEVER, openMode_, and saveCount_.

◆ File() [2/2]

File::File ( const File f)

default copy constructor

Copy everything but the fstream object (which cannot be copied).

Parameters
[in]fthe file object that is to be copied.

References counter_, fileType_, lastSavedTimeStep_, logarithmicSaveCountBase_, name_, openMode_, and saveCount_.

◆ ~File()

File::~File ( )
virtualdefault

destructor

Destructor

Member Function Documentation

◆ close()

◆ decreaseCounter()

void File::decreaseCounter ( )
inline
150 {counter_--;}

References counter_.

Referenced by CGHandler::restart().

◆ getCounter()

unsigned int File::getCounter ( ) const

In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next file i.e. to be opened for reading or writing; NOTE: needed only if FILE::fileType_ is multiple files.

Returns
unsigned int counter_
224 {
225  return counter_;
226 }

References counter_.

Referenced by DPMBase::findNextExistingDataFile(), getFullName(), main(), openWrite(), DPMBase::readDataFile(), SaveCountUnitTest::SaveCountUnitTest(), DPMBase::writeEneTimeStep(), Drum::writeEneTimeStep(), Penetration::writeEneTimeStep(), Silo::writeEneTimeStep(), and DPMBase::writeOutputFiles().

◆ getFileType()

FileType File::getFileType ( ) const

Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.

Returns
Returns the FileType (File::fileType_)
208 {
209  return fileType_;
210 }

References fileType_.

Referenced by BaseInteraction::BaseInteraction(), commandLineCG(), DPMBase::findNextExistingDataFile(), getFullName(), openWrite(), DPMBase::readDataFile(), saveCurrentTimeStep(), DPMBase::writeEneTimeStep(), DPMBase::writeOutputFiles(), and BaseInteraction::~BaseInteraction().

◆ getFstream()

◆ getFullName() [1/2]

const std::string File::getFullName ( ) const

Also allows to access the file name, however with additional information which is the file counter, e.g., "problem.data.0000".

171 {
172  return getFullName(getCounter() - 1);
173 }

References getCounter().

Referenced by CGHandler::evaluateDataFiles(), CGHandler::evaluateRestartFiles(), main(), open(), DPMBase::readDataFile(), DPMBase::readRestartFile(), CGHandler::restart(), write(), and ChuteWithPeriodicInflow::writeXBallsScript().

◆ getFullName() [2/2]

const std::string File::getFullName ( unsigned  counter) const

Allows to access the file name, however with additional information which is the file counter, e.g., "problem.data.0000".

In case of FileType:fileType_== multiple files or multiple files padded, multiple files are generated and are named as problem.data.0, problem.data.1 or problem.data.0000, problem.data.0001

Returns
Returns a constant of type std::string
180 {
181  //get the full file name
182  std::stringstream lastName("");
183  lastName << name_;
184  if (getFileType() == FileType::MULTIPLE_FILES)
185  {
186  lastName << "." << counter;
187  }
189  {
190  lastName << "." << to_string_padded(counter);
191  }
192  return lastName.str();
193 }

References getFileType(), name_, NO_FILE, and to_string_padded().

◆ getLastSavedTimeStep()

unsigned int File::getLastSavedTimeStep ( ) const

Gets File::nextSavedTimeStep_.

Returns the time step at which the next write or read operation has to happen

Returns
unsigned int nextSaveTimeStep_
294 {
295  return lastSavedTimeStep_;
296 }

References lastSavedTimeStep_.

Referenced by SaveCountUnitTest::SaveCountUnitTest().

◆ getName()

◆ getOpenMode()

std::fstream::openmode File::getOpenMode ( ) const

Allows the user to know the file mode i.e. gets File::openMode_.

Returns
std::fstream::openmode
240 {
241  return openMode_;
242 }

References openMode_.

◆ getSaveCount()

◆ increaseCounter()

void File::increaseCounter ( )
inline
148 {counter_++;}

References counter_.

◆ open() [1/2]

bool File::open ( )

Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the nextSavedTimeStep and the counter. the counter is useful when the fileType_ is set to Multiple or Multiple with padded.

Returns a bool to check if the file is open or closed. It also increments the nextSavedTimeStep with the saveCount

Returns
bool (True or False)
Bug:
Deepak checked by using fstream_.fail() instead of !fstrea_.is_open(), however this breaks selftests, Thomas will look at this
348 {
349  //close old file if multi-file output
350  if (fileType_ == FileType::MULTIPLE_FILES || fileType_ == FileType::MULTIPLE_FILES_PADDED)
351  {
352  fstream_.close();
353  }
354 
355  counter_++;
356 
357  if (!fstream_.is_open())
358  {
359  fstream_.open(getFullName().c_str(), openMode_);
360  if (!fstream_.is_open())
361  {
362  return false;
363  }
364  }
365 
366  return true;
367 }

References counter_, fileType_, fstream_, getFullName(), NO_FILE, and openMode_.

Referenced by DPMBase::findNextExistingDataFile(), open(), openWrite(), openWriteNoAppend(), DPMBase::readDataFile(), DPMBase::readNextDataFile(), DPMBase::readNextFStatFile(), DPMBase::readRestartFile(), CSCInit::save(), ClosedCSCWalls::saveWalls(), CSCWalls::saveWalls(), and DPMBase::solve().

◆ open() [2/2]

bool File::open ( std::fstream::openmode  openMode)

First calls setOpenMode(openMode), then calls open().

Parameters
[in]openMode
373 {
374  setOpenMode(openMode);
375  return open();
376 }

References open(), and setOpenMode().

◆ openWrite()

bool File::openWrite ( unsigned  nTimeSteps)

First sets openmode to write (and append in some cases), then calls open().

Parameters
[in]openMode
382 {
383  setLastSavedTimeStep(nTimeSteps);
384  if (getFileType() == FileType::ONE_FILE && getCounter() != 0)
385  {
386  setOpenMode(std::fstream::out | std::fstream::app);
387  }
388  else
389  {
390  setOpenMode(std::fstream::out);
391  }
392  return open();
393 }

References getCounter(), getFileType(), open(), setLastSavedTimeStep(), and setOpenMode().

Referenced by DPMBase::writeDataFile(), DPMBase::writeEneFile(), and DPMBase::writeFStatFile().

◆ openWriteNoAppend()

bool File::openWriteNoAppend ( unsigned  nTimeSteps)
Parameters
[in]openMode
399 {
400  setLastSavedTimeStep(nTimeSteps);
401  return open(std::fstream::out);
402 }

References open(), and setLastSavedTimeStep().

Referenced by DPMBase::writeRestartFile().

◆ read()

void File::read ( std::istream &  is)

read function, which accepts an input stream std::istream.

Read function, which accepts an input stream object as input and assigns the member variables i.e. name_, fileType_, saveCount_, counter_ and lastSavedTimeStep_

Parameters
[in,out]is
418 {
419  std::string dummy;
420  is >> dummy;
421  if (!dummy.compare("name"))
422  is >> name_ >> dummy;
423  is >> fileType_;
424  is >> dummy >> saveCount_;
425  is >> dummy >> counter_;
426  if (counter_ != 0)
427  {
428  is >> dummy >> lastSavedTimeStep_;
429  }
430  else
431  {
433  }
434  //if (dummy != "lastSavedTimeStep") lastSavedTimeStep_=SAVE;
435 }

References counter_, fileType_, lastSavedTimeStep_, name_, NEVER, and saveCount_.

Referenced by operator>>().

◆ saveCurrentTimeStep()

bool File::saveCurrentTimeStep ( unsigned int  ntimeSteps)

determined if this time step has to be written; if so, opens the output file

Parameters
[in]ntimeSteps
Returns
True or False (a bool)
312  {
313  return getFileType() != FileType::NO_FILE && saveCurrentTimeStepNoFileTypeCheck(ntimeSteps);
314 }

References getFileType(), and saveCurrentTimeStepNoFileTypeCheck().

Referenced by CGHandler::evaluate(), and DPMBase::writeOutputFiles().

◆ saveCurrentTimeStepNoFileTypeCheck()

bool File::saveCurrentTimeStepNoFileTypeCheck ( unsigned int  ntimeSteps)
318 {
319  /* check:
320  * - if this time step should be written
321  * - if the file type is not NO_FILE
322  * - if file can be opened
323  * in that case, change lastSavedTimeStep and return true;
324  */
325  if ((lastSavedTimeStep_ == NEVER || ntimeSteps >= lastSavedTimeStep_ + saveCount_))
326  {
327  //note: do not do the following at t = 0 because this makes no sense for a logarithm
328  if (logarithmicSaveCountBase_ > 1 && ntimeSteps > 0 &&
330  {
331  /*calculate the new saveCount base on the user input logarithmicSaveCountBase,
332  *and multiply by the actual number of time steps
333  */
335  }
336  return true;
337  } else {
338  return false;
339  }
340 }

References lastSavedTimeStep_, logarithmicSaveCountBase_, NEVER, and saveCount_.

Referenced by saveCurrentTimeStep(), and DPMBase::writeOutputFiles().

◆ setCounter()

void File::setCounter ( unsigned int  counter)

Allows the user to set the file counter according to his need. Sets File::counter_.

Parameters
[in]counter
232 {
233  counter_ = counter;
234 }

References counter_.

Referenced by CGHandler::evaluateDataFiles(), main(), DPMBase::readDataFile(), DPMBase::readRestartFile(), and DPMBase::resetFileCounter().

◆ setFileType()

void File::setFileType ( FileType  fileType)

Sets the type of file needed to write into or read from. File::fileType_.

Parameters
[in]fileType
216 {
217  fileType_ = fileType;
218 }

References fileType_.

Referenced by ChuteRestartDemo::actionsOnRestart(), BaseCluster::actionsOnRestart(), AxisymmetricWallSelfTest::AxisymmetricWallSelfTest(), BoundariesSelfTest::BoundariesSelfTest(), commandLineCG(), ChuteBottom::constructor(), DPMBase::constructor(), FluxAndPeriodicBoundarySelfTest::FluxAndPeriodicBoundarySelfTest(), FluxBoundarySelfTest::FluxBoundarySelfTest(), ForceLawsMPI2Test::ForceLawsMPI2Test(), CLiveStatistics< T >::getLiveStatistics(), HorizontalMixer::HorizontalMixer(), InitialConditions< SpeciesType >::InitialConditions(), LeesEdwardsDemo::LeesEdwardsDemo(), LiquidMigrationMPI2Test::LiquidMigrationMPI2Test(), main(), ParticleParticleCollision::ParticleParticleCollision(), DPMBase::readDataFile(), DPMBase::readNextArgument(), DPMBase::readOld(), FlowRule::run(), statistics_while_running< T >::run(), AngleOfRepose::run(), DPMBase::setFileType(), ChutePeriodic::setup(), ShiftingConstantMassFlowMaserBoundarySelfTest::setupInitialConditions(), ShiftingMaserBoundarySelfTest::setupInitialConditions(), ChutePeriodic::setupInitialConditions(), Cstatic3D::setupInitialConditions(), RandomClusterInsertionBoundarySelfTest::setupInitialConditions(), MarbleRun::setupInitialConditions(), GetDistanceAndNormalForIntersectionOfWalls::setupInitialConditions(), GetDistanceAndNormalForScrew::setupInitialConditions(), GetDistanceAndNormalForTriangleWall::setupInitialConditions(), Drum::setupInitialConditions(), Penetration::setupInitialConditions(), Silo::setupInitialConditions(), CubeDeletionBoundarySelfTest::setupInitialConditions(), DeletionBoundarySelfTest::setupInitialConditions(), LeesEdwardsSelfTest::setupInitialConditions(), ContactDetectionIntersectionOfWallsTest::setupInitialConditions(), GetDistanceAndNormalForTriangleWalls::setupInitialConditions(), RollingOverTriangleWalls::setupInitialConditions(), Packing::setupInitialConditions(), HertzianSinterForceUnitTest::setupInitialConditions(), MovingWalls::setupInitialConditions(), BaseCluster::setupInitialConditions(), SilbertHstop::SilbertHstop(), SilbertPeriodic::SilbertPeriodic(), TimeDependentPeriodicBoundary3DSelfTest::TimeDependentPeriodicBoundary3DSelfTest(), TimeDependentPeriodicBoundaryTest::TimeDependentPeriodicBoundaryTest(), TriangulatedScrewSelfTest::TriangulatedScrewSelfTest(), TriangulatedStepWallSelfTest::TriangulatedStepWallSelfTest(), TriangulatedWallSelfTest::TriangulatedWallSelfTest(), Tutorial11::Tutorial11(), and TwoByTwoMPIDomainMPI4Test::TwoByTwoMPIDomainMPI4Test().

◆ setLastSavedTimeStep()

void File::setLastSavedTimeStep ( unsigned int  lastSavedTimeStep)

Sets File::nextSavedTimeStep_.

Allows one to set the time step at which the next write or read operation has to happen

Parameters
[in]lastSavedTimeStep
303 {
304  lastSavedTimeStep_ = lastSavedTimeStep;
305 }

References lastSavedTimeStep_.

Referenced by BaseCG::BaseCG(), CGHandler::evaluate(), CGHandler::finish(), openWrite(), openWriteNoAppend(), DPMBase::setLastSavedTimeStep(), and DPMBase::writeOutputFiles().

◆ setlogarithmicSaveCount()

void File::setlogarithmicSaveCount ( const Mdouble  logarithmicSaveCountBase)

the function to set the user input base of logarithmic saving count

File::setlogarithmicSaveCount assigns the base of the saveCount on a logarithmic time scale

Parameters
[in]logarithmicSaveCountBase
284 {
285  logger.assert_always(logarithmicSaveCountBase > 1, "logarithmicSaveCountBase should always be larger than 1");
286  logarithmicSaveCountBase_ = logarithmicSaveCountBase;
287 }

References logarithmicSaveCountBase_, and logger.

Referenced by DPMBase::setLogarithmicSaveCount().

◆ setName()

void File::setName ( const std::string &  name)

Sets the file name, e.g. "Name.data".

Note the file name is usually set by MD::setName(), which sets names for all file types (data, restart, fstat, stat, ene)

Parameters
[in]name(Takes in the to be name of the File)
199 {
200  logger.assert_always(!getName().empty(), "Error: Name cannot be empty");
201  this->name_ = name;
202 }

References getName(), logger, units::name, and name_.

Referenced by commandLineCG(), Indenter::Indenter(), main(), DPMBase::read(), DPMBase::readDataFile(), DPMBase::readRestartFile(), CGHandler::restart(), AngleOfRepose::set_study(), SilbertPeriodic::set_study(), setCGHandler(), FlowRule::setName(), and DPMBase::setName().

◆ setOpenMode()

void File::setOpenMode ( std::fstream::openmode  openMode)

Allows the user to Sets File::openMode_.

Parameters
[in]openmode
248 {
249  openMode_ = openMode;
250 }

References openMode_.

Referenced by open(), openWrite(), DPMBase::setOpenMode(), and DPMBase::solve().

◆ setSaveCount()

◆ write()

void File::write ( std::ostream &  os) const

print function, which accepts an std::stringstream as input.

BaseParticle print function, which accepts an output stream object as input and writes the info to the std::ostream

Parameters
[in,out]os
Todo:
TW: openMode_ is not saved, maybe it should not even be stored but set every time you open a file
443 {
444  //only write name if it differs from the default name
445  if (getFullName().compare(name_))
446  os << "name " << name_ << " ";
447  os << "fileType " << fileType_;
448  os << " saveCount " << saveCount_;
449  os << " counter " << counter_;
450  if (counter_ != 0)
451  {
452  os << " lastSavedTimeStep " << lastSavedTimeStep_;
453  }
455 }

References helpers::compare(), counter_, fileType_, getFullName(), lastSavedTimeStep_, name_, and saveCount_.

Referenced by operator<<().

◆ writeFirstAndLastTimeStep()

void File::writeFirstAndLastTimeStep ( )

Sets File::saveCount_ to the highest possible value such that only the first and last time step is written.

File::setSaveCount assigns the number of time steps to be skipped before the data is written to an existing file or a new file.

Parameters
[in]saveCount
265 {
266  saveCount_ = NEVER;
267 }

References NEVER, and saveCount_.

Referenced by ForceLawsMPI2Test::ForceLawsMPI2Test(), LiquidMigrationMPI2Test::LiquidMigrationMPI2Test(), MarbleRun::setupInitialConditions(), Drum::setupInitialConditions(), HertzSelfTest::setupInitialConditions(), MindlinSelfTest::setupInitialConditions(), Penetration::setupInitialConditions(), Silo::setupInitialConditions(), UnionOfWalls::setupInitialConditions(), and TwoByTwoMPIDomainMPI4Test::TwoByTwoMPIDomainMPI4Test().

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const File o 
)
friend

Operator overloading used to write data obtained from an object of class File into an output stream. It also returns a reference to the output stream.

Parameters
[in,out]os
[in]o
Returns
std::ostream& os
463 {
464  o.write(os);
465  return os;
466 }

◆ operator>>

std::istream& operator>> ( std::istream &  is,
File o 
)
friend

Operator overloading used to read data from the input stream into member variables of an object of class File. It also returns a reference of type std::istream&.

Parameters
[in,out]is
[in]o
Returns
std::istream&
474 {
475  o.read(is);
476  return (is);
477 }

Member Data Documentation

◆ counter_

unsigned int File::counter_
private

counts the number of already opened files, i.e. counter=1 means .0000 exists

Referenced by decreaseCounter(), File(), getCounter(), increaseCounter(), open(), read(), setCounter(), and write().

◆ fileType_

FileType File::fileType_
private

fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as described in the description of the class.

Referenced by File(), getFileType(), open(), read(), setFileType(), and write().

◆ fstream_

std::fstream File::fstream_
private

Stream object used to read/write data files.

Referenced by close(), getFstream(), and open().

◆ lastSavedTimeStep_

unsigned int File::lastSavedTimeStep_
private

the time step at which the next write or read operation has to happen.

Referenced by File(), getLastSavedTimeStep(), read(), saveCurrentTimeStepNoFileTypeCheck(), setLastSavedTimeStep(), and write().

◆ logarithmicSaveCountBase_

Mdouble File::logarithmicSaveCountBase_
private

the switch allow user to set saveCount in logarithmic timescale with equal distance , the number is the base of log scale from user input

Referenced by File(), saveCurrentTimeStepNoFileTypeCheck(), and setlogarithmicSaveCount().

◆ name_

std::string File::name_
private

name of the file.

Referenced by File(), getFullName(), getName(), read(), setName(), and write().

◆ openMode_

std::fstream::openmode File::openMode_
private

A variable to indicate how the file should be opened i.e. in, out, ... see http://en.cppreference.com (std::fstream::out by default)

Referenced by File(), getOpenMode(), open(), and setOpenMode().

◆ saveCount_

unsigned int File::saveCount_
private

Allows one to define the number of time steps to be skipped to make a snap shot. E.g. TMax = 100, saveCount_ = 10, timeStep = 1; It stores data at t={0,10,20,30,40...100}. And if TMax =101, it stores data at t={0,10,20,30,...100,101}.

Referenced by File(), getSaveCount(), read(), saveCurrentTimeStepNoFileTypeCheck(), setSaveCount(), write(), and writeFirstAndLastTimeStep().


The documentation for this class was generated from the following files:
File::getName
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:165
File::logarithmicSaveCountBase_
Mdouble logarithmicSaveCountBase_
the switch allow user to set saveCount in logarithmic timescale with equal distance ,...
Definition: File.h:282
to_string_padded
std::string to_string_padded(unsigned int value)
Pads the number This function tries to pad the number to 4 digits, which is used when you create mult...
Definition: File.cc:44
File::saveCurrentTimeStepNoFileTypeCheck
bool saveCurrentTimeStepNoFileTypeCheck(unsigned int ntimeSteps)
Definition: File.cc:317
File::saveCount_
unsigned int saveCount_
Allows one to define the number of time steps to be skipped to make a snap shot. E....
Definition: File.h:276
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
File::getCounter
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
Definition: File.cc:223
File::name_
std::string name_
name of the file.
Definition: File.h:249
FileType::NO_FILE
@ NO_FILE
file will not be created/read
File::open
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:347
File::setOpenMode
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.
Definition: File.cc:247
File::fileType_
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
Definition: File.h:260
File::fstream_
std::fstream fstream_
Stream object used to read/write data files.
Definition: File.h:254
File::setLastSavedTimeStep
void setLastSavedTimeStep(unsigned int lastSavedTimeStep)
Sets File::nextSavedTimeStep_.
Definition: File.cc:302
NEVER
const unsigned NEVER
Definition: File.h:35
File::lastSavedTimeStep_
unsigned int lastSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:287
File::write
void write(std::ostream &os) const
print function, which accepts an std::stringstream as input.
Definition: File.cc:442
File::read
void read(std::istream &is)
read function, which accepts an input stream std::istream.
Definition: File.cc:417
File::openMode_
std::fstream::openmode openMode_
A variable to indicate how the file should be opened i.e. in, out, ... see http://en....
Definition: File.h:270
helpers::compare
bool compare(std::istream &is, std::string s)
Checks if the next argument in the input stream is a certain string.
Definition: Helpers.cc:858
units::name
std::string name
Definition: MercuryProb.h:48
File::getFileType
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Definition: File.cc:207
File::getFullName
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter,...
Definition: File.cc:170
File::counter_
unsigned int counter_
counts the number of already opened files, i.e. counter=1 means .0000 exists
Definition: File.h:265