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.

80 {
81  //sets the default for the number of time steps to be skipped
82  //in between each saved "snapshot" of the system to zero
83  //(i.e. records every time step by default)
84  saveCount_ = 0;
85 
86  // file name has to be set by the user
87  name_ = "out";
88 
89  // output into a single file by default
91 
92  // counter of currently open file set to 0 by default
93  counter_ = 0;
94 
95  //stores the time step of the last write/read operation; NEVER by default
97 
98  //sets the default openMode to "out"
99  //i.e. files will by default be written to, not read from.
101 
102  //sets the default logarithmicSaveCount to zero
104 }
const unsigned NEVER
Definition: File.h:13
@ ONE_FILE
all data will be written into/ read from a single file called name_
unsigned int saveCount_
Allows one to define the number of time steps to be skipped to make a snap shot. E....
Definition: File.h:254
FileType fileType_
fileType_ indicates the type of the files. Whether it is No file, one file or multiple file as descri...
Definition: File.h:238
unsigned int counter_
counts the number of already opened files, i.e. counter=1 means .0000 exists
Definition: File.h:243
unsigned int lastSavedTimeStep_
the time step at which the next write or read operation has to happen.
Definition: File.h:265
std::fstream::openmode openMode_
A variable to indicate how the file should be opened i.e. in, out, ... see http://en....
Definition: File.h:248
Mdouble logarithmicSaveCountBase_
the switch allow user to set saveCount in logarithmic timescale with equal distance ,...
Definition: File.h:260
std::string name_
name of the file.
Definition: File.h:227
std::ofstream out("Result.txt")

References counter_, fileType_, lastSavedTimeStep_, logarithmicSaveCountBase_, name_, NEVER, ONE_FILE, openMode_, out(), 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.
111 {
112  saveCount_ = f.saveCount_;
113  name_ = f.name_;
114  fileType_ = f.fileType_;
115  counter_ = f.counter_;
116  lastSavedTimeStep_ = f.lastSavedTimeStep_;
117  openMode_ = f.openMode_;
118  logarithmicSaveCountBase_ = f.logarithmicSaveCountBase_;
119 }
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237

References counter_, f(), fileType_, lastSavedTimeStep_, logarithmicSaveCountBase_, name_, openMode_, and saveCount_.

◆ ~File()

File::~File ( )
virtualdefault

destructor

Destructor

Member Function Documentation

◆ close()

◆ decreaseCounter()

void File::decreaseCounter ( )
inline
128 {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_
202 {
203  return counter_;
204 }

References counter_.

Referenced by DPMBase::findNextExistingDataFile(), getFullName(), 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_)
186 {
187  return fileType_;
188 }

References fileType_.

Referenced by commandLineCG(), CGHandler::evaluateRestartFiles(), 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".

149 {
150  return getFullName(getCounter() - 1);
151 }
const std::string getFullName() const
Also allows to access the file name, however with additional information which is the file counter,...
Definition: File.cc:148
unsigned int getCounter() const
In case of multiple files, File::getCounter() returns the the number (FILE::Counter_) of the next fil...
Definition: File.cc:201

References getCounter().

Referenced by ClosedCSCStats::ClosedCSCStats(), CSCStats::CSCStats(), CGHandler::evaluateDataFiles(), CGHandler::evaluateRestartFiles(), open(), DPMBase::readDataFile(), DPMBase::readNextDataFile(), DPMBase::readNextFStatFile(), 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
158 {
159  //get the full file name
160  std::stringstream lastName("");
161  lastName << name_;
163  {
164  lastName << "." << counter;
165  }
167  {
168  lastName << "." << to_string_padded(counter);
169  }
170  return lastName.str();
171 }
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:22
@ MULTIPLE_FILES
each time-step will be written into/read from separate files numbered consecutively: name_....
@ MULTIPLE_FILES_PADDED
each time-step will be written into/read from separate files numbered consecutively,...
FileType getFileType() const
Gets the file type e.g. NOFILE, ONEFILE and MULTIPLE FILES. File::fileType_.
Definition: File.cc:185

References getFileType(), MULTIPLE_FILES, MULTIPLE_FILES_PADDED, name_, 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_
272 {
273  return lastSavedTimeStep_;
274 }

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
218 {
219  return openMode_;
220 }

References openMode_.

◆ getSaveCount()

◆ increaseCounter()

void File::increaseCounter ( )
inline
126 {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
326 {
327  //close old file if multi-file output
329  {
330  fstream_.close();
331  }
332 
333  counter_++;
334 
335  if (!fstream_.is_open())
336  {
337  fstream_.open(getFullName().c_str(), openMode_);
338  if (!fstream_.is_open())
339  {
340  return false;
341  }
342  }
343 
344  return true;
345 }

References counter_, fileType_, fstream_, getFullName(), MULTIPLE_FILES, MULTIPLE_FILES_PADDED, and openMode_.

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

◆ open() [2/2]

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

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

Parameters
[in]openMode
351 {
352  setOpenMode(openMode);
353  return open();
354 }
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.
Definition: File.cc:225
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:325

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
360 {
361  setLastSavedTimeStep(nTimeSteps);
362  if (getFileType() == FileType::ONE_FILE && getCounter() != 0)
363  {
364  setOpenMode(std::fstream::out | std::fstream::app);
365  }
366  else
367  {
369  }
370  return open();
371 }
void setLastSavedTimeStep(unsigned int lastSavedTimeStep)
Sets File::nextSavedTimeStep_.
Definition: File.cc:280

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

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

◆ openWriteNoAppend()

bool File::openWriteNoAppend ( unsigned  nTimeSteps)
Parameters
[in]openMode
377 {
378  setLastSavedTimeStep(nTimeSteps);
379  return open(std::fstream::out);
380 }

References open(), out(), 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
396 {
397  std::string dummy;
398  is >> dummy;
399  if (!dummy.compare("name"))
400  is >> name_ >> dummy;
401  is >> fileType_;
402  is >> dummy >> saveCount_;
403  is >> dummy >> counter_;
404  if (counter_ != 0)
405  {
406  is >> dummy >> lastSavedTimeStep_;
407  }
408  else
409  {
411  }
412  //if (dummy != "lastSavedTimeStep") lastSavedTimeStep_=SAVE;
413 }
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References counter_, fileType_, lastSavedTimeStep_, name_, NEVER, saveCount_, and oomph::Global_string_for_annotation::string().

◆ 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)
290  {
292 }
@ NO_FILE
file will not be created/read
bool saveCurrentTimeStepNoFileTypeCheck(unsigned int ntimeSteps)
Definition: File.cc:295

References getFileType(), NO_FILE, and saveCurrentTimeStepNoFileTypeCheck().

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

◆ saveCurrentTimeStepNoFileTypeCheck()

bool File::saveCurrentTimeStepNoFileTypeCheck ( unsigned int  ntimeSteps)
296 {
297  /* check:
298  * - if this time step should be written
299  * - if the file type is not NO_FILE
300  * - if file can be opened
301  * in that case, change lastSavedTimeStep and return true;
302  */
303  if ((lastSavedTimeStep_ == NEVER || ntimeSteps >= lastSavedTimeStep_ + saveCount_))
304  {
305  //note: do not do the following at t = 0 because this makes no sense for a logarithm
306  if (logarithmicSaveCountBase_ > 1 && ntimeSteps > 0 &&
308  {
309  /*calculate the new saveCount base on the user input logarithmicSaveCountBase,
310  *and multiply by the actual number of time steps
311  */
313  }
314  return true;
315  } else {
316  return false;
317  }
318 }
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 ceil(const bfloat16 &a)
Definition: BFloat16.h:644

References Eigen::bfloat16_impl::ceil(), 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
210 {
211  counter_ = counter;
212 }

References counter_.

Referenced by CGHandler::evaluateDataFiles(), 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
194 {
195  fileType_ = fileType;
196 }

References fileType_.

Referenced by ChuteRestartDemo::actionsOnRestart(), BaseCluster::actionsOnRestart(), AxisymmetricWallSelfTest::AxisymmetricWallSelfTest(), BoundariesSelfTest::BoundariesSelfTest(), ClosedCSCStats::ClosedCSCStats(), commandLineCG(), ChuteBottom::constructor(), DPMBase::constructor(), CSCStats::CSCStats(), FluxAndPeriodicBoundarySelfTest::FluxAndPeriodicBoundarySelfTest(), FluxBoundarySelfTest::FluxBoundarySelfTest(), ForceLawsMPI2Test::ForceLawsMPI2Test(), CLiveStatistics< T >::getLiveStatistics(), HorizontalMixer::HorizontalMixer(), InitialConditions< SpeciesType >::InitialConditions(), LeesEdwardsDemo::LeesEdwardsDemo(), LeesEdwardsSelfTest::LeesEdwardsSelfTest(), LiquidMigrationMPI2Test::LiquidMigrationMPI2Test(), main(), ParticleParticleCollision::ParticleParticleCollision(), DPMBase::readDataFile(), DPMBase::readNextArgument(), DPMBase::readOld(), FlowRule::run(), statistics_while_running< T >::run(), AngleOfRepose::run(), DPMBase::setFileType(), Calibration::setOutput(), ChutePeriodic::setup(), RandomClusterInsertionBoundarySelfTest::setupInitialConditions(), MarbleRun::setupInitialConditions(), ShiftingConstantMassFlowMaserBoundarySelfTest::setupInitialConditions(), ShiftingMaserBoundarySelfTest::setupInitialConditions(), ChutePeriodic::setupInitialConditions(), Cstatic3D::setupInitialConditions(), GetDistanceAndNormalForIntersectionOfWalls::setupInitialConditions(), GetDistanceAndNormalForScrew::setupInitialConditions(), GetDistanceAndNormalForTriangleWall::setupInitialConditions(), Drum::setupInitialConditions(), Penetration::setupInitialConditions(), Silo::setupInitialConditions(), CubeDeletionBoundarySelfTest::setupInitialConditions(), DeletionBoundarySelfTest::setupInitialConditions(), ContactDetectionIntersectionOfWallsTest::setupInitialConditions(), GetDistanceAndNormalForTriangleWalls::setupInitialConditions(), RollingOverTriangleWalls::setupInitialConditions(), Packing::setupInitialConditions(), HertzianSinterForceUnitTest::setupInitialConditions(), MovingWalls::setupInitialConditions(), BaseCluster::setupInitialConditions(), SilbertHstop::SilbertHstop(), SilbertPeriodic::SilbertPeriodic(), statistics_while_running< T >::statistics_while_running(), 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
281 {
282  lastSavedTimeStep_ = lastSavedTimeStep;
283 }

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
262 {
263  logger.assert_always(logarithmicSaveCountBase > 1, "logarithmicSaveCountBase should always be larger than 1");
264  logarithmicSaveCountBase_ = logarithmicSaveCountBase;
265 }
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.

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)
177 {
178  logger.assert_always(!getName().empty(), "Error: Name cannot be empty");
179  this->name_ = name;
180 }
const std::string & getName() const
Allows to access the file name, e.g., "problem.data".
Definition: File.cc:143
string name
Definition: plotDoE.py:33

References getName(), logger, plotDoE::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
226 {
227  openMode_ = openMode;
228 }

References openMode_.

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

◆ 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
421 {
422  //only write name if it differs from the default name
423  if (getFullName().compare(name_))
424  os << "name " << name_ << " ";
425  os << "fileType " << fileType_;
426  os << " saveCount " << saveCount_;
427  os << " counter " << counter_;
428  if (counter_ != 0)
429  {
430  os << " lastSavedTimeStep " << lastSavedTimeStep_;
431  }
433 }
void compare(const Packet &a, const Packet &b)
Definition: blasutil.cpp:24

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

◆ 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
243 {
244  saveCount_ = NEVER;
245 }

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
441 {
442  o.write(os);
443  return os;
444 }
void write(std::ostream &os) const
print function, which accepts an std::stringstream as input.
Definition: File.cc:420

◆ 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&
452 {
453  o.read(is);
454  return (is);
455 }
void read(std::istream &is)
read function, which accepts an input stream std::istream.
Definition: File.cc:395

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: