Commit a071247e authored by Spencer Sherwin's avatar Spencer Sherwin

Modified to make MetricFile check parallel .fld files

parent 66b19fc8
......@@ -40,6 +40,12 @@
#include <string>
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <boost/version.hpp>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
std::string PortablePath(const boost::filesystem::path& path);
namespace Nektar
{
......
......@@ -82,28 +82,59 @@ namespace Nektar
std::string MetricFile::CalculateHash(std::string pfilename)
{
int fdot = pfilename.find_last_of('.');
int fdot = pfilename.find_last_of('.');
string ending = pfilename.substr(fdot);
string filename;
if(ending == ".fld" || ending == ".chk" || ending == ".rst")
{
TiXmlDocument *xmlFldFile = new TiXmlDocument(pfilename);
xmlFldFile->LoadFile(pfilename);
TiXmlDocument *xmlFldFile;
fs::path pathfilename(pfilename);
// strip out meta data before check
TiXmlElement* vNektar =
xmlFldFile->FirstChildElement("NEKTAR");
TiXmlNode* vMetaData =
vNektar->FirstChild("Metadata");
if(vMetaData) // delete section
if(fs::is_directory(pathfilename))
{
vNektar->RemoveChild(vMetaData);
std::vector<fs::path> dirfiles;
// make list of all files in directoryj
copy(fs::directory_iterator(pathfilename),
fs::directory_iterator(),
back_inserter(dirfiles));
xmlFldFile = new TiXmlDocument;
// load all them into the
for(int i = 0; i < dirfiles.size(); ++i)
{
std::string infile = PortablePath(dirfiles[i]);
std::ifstream file(infile.c_str());
ASSERTL0(file.good(), "Unable to open file: " + infile);
file >> (*xmlFldFile);
}
}
else
{
xmlFldFile = new TiXmlDocument(pfilename);
xmlFldFile->LoadFile(pfilename);
}
// strip out meta data before check
TiXmlElement* vNektar = xmlFldFile->FirstChildElement("NEKTAR");
while(vNektar)
{
TiXmlNode* vMetaData = vNektar->FirstChild("Metadata");
// delete MetaData section
if(vMetaData)
{
vNektar->RemoveChild(vMetaData);
}
vNektar = vNektar->NextSiblingElement("NEKTAR");
}
filename = pfilename + ".tmp";
xmlFldFile->SaveFile(filename);
}
else
{
......
......@@ -41,8 +41,6 @@
#include <TestData.h>
#include <Metric.h>
#include <boost/filesystem.hpp>
#include <boost/version.hpp>
#include <boost/program_options.hpp>
#include <boost/thread.hpp>
......@@ -51,9 +49,8 @@ using namespace Nektar;
// Define some namespace aliases
namespace po = boost::program_options;
namespace fs = boost::filesystem;
string PortablePath(const boost::filesystem::path& path)
std::string PortablePath(const boost::filesystem::path& path)
{
boost::filesystem::path temp = path;
#if BOOST_VERSION > 104200
......
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