Commit 4e36b131 authored by Michael Turner's avatar Michael Turner

Merge branch 'feature/mesh_info' into 'master'

provenance and meshing data from NekMesh

Closes #76

See merge request !872
parents a8c08370 64d84154
......@@ -48,6 +48,8 @@ v5.0.0
- Additional curve types in GEO reader: BSpline, Circle, Ellipse (!800)
- Fix default command line argument value (!823)
- Add projection meshing module which can curve linear meshes with CAD (!826)
- XML meshes now write with provenance information, including information about
their source, for debugging purposes (!872)
- Force 3-node loops to avoid degenerate 1-triangle faces (!875)
- Smooth BL normals in 2D when normals intersect or cause invalid macro BL
elements (!877)
......
......@@ -46,6 +46,22 @@ namespace Nektar
LIB_UTILITIES_EXPORT extern const std::string kGitSha1;
LIB_UTILITIES_EXPORT extern const std::string kGitBranch;
}
//This class is a workaround for a windows quirk which means that it cant
//figure out how the extern works when a library other than LibUtilities
//wants accsess to the information. This class wraps the consts with a class
//so that they can be used elsewhere (such as nekmesh)
namespace LibUtilities
{
class GitConsts
{
public:
LIB_UTILITIES_EXPORT GitConsts(){}
LIB_UTILITIES_EXPORT ~GitConsts(){}
LIB_UTILITIES_EXPORT std::string GetSha1(){return NekConstants::kGitSha1;}
LIB_UTILITIES_EXPORT std::string GetBranch(){return NekConstants::kGitBranch;}
};
}
}
#endif
......@@ -36,6 +36,8 @@
#ifndef NEKMESHUTILS_MESHELEMENTS_MESH
#define NEKMESHUTILS_MESHELEMENTS_MESH
#include <tinyxml.h>
#include <NekMeshUtils/NekMeshUtilsDeclspec.h>
#include <NekMeshUtils/MeshElements/Element.h>
#include <NekMeshUtils/MeshElements/Composite.h>
......@@ -129,6 +131,8 @@ public:
CADSystemSharedPtr m_cad;
/// Octree system pointer, if there is no octree its empty
OctreeSharedPtr m_octree;
/// XML info tag for provenance information
TiXmlElement *m_infotag;
/// Returns the total number of elements in the mesh with
/// dimension expDim.
......
......@@ -79,6 +79,10 @@ void InputMCF::ParseFile(string nm)
"no parameters tag");
TiXmlElement *mcf = pSession->GetElement("NEKTAR/MESHING");
TiXmlNode *clone = mcf->Clone();
//save meshing tag to end of file
m_mesh->m_infotag->LinkEndChild(clone);
TiXmlElement *info = mcf->FirstChildElement("INFORMATION");
TiXmlElement *I = info->FirstChildElement("I");
......
......@@ -34,8 +34,12 @@
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <chrono>
#include <boost/algorithm/string.hpp>
#include <LibUtilities/BasicConst/GitRevision.h>
#include <boost/program_options.hpp>
#include <boost/asio/ip/host_name.hpp>
#include <boost/format.hpp>
#include <NekMeshUtils/Module/Module.h>
......@@ -43,6 +47,7 @@ using namespace std;
using namespace Nektar::NekMeshUtils;
namespace po = boost::program_options;
namespace ip = boost::asio::ip;
int main(int argc, char* argv[])
{
......@@ -158,6 +163,49 @@ int main(int argc, char* argv[])
*/
MeshSharedPtr mesh = std::shared_ptr<Mesh>(new Mesh());
// add provenance information to mesh
map<string, string> metadata;
// Nektar++ release version from VERSION file
metadata["NektarVersion"] = string(NEKTAR_VERSION);
// Date/time stamp
auto now = std::chrono::system_clock::now();
auto now_t = std::chrono::system_clock::to_time_t(now);
auto now_tm = *std::localtime(&now_t);
char buffer[128];
strftime(buffer, sizeof(buffer), "%d-%b-%Y %H:%M:%S", &now_tm);
metadata["Timestamp"] = buffer;
// Hostname
boost::system::error_code ec;
metadata["Hostname"] = ip::host_name(ec);
// Git information
// If built from a distributed package, do not include this
Nektar::LibUtilities::GitConsts gc = Nektar::LibUtilities::GitConsts();
if (gc.GetSha1() != "GITDIR-NOTFOUND")
{
metadata["GitSHA1"] = gc.GetSha1();
metadata["GitBranch"] = gc.GetBranch();
}
mesh->m_infotag = new TiXmlElement("METADATA");
stringstream ss;
for(int i = 1; i < argc; i++)
{
ss << argv[i] << " ";
}
metadata["CommandString"] = ss.str();
TiXmlElement *provTag = new TiXmlElement("PROVENANCE");
for (auto &infoit : metadata)
{
TiXmlElement *e = new TiXmlElement(infoit.first);
e->LinkEndChild(new TiXmlText(infoit.second));
provTag->LinkEndChild(e);
}
mesh->m_infotag->LinkEndChild(provTag);
vector<ModuleSharedPtr> modules;
vector<string> modcmds;
......
......@@ -113,6 +113,11 @@ void OutputNekpp::Process()
TiXmlElement *root = new TiXmlElement("NEKTAR");
doc.LinkEndChild(root);
//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);
......@@ -126,8 +131,6 @@ void OutputNekpp::Process()
WriteXmlCurves(geomTag);
WriteXmlComposites(geomTag);
WriteXmlDomain(geomTag);
WriteXmlExpansions(root);
WriteXmlConditions(root);
// Extract the output filename and extension
string filename = m_config["outfile"].as<string>();
......
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