Skip to content
Snippets Groups Projects
Commit 85c6bc98 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Add generation info to .vtu and .pvtu files

parent 7f2eefae
No related branches found
No related tags found
1 merge request!75Feature/language discretization
......@@ -3,7 +3,9 @@
#include <mesh/Connectivity.hpp>
#include <mesh/Mesh.hpp>
#include <utils/Messenger.hpp>
#include <utils/RevisionInfo.hpp>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <sstream>
......@@ -18,6 +20,22 @@ VTKWriter::_getFilenamePVTU() const
return sout.str();
}
std::string
VTKWriter::_getDateAndVersionComment() const
{
std::ostringstream os;
std::time_t now = std::time(nullptr);
os << "<!--\n";
os << " Generated by pugs: " << std::ctime(&now);
os << " version: " << RevisionInfo::version() << '\n';
os << " tag: " << RevisionInfo::gitTag() << '\n';
os << " HEAD: " << RevisionInfo::gitHead() << '\n';
os << " hash: " << RevisionInfo::gitHash() << " (" << ((RevisionInfo::gitIsClean()) ? "clean" : "dirty") << ")\n";
os << "-->\n";
return os.str();
}
std::string
VTKWriter::_getFilenameVTU(int rank_number) const
{
......@@ -269,6 +287,7 @@ VTKWriter::_write(const std::shared_ptr<const MeshType>& mesh,
if (parallel::rank() == 0) { // write PVTK file
std::ofstream fout(_getFilenamePVTU());
fout << "<?xml version=\"1.0\"?>\n";
fout << _getDateAndVersionComment();
fout << "<VTKFile type=\"PUnstructuredGrid\">\n";
fout << "<PUnstructuredGrid GhostLevel=\"0\">\n";
......@@ -318,6 +337,7 @@ VTKWriter::_write(const std::shared_ptr<const MeshType>& mesh,
{ // write VTK files
std::ofstream fout(_getFilenameVTU(parallel::rank()));
fout << "<?xml version=\"1.0\"?>\n";
fout << _getDateAndVersionComment();
fout << "<VTKFile type=\"UnstructuredGrid\">\n";
fout << "<UnstructuredGrid>\n";
fout << "<Piece NumberOfPoints=\"" << mesh->numberOfNodes() << "\" NumberOfCells=\"" << mesh->numberOfCells()
......
......@@ -19,6 +19,8 @@ class VTKWriter : public IWriter
mutable double m_last_time;
const double m_time_period;
std::string _getDateAndVersionComment() const;
std::string _getFilenamePVTU() const;
std::string _getFilenameVTU(int rank_number) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment