Nektar++
|
Class for operating on Nektar++ input/output files. More...
#include <FieldIO.h>
Public Member Functions | |
FieldIO (LibUtilities::CommSharedPtr pComm, bool sharedFilesystem) | |
Constructor for FieldIO base class. More... | |
virtual | ~FieldIO () |
void | Write (const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap=NullFieldMetaDataMap, const bool backup=false) |
Write out the field information to the file outFile . More... | |
void | Import (const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata=NullVectorNekDoubleVector, FieldMetaDataMap &fieldinfomap=NullFieldMetaDataMap, const Array< OneD, int > &ElementIDs=NullInt1DArray) |
Read field information from the file infilename . More... | |
DataSourceSharedPtr | ImportFieldMetaData (const std::string &filename, FieldMetaDataMap &fieldmetadatamap) |
Import the metadata from a field file. More... | |
virtual const std::string & | GetClassName () const =0 |
Static Public Member Functions | |
static const std::string | GetFileType (const std::string &filename, CommSharedPtr comm) |
Determine file type of given input file. More... | |
static boost::shared_ptr< FieldIO > | CreateDefault (const LibUtilities::SessionReaderSharedPtr session) |
Returns an object for the default FieldIO method. More... | |
static boost::shared_ptr< FieldIO > | CreateForFile (const LibUtilities::SessionReaderSharedPtr session, const std::string &filename) |
Construct a FieldIO object for a given input filename. More... | |
Protected Member Functions | |
void | AddInfoTag (TagWriterSharedPtr root, const FieldMetaDataMap &fieldmetadatamap) |
Add provenance information to the field metadata map. More... | |
int | CheckFieldDefinition (const FieldDefinitionsSharedPtr &fielddefs) |
Check field definitions for correctness and return storage size. More... | |
virtual std::string | GetFileEnding () const |
Helper function that determines default file extension. More... | |
std::string | SetUpOutput (const std::string outname, bool perRank, bool backup=false) |
Set up the filesystem ready for output. More... | |
virtual void | v_Write (const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap, const bool backup=false)=0 |
Write out the field information to the file outFile . More... | |
virtual void | v_Import (const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata=NullVectorNekDoubleVector, FieldMetaDataMap &fieldinfomap=NullFieldMetaDataMap, const Array< OneD, int > &ElementIDs=NullInt1DArray)=0 |
Read field information from the file infilename . More... | |
virtual DataSourceSharedPtr | v_ImportFieldMetaData (const std::string &filename, FieldMetaDataMap &fieldmetadatamap)=0 |
Import the metadata from a field file. More... | |
Protected Attributes | |
LibUtilities::CommSharedPtr | m_comm |
Communicator to use when writing parallel format. More... | |
bool | m_sharedFilesystem |
Boolean dictating whether we are on a shared filesystem. More... | |
Class for operating on Nektar++ input/output files.
Nektar++ input/output of field data can be described as follows:
This base class represents the minimum functionality that subclasses need to implement in order to implement the above functionality. Each subclass is free to determine its own file structure and parallel behaviour.
Nektar::LibUtilities::FieldIO::FieldIO | ( | LibUtilities::CommSharedPtr | pComm, |
bool | sharedFilesystem | ||
) |
Constructor for FieldIO base class.
Definition at line 313 of file FieldIO.cpp.
|
inlinevirtual |
|
protected |
Add provenance information to the field metadata map.
This routine adds some basic provenance information to the field metadata to enable better tracking of version information:
root | Root tag, which is encapsulated using the TagWriter structure to enable multi-file format support. |
fieldmetadatamap | Any existing field metadata. |
Definition at line 334 of file FieldIO.cpp.
References Nektar::NekConstants::kGitBranch, Nektar::NekConstants::kGitSha1, NEKTAR_VERSION, and Nektar::LibUtilities::NullFieldMetaDataMap.
Referenced by Nektar::LibUtilities::FieldIOHdf5::v_Write(), Nektar::LibUtilities::FieldIOXml::v_Write(), and Nektar::LibUtilities::FieldIOXml::WriteMultiFldFileIDs().
|
protected |
Check field definitions for correctness and return storage size.
fielddefs | Field definitions to check. |
Definition at line 561 of file FieldIO.cpp.
References ASSERTL0, Nektar::LibUtilities::eHexahedron, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::ePyramid, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eSegment, Nektar::LibUtilities::eTetrahedron, Nektar::LibUtilities::eTriangle, Nektar::LibUtilities::StdTriData::getNumberOfCoefficients(), Nektar::LibUtilities::StdTetData::getNumberOfCoefficients(), Nektar::LibUtilities::StdPyrData::getNumberOfCoefficients(), and Nektar::LibUtilities::StdPrismData::getNumberOfCoefficients().
Referenced by Nektar::LibUtilities::FieldIOXml::ImportFieldData(), Nektar::LibUtilities::FieldIOHdf5::ImportFieldData(), Nektar::LibUtilities::FieldIOHdf5::v_Write(), and Nektar::LibUtilities::FieldIOXml::v_Write().
|
static |
Returns an object for the default FieldIO method.
This function returns a FieldIO class as determined by the hard-coded default (XML), which can be overridden by changing the session reader SOLVERINFO variable FieldIOFormat.
session | Session reader |
Definition at line 181 of file FieldIO.cpp.
References Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), and Nektar::LibUtilities::GetFieldIOFactory().
Referenced by Nektar::VortexWaveInteraction::FileRelaxation(), Nektar::FilterBenchmark::FilterBenchmark(), Nektar::SolverUtils::FilterCheckpoint::FilterCheckpoint(), Nektar::FilterCheckpointCellModel::FilterCheckpointCellModel(), Nektar::SolverUtils::FilterModalEnergy::FilterModalEnergy(), Nektar::SolverUtils::FilterThresholdMax::FilterThresholdMax(), Nektar::SolverUtils::FilterThresholdMin::FilterThresholdMin(), Nektar::GlobalMapping::Mapping::Mapping(), and Nektar::SolverUtils::EquationSystem::v_InitObject().
|
static |
Construct a FieldIO object for a given input filename.
This is a convenience function that takes an input filename and constructs the appropriate FieldIO subclass, using FieldIO::GetFileType.
session | Session reader |
filename | Input filename |
filename
. Definition at line 212 of file FieldIO.cpp.
References Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::GetFieldIOFactory(), and GetFileType().
Referenced by Nektar::SolverUtils::UnsteadySystem::CheckForRestartTime(), Nektar::SolverUtils::Forcing::EvaluateFunction(), Nektar::GlobalMapping::Mapping::EvaluateFunction(), Nektar::SolverUtils::EquationSystem::EvaluateFunctionFld(), Nektar::SolverUtils::EquationSystem::ImportFld(), Nektar::LinearisedAdvection::ImportFldBase(), Nektar::SolverUtils::EquationSystem::ImportFldBase(), Nektar::SpatialDomains::MeshGraph::ReadExpansions(), and Nektar::SolverUtils::FilterFieldConvert::v_Initialise().
|
pure virtual |
Implemented in Nektar::LibUtilities::FieldIOXml, and Nektar::LibUtilities::FieldIOHdf5.
|
inlineprotectedvirtual |
Helper function that determines default file extension.
Reimplemented in Nektar::LibUtilities::PtsIO.
Definition at line 279 of file FieldIO.h.
Referenced by Nektar::LibUtilities::FieldIOXml::SetUpFieldMetaData(), and SetUpOutput().
|
static |
Determine file type of given input file.
This method attempts to identify the file type of a given input file filename
. It returns a string corresponding to GetFieldIOFactory() or throws an assertion if it cannot be identified.
filename | Input filename |
comm | Communicator for parallel runs |
filename
. Definition at line 101 of file FieldIO.cpp.
References ASSERTL0, Nektar::LibUtilities::eHDF5, Nektar::LibUtilities::eXML, and Nektar::LibUtilities::PortablePath().
Referenced by CreateForFile(), Nektar::MultiRegions::ExpList::ExtractFileBCs(), Nektar::LibUtilities::Import(), and Nektar::LibUtilities::MeshPartition::ReadExpansions().
|
inline |
Read field information from the file infilename
.
infilename | Input filename (or directory if parallel format) |
fielddefs | On return contains field definitions as read from the input. |
fielddata | On return, contains binary field data that stores the input corresponding to fielddefs . |
fieldinfo | On returnm, contains the associated field metadata map. |
ElementIDs | Element IDs that lie on this processor, which can be optionally supplied to avoid reading the entire file on each processor. |
Definition at line 342 of file FieldIO.h.
References v_Import().
|
inline |
Import the metadata from a field file.
filename | Input filename. |
fieldmetadatamap | On return contains the field metadata map from filename . |
Definition at line 358 of file FieldIO.h.
References v_ImportFieldMetaData().
Referenced by Nektar::LibUtilities::PtsIO::Import(), and Nektar::LibUtilities::FieldIOXml::v_Import().
|
protected |
Set up the filesystem ready for output.
This function sets up the output given an output filename outname
. This will therefore remove any file or directory with the desired output filename and return the absolute path to the output.
If perRank
is set, a new directory will be created to contain one file per process rank.
outname | Desired output filename. |
perRank | True if one file-per-rank output is required. |
Definition at line 400 of file FieldIO.cpp.
References ASSERTL0, CellMLToNektar.pycml::format, GetFileEnding(), m_comm, m_sharedFilesystem, Nektar::LibUtilities::PortablePath(), Nektar::LibUtilities::ReduceMax, and Nektar::LibUtilities::ReduceMin.
Referenced by Nektar::LibUtilities::FieldIOHdf5::v_Write(), Nektar::LibUtilities::FieldIOXml::v_Write(), and Nektar::LibUtilities::PtsIO::Write().
|
protectedpure virtual |
Read field information from the file infilename
.
infilename | Input filename (or directory if parallel format) |
fielddefs | On return contains field definitions as read from the input. |
fielddata | On return, contains binary field data that stores the input corresponding to fielddefs . |
fieldinfo | On returnm, contains the associated field metadata map. |
ElementIDs | Element IDs that lie on this processor, which can be optionally supplied to avoid reading the entire file on each processor. |
Implemented in Nektar::LibUtilities::FieldIOHdf5, and Nektar::LibUtilities::FieldIOXml.
Referenced by Import().
|
protectedpure virtual |
Import the metadata from a field file.
filename | Input filename. |
fieldmetadatamap | On return contains the field metadata map from filename . |
Implemented in Nektar::LibUtilities::FieldIOHdf5, and Nektar::LibUtilities::FieldIOXml.
Referenced by ImportFieldMetaData().
|
protectedpure virtual |
Write out the field information to the file outFile
.
outFile | Output filename |
fielddefs | Field definitions that define the output |
fielddata | Binary field data that stores the output corresponding to fielddefs . |
fieldinfomap | Associated field metadata map. |
Implemented in Nektar::LibUtilities::FieldIOXml, and Nektar::LibUtilities::FieldIOHdf5.
Referenced by Write().
|
inline |
Write out the field information to the file outFile
.
outFile | Output filename |
fielddefs | Field definitions that define the output |
fielddata | Binary field data that stores the output corresponding to fielddefs . |
fieldinfomap | Associated field metadata map. |
Definition at line 320 of file FieldIO.h.
References v_Write().
|
protected |
Communicator to use when writing parallel format.
Definition at line 265 of file FieldIO.h.
Referenced by Nektar::LibUtilities::PtsIO::Import(), Nektar::LibUtilities::FieldIOHdf5::ImportFieldData(), Nektar::LibUtilities::FieldIOHdf5::ImportFieldDef(), Nektar::LibUtilities::PtsIO::SetUpFieldMetaData(), Nektar::LibUtilities::FieldIOXml::SetUpFieldMetaData(), SetUpOutput(), Nektar::LibUtilities::FieldIOHdf5::v_Import(), Nektar::LibUtilities::FieldIOHdf5::v_Write(), and Nektar::LibUtilities::FieldIOXml::v_Write().
|
protected |
Boolean dictating whether we are on a shared filesystem.
Definition at line 267 of file FieldIO.h.
Referenced by SetUpOutput().