Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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
 
void SetDynamic (int deciderproc=-1)
 call this to use dynamic set selection deciderproc defaults to nprocs - 1 if < 0
 
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
 
bool GetSparseFPP () const
 
 NFilesIter (std::string fileName, Vector< int > readRanks, bool setBuf=false)
 constructor for reading
 
 ~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
 
bool ReadyToRead ()
 
NFilesIteroperator++ ()
 
std::fstream & Stream ()
 
std::streampos SeekPos ()
 get the current Stream()'s seek position
 
const std::string & FileName () const
 
int FileNumber () const
 
int CoordinatorProc () const
 this is the processor coordinating dynamic set selection
 
Vector< intFileNumbersWritten ()
 these are the file numbers to which each rank wrote [rank] a rank only writes to one file
 
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]
 
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
 
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
 
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)
 

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

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