Commit 12367881 authored by Dave Moxey's avatar Dave Moxey

Updates to simplify provenance after merge

parent 304add83
......@@ -36,6 +36,8 @@
#ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIOXML_H
#define NEKTAR_LIB_UTILITIES_BASIC_UTILS_FIELDIOXML_H
#include <boost/algorithm/string/predicate.hpp>
#include <LibUtilities/BasicUtils/FieldIO.h>
#include <LibUtilities/BasicUtils/FileSystem.h>
......@@ -127,9 +129,32 @@ public:
/// Set an attribute key/value pair on this tag.
virtual void SetAttr(const std::string &key, const std::string &val)
{
TiXmlElement *child = new TiXmlElement(key.c_str());
child->LinkEndChild(new TiXmlText(val.c_str()));
m_El->LinkEndChild(child);
if (boost::starts_with(key, "XML_"))
{
// Auto-expand XML parameters.
std::string elmtName = key.substr(4);
TiXmlElement *child = new TiXmlElement(elmtName.c_str());
// Parse string we're given
TiXmlDocument doc;
doc.Parse(val.c_str());
TiXmlElement *e = doc.FirstChildElement();
while (e)
{
child->LinkEndChild(e->Clone());
e = e->NextSiblingElement();
}
m_El->LinkEndChild(child);
}
else
{
TiXmlElement *child = new TiXmlElement(key.c_str());
child->LinkEndChild(new TiXmlText(val.c_str()));
m_El->LinkEndChild(child);
}
}
private:
......
......@@ -38,6 +38,8 @@
#include <set>
#include <LibUtilities/BasicUtils/FieldIO.h>
#include <NekMeshUtils/NekMeshUtilsDeclspec.h>
#include <NekMeshUtils/MeshElements/Element.h>
#include <NekMeshUtils/MeshElements/Composite.h>
......@@ -132,7 +134,7 @@ public:
/// Octree system pointer, if there is no octree its empty
OctreeSharedPtr m_octree;
/// Metadata map for storing any mesh generation parameters
MeshMetaDataMap m_metadata;
LibUtilities::FieldMetaDataMap m_metadata;
/// Returns the total number of elements in the mesh with
/// dimension expDim.
......
......@@ -1204,7 +1204,10 @@ void MeshGraphHDF5::WriteDomain(vector<CompositeMap> &domain)
dst->WriteVectorString(doms, tp);
}
void MeshGraphHDF5::WriteGeometry(std::string &outfilename, bool defaultExp)
void MeshGraphHDF5::WriteGeometry(
std::string &outfilename,
bool defaultExp,
const LibUtilities::FieldMetaDataMap &metadata)
{
vector<string> tmp;
boost::split(tmp, outfilename, boost::is_any_of("."));
......
......@@ -53,7 +53,10 @@ public:
{
}
void WriteGeometry(std::string &outfilename, bool defaultExp = false);
void WriteGeometry(std::string &outfilename,
bool defaultExp = false,
const LibUtilities::FieldMetaDataMap &metadata
= LibUtilities::NullFieldMetaDataMap);
void WriteGeometry(std::string outname,
std::vector<std::set<unsigned int>> elements,
......
......@@ -39,6 +39,7 @@
#include <LibUtilities/BasicUtils/ParseUtils.h>
#include <LibUtilities/BasicUtils/FileSystem.h>
#include <LibUtilities/BasicUtils/FieldIOXml.h>
#include <boost/format.hpp>
......@@ -2732,9 +2733,9 @@ void MeshGraphXml::WriteDefaultExpansion(TiXmlElement *root)
* representing this MeshGraph instance inside a NEKTAR tag.
*/
void MeshGraphXml::WriteGeometry(
std::string &outfilename,
bool defaultExp,
const LibUtilties::FieldMetaDataMap &metadata)
std::string &outfilename,
bool defaultExp,
const LibUtilities::FieldMetaDataMap &metadata)
{
// Create empty TinyXML document.
TiXmlDocument doc;
......
......@@ -57,7 +57,8 @@ public:
void WriteGeometry(std::string &outfilename,
bool defaultExp = false,
const LibUtilities::FieldMetaDataMap &metadata);
const LibUtilities::FieldMetaDataMap &metadata
= LibUtilities::NullFieldMetaDataMap);
void WriteGeometry(std::string outname,
std::vector<std::set<unsigned int>> elements,
......
......@@ -82,11 +82,9 @@ void InputMCF::ParseFile(string nm)
TiXmlElement *mcf = pSession->GetElement("NEKTAR/MESHING");
// Save MESHING tag as provenance information.
TiXmlPrinter printer;
printer->Print(mcf);
std::stringstream ss;
ss << printer.CStr();
m_mesh->m_metadata["NekMeshMCF"] = ss.str();
ss << *mcf;
m_mesh->m_metadata["XML_NekMeshMCF"] = ss.str();
TiXmlElement *info = mcf->FirstChildElement("INFORMATION");
TiXmlElement *I = info->FirstChildElement("I");
......
......@@ -165,6 +165,11 @@ int main(int argc, char* argv[])
MeshSharedPtr mesh = std::shared_ptr<Mesh>(new Mesh());
// Add provenance information to mesh.
stringstream ss;
for(int i = 1; i < argc; i++)
{
ss << argv[i] << " ";
}
mesh->m_metadata["NekMeshCommandLine"] = ss.str();
vector<ModuleSharedPtr> modules;
......
......@@ -114,31 +114,9 @@ void OutputNekpp::Process()
string file = m_config["outfile"].as<string>();
string ext = boost::filesystem::extension(file);
<<<<<<< HEAD
// Default to compressed XML output.
std::string type = "XmlCompressed";
=======
//add metadata
root->LinkEndChild(m_mesh->m_infotag);
WriteXmlExpansions(root);
WriteXmlConditions(root);
// Begin <GEOMETRY> section
TiXmlElement *geomTag = new TiXmlElement("GEOMETRY");
geomTag->SetAttribute("DIM", m_mesh->m_expDim);
geomTag->SetAttribute("SPACE", m_mesh->m_spaceDim);
root->LinkEndChild(geomTag);
WriteXmlNodes(geomTag);
WriteXmlEdges(geomTag);
WriteXmlFaces(geomTag);
WriteXmlElements(geomTag);
WriteXmlCurves(geomTag);
WriteXmlComposites(geomTag);
WriteXmlDomain(geomTag);
>>>>>>> upstream/master
// Extract the output filename and extension
string filename = m_config["outfile"].as<string>();
......@@ -165,7 +143,7 @@ void OutputNekpp::Process()
TransferDomain(graph);
string out = m_config["outfile"].as<string>();
graph->WriteGeometry(out, true);
graph->WriteGeometry(out, true, m_mesh->m_metadata);
/*
// Test the resulting XML file (with a basic test) by loading it
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment