Block-Structured AMR Software Framework
amrex::NFilesIter Class Reference

This class encapsulates writing to nfiles. More...

#include <AMReX_NFiles.H>

Public Member Functions

 NFilesIter (int noutfiles, std::string fileprefix, bool groupsets, bool setBuf)
 the nfiles will be named "filePrefix" + "00000" through "filePrefix" + "noutfiles-1" the range [1, nProcs] for noutfiles is enforced More...
 
void SetDynamic (int deciderproc=-1)
 call this to use dynamic set selection deciderproc defaults to nprocs - 1 if < 0 More...
 
bool GetDynamic () const
 
void SetSparseFPP (const Vector< int > &ranksToWrite)
 call this to use a file per process for a sparse set of writers. ranksToWrite.size() will set noutfiles rank ranksToWrite[n] will write to file_rank More...
 
bool GetSparseFPP () const
 
 NFilesIter (std::string fileName, Vector< int > readRanks, bool setBuf=false)
 constructor for reading More...
 
 ~NFilesIter ()
 
 NFilesIter (NFilesIter const &)=delete
 
 NFilesIter (NFilesIter &&)=delete
 
NFilesIteroperator= (NFilesIter const &)=delete
 
NFilesIteroperator= (NFilesIter &&)=delete
 
bool ReadyToWrite (bool appendFirst=false)
 if appendFirst is true, the first set for this iterator will open the files in append mode More...
 
bool ReadyToRead ()
 
NFilesIteroperator++ ()
 
std::fstream & Stream ()
 
std::streampos SeekPos ()
 get the current Stream()'s seek position More...
 
const std::string & FileName () const
 
int FileNumber () const
 
int CoordinatorProc () const
 this is the processor coordinating dynamic set selection More...
 
Vector< intFileNumbersWritten ()
 these are the file numbers to which each rank wrote [rank] a rank only writes to one file More...
 
const Vector< Vector< int > > & FileNumbersWriteOrder () const
 these are the order of ranks which wrote to each file [filenumber][ranks in order they wrote to filenumber] More...
 
void CleanUpMessages ()
 

Static Public Member Functions

static int LengthOfSet (int nProcs, int nOutFiles)
 
static int WhichSetPosition (int whichproc, int nprocs, int noutfiles, bool groupsets)
 
static int ActualNFiles (int nOutFiles)
 this returns the actual number of files used the range [1, nProcs] is enforced More...
 
static bool CheckNFiles (int nProcs, int nOutFiles, bool groupSets)
 this checks if nOutFiles equals the calculated number of files returns false if they do not match More...
 
static int FileNumber (int nOutFiles, int whichProc, bool groupSets)
 
static std::string FileName (int nOutFiles, const std::string &filePrefix, int whichProc, bool groupSets)
 
static std::string FileName (int fileNumber, const std::string &filePrefix)
 
static int GetMinDigits ()
 
static void SetMinDigits (int md)
 

Private Attributes

int myProc = -1
 
int nProcs = -1
 
int nOutFiles = -1
 
int nSets = -1
 
bool groupSets = false
 
int mySetPosition = -1
 
int fileNumber = -1
 
std::string filePrefix
 
std::string fullFileName
 
VisMFBuffer::IO_Buffer io_buffer
 
std::fstream fileStream
 
bool finishedWriting = false
 
bool isReading = false
 
bool finishedReading = false
 
Vector< intreadRanks
 
Vector< Vector< int > > fileNumbersWriteOrder
 [filenumber][ranks in order they wrote to filenumber] More...
 
int myReadIndex = -1
 
bool useStaticSetSelection = true
 
int remainingWriters = -1
 
int deciderProc =-1
 
int coordinatorProc = -1
 
int deciderTag = -1
 
int coordinatorTag = -1
 
int doneTag = -1
 
int writeTag =-1
 
int stWriteTag = -1
 
int stReadTag = -1
 
Vector< intavailableDeciders
 
Vector< intsetZeroProcs
 
bool useSparseFPP = false
 
Vector< intsparseWritingRanks
 
int mySparseFileNumber = -1
 
Vector< std::pair< int, int > > unreadMessages
 these were ignored by the decider procs and need to be cleaned up More...
 

Static Private Attributes

static int currentDeciderIndex
 
static const int indexUndefined = -1
 
static AMREX_EXPORT int minDigits
 for Concatenate More...
 

Detailed Description

This class encapsulates writing to nfiles.

an example:

for(NFilesIter nfi(nOutFiles, filePrefix); nfi.ReadyToWrite(); ++nfi) { // do your writing here nfi.Stream().write((const char *) data.dataPtr(), nChars); }

Constructor & Destructor Documentation

◆ NFilesIter() [1/4]

amrex::NFilesIter::NFilesIter ( int  noutfiles,
std::string  fileprefix,
bool  groupsets,
bool  setBuf 
)

the nfiles will be named "filePrefix" + "00000" through "filePrefix" + "noutfiles-1" the range [1, nProcs] for noutfiles is enforced

constructor for writing with static set selection

Parameters
noutfiles
&fileprefix
groupsets
setBuf

◆ NFilesIter() [2/4]

amrex::NFilesIter::NFilesIter ( std::string  fileName,
Vector< int readRanks,
bool  setBuf = false 
)

constructor for reading

Parameters
&fileName
&readRanks
setBuf

◆ ~NFilesIter()

amrex::NFilesIter::~NFilesIter ( )

◆ NFilesIter() [3/4]

amrex::NFilesIter::NFilesIter ( NFilesIter const &  )
delete

◆ NFilesIter() [4/4]

amrex::NFilesIter::NFilesIter ( NFilesIter &&  )
delete

Member Function Documentation

◆ ActualNFiles()

static int amrex::NFilesIter::ActualNFiles ( int  nOutFiles)
inlinestatic

this returns the actual number of files used the range [1, nProcs] is enforced

Parameters
nOutFiles

◆ CheckNFiles()

bool amrex::NFilesIter::CheckNFiles ( int  nProcs,
int  nOutFiles,
bool  groupSets 
)
static

this checks if nOutFiles equals the calculated number of files returns false if they do not match

Parameters
nProcs
nOutFiles
groupSets

◆ CleanUpMessages()

void amrex::NFilesIter::CleanUpMessages ( )

◆ CoordinatorProc()

int amrex::NFilesIter::CoordinatorProc ( ) const
inline

this is the processor coordinating dynamic set selection

◆ FileName() [1/3]

const std::string& amrex::NFilesIter::FileName ( ) const
inline

◆ FileName() [2/3]

static std::string amrex::NFilesIter::FileName ( int  fileNumber,
const std::string &  filePrefix 
)
inlinestatic

◆ FileName() [3/3]

static std::string amrex::NFilesIter::FileName ( int  nOutFiles,
const std::string &  filePrefix,
int  whichProc,
bool  groupSets 
)
inlinestatic

◆ FileNumber() [1/2]

int amrex::NFilesIter::FileNumber ( ) const
inline

◆ FileNumber() [2/2]

static int amrex::NFilesIter::FileNumber ( int  nOutFiles,
int  whichProc,
bool  groupSets 
)
inlinestatic

◆ FileNumbersWriteOrder()

const Vector< Vector<int> >& amrex::NFilesIter::FileNumbersWriteOrder ( ) const
inline

these are the order of ranks which wrote to each file [filenumber][ranks in order they wrote to filenumber]

◆ FileNumbersWritten()

Vector< int > amrex::NFilesIter::FileNumbersWritten ( )

these are the file numbers to which each rank wrote [rank] a rank only writes to one file

◆ GetDynamic()

bool amrex::NFilesIter::GetDynamic ( ) const
inline

◆ GetMinDigits()

static int amrex::NFilesIter::GetMinDigits ( )
inlinestatic

◆ GetSparseFPP()

bool amrex::NFilesIter::GetSparseFPP ( ) const
inline

◆ LengthOfSet()

static int amrex::NFilesIter::LengthOfSet ( int  nProcs,
int  nOutFiles 
)
inlinestatic

◆ operator++()

NFilesIter & amrex::NFilesIter::operator++ ( )

◆ operator=() [1/2]

NFilesIter& amrex::NFilesIter::operator= ( NFilesIter &&  )
delete

◆ operator=() [2/2]

NFilesIter& amrex::NFilesIter::operator= ( NFilesIter const &  )
delete

◆ ReadyToRead()

bool amrex::NFilesIter::ReadyToRead ( )

◆ ReadyToWrite()

bool amrex::NFilesIter::ReadyToWrite ( bool  appendFirst = false)

if appendFirst is true, the first set for this iterator will open the files in append mode

Parameters
appendFirst

◆ SeekPos()

std::streampos amrex::NFilesIter::SeekPos ( )

get the current Stream()'s seek position

◆ SetDynamic()

void amrex::NFilesIter::SetDynamic ( int  deciderproc = -1)

call this to use dynamic set selection deciderproc defaults to nprocs - 1 if < 0

Parameters
deciderproc

◆ SetMinDigits()

static void amrex::NFilesIter::SetMinDigits ( int  md)
inlinestatic

◆ SetSparseFPP()

void amrex::NFilesIter::SetSparseFPP ( const Vector< int > &  ranksToWrite)

call this to use a file per process for a sparse set of writers. ranksToWrite.size() will set noutfiles rank ranksToWrite[n] will write to file_rank

Parameters
&ranksToWrite

◆ Stream()

std::fstream& amrex::NFilesIter::Stream ( )
inline

◆ WhichSetPosition()

static int amrex::NFilesIter::WhichSetPosition ( int  whichproc,
int  nprocs,
int  noutfiles,
bool  groupsets 
)
inlinestatic

Member Data Documentation

◆ availableDeciders

Vector<int> amrex::NFilesIter::availableDeciders
private

◆ coordinatorProc

int amrex::NFilesIter::coordinatorProc = -1
private

◆ coordinatorTag

int amrex::NFilesIter::coordinatorTag = -1
private

◆ currentDeciderIndex

int amrex::NFilesIter::currentDeciderIndex
staticprivate

◆ deciderProc

int amrex::NFilesIter::deciderProc =-1
private

◆ deciderTag

int amrex::NFilesIter::deciderTag = -1
private

◆ doneTag

int amrex::NFilesIter::doneTag = -1
private

◆ fileNumber

int amrex::NFilesIter::fileNumber = -1
private

◆ fileNumbersWriteOrder

Vector< Vector<int> > amrex::NFilesIter::fileNumbersWriteOrder
private

[filenumber][ranks in order they wrote to filenumber]

◆ filePrefix

std::string amrex::NFilesIter::filePrefix
private

◆ fileStream

std::fstream amrex::NFilesIter::fileStream
private

◆ finishedReading

bool amrex::NFilesIter::finishedReading = false
private

◆ finishedWriting

bool amrex::NFilesIter::finishedWriting = false
private

◆ fullFileName

std::string amrex::NFilesIter::fullFileName
private

◆ groupSets

bool amrex::NFilesIter::groupSets = false
private

◆ indexUndefined

const int amrex::NFilesIter::indexUndefined = -1
staticprivate

◆ io_buffer

VisMFBuffer::IO_Buffer amrex::NFilesIter::io_buffer
private

◆ isReading

bool amrex::NFilesIter::isReading = false
private

◆ minDigits

int amrex::NFilesIter::minDigits
staticprivate

for Concatenate

◆ myProc

int amrex::NFilesIter::myProc = -1
private

◆ myReadIndex

int amrex::NFilesIter::myReadIndex = -1
private

◆ mySetPosition

int amrex::NFilesIter::mySetPosition = -1
private

◆ mySparseFileNumber

int amrex::NFilesIter::mySparseFileNumber = -1
private

◆ nOutFiles

int amrex::NFilesIter::nOutFiles = -1
private

◆ nProcs

int amrex::NFilesIter::nProcs = -1
private

◆ nSets

int amrex::NFilesIter::nSets = -1
private

◆ readRanks

Vector<int> amrex::NFilesIter::readRanks
private

◆ remainingWriters

int amrex::NFilesIter::remainingWriters = -1
private

◆ setZeroProcs

Vector<int> amrex::NFilesIter::setZeroProcs
private

◆ sparseWritingRanks

Vector<int> amrex::NFilesIter::sparseWritingRanks
private

◆ stReadTag

int amrex::NFilesIter::stReadTag = -1
private

◆ stWriteTag

int amrex::NFilesIter::stWriteTag = -1
private

◆ unreadMessages

Vector<std::pair<int, int> > amrex::NFilesIter::unreadMessages
private

these were ignored by the decider procs and need to be cleaned up

[](tag, nmessages)

◆ useSparseFPP

bool amrex::NFilesIter::useSparseFPP = false
private

◆ useStaticSetSelection

bool amrex::NFilesIter::useStaticSetSelection = true
private

◆ writeTag

int amrex::NFilesIter::writeTag =-1
private

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