From 219e6c8af2eb70be80a130f014d76bf05a48801b Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Sun, 8 Jun 2014 09:48:15 +0000 Subject: [PATCH] Prepend communicator rank and size to the filename when writing a distributed grid Otherwise, all processes will write into the same file --> not a good idea. [[Imported from SVN: r9776]] --- dune/gfe/cosseratvtkwriter.hh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dune/gfe/cosseratvtkwriter.hh b/dune/gfe/cosseratvtkwriter.hh index 76901acd..eba8499e 100644 --- a/dune/gfe/cosseratvtkwriter.hh +++ b/dune/gfe/cosseratvtkwriter.hh @@ -202,7 +202,17 @@ public: #elif defined SECOND_ORDER // Write as P2 space - std::ofstream outFile(filename + ".vtu"); + std::stringstream fullfilename; + + // Prepend rank and communicator size to the filename, if there are more than one process + if (gridView.comm().size() > 1) + { + fullfilename << 's' << std::setw(4) << std::setfill('0') << gridView.comm().size() << '-'; + fullfilename << 'p' << std::setw(4) << std::setfill('0') << gridView.comm().rank() << '-'; + fullfilename << filename; + } + + std::ofstream outFile(fullfilename.str() + ".vtu"); // Write header outFile << "<?xml version=\"1.0\"?>" << std::endl; -- GitLab