36 #ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIOXML_H
37 #define NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIOXML_H
44 namespace LibUtilities
59 m_doc =
new TiXmlDocument(fn);
60 bool loadOkay =
m_doc->LoadFile();
61 std::stringstream errstr;
62 errstr <<
"Unable to load file: " << fn << std::endl;
63 errstr <<
"Reason: " <<
m_doc->ErrorDesc() << std::endl;
64 errstr <<
"Position: Line " <<
m_doc->ErrorRow() <<
", Column "
65 <<
m_doc->ErrorCol() << std::endl;
85 const TiXmlDocument &
Get()
const
122 TiXmlElement *child =
new TiXmlElement(name.c_str());
123 m_El->LinkEndChild(child);
128 virtual void SetAttr(
const std::string &key,
const std::string &val)
130 TiXmlElement *child =
new TiXmlElement(key.c_str());
131 child->LinkEndChild(
new TiXmlText(val.c_str()));
132 m_El->LinkEndChild(child);
193 bool sharedFilesystem);
201 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
206 const std::vector<FieldDefinitionsSharedPtr> &fielddefs,
207 std::vector<std::vector<NekDouble> > &fielddata);
210 const std::string &outfile,
211 const std::vector<std::string> fileNames,
212 std::vector<std::vector<unsigned int> > &elementList,
216 const std::string &outname,
217 const std::vector<FieldDefinitionsSharedPtr> &fielddefs,
221 const std::string &inFile,
222 std::vector<std::string> &fileNames,
223 std::vector<std::vector<unsigned int> > &elementList,
227 const std::string &infilename,
228 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
229 std::vector<std::vector<NekDouble> > &fielddata =
242 const std::string &outFile,
243 std::vector<FieldDefinitionsSharedPtr> &fielddefs,
244 std::vector<std::vector<NekDouble> > &fielddata,
246 const bool backup =
false);
#define ASSERTL0(condition, msg)
bool m_needsFree
Boolean dictating whether document needs to be freed or not.
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
TiXmlElement * m_El
Internal TinyXML document storage.
static DataSourceSharedPtr create(TiXmlDocument &fn)
Create a new XML data source based on a TiXmlDocument.
virtual TagWriterSharedPtr AddChild(const std::string &name)
Add a child node.
FieldIOXml(LibUtilities::CommSharedPtr pComm, bool sharedFilesystem)
Default constructor.
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.
boost::shared_ptr< XmlTagWriter > XmlTagWriterSharedPtr
TiXmlDocument & Get()
Return the TinyXML document of this source.
virtual 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)
Write an XML file to outFile given the field definitions fielddefs, field data fielddata and metadata...
static std::string className
Name of class.
const TiXmlDocument & Get() const
Return the TinyXML document of this source.
std::map< std::string, std::string > FieldMetaDataMap
boost::shared_ptr< DataSource > DataSourceSharedPtr
Base class for writing hierarchical data (XML or HDF5).
boost::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
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)
Import an XML format file.
static DataSourceSharedPtr create(const std::string &fn)
Create a new XML data source based on the filename.
#define LIB_UTILITIES_EXPORT
static std::vector< std::vector< NekDouble > > NullVectorNekDoubleVector
static FieldIOSharedPtr create(LibUtilities::CommSharedPtr pComm, bool sharedFilesystem)
Creates an instance of this class.
boost::shared_ptr< FieldIO > FieldIOSharedPtr
void ImportFieldData(DataSourceSharedPtr dataSource, const std::vector< FieldDefinitionsSharedPtr > &fielddefs, std::vector< std::vector< NekDouble > > &fielddata)
Import field data from a 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.
TiXmlDocument * m_doc
Internal TinyXML document storage.
XmlTagWriter(TiXmlElement *elem)
Default constructor.
virtual void SetAttr(const std::string &key, const std::string &val)
Set an attribute key/value pair on this tag.
~XmlDataSource()
Destructor cleans up memory usage.
XmlDataSource(const std::string &fn)
Constructor based on filename.
boost::shared_ptr< XmlDataSource > XmlDataSourceSharedPtr
Class for operating on Nektar++ input/output files.
virtual const std::string & GetClassName() const
Returns the class name.
boost::shared_ptr< TagWriter > TagWriterSharedPtr
void SetUpFieldMetaData(const std::string &outname, const std::vector< FieldDefinitionsSharedPtr > &fielddefs, const FieldMetaDataMap &fieldmetadatamap)
Set up field meta data map.
void ImportFieldDefs(DataSourceSharedPtr dataSource, std::vector< FieldDefinitionsSharedPtr > &fielddefs, bool expChild)
Import field definitions from the target file.
static Array< OneD, int > NullInt1DArray
static FieldMetaDataMap NullFieldMetaDataMap
virtual DataSourceSharedPtr v_ImportFieldMetaData(const std::string &filename, FieldMetaDataMap &fieldmetadatamap)
Import field metadata from filename and return the data source which wraps filename.
XmlDataSource(TiXmlDocument &doc)
Default constructor.