From ea84ec858d92cf1ed5665fcb071264f008ae1336 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Tue, 30 Sep 2014 20:01:40 +0000 Subject: [PATCH] Properly construct the full filename in situations with more than one process [[Imported from SVN: r9907]] --- dune/gfe/vtkfile.hh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dune/gfe/vtkfile.hh b/dune/gfe/vtkfile.hh index ec9090f6..aa39b6e8 100644 --- a/dune/gfe/vtkfile.hh +++ b/dune/gfe/vtkfile.hh @@ -154,12 +154,18 @@ namespace Dune { */ void read(const std::string& filename) { + std::string fullfilename = filename + ".vtu"; + + // Prepend rank and communicator size to the filename, if there are more than one process + if (commSize_ > 1) + fullfilename = getParallelPieceName(filename, "", commRank_, commSize_); + #if ! HAVE_TINYXML2 DUNE_THROW(Dune::NotImplemented, "You need TinyXML2 for vtk file reading!"); #else tinyxml2::XMLDocument doc; - if (doc.LoadFile(filename.c_str()) != tinyxml2::XML_SUCCESS) - DUNE_THROW(Dune::IOError, "Couldn't open the file '" << filename << "'"); + if (doc.LoadFile(fullfilename.c_str()) != tinyxml2::XML_SUCCESS) + DUNE_THROW(Dune::IOError, "Couldn't open the file '" << fullfilename << "'"); // Get number of cells and number of points tinyxml2::XMLElement* pieceElement = doc.FirstChildElement( "VTKFile" )->FirstChildElement( "UnstructuredGrid" )->FirstChildElement( "Piece" ); -- GitLab