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, int mpi_tag=-1)
 constructor for reading
 ~NFilesIter ()
 NFilesIter (NFilesIter const &)=delete
 NFilesIter (NFilesIter &&)=delete
NFilesIter & operator= (NFilesIter const &)=delete
NFilesIter & operator= (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 ()
NFilesIter & operator++ ()
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< int > FileNumbersWritten ()
 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,
int mpi_tag = -1 )

constructor for reading

The ranks in readRanks take turns reading the file and hand off with point-to-point messages. If there is more than one reader, mpi_tag must be a valid tag that is the same on every rank in readRanks. Obtain it from ParallelDescriptor::SeqNum() called by all ranks, not only readers.

Parameters
&fileName
&readRanks
setBuf
mpi_tag

◆ ~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()

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
inlinenodiscard

this is the processor coordinating dynamic set selection

◆ FileName() [1/3]

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

◆ FileName() [2/3]

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

◆ FileName() [3/3]

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

◆ FileNumber() [1/2]

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

◆ FileNumber() [2/2]

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

◆ FileNumbersWriteOrder()

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

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
inlinenodiscard

◆ GetMinDigits()

int amrex::NFilesIter::GetMinDigits ( )
inlinestatic

◆ GetSparseFPP()

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

◆ LengthOfSet()

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()

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()

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

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