Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
ParallelColumnDataWriter Class Reference

#include <ParallelColumnDataWriter.hpp>

+ Inheritance diagram for ParallelColumnDataWriter:
+ Collaboration diagram for ParallelColumnDataWriter:

Public Member Functions

 ParallelColumnDataWriter (const std::string &rDirectory, const std::string &rBaseName, bool cleanDirectory=true)
 
virtual ~ParallelColumnDataWriter ()
 
void PutVector (int variableID, Vec petscVector)
 
void PutVectorStripe (int variableId, DistributedVector::Stripe &rStripe)
 
void PutVariable (int variableID, double variableValue, long dimensionPosition=-1)
 
void EndDefineMode ()
 
void AdvanceAlongUnlimitedDimension ()
 
void Close ()
 
- Public Member Functions inherited from ColumnDataWriter
 ColumnDataWriter (const std::string &rDirectory, const std::string &rBaseName, bool cleanDirectory=true, unsigned precision=8)
 
virtual ~ColumnDataWriter ()
 
int DefineUnlimitedDimension (const std::string &rDimensionName, const std::string &rDimensionUnits)
 
int DefineFixedDimension (const std::string &rDimensionName, const std::string &rDimensionUnits, long dimensionSize)
 
int DefineVariable (const std::string &rVariableName, const std::string &rVariableUnits)
 
void SetCommentForInfoFile (std::string comment)
 
std::string GetOutputDirectory ()
 
- Public Member Functions inherited from AbstractDataWriter
virtual ~AbstractDataWriter ()
 

Private Attributes

bool mIsParallel
 
Vec mConcentrated
 
VecScatter mToMaster
 

Additional Inherited Members

- Protected Member Functions inherited from ColumnDataWriter
void CreateFixedDimensionFile (const std::string &rFileName)
 
void CreateInfoFile (const std::string &rFileName)
 
void CheckVariableName (const std::string &rName)
 
void CheckUnitsName (const std::string &rName)
 
void DoAdvanceAlongUnlimitedDimension ()
 
- Protected Attributes inherited from ColumnDataWriter
OutputFileHandler mOutputFileHandler
 
std::string mDirectory
 
std::string mBaseName
 
bool mIsInDefineMode
 
bool mIsFixedDimensionSet
 
bool mIsUnlimitedDimensionSet
 
long mUnlimitedDimensionPosition
 
long mFixedDimensionSize
 
out_stream mpCurrentOutputFile
 
out_stream mpCurrentAncillaryFile
 
DataWriterVariablempUnlimitedDimensionVariable
 
DataWriterVariablempFixedDimensionVariable
 
std::string mUnlimitedDimensionName
 
std::string mUnlimitedDimensionUnits
 
std::string mFixedDimensionName
 
std::string mFixedDimensionUnits
 
std::vector< DataWriterVariablemVariables
 
const unsigned mFieldWidth
 
const unsigned mPrecision
 
std::string mFileExtension
 
int mRowStartPosition
 
int mRowWidth
 
int mAncillaryRowStartPosition
 
int mAncillaryRowWidth
 
bool mHasPutVariable
 
bool mNeedAdvanceAlongUnlimitedDimension
 
std::string mCommentForInfoFile
 
- Static Protected Attributes inherited from ColumnDataWriter
static const int SPACING = 1
 
static const int FIXED_DIMENSION_VAR_ID = -1
 
static const int UNLIMITED_DIMENSION_VAR_ID = -2
 

Detailed Description

A parallelised column data writer class.

Definition at line 49 of file ParallelColumnDataWriter.hpp.

Constructor & Destructor Documentation

◆ ParallelColumnDataWriter()

ParallelColumnDataWriter::ParallelColumnDataWriter ( const std::string &  rDirectory,
const std::string &  rBaseName,
bool  cleanDirectory = true 
)

Constructor.

Parameters
rDirectorythe directory in which to write the data to file
rBaseNamethe name of the file in which to write the data
cleanDirectorywhether to clean the directory (defaults to true)

Definition at line 40 of file ParallelColumnDataWriter.cpp.

References mIsParallel.

◆ ~ParallelColumnDataWriter()

ParallelColumnDataWriter::~ParallelColumnDataWriter ( )
virtual

Destructor.

Definition at line 148 of file ParallelColumnDataWriter.cpp.

References Close(), PetscTools::Destroy(), mConcentrated, mToMaster, and PETSC_DESTROY_PARAM.

Member Function Documentation

◆ AdvanceAlongUnlimitedDimension()

void ParallelColumnDataWriter::AdvanceAlongUnlimitedDimension ( )
virtual

Advance along the unlimited dimension. Normally this will be called when all variables in a row have been input.

Reimplemented from ColumnDataWriter.

Definition at line 158 of file ParallelColumnDataWriter.cpp.

References PetscTools::AmMaster(), PetscTools::Barrier(), and ColumnDataWriter::DoAdvanceAlongUnlimitedDimension().

◆ Close()

void ParallelColumnDataWriter::Close ( )
virtual

Close any open files.

Reimplemented from ColumnDataWriter.

Definition at line 169 of file ParallelColumnDataWriter.cpp.

References PetscTools::AmMaster(), PetscTools::Barrier(), and ColumnDataWriter::Close().

Referenced by ~ParallelColumnDataWriter().

◆ EndDefineMode()

void ParallelColumnDataWriter::EndDefineMode ( )
virtual

End the define mode of the DataWriter.

Reimplemented from ColumnDataWriter.

Definition at line 119 of file ParallelColumnDataWriter.cpp.

References PetscTools::AmMaster(), ColumnDataWriter::EndDefineMode(), and ColumnDataWriter::mIsInDefineMode.

◆ PutVariable()

void ParallelColumnDataWriter::PutVariable ( int  variableID,
double  variableValue,
long  dimensionPosition = -1 
)
virtual

Input the variable value to the output file or ancillary file

Parameters
variableID
variableValue
dimensionPositionThe position in column (defaults to -1). This is required if there is a fixed dimension, and will be the position along that dimension

There are two ways of calling PutVariable: 1) All processes call it as a collective operation from the user's code. This only makes sense if they are writing the unlimited dimension (time) variable. It is actually a no-op if any non-master process attempts to write anything at all. 2) The master calls the equivalent method in the parent class after concentrating the data into a single Vec (ie. from the method PutVector() above).

Reimplemented from ColumnDataWriter.

Definition at line 139 of file ParallelColumnDataWriter.cpp.

References PetscTools::AmMaster(), and ColumnDataWriter::PutVariable().

◆ PutVector()

void ParallelColumnDataWriter::PutVector ( int  variableID,
Vec  petscVector 
)

Write data for a given variable from a PETSc vector to the dataset.

Parameters
variableIDthe variable
petscVectorthe data

Definition at line 58 of file ParallelColumnDataWriter.cpp.

References PetscTools::AmMaster(), EXCEPTION, mConcentrated, ColumnDataWriter::mFixedDimensionSize, mToMaster, and ColumnDataWriter::PutVariable().

Referenced by PutVectorStripe().

◆ PutVectorStripe()

void ParallelColumnDataWriter::PutVectorStripe ( int  variableId,
DistributedVector::Stripe rStripe 
)

Write data for a given variable from a stripe to the dataset.

Parameters
variableIdthe variable
rStripethe data
Todo:
allow this to be a const-reference

Definition at line 101 of file ParallelColumnDataWriter.cpp.

References DistributedVector::Begin(), DistributedVectorFactory::CreateDistributedVector(), DistributedVectorFactory::CreateVec(), PetscTools::Destroy(), DistributedVector::End(), DistributedVector::Stripe::GetFactory(), and PutVector().

Member Data Documentation

◆ mConcentrated

Vec ParallelColumnDataWriter::mConcentrated
private

Vector to hold concentrated copy of distributed vector on the master process

Definition at line 54 of file ParallelColumnDataWriter.hpp.

Referenced by ~ParallelColumnDataWriter(), and PutVector().

◆ mIsParallel

bool ParallelColumnDataWriter::mIsParallel
private

Set to true in constructor if running in parallel

Definition at line 53 of file ParallelColumnDataWriter.hpp.

Referenced by ParallelColumnDataWriter().

◆ mToMaster

VecScatter ParallelColumnDataWriter::mToMaster
private

variable holding information for concentrating a vector

Definition at line 55 of file ParallelColumnDataWriter.hpp.

Referenced by ~ParallelColumnDataWriter(), and PutVector().


The documentation for this class was generated from the following files: