Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer,
es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Die Konten der externen Nutzer:innen sind über den Reiter "Standard" erreichbar.
Die Administratoren


Dear Gitlab user,
it is now possible to log in to our service using the ZIH login/LDAP. The accounts of external users can be accessed via the "Standard" tab.
The administrators

Commit 52771082 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

write vtu files in subdirectories

parent fed1a0df
......@@ -19,7 +19,9 @@
******************************************************************************/
#include "boost/lexical_cast.hpp"
#include <boost/lexical_cast.hpp>
#include <boost/filesystem.hpp>
#include "FileWriter.h"
#include "Initfile.h"
#include "ValueWriter.h"
......@@ -119,12 +121,23 @@ namespace AMDiS
}
std::string fn = filename;
if (createParaViewSubDir) {
using namespace boost::filesystem;
path vtu_path = fn;
path vtu_filename = vtu_path.filename();
vtu_path.remove_filename() /= vtu_filename.stem();
create_directory(vtu_path);
vtu_path /= vtu_filename;
fn = vtu_path.string();
}
#if HAVE_PARALLEL_DOMAIN_AMDIS
std::string paraFilename = fn;
fn += "-p" + boost::lexical_cast<std::string>(MPI::COMM_WORLD.Get_rank()) + "-";
std::string postfix = "";
#endif
if (appendIndex) {
TEST_EXIT(indexLength <= 99)("index lenght > 99\n");
......@@ -174,10 +187,11 @@ namespace AMDiS
}
if (writeParaViewFormat) {
std::string vtu_file = fn + paraviewFileExt;
VtkWriter::Aux vtkWriter(&dataCollectors,
solutionNames,
VtkWriter::Vtuformat(paraViewMode), (paraViewPrecision == 1), writeParaViewVectorFormat);
vtkWriter.writeFile(fn + paraviewFileExt);
vtkWriter.writeFile(vtu_file);
#if HAVE_PARALLEL_DOMAIN_AMDIS
if (MPI::COMM_WORLD.Get_rank() == 0) {
......@@ -206,14 +220,14 @@ namespace AMDiS
}
if (writeParaViewAnimation) {
std::string fn_2 = fn_ + paraviewFileExt;
std::string pvd_file = fn_ + paraviewFileExt;
#if HAVE_PARALLEL_DOMAIN_AMDIS
fn_2 = fn_ + paraviewParallelFileExt;
pvd_file = fn_ + paraviewParallelFileExt;
if (MPI::COMM_WORLD.Get_rank() == 0)
#endif
{
VtkWriter::detail::updateAnimationFile(adaptInfo,
fn_2,
pvd_file,
&paraviewAnimationFrames,
filename + ".pvd");
}
......
......@@ -175,6 +175,9 @@ namespace AMDiS {
/// 1: extend number of component to 3, so that paraview can display the std::vector as worldstd::vector
bool writeAs3dVector;
/// create a subdirectory where to put the vtu file
bool createParaViewSubDir;
/// 0: Don't write ParaView animation file; 1: Write ParaView animation file.
int writeParaViewAnimation;
......
......@@ -165,6 +165,7 @@ namespace AMDiS
Parameters::get(name + "->ParaView vector format", writeParaViewVectorFormat);
Parameters::get(name + "->write vector as 3d vector", writeAs3dVector);
Parameters::get(name + "->ParaView animation", writeParaViewAnimation);
Parameters::get(name + "->ParaView create subdirectory", createParaViewSubDir);
Parameters::get(name + "->ParaView ext", paraviewFileExt);
Parameters::get(name + "->Periodic format", writePeriodicFormat);
Parameters::get(name + "->Periodic ext", periodicFileExt);
......
......@@ -131,6 +131,32 @@ namespace AMDiS { namespace io {
base64.append(writePaddChars,'=');
return base64;
}
std::string extract_relative_path(std::string valueFilename, std::string animationFilename)
{
using namespace boost::filesystem;
path vtu_path = valueFilename;
path pvd_path = animationFilename;
path::iterator it_vtu, it_pvd;
path vtu_path0 = absolute(vtu_path); vtu_path0.remove_filename();
path pvd_path0 = absolute(pvd_path); pvd_path0.remove_filename();
// find matching root directories
for (it_vtu = vtu_path0.begin(), it_pvd = pvd_path0.begin();
it_vtu != vtu_path0.end() && it_pvd != pvd_path0.end() && *it_vtu == *it_pvd;
it_vtu++, it_pvd++) {}
// create relative path
path new_vtu_path;
for (; it_pvd != pvd_path0.end(); it_pvd++)
new_vtu_path /= "..";
for (; it_vtu != vtu_path0.end(); it_vtu++)
new_vtu_path /= *it_vtu;
new_vtu_path /= vtu_path.filename();
return new_vtu_path.string();
}
int updateAnimationFile(AdaptInfo *adaptInfo,
string valueFilename,
......@@ -139,9 +165,8 @@ namespace AMDiS { namespace io {
{
FUNCNAME("updateAnimationFile()");
size_t found = valueFilename.find_last_of("/\\");
paraViewAnimationFrames->push_back(make_pair(adaptInfo->getTime(),
valueFilename.substr(found + 1)));
paraViewAnimationFrames->push_back(
make_pair(adaptInfo->getTime(), extract_relative_path(valueFilename, animationFilename)));
boost::iostreams::filtering_ostream file;
{
......
......@@ -281,6 +281,8 @@ namespace AMDiS { namespace io {
std::string base64Encode(std::string text);
std::string extract_relative_path(std::string valueFilename, std::string animationFilename);
/// Adds a new entry to a ParaView animation file.
int updateAnimationFile(AdaptInfo *adaptInfo,
std::string valueFilename,
......
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