35#ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIO_H
36#define NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIO_H
65 void SetAttr(
const std::string &key,
const std::string &val)
76 virtual void v_SetAttr(
const std::string &key,
const std::string &val) = 0;
124 const std::vector<unsigned int> &elementIDs,
125 const std::vector<LibUtilities::BasisType> &basis,
bool uniOrder,
126 const std::vector<unsigned int> &numModes,
127 const std::vector<std::string> &fields,
int NumHomoDir = 0,
129 bool homoStrips =
false,
133 const std::vector<LibUtilities::PointsType> &points =
135 bool pointsDef =
false,
137 bool numPointsDef =
false)
187 const std::string &outFile,
188 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
189 std::vector<std::vector<NekDouble>> &fielddata,
191 const bool backup =
false);
193 const std::string &infilename,
194 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
226class FieldIO :
public std::enable_shared_from_this<FieldIO>
230 bool sharedFilesystem);
237 const std::string &outFile,
238 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
239 std::vector<std::vector<NekDouble>> &fielddata,
241 const bool backup =
false);
244 const std::string &infilename,
245 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
246 std::vector<std::vector<NekDouble>> &fielddata =
266 const std::string &filename);
292 bool backup =
false);
296 const std::string &outFile,
297 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
298 std::vector<std::vector<NekDouble>> &fielddata,
303 const std::string &infilename,
304 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
305 std::vector<std::vector<NekDouble>> &fielddata =
334 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
335 std::vector<std::vector<NekDouble>> &fielddata,
339 v_Write(outFile, fielddefs, fielddata, fieldinfomap, backup);
356 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
357 std::vector<std::vector<NekDouble>> &fielddata,
361 v_Import(infilename, fielddefs, fielddata, fieldinfo, ElementIDs);
#define LIB_UTILITIES_EXPORT
Class for operating on Nektar++ input/output files.
int CheckFieldDefinition(const FieldDefinitionsSharedPtr &fielddefs)
Check field definitions for correctness and return storage size.
static const std::string GetFileType(const std::string &filename, CommSharedPtr comm)
Determine file type of given input file.
std::vector< unsigned int > GetNumberOfCoeffsPerElement(const FieldDefinitionsSharedPtr &fielddefs)
Compute number of data points needed to store expansion inside each element.
bool m_sharedFilesystem
Boolean dictating whether we are on a shared filesystem.
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.
DataSourceSharedPtr ImportFieldMetaData(const std::string &filename, FieldMetaDataMap &fieldmetadatamap)
Import the metadata from a field file.
static std::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
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.
virtual std::string v_GetFileEnding() const
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.
static std::shared_ptr< FieldIO > CreateDefault(const LibUtilities::SessionReaderSharedPtr session)
Returns an object for the default FieldIO method.
std::string SetUpOutput(const std::string outname, bool perRank, bool backup=false)
Set up the filesystem ready for output.
const std::string & GetClassName() const
LibUtilities::CommSharedPtr m_comm
Communicator to use when writing parallel format.
FieldIO(LibUtilities::CommSharedPtr pComm, bool sharedFilesystem)
Constructor for FieldIO base class.
std::string GetFileEnding() const
Helper function that determines default file extension.
virtual const std::string & v_GetClassName() const =0
static void AddInfoTag(TagWriterSharedPtr root, const FieldMetaDataMap &fieldmetadatamap)
Add provenance information to the field metadata map.
virtual DataSourceSharedPtr v_ImportFieldMetaData(const std::string &filename, FieldMetaDataMap &fieldmetadatamap)=0
Import the metadata from a field file.
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.
Provides a generic Factory class.
Base class for writing hierarchical data (XML or HDF5).
void SetAttr(const std::string &key, const std::string &val)
Set an attribute on the node.
std::shared_ptr< TagWriter > AddChild(const std::string &name)
Create a child node.
virtual void v_SetAttr(const std::string &key, const std::string &val)=0
virtual std::shared_ptr< TagWriter > v_AddChild(const std::string &name)=0
static std::vector< unsigned int > NullUnsignedIntVector
void Import(const std::string &infilename, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, FieldMetaDataMap &fieldinfomap, const Array< OneD, int > &ElementIDs)
This function allows for data to be imported from an FLD file when a session and/or communicator is n...
std::shared_ptr< TagWriter > TagWriterSharedPtr
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::shared_ptr< DataSource > DataSourceSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
LibUtilities::NekFactory< std::string, FieldIO, LibUtilities::CommSharedPtr, bool > FieldIOFactory
Datatype of the NekFactory used to instantiate classes.
std::shared_ptr< SessionReader > SessionReaderSharedPtr
static FieldMetaDataMap NullFieldMetaDataMap
static std::vector< std::vector< NekDouble > > NullVectorNekDoubleVector
std::shared_ptr< FieldDefinitions > FieldDefinitionsSharedPtr
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
static std::vector< NekDouble > NullNekDoubleVector
void Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap, const bool backup)
This function allows for data to be written to an FLD file when a session and/or communicator is not ...
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
static std::vector< LibUtilities::PointsType > NullPointsTypeVector
static Array< OneD, int > NullInt1DArray
Metadata that describes the storage properties of field output.
std::vector< NekDouble > m_homogeneousLengths
Spatial lengths of each homogeneous direction.
int m_numHomogeneousDir
Number of homogeneous directions, in the range .
std::vector< LibUtilities::BasisType > m_basis
Vector of basis types for each of the coordinate directions.
bool m_pointsDef
Boolean determining whether points have been defined in output.
std::vector< std::string > m_fields
Vector of field names that this data encapsulates.
std::vector< unsigned int > m_homogeneousSIDs
IDs corresponding to homogeneous strip IDs.
std::vector< unsigned int > m_numPoints
Define number of points per direction.
std::vector< LibUtilities::PointsType > m_points
Define the type of points per direction.
bool m_uniOrder
Define order of the element group.
std::vector< unsigned int > m_homogeneousYIDs
IDs corresponding to y-direction homogeneous IDs.
std::vector< unsigned int > m_homogeneousZIDs
IDs corresponding to z-direction homogeneous IDs.
std::vector< unsigned int > m_numModes
Define number of modes per direction.
ShapeType m_shapeType
Shape type of this field data.
bool m_homoStrips
Boolean determining whether homogeneous strips are used.
FieldDefinitions(ShapeType shapeType, const std::vector< unsigned int > &elementIDs, const std::vector< LibUtilities::BasisType > &basis, bool uniOrder, const std::vector< unsigned int > &numModes, const std::vector< std::string > &fields, int NumHomoDir=0, const std::vector< NekDouble > &HomoLengths=NullNekDoubleVector, bool homoStrips=false, const std::vector< unsigned int > &HomoSIDs=NullUnsignedIntVector, const std::vector< unsigned int > &HomoZIDs=NullUnsignedIntVector, const std::vector< unsigned int > &HomoYIDs=NullUnsignedIntVector, const std::vector< LibUtilities::PointsType > &points=NullPointsTypeVector, bool pointsDef=false, const std::vector< unsigned int > &numPoints=NullUnsignedIntVector, bool numPointsDef=false)
Simple constructor to allocate all internal properties.
bool m_numPointsDef
Boolean determining whether number of points has been defined.
std::vector< unsigned int > m_elementIDs
Element IDs of the field data.
FieldDefinitions()
Default constructor.