File I/O for FabArray<FArrayBox>. Wrapper class for reading/writing FabArray<FArrayBox> objects to disk in various "smart" ways. More...
#include <AMReX_VisMF.H>
Classes | |
struct | FabOnDisk |
A structure containing info regarding an on-disk FAB. More... | |
struct | FabReadLink |
This structure is used to store the read order for each FabArray file. More... | |
struct | Header |
An on-disk FabArray<FArrayBox> contains this info in a header file. More... | |
struct | PersistentIFStream |
This structure is used to store file ifstreams that remain open. More... | |
Public Types | |
enum | How { OneFilePerCPU , NFiles } |
How we write out FabArray<FArrayBox>s. These are deprecated, we always use NFiles. For OneFilePerCPU, set NFiles to NProcs. More... | |
Public Types inherited from amrex::VisMFBuffer | |
enum | { IO_Buffer_Size = 262144 * 8 } |
We try to do I/O with buffers of this size. More... | |
using | Setbuf_Char_Type = char |
The type of a char buffer required by [p]setbuf(). More... | |
using | IO_Buffer = Vector< Setbuf_Char_Type > |
A simple character buffer for setbuf() usage. More... | |
Public Member Functions | |
VisMF (std::string fafab_name) | |
Construct by reading in the on-disk VisMF of the specified name. The FABs in the on-disk FabArray are read on demand unless the entire FabArray is requested. The name here is the name of the FabArray not the name of the on-disk files. More... | |
~VisMF ()=default | |
VisMF (const VisMF &)=delete | |
VisMF (VisMF &&)=delete | |
VisMF & | operator= (const VisMF &)=delete |
VisMF & | operator= (VisMF &&)=delete |
int | nComp () const |
The number of components in the on-disk FabArray<FArrayBox>. More... | |
int | nGrow () const |
The grow factor of the on-disk FabArray<FArrayBox>. More... | |
IntVect | nGrowVect () const |
int | size () const |
const BoxArray & | boxArray () const |
The BoxArray of the on-disk FabArray<FArrayBox>. More... | |
Real | min (int fabIndex, int nComp) const |
The min of the FAB (in valid region) at specified index and component. More... | |
Real | min (int nComp) const |
The min of the FabArray (in valid region) at specified component. More... | |
Real | max (int fabIndex, int nComp) const |
The max of the FAB (in valid region) at specified index and component. More... | |
Real | max (int nComp) const |
The max of the FabArray (in valid region) at specified component. More... | |
const FArrayBox & | GetFab (int fabIndex, int compIndex) const |
The FAB at the specified index and component. Reads it from disk if necessary. This reads only the specified component. More... | |
void | clear (int fabIndex, int compIndex) |
Delete()s the FAB at the specified index and component. More... | |
void | clear (int fabIndex) |
Delete()s the FAB at the specified index (all components). More... | |
void | clear () |
Delete()s all the FABs. More... | |
FArrayBox * | readFAB (int idx, const std::string &mf_name) |
Read the entire fab (all components). More... | |
FArrayBox * | readFAB (int idx, int icomp) |
Read the specified fab component. More... | |
Static Public Member Functions | |
static std::ifstream * | OpenStream (const std::string &fileName) |
Open the stream if it is not already open Close the stream if not persistent or forced Close all open streams. More... | |
static void | CloseStream (const std::string &fileName, bool forceClose=false) |
static void | DeleteStream (const std::string &fileName) |
static void | CloseAllStreams () |
static bool | NoFabHeader (const VisMF::Header &hdr) |
static Long | Write (const FabArray< FArrayBox > &mf, const std::string &name, VisMF::How how=NFiles, bool set_ghost=false) |
Write a FabArray<FArrayBox> to disk in a "smart" way. Returns the total number of bytes written on this processor. If set_ghost is true, sets the ghost cells in the FabArray<FArrayBox> to one-half the average of the min and max over the valid region of each contained FAB. More... | |
static void | AsyncWrite (const FabArray< FArrayBox > &mf, const std::string &mf_name, bool valid_cells_only=false) |
static void | AsyncWrite (FabArray< FArrayBox > &&mf, const std::string &mf_name, bool valid_cells_only=false) |
static Long | WriteOnlyHeader (const FabArray< FArrayBox > &mf, const std::string &mf_name, VisMF::How how=NFiles) |
Write only the header-file corresponding to FabArray<FArrayBox> to disk without the corresponding FAB data. This writes BoxArray information (which might still be needed by data post-processing tools such as yt) when the FAB data is not needed. Returns the total number of bytes written on this processor. More... | |
static void | RemoveFiles (const std::string &name, bool verbose=false) |
this will remove nfiles associated with name and the header More... | |
static void | Read (FabArray< FArrayBox > &mf, const std::string &name, const char *faHeader=nullptr, int coordinatorProc=ParallelDescriptor::IOProcessorNumber(), int allow_empty_mf=0) |
Read a FabArray<FArrayBox> from disk written using VisMF::Write(). If the FabArray<FArrayBox> fafab has been fully defined, the BoxArray on the disk must match the BoxArray in fafab. If it is constructed with the default constructor, the BoxArray on the disk will be used and a new DistributionMapping will be made. A pre-read FabArray header can be passed in to avoid a read and broadcast. More... | |
static bool | Exist (const std::string &name) |
Does FabArray exist? More... | |
static void | ReadFAHeader (const std::string &fafabName, Vector< char > &header) |
Read only the header of a FabArray, header will be resized here. More... | |
static bool | Check (const std::string &name) |
Check if the multifab is ok, false is returned if not ok. More... | |
static Long | FileOffset (std::ostream &os) |
The file offset of the passed ostream. More... | |
static int | GetNOutFiles () |
static void | SetNOutFiles (int noutfiles, MPI_Comm comm=ParallelDescriptor::Communicator()) |
static int | GetMFFileInStreams () |
static void | SetMFFileInStreams (int nstreams, MPI_Comm comm=ParallelDescriptor::Communicator()) |
static int | GetVerbose () |
static void | SetVerbose (int v) |
static VisMF::Header::Version | GetHeaderVersion () |
static void | SetHeaderVersion (VisMF::Header::Version version) |
static bool | GetGroupSets () |
static void | SetGroupSets (bool groupsets) |
static bool | GetSetBuf () |
static void | SetSetBuf (bool setbuf) |
static bool | GetUseSingleRead () |
static void | SetUseSingleRead (bool usesingleread) |
static bool | GetUseSingleWrite () |
static void | SetUseSingleWrite (bool usesinglewrite) |
static bool | GetCheckFilePositions () |
static void | SetCheckFilePositions (bool cfp) |
static bool | GetUsePersistentIFStreams () |
static void | SetUsePersistentIFStreams (bool usepifs) |
static bool | GetUseSynchronousReads () |
static void | SetUseSynchronousReads (bool usepsr) |
static bool | GetUseDynamicSetSelection () |
static void | SetUseDynamicSetSelection (bool usedss) |
static std::string | DirName (const std::string &filename) |
static std::string | BaseName (const std::string &filename) |
static void | Initialize () |
static void | Finalize () |
Static Public Member Functions inherited from amrex::VisMFBuffer | |
static Long | GetIOBufferSize () |
static void | SetIOBufferSize (Long iobuffersize) |
static void | ClearBuffer (IO_Buffer &buf) |
Static Private Member Functions | |
static FabOnDisk | Write (const FArrayBox &fab, const std::string &filename, std::ostream &os, Long &bytes) |
static Long | WriteHeaderDoit (const std::string &mf_name, VisMF::Header const &hdr) |
static Long | WriteHeader (const std::string &mf_name, VisMF::Header &hdr, int procToWrite=ParallelDescriptor::IOProcessorNumber(), MPI_Comm comm=ParallelDescriptor::Communicator()) |
static void | FindOffsets (const FabArray< FArrayBox > &mf, const std::string &filePrefix, VisMF::Header &hdr, VisMF::Header::Version whichVersion, NFilesIter &nfi, MPI_Comm comm=ParallelDescriptor::Communicator()) |
fileNumbers must be passed in for dynamic set selection [proc] More... | |
static FArrayBox * | readFAB (int idx, const std::string &mf_name, const Header &hdr, int whichComp=-1) |
Make a new FAB from a fab in a FabArray<FArrayBox> on disk. The returned *FAB will have either one component filled from fafab[fabIndex][whichComp] or fafab[fabIndex].nComp() components. whichComp == -1 means reads the whole FAB. Otherwise read just that component. More... | |
static void | readFAB (FabArray< FArrayBox > &mf, int idx, const std::string &mf_name, const Header &hdr) |
Read the whole FAB into fafab[fabIndex]. More... | |
static void | AsyncWriteDoit (const FabArray< FArrayBox > &mf, const std::string &mf_name, bool is_rvalue, bool valid_cells_only) |
Private Attributes | |
std::string | m_fafabname |
Name of the FabArray<FArrayBox>. More... | |
Header | m_hdr |
The VisMF header as read from disk. More... | |
Vector< Vector< FArrayBox * > > | m_pa |
We manage the FABs individually. More... | |
Static Private Attributes | |
static AMREX_EXPORT std::map< std::string, VisMF::PersistentIFStream > | persistentIFStreams |
Persistent streams. These open on demand and should be closed when not needed with CloseAllStreams. ~VisMF also closes them. [filename, pifs]. More... | |
static AMREX_EXPORT int | nOutFiles |
The number of files to write for a FabArray<FArrayBox>. More... | |
static AMREX_EXPORT int | nMFFileInStreams |
static AMREX_EXPORT int | verbose |
static AMREX_EXPORT VisMF::Header::Version | currentVersion |
static AMREX_EXPORT bool | groupSets |
static AMREX_EXPORT bool | setBuf |
static AMREX_EXPORT bool | useSingleRead |
static AMREX_EXPORT bool | useSingleWrite |
static AMREX_EXPORT bool | checkFilePositions |
static AMREX_EXPORT bool | usePersistentIFStreams |
static AMREX_EXPORT bool | useSynchronousReads |
static AMREX_EXPORT bool | useDynamicSetSelection |
static AMREX_EXPORT bool | allowSparseWrites |
Additional Inherited Members | |
Static Protected Attributes inherited from amrex::VisMFBuffer | |
static AMREX_EXPORT Long | ioBufferSize |
-— the settable buffer size More... | |
File I/O for FabArray<FArrayBox>. Wrapper class for reading/writing FabArray<FArrayBox> objects to disk in various "smart" ways.
enum amrex::VisMF::How |
How we write out FabArray<FArrayBox>s. These are deprecated, we always use NFiles. For OneFilePerCPU, set NFiles to NProcs.
Enumerator | |
---|---|
OneFilePerCPU | |
NFiles |
|
explicit |
|
default |
|
delete |
|
delete |
|
static |
|
static |
|
staticprivate |
|
static |
const BoxArray & amrex::VisMF::boxArray | ( | ) | const |
The BoxArray of the on-disk FabArray<FArrayBox>.
|
static |
Check if the multifab is ok, false is returned if not ok.
void amrex::VisMF::clear | ( | ) |
Delete()s all the FABs.
void amrex::VisMF::clear | ( | int | fabIndex | ) |
Delete()s the FAB at the specified index (all components).
Delete()s the FAB at the specified index and component.
|
static |
|
static |
|
static |
|
static |
|
static |
Does FabArray exist?
|
static |
The file offset of the passed ostream.
|
static |
|
staticprivate |
fileNumbers must be passed in for dynamic set selection [proc]
|
inlinestatic |
The FAB at the specified index and component. Reads it from disk if necessary. This reads only the specified component.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
The max of the FAB (in valid region) at specified index and component.
Real amrex::VisMF::max | ( | int | nComp | ) | const |
The max of the FabArray (in valid region) at specified component.
The min of the FAB (in valid region) at specified index and component.
Real amrex::VisMF::min | ( | int | nComp | ) | const |
The min of the FabArray (in valid region) at specified component.
int amrex::VisMF::nComp | ( | ) | const |
The number of components in the on-disk FabArray<FArrayBox>.
int amrex::VisMF::nGrow | ( | ) | const |
The grow factor of the on-disk FabArray<FArrayBox>.
IntVect amrex::VisMF::nGrowVect | ( | ) | const |
|
static |
|
static |
Open the stream if it is not already open Close the stream if not persistent or forced Close all open streams.
|
static |
Read a FabArray<FArrayBox> from disk written using VisMF::Write(). If the FabArray<FArrayBox> fafab has been fully defined, the BoxArray on the disk must match the BoxArray in fafab. If it is constructed with the default constructor, the BoxArray on the disk will be used and a new DistributionMapping will be made. A pre-read FabArray header can be passed in to avoid a read and broadcast.
|
staticprivate |
Read the whole FAB into fafab[fabIndex].
Read the entire fab (all components).
|
staticprivate |
Make a new FAB from a fab in a FabArray<FArrayBox> on disk. The returned *FAB will have either one component filled from fafab[fabIndex][whichComp] or fafab[fabIndex].nComp() components. whichComp == -1 means reads the whole FAB. Otherwise read just that component.
|
static |
Read only the header of a FabArray, header will be resized here.
|
static |
this will remove nfiles associated with name and the header
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
|
static |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
Write a FabArray<FArrayBox> to disk in a "smart" way. Returns the total number of bytes written on this processor. If set_ghost is true, sets the ghost cells in the FabArray<FArrayBox> to one-half the average of the min and max over the valid region of each contained FAB.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
static |
Write only the header-file corresponding to FabArray<FArrayBox> to disk without the corresponding FAB data. This writes BoxArray information (which might still be needed by data post-processing tools such as yt) when the FAB data is not needed. Returns the total number of bytes written on this processor.
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
private |
Name of the FabArray<FArrayBox>.
|
staticprivate |
|
staticprivate |
The number of files to write for a FabArray<FArrayBox>.
|
staticprivate |
Persistent streams. These open on demand and should be closed when not needed with CloseAllStreams. ~VisMF also closes them. [filename, pifs].
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |
|
staticprivate |