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... | |
const std::string & | GetClassName () const |
std::string | GetFileEnding () const |
Helper function that determines default file extension. More... | |
Static Public Member Functions | |
static const std::string | GetFileType (const std::string &filename, CommSharedPtr comm) |
Determine file type of given input file. More... | |
static std::shared_ptr< FieldIO > | CreateDefault (const LibUtilities::SessionReaderSharedPtr session) |
Returns an object for the default FieldIO method. More... | |
static std::shared_ptr< FieldIO > | CreateForFile (const LibUtilities::SessionReaderSharedPtr session, const std::string &filename) |
Construct a FieldIO object for a given input filename. More... | |
static void | AddInfoTag (TagWriterSharedPtr root, const FieldMetaDataMap &fieldmetadatamap) |
Add provenance information to the field metadata map. More... | |
Protected Member Functions | |
int | CheckFieldDefinition (const FieldDefinitionsSharedPtr &fielddefs) |
Check field definitions for correctness and return storage size. More... | |
std::vector< unsigned int > | GetNumberOfCoeffsPerElement (const FieldDefinitionsSharedPtr &fielddefs) |
Compute number of data points needed to store expansion inside each element. 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... | |
virtual std::string | v_GetFileEnding () const |
virtual const std::string & | v_GetClassName () const =0 |
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 321 of file FieldIO.cpp.
|
inlinevirtual |
|
static |
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 342 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(), Nektar::SpatialDomains::MeshGraphIOXml::v_WriteGeometry(), and Nektar::LibUtilities::FieldIOXml::WriteMultiFldFileIDs().
|
protected |
Check field definitions for correctness and return storage size.
fielddefs | Field definitions to check. |
Definition at line 690 of file FieldIO.cpp.
References ASSERTL0, Nektar::ErrorUtil::efatal, Nektar::LibUtilities::eHexahedron, Nektar::LibUtilities::ePrism, Nektar::LibUtilities::ePyramid, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::eSegment, Nektar::LibUtilities::eTetrahedron, Nektar::LibUtilities::eTriangle, Nektar::LibUtilities::GetNumberOfDataPoints(), and NEKERROR.
Referenced by Nektar::LibUtilities::FieldIOXml::ImportFieldData(), Nektar::LibUtilities::FieldIOHdf5::v_Import(), 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 195 of file FieldIO.cpp.
References Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), and Nektar::LibUtilities::GetFieldIOFactory().
Referenced by Diffusion::Diffusion(), Nektar::VortexWaveInteraction::FileRelaxation(), Nektar::FilterBenchmark::FilterBenchmark(), Nektar::SolverUtils::FilterCheckpoint::FilterCheckpoint(), Nektar::FilterCheckpointCellModel::FilterCheckpointCellModel(), Nektar::FilterHilbertFFTPhase::FilterHilbertFFTPhase(), Nektar::SolverUtils::FilterModalEnergy::FilterModalEnergy(), Nektar::FilterOffsetPhase::FilterOffsetPhase(), 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 224 of file FieldIO.cpp.
References Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::LibUtilities::GetFieldIOFactory(), and GetFileType().
Referenced by Nektar::SolverUtils::UnsteadySystem::CheckForRestartTime(), Nektar::SolverUtils::SessionFunction::EvaluateFld(), Nektar::GlobalMapping::Mapping::EvaluateFunction(), Nektar::SolverUtils::EquationSystem::ImportFld(), Nektar::LinearisedAdvection::ImportFldBase(), Nektar::SolverUtils::FileFieldInterpolator::ImportFldBase(), Nektar::CellModel::LoadCellModel(), Nektar::SpatialDomains::MeshGraph::ReadExpansionInfo(), Nektar::SmoothedProfileMethod::ReadPhi(), Nektar::SolverUtils::ForcingMovingReferenceFrame::SetInitialConditions(), Nektar::SolverUtils::FilterBodyFittedVelocity::v_Initialise(), and Nektar::SolverUtils::FilterFieldConvert::v_Initialise().
|
inline |
Definition at line 257 of file FieldIO.h.
References v_GetClassName().
|
inline |
Helper function that determines default file extension.
Definition at line 273 of file FieldIO.h.
References v_GetFileEnding().
Referenced by Nektar::LibUtilities::PtsIO::Import(), Nektar::LibUtilities::FieldIOXml::SetUpFieldMetaData(), Nektar::LibUtilities::PtsIO::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 95 of file FieldIO.cpp.
References ASSERTL0, Nektar::UnitTests::d(), Nektar::ErrorUtil::efatal, Nektar::LibUtilities::eHDF5, Nektar::LibUtilities::eXML, NEKERROR, and Nektar::LibUtilities::PortablePath().
Referenced by CreateForFile(), Nektar::MultiRegions::ExpList::ExtractCoeffsFromFile(), Nektar::FieldUtils::Field::FieldIOForFile(), Nektar::LibUtilities::Import(), and Nektar::SpatialDomains::MeshPartition::ReadExpansions().
|
protected |
Compute number of data points needed to store expansion inside each element.
fielddefs | Field definitions. |
Definition at line 767 of file FieldIO.cpp.
References Nektar::LibUtilities::GetNumberOfDataPoints().
Referenced by Nektar::LibUtilities::FieldIOHdf5::v_Import().
|
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 355 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 371 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 404 of file FieldIO.cpp.
References ASSERTL0, Nektar::ErrorUtil::efatal, CellMLToNektar.pycml::format, GetFileEnding(), m_comm, m_sharedFilesystem, NEKERROR, Nektar::LibUtilities::PortablePath(), Nektar::LibUtilities::ReduceMax, and Nektar::LibUtilities::ReduceMin.
Referenced by Nektar::LibUtilities::FieldIOHdf5::v_Write(), Nektar::LibUtilities::FieldIOXml::v_Write(), Nektar::LibUtilities::CsvIO::Write(), and Nektar::LibUtilities::PtsIO::Write().
|
protectedpure virtual |
Implemented in Nektar::LibUtilities::FieldIOHdf5, and Nektar::LibUtilities::FieldIOXml.
Referenced by GetClassName().
|
inlineprotectedvirtual |
Reimplemented in Nektar::LibUtilities::CsvIO, and Nektar::LibUtilities::PtsIO.
Definition at line 314 of file FieldIO.h.
Referenced by GetFileEnding().
|
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::FieldIOHdf5, and Nektar::LibUtilities::FieldIOXml.
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 333 of file FieldIO.h.
References v_Write().
|
protected |
Communicator to use when writing parallel format.
Definition at line 280 of file FieldIO.h.
Referenced by Nektar::LibUtilities::PtsIO::Import(), Nektar::LibUtilities::FieldIOHdf5::ImportFieldDef(), Nektar::LibUtilities::FieldIOXml::SetUpFieldMetaData(), Nektar::LibUtilities::PtsIO::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 282 of file FieldIO.h.
Referenced by SetUpOutput().