From 6dc98a032b70ebdf05bc11a316a441bb98dbfef6 Mon Sep 17 00:00:00 2001
From: Dmitrij Naumov <dmitrij@naumov.de>
Date: Thu, 13 Nov 2014 01:36:58 +0000
Subject: [PATCH] [PL] Pass output stream to Process::post().

---
 Applications/CLI/ogs.cpp            | 8 +++++++-
 ProcessLib/GroundwaterFlowProcess.h | 2 +-
 ProcessLib/Process.h                | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp
index 1440d0035db..1b35788142c 100644
--- a/Applications/CLI/ogs.cpp
+++ b/Applications/CLI/ogs.cpp
@@ -83,13 +83,19 @@ int main(int argc, char *argv[])
 		(*p_it)->initialize();
 	}
 
+	std::string const output_file_name(project.getOutputFilePrefix() + "_result.dat");
+	DBUG("Create output file %s", output_file_name.c_str());
+	std::ofstream output_file(output_file_name);
+
 	INFO("Solve processes.");
 	for (auto p_it = project.processesBegin(); p_it != project.processesEnd(); ++p_it)
 	{
 		(*p_it)->solve();
-		(*p_it)->post();
+		(*p_it)->post(output_file);
 	}
 
+	output_file.close();
+
 	delete fmt;
 	delete logog_cout;
 	LOGOG_SHUTDOWN();
diff --git a/ProcessLib/GroundwaterFlowProcess.h b/ProcessLib/GroundwaterFlowProcess.h
index 7fe8be2841d..07423a5af2b 100644
--- a/ProcessLib/GroundwaterFlowProcess.h
+++ b/ProcessLib/GroundwaterFlowProcess.h
@@ -133,7 +133,7 @@ public:
         _linearSolver->solve(*_rhs, *_x);
     }
 
-    void post()
+    void post(std::ostream& os)
     {
         DBUG("Postprocessing GroundwaterFlowProcess.");
         // Postprocessing of the linear system of equations solver results:
diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h
index 1fdc4df7bd9..b7cb012aae9 100644
--- a/ProcessLib/Process.h
+++ b/ProcessLib/Process.h
@@ -28,7 +28,10 @@ public:
 
     virtual void initialize() = 0;
     virtual void solve() = 0;
-    virtual void post() = 0;
+
+    /// Postprocessing after solve().
+    /// The output stream is dedicated for the ascii result output.
+    virtual void post(std::ostream& os) = 0;
 
 protected:
     MeshLib::Mesh const& _mesh;
-- 
GitLab