36 #ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIO_H
37 #define NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIO_H
51 namespace LibUtilities
64 virtual boost::shared_ptr<TagWriter>
AddChild(
const std::string &name) = 0;
66 virtual void SetAttr(
const std::string &key,
const std::string &val) = 0;
119 const std::vector<unsigned int> &elementIDs,
120 const std::vector<LibUtilities::BasisType> &basis,
122 const std::vector<unsigned int> &numModes,
123 const std::vector<std::string> &fields,
126 bool homoStrips =
false,
130 const std::vector<LibUtilities::PointsType> &points =
132 bool pointsDef =
false,
134 bool numPointsDef =
false)
184 const std::string &outFile,
185 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
186 std::vector<std::vector<NekDouble> > &fielddata,
187 const FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
188 const bool backup =
false);
190 const std::string &infilename,
191 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
193 FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
224 class FieldIO :
public boost::enable_shared_from_this<FieldIO>
228 LibUtilities::CommSharedPtr pComm,
bool sharedFilesystem);
235 const std::string &outFile,
236 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
237 std::vector<std::vector<NekDouble> > &fielddata,
238 const FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
239 const bool backup =
false);
242 const std::string &infilename,
243 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
244 std::vector<std::vector<NekDouble> > &fielddata =
246 FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
250 const std::string &filename,
251 FieldMetaDataMap &fieldmetadatamap);
261 const std::string &filename);
270 TagWriterSharedPtr root,
271 const FieldMetaDataMap &fieldmetadatamap);
274 const FieldDefinitionsSharedPtr &fielddefs);
285 const std::string outname,
bool perRank,
bool backup =
false);
289 const std::string &outFile,
290 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
291 std::vector<std::vector<NekDouble> > &fielddata,
292 const FieldMetaDataMap &fieldinfomap,
293 const bool backup =
false) = 0;
297 const std::string &infilename,
298 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
299 std::vector<std::vector<NekDouble> >
301 FieldMetaDataMap &fieldinfomap = NullFieldMetaDataMap,
306 const std::string &filename, FieldMetaDataMap &fieldmetadatamap) = 0;
321 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
322 std::vector<std::vector<NekDouble> > &fielddata,
323 const FieldMetaDataMap &fieldinfomap,
326 v_Write(outFile, fielddefs, fielddata, fieldinfomap, backup);
343 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
344 std::vector<std::vector<NekDouble> > &fielddata,
345 FieldMetaDataMap &fieldinfo,
348 v_Import(infilename, fielddefs, fielddata, fieldinfo, ElementIDs);
359 const std::string &filename, FieldMetaDataMap &fieldmetadatamap)
std::vector< unsigned int > m_numPoints
Define number of points per direction.
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.
LibUtilities::NekFactory< std::string, FieldIO, LibUtilities::CommSharedPtr, bool > FieldIOFactory
Datatype of the NekFactory used to instantiate classes.
std::vector< unsigned int > m_homogeneousYIDs
IDs corresponding to y-direction homogeneous IDs.
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::vector< NekDouble > m_homogeneousLengths
Spatial lengths of each homogeneous direction.
FieldDefinitions()
Default constructor.
boost::shared_ptr< FieldDefinitions > FieldDefinitionsSharedPtr
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.
ShapeType m_shapeType
Shape type of this field data.
virtual void SetAttr(const std::string &key, const std::string &val)=0
Set an attribute on the node.
virtual DataSourceSharedPtr v_ImportFieldMetaData(const std::string &filename, FieldMetaDataMap &fieldmetadatamap)=0
Import the metadata from a field file.
std::vector< unsigned int > m_homogeneousZIDs
IDs corresponding to z-direction homogeneous IDs.
bool m_uniOrder
Define order of the element group.
FieldIOFactory & GetFieldIOFactory()
Returns the FieldIO factory.
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.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
int CheckFieldDefinition(const FieldDefinitionsSharedPtr &fielddefs)
Check field definitions for correctness and return storage size.
bool m_numPointsDef
Boolean determining whether number of points has been defined.
std::vector< unsigned int > m_homogeneousSIDs
IDs corresponding to homogeneous strip IDs.
virtual const std::string & GetClassName() const =0
boost::shared_ptr< DataSource > DataSourceSharedPtr
std::vector< LibUtilities::BasisType > m_basis
Vector of basis types for each of the coordinate directions.
static std::vector< NekDouble > NullNekDoubleVector
Base class for writing hierarchical data (XML or HDF5).
bool m_sharedFilesystem
Boolean dictating whether we are on a shared filesystem.
Metadata that describes the storage properties of field output.
std::vector< unsigned int > m_numModes
Define number of modes per direction.
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
static const std::string GetFileType(const std::string &filename, CommSharedPtr comm)
Determine file type of given input file.
#define LIB_UTILITIES_EXPORT
static std::vector< std::vector< NekDouble > > NullVectorNekDoubleVector
static std::vector< unsigned int > NullUnsignedIntVector
DataSourceSharedPtr ImportFieldMetaData(const std::string &filename, FieldMetaDataMap &fieldmetadatamap)
Import the metadata from a field file.
boost::shared_ptr< FieldIO > FieldIOSharedPtr
std::vector< unsigned int > m_elementIDs
Element IDs of the field data.
std::string SetUpOutput(const std::string outname, bool perRank, bool backup=false)
Set up the filesystem ready for output.
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::vector< std::string > m_fields
Vector of field names that this data encapsulates.
LibUtilities::CommSharedPtr m_comm
Communicator to use when writing parallel format.
static boost::shared_ptr< FieldIO > CreateDefault(const LibUtilities::SessionReaderSharedPtr session)
Returns an object for the default FieldIO method.
static boost::shared_ptr< FieldIO > CreateForFile(const LibUtilities::SessionReaderSharedPtr session, const std::string &filename)
Construct a FieldIO object for a given input filename.
virtual boost::shared_ptr< TagWriter > AddChild(const std::string &name)=0
Create a child node.
static std::vector< LibUtilities::PointsType > NullPointsTypeVector
bool m_homoStrips
Boolean determining whether homogeneous strips are used.
std::vector< LibUtilities::PointsType > m_points
Define the type of points per direction.
Class for operating on Nektar++ input/output files.
virtual std::string GetFileEnding() const
Helper function that determines default file extension.
boost::shared_ptr< TagWriter > TagWriterSharedPtr
bool m_pointsDef
Boolean determining whether points have been defined in output.
int m_numHomogeneousDir
Number of homogeneous directions, in the range .
static Array< OneD, int > NullInt1DArray
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.
static FieldMetaDataMap NullFieldMetaDataMap
void AddInfoTag(TagWriterSharedPtr root, const FieldMetaDataMap &fieldmetadatamap)
Add provenance information to the field metadata map.
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.
Provides a generic Factory class.
FieldIO(LibUtilities::CommSharedPtr pComm, bool sharedFilesystem)
Constructor for FieldIO base class.