From ad9c0ad54ac379362067154716eddca0fc13b863 Mon Sep 17 00:00:00 2001
From: Michael Sinsbeck <michael@sinsbeck.com>
Date: Thu, 18 Aug 2011 09:20:37 +0000
Subject: [PATCH] Replaced paraview output by viplab output

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@6517 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 .../msm/mcwhorter/mcwhorter_analytic.hh       |  5 ++
 .../lecture/msm/mcwhorter/mcwhorterproblem.hh | 51 +++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/appl/lecture/msm/mcwhorter/mcwhorter_analytic.hh b/appl/lecture/msm/mcwhorter/mcwhorter_analytic.hh
index 30d9c6257f..9a264c8b1b 100644
--- a/appl/lecture/msm/mcwhorter/mcwhorter_analytic.hh
+++ b/appl/lecture/msm/mcwhorter/mcwhorter_analytic.hh
@@ -343,6 +343,11 @@ public:
         updateExSol();
     }
 
+    BlockVector AnalyticSolution() const
+    {
+    	return analyticSolution_;
+    }
+
     //Write saturation and pressure into file
      template<class MultiWriter>
      void addOutputVtkFields(MultiWriter &writer)
diff --git a/appl/lecture/msm/mcwhorter/mcwhorterproblem.hh b/appl/lecture/msm/mcwhorter/mcwhorterproblem.hh
index 439118a85e..f303122399 100644
--- a/appl/lecture/msm/mcwhorter/mcwhorterproblem.hh
+++ b/appl/lecture/msm/mcwhorter/mcwhorterproblem.hh
@@ -134,6 +134,7 @@ class McWhorterProblem: public IMPESProblem2P<TypeTag>
 
     typedef typename GridView::Traits::template Codim<0>::Entity Element;
     typedef typename GridView::Intersection Intersection;
+    typedef typename GridView::template Codim<0>::Iterator ElementIterator;
     typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition;
     typedef Dune::FieldVector<Scalar, dim> LocalPosition;
     typedef typename GET_PROP(TypeTag, PTAG(ParameterTree)) Params;
@@ -152,6 +153,11 @@ public:
        analyticSolution_(*this)
      {
         this->setOutputInterval(10);
+
+        //Write header for ViPLab-Outputfile
+    	std::ofstream dataFile;
+		dataFile.open("vipplot.vgf");
+		dataFile.close();
      }
 
     /*!
@@ -240,6 +246,51 @@ public:
         values = 0;
     }
 
+    //Override outputfunction for ViPLab-Output
+    void writeOutput()
+    {
+    	double time = this->timeManager().time();
+    	if (time < 0)
+    		return;
+
+    	std::ofstream dataFile;
+		dataFile.open("vipplot.vgf", std::fstream::app);
+
+    	std::cout<<"Writing output for time step.\n";
+
+    	if (time  > 0)
+    		dataFile << "# newframe\n";
+
+		dataFile << "# title Mc Whorther Problem\n";
+		dataFile << "# x-label x\n";
+		dataFile << "# y-label Saturation\n";
+		dataFile << "# color 0 0 0\n";
+//		dataFile << "# symbol none";
+//		dataFile << "# linestyle solid";
+		ElementIterator eItEnd = this->gridView().template end<0>();
+	    for (ElementIterator eIt = this->gridView().template begin<0>(); eIt != eItEnd; ++eIt)
+	    {
+	    	int currentIdx = this->variables().index(*eIt);
+	    	Scalar sat = this->variables().saturation()[currentIdx];
+	    	Scalar leftPos = eIt->geometry().corner(0)[0];
+	    	Scalar rightPos = eIt->geometry().corner(1)[0];
+	    	dataFile << leftPos <<" "<<sat<<" "<<rightPos<<" "<<sat<<"\n";
+	    }
+
+		dataFile << "# color 0 0 255\n";
+		for (ElementIterator eIt = this->gridView().template begin<0>(); eIt != eItEnd; ++eIt)
+	    {
+	    	int currentIdx = this->variables().index(*eIt);
+	    	Scalar sat = analyticSolution_.AnalyticSolution()[currentIdx];
+	    	Scalar leftPos = eIt->geometry().corner(0)[0];
+	    	Scalar rightPos = eIt->geometry().corner(1)[0];
+	    	dataFile << leftPos <<" "<<sat<<" "<<rightPos<<" "<<sat<<"\n";
+	    }
+		dataFile << "# legend Numerical Solution, Analytic Solution\n";
+		dataFile.close();
+    }
+
+
   /*  McWhorterProblem(VC& variables, Fluid& wettingphase, Fluid& nonwettingphase,
             Matrix2p<Grid, Scalar>& soil, TwoPhaseRelations<Grid, Scalar>& materialLaw = *(new TwoPhaseRelations<Grid,Scalar>&),
             const GlobalPosition Right = 0)
-- 
GitLab