35#ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIOXML_H
36#define NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIOXML_H
38#include <boost/algorithm/string/predicate.hpp>
60 m_doc =
new TiXmlDocument(fn);
61 bool loadOkay =
m_doc->LoadFile();
62 std::stringstream errstr;
63 errstr <<
"Unable to load file: " << fn << std::endl;
64 errstr <<
"Reason: " <<
m_doc->ErrorDesc() << std::endl;
65 errstr <<
"Position: Line " <<
m_doc->ErrorRow() <<
", Column "
66 <<
m_doc->ErrorCol() << std::endl;
86 const TiXmlDocument &
Get()
const
126 TiXmlElement *child =
new TiXmlElement(
name.c_str());
127 m_El->LinkEndChild(child);
132 void v_SetAttr(
const std::string &key,
const std::string &val)
override
134 if (boost::starts_with(key,
"XML_"))
137 std::string elmtName = key.substr(4);
138 TiXmlElement *child =
new TiXmlElement(elmtName.c_str());
142 doc.Parse(val.c_str());
144 TiXmlElement *e = doc.FirstChildElement();
148 child->LinkEndChild(e->Clone());
149 e = e->NextSiblingElement();
152 m_El->LinkEndChild(child);
156 TiXmlElement *child =
new TiXmlElement(key.c_str());
157 child->LinkEndChild(
new TiXmlText(val.c_str()));
158 m_El->LinkEndChild(child);
219 bool sharedFilesystem);
227 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
bool expChild);
231 const std::vector<FieldDefinitionsSharedPtr> &fielddefs,
232 std::vector<std::vector<NekDouble>> &fielddata);
235 const std::string &outfile,
const std::vector<std::string> fileNames,
236 std::vector<std::vector<unsigned int>> &elementList,
240 const std::string &outname,
241 const std::vector<FieldDefinitionsSharedPtr> &fielddefs,
245 const std::string &inFile, std::vector<std::string> &fileNames,
246 std::vector<std::vector<unsigned int>> &elementList,
251 const std::string &outFile,
252 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
253 std::vector<std::vector<NekDouble>> &fielddata,
255 const bool backup =
false)
override;
258 const std::string &infilename,
259 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
260 std::vector<std::vector<NekDouble>> &fielddata =
#define ASSERTL0(condition, msg)
#define LIB_UTILITIES_EXPORT
Class for operating on Nektar++ input/output files.
void ImportMultiFldFileIDs(const std::string &inFile, std::vector< std::string > &fileNames, std::vector< std::vector< unsigned int > > &elementList, FieldMetaDataMap &fieldmetadatamap)
Read file containing element ID to partition mapping.
void ImportFieldData(DataSourceSharedPtr dataSource, const std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata)
Import field data from a target file.
const std::string & v_GetClassName() const override
Returns the class name.
void ImportFieldDefs(DataSourceSharedPtr dataSource, std::vector< FieldDefinitionsSharedPtr > &fielddefs, bool expChild)
Import field definitions from the target file.
void WriteMultiFldFileIDs(const std::string &outfile, const std::vector< std::string > fileNames, std::vector< std::vector< unsigned int > > &elementList, const FieldMetaDataMap &fieldinfomap=NullFieldMetaDataMap)
Write out a file containing element ID to partition mapping.
static FieldIOSharedPtr create(LibUtilities::CommSharedPtr pComm, bool sharedFilesystem)
Creates an instance of this class.
DataSourceSharedPtr v_ImportFieldMetaData(const std::string &filename, FieldMetaDataMap &fieldmetadatamap) override
Import field metadata from filename and return the data source which wraps filename.
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) override
Import an XML format file.
void v_Write(const std::string &outFile, std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata, const FieldMetaDataMap &fieldinfomap=NullFieldMetaDataMap, const bool backup=false) override
Write an XML file to outFile given the field definitions fielddefs, field data fielddata and metadata...
FieldIOXml(LibUtilities::CommSharedPtr pComm, bool sharedFilesystem)
Default constructor.
void SetUpFieldMetaData(const std::string &outname, const std::vector< FieldDefinitionsSharedPtr > &fielddefs, const FieldMetaDataMap &fieldmetadatamap)
Set up field meta data map.
static std::string className
Name of class.
Base class for writing hierarchical data (XML or HDF5).
TiXmlDocument * m_doc
Internal TinyXML document storage.
static DataSourceSharedPtr create(TiXmlDocument &fn)
Create a new XML data source based on a TiXmlDocument.
static DataSourceSharedPtr create(const std::string &fn)
Create a new XML data source based on the filename.
~XmlDataSource()
Destructor cleans up memory usage.
const TiXmlDocument & Get() const
Return the TinyXML document of this source.
XmlDataSource(const std::string &fn)
Constructor based on filename.
bool m_needsFree
Boolean dictating whether document needs to be freed or not.
TiXmlDocument & Get()
Return the TinyXML document of this source.
XmlDataSource(TiXmlDocument &doc)
Default constructor.
XmlTagWriter(TiXmlElement *elem)
Default constructor.
void v_SetAttr(const std::string &key, const std::string &val) override
Set an attribute key/value pair on this tag.
TiXmlElement * m_El
Internal TinyXML document storage.
TagWriterSharedPtr v_AddChild(const std::string &name) override
Add a child node.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
std::shared_ptr< TagWriter > TagWriterSharedPtr
std::shared_ptr< FieldIO > FieldIOSharedPtr
std::shared_ptr< DataSource > DataSourceSharedPtr
std::map< std::string, std::string > FieldMetaDataMap
static FieldMetaDataMap NullFieldMetaDataMap
std::shared_ptr< XmlDataSource > XmlDataSourceSharedPtr
static std::vector< std::vector< NekDouble > > NullVectorNekDoubleVector
std::shared_ptr< XmlTagWriter > XmlTagWriterSharedPtr
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
static Array< OneD, int > NullInt1DArray