From 6f7f334f930a8fcd742a4b2de2fb5572925eaa84 Mon Sep 17 00:00:00 2001
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
Date: Tue, 4 Dec 2012 13:16:49 +0000
Subject: [PATCH] implicit branch: unify 2p2c test problem

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/branches/implicit@9764 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 test/implicit/2p2c/Makefile.am                |  5 +-
 test/implicit/2p2c/injectionproblem.hh        | 42 ++++++------
 test/implicit/2p2c/test_box2p2c.cc            | 67 +++++++++++++++++++
 test/implicit/2p2c/test_box2p2c.input         | 42 ++++++++++++
 .../2p2c/{test_2p2c.cc => test_cc2p2c.cc}     |  2 +-
 .../{test_2p2c.input => test_cc2p2c.input}    |  2 +-
 6 files changed, 134 insertions(+), 26 deletions(-)
 create mode 100644 test/implicit/2p2c/test_box2p2c.cc
 create mode 100644 test/implicit/2p2c/test_box2p2c.input
 rename test/implicit/2p2c/{test_2p2c.cc => test_cc2p2c.cc} (98%)
 rename test/implicit/2p2c/{test_2p2c.input => test_cc2p2c.input} (96%)

diff --git a/test/implicit/2p2c/Makefile.am b/test/implicit/2p2c/Makefile.am
index 5acdf0abf9..64ecc40198 100644
--- a/test/implicit/2p2c/Makefile.am
+++ b/test/implicit/2p2c/Makefile.am
@@ -1,8 +1,9 @@
-check_PROGRAMS = test_2p2c
+check_PROGRAMS = test_box2p2c test_cc2p2c
 
 noinst_HEADERS = *.hh
 EXTRA_DIST=*reference.vtu *.input grids/*.dgf CMakeLists.txt
 
-test_2p2c_SOURCES = test_2p2c.cc
+test_box2p2c_SOURCES = test_box2p2c.cc
+test_cc2p2c_SOURCES = test_cc2p2c.cc
 
 include $(top_srcdir)/am/global-rules
diff --git a/test/implicit/2p2c/injectionproblem.hh b/test/implicit/2p2c/injectionproblem.hh
index 6faef0455e..a7d92f5fb5 100644
--- a/test/implicit/2p2c/injectionproblem.hh
+++ b/test/implicit/2p2c/injectionproblem.hh
@@ -40,8 +40,10 @@ class InjectionProblem;
 
 namespace Properties
 {
-NEW_TYPE_TAG(InjectionProblem, INHERITS_FROM(BoxTwoPTwoC, InjectionSpatialParams));
-
+NEW_TYPE_TAG(InjectionProblem, INHERITS_FROM(TwoPTwoC, InjectionSpatialParams));
+NEW_TYPE_TAG(InjectionBoxProblem, INHERITS_FROM(BoxModel, InjectionProblem));
+NEW_TYPE_TAG(InjectionCCProblem, INHERITS_FROM(CCModel, InjectionProblem));
+    
 // Set the grid type
 SET_PROP(InjectionProblem, Grid)
 {
@@ -130,6 +132,8 @@ class InjectionProblem : public ImplicitPorousMediaProblem<TypeTag>
     typedef typename GET_PROP_TYPE(TypeTag, GridCreator) GridCreator;
 
     typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition;
+    
+    enum { isBox = GET_PROP_VALUE(TypeTag, ImplicitIsBox) };
 
 public:
     /*!
@@ -243,12 +247,10 @@ public:
      *        used for which equation on a given boundary segment.
      *
      * \param values The boundary types for the conservation equations
-     * \param vertex The vertex for which the boundary type is set
+     * \param globalPos The position for which the bc type should be evaluated
      */
-    void boundaryTypes(BoundaryTypes &values, const Vertex &vertex) const
+    void boundaryTypesAtPos(BoundaryTypes &values, const GlobalPosition &globalPos) const
     {
-        const GlobalPosition globalPos = vertex.geometry().center();
-
         if (globalPos[0] < eps_)
             values.setAllDirichlet();
         else
@@ -260,14 +262,12 @@ public:
      *        boundary segment.
      *
      * \param values The dirichlet values for the primary variables
-     * \param vertex The vertex for which the boundary type is set
+     * \param globalPos The position for which the bc type should be evaluated
      *
      * For this method, the \a values parameter stores primary variables.
      */
-    void dirichlet(PrimaryVariables &values, const Vertex &vertex) const
+    void dirichletAtPos(PrimaryVariables &values, const GlobalPosition &globalPos) const
     {
-        const GlobalPosition globalPos = vertex.geometry().center();
-
         initial_(values, globalPos);
     }
 
@@ -292,10 +292,15 @@ public:
                  int scvIdx,
                  int boundaryFaceIdx) const
     {
-        const GlobalPosition &globalPos = element.geometry().corner(scvIdx);
-
         values = 0;
-        if (globalPos[1] < 15 && globalPos[1] > 5) {
+        
+        GlobalPosition globalPos;
+        if (isBox)
+            globalPos = element.geometry().corner(scvIdx);
+        else 
+            globalPos = is.geometry().center();
+
+        if (globalPos[1] < 15 && globalPos[1] > 7) {
             values[contiN2EqIdx] = -1e-3; // kg/(s*m^2)
         }
     }
@@ -311,20 +316,13 @@ public:
      * \brief Evaluate the initial value for a control volume.
      *
      * \param values The initial values for the primary variables
-     * \param element The finite element
-     * \param fvGeometry The finite-volume geometry in the box scheme
-     * \param scvIdx The local vertex index
+     * \param globalPos The position for which the initial condition should be evaluated
      *
      * For this method, the \a values parameter stores primary
      * variables.
      */
-    void initial(PrimaryVariables &values,
-                 const Element &element,
-                 const FVElementGeometry &fvGeometry,
-                 int scvIdx) const
+    void initialAtPos(PrimaryVariables &values, const GlobalPosition &globalPos) const
     {
-        const GlobalPosition &globalPos = element.geometry().corner(scvIdx);
-
         initial_(values, globalPos);
     }
 
diff --git a/test/implicit/2p2c/test_box2p2c.cc b/test/implicit/2p2c/test_box2p2c.cc
new file mode 100644
index 0000000000..03dd3a88b5
--- /dev/null
+++ b/test/implicit/2p2c/test_box2p2c.cc
@@ -0,0 +1,67 @@
+// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// vi: set et ts=4 sw=4 sts=4:
+/*****************************************************************************
+ *   See the file COPYING for full copying permissions.                      *
+ *                                                                           *
+ *   This program is free software: you can redistribute it and/or modify    *
+ *   it under the terms of the GNU General Public License as published by    *
+ *   the Free Software Foundation, either version 2 of the License, or       *
+ *   (at your option) any later version.                                     *
+ *                                                                           *
+ *   This program is distributed in the hope that it will be useful,         *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
+ *   GNU General Public License for more details.                            *
+ *                                                                           *
+ *   You should have received a copy of the GNU General Public License       *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
+ *****************************************************************************/
+/*!
+ * \file
+ *
+ * \brief Test for the 2p2c box model.
+ */
+#include "config.h"
+#include "injectionproblem.hh"
+#include <dumux/common/start.hh>
+
+/*!
+ * \brief Provides an interface for customizing error messages associated with
+ *        reading in parameters.
+ *
+ * \param progName  The name of the program, that was tried to be started.
+ * \param errorMsg  The error message that was issued by the start function.
+ *                  Comprises the thing that went wrong and a general help message.
+ */
+void usage(const char *progName, const std::string &errorMsg)
+{
+    if (errorMsg.size() > 0) {
+        std::string errorMessageOut = "\nUsage: ";
+                    errorMessageOut += progName;
+                    errorMessageOut += " [options]\n";
+                    errorMessageOut += errorMsg;
+                    errorMessageOut += "\n\nThe list of mandatory options for this program is:\n"
+                                        "\t-TimeManager.TEnd              End of the simulation [s] \n"
+                                        "\t-TimeManager.DtInitial         Initial timestep size [s] \n"
+                                        "\t-Grid.File                     Name of the file containing the grid \n"
+                                        "\t                               definition in DGF format\n"
+                                        "\t-FluidSystem.NTemperature      Number of tabularization entries [-] \n"
+                                        "\t-FluidSystem.NPressure         Number of tabularization entries [-] \n"
+                                        "\t-FluidSystem.PressureLow       Low end for tabularization of fluid properties [Pa] \n"
+                                        "\t-FluidSystem.PressureHigh      High end for tabularization of fluid properties [Pa] \n"
+                                        "\t-FluidSystem.TemperatureLow    Low end for tabularization of fluid properties [Pa] \n"
+                                        "\t-FluidSystem.TemperatureHigh   High end for tabularization of fluid properties [Pa] \n"
+                                        "\t-SimulationControl.Name        The name of the output files [-] \n"
+                                        "\t-InitialConditions.Temperature Initial temperature in the reservoir [K] \n"
+                                        "\t-InitialConditions.DepthBOR    Depth below ground surface [m] \n";
+
+        std::cout << errorMessageOut
+                  << "\n";
+    }
+}
+
+int main(int argc, char** argv)
+{
+    typedef TTAG(InjectionBoxProblem) ProblemTypeTag;
+    return Dumux::start<ProblemTypeTag>(argc, argv, usage);
+}
diff --git a/test/implicit/2p2c/test_box2p2c.input b/test/implicit/2p2c/test_box2p2c.input
new file mode 100644
index 0000000000..103b865b9f
--- /dev/null
+++ b/test/implicit/2p2c/test_box2p2c.input
@@ -0,0 +1,42 @@
+###############################################################
+# Parameter file for test_2p2c.
+# Everything behind a '#' is a comment.
+# Type "./test_2p2c --help" for more information.
+###############################################################
+
+###############################################################
+# Mandatory arguments
+###############################################################
+
+[TimeManager]
+DtInitial = 250 # [s]
+TEnd = 1e4 # [s]
+
+[Grid]
+File = ./grids/test_2p2c.dgf 
+
+[Problem]
+Name = injectionbox # [-] the name of the output files
+
+InitialTemperature = 313.15 # [K] 40°C initial temperature in the reservoir
+DepthBOR = 2700 # [m] depth below ground surface 
+
+# tabularization 
+NTemperature = 3 # [-] number of temperature table entries
+NPressure = 200 # [-] number of pressure table entries
+PressureLow = 1e5 # [Pa] lower pressure limit for tabularization
+PressureHigh = 3e7 # [Pa] upper pressure limit for tabularization
+TemperatureLow = 312.15 # [Pa] lower temperature limit for tabularization
+TemperatureHigh = 314.15 # [Pa] upper temperature limit for tabularization
+
+###############################################################
+# Simulation restart
+#
+# DuMux simulations can be restarted from *.drs files
+# Set Restart to the value of a specific file, 
+# e.g.:  'Restart = 27184.1' for the restart file
+# name_time=27184.1_rank=0.drs
+# Please comment in the two lines below, if restart is desired.
+###############################################################
+# [TimeManager]
+# Restart = ... 
diff --git a/test/implicit/2p2c/test_2p2c.cc b/test/implicit/2p2c/test_cc2p2c.cc
similarity index 98%
rename from test/implicit/2p2c/test_2p2c.cc
rename to test/implicit/2p2c/test_cc2p2c.cc
index 0c1daa929a..48fb4ba1fa 100644
--- a/test/implicit/2p2c/test_2p2c.cc
+++ b/test/implicit/2p2c/test_cc2p2c.cc
@@ -62,6 +62,6 @@ void usage(const char *progName, const std::string &errorMsg)
 
 int main(int argc, char** argv)
 {
-    typedef TTAG(InjectionProblem) ProblemTypeTag;
+    typedef TTAG(InjectionCCProblem) ProblemTypeTag;
     return Dumux::start<ProblemTypeTag>(argc, argv, usage);
 }
diff --git a/test/implicit/2p2c/test_2p2c.input b/test/implicit/2p2c/test_cc2p2c.input
similarity index 96%
rename from test/implicit/2p2c/test_2p2c.input
rename to test/implicit/2p2c/test_cc2p2c.input
index e5d98a4cd0..e1aed4b660 100644
--- a/test/implicit/2p2c/test_2p2c.input
+++ b/test/implicit/2p2c/test_cc2p2c.input
@@ -16,7 +16,7 @@ TEnd = 1e4 # [s]
 File = ./grids/test_2p2c.dgf 
 
 [Problem]
-Name = injection # [-] the name of the output files
+Name = injectioncc # [-] the name of the output files
 
 InitialTemperature = 313.15 # [K] 40°C initial temperature in the reservoir
 DepthBOR = 2700 # [m] depth below ground surface 
-- 
GitLab