From 6436e152c44ef7ef0c049750e5f0fa446514b048 Mon Sep 17 00:00:00 2001
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
Date: Tue, 4 Dec 2012 21:37:28 +0000
Subject: [PATCH] implicit branch: unify 2pni test.

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/branches/implicit@9775 2fb0f335-1f38-0410-981e-8018bf24f1b0
---
 test/implicit/2pni/Makefile.am                |  5 +-
 test/implicit/2pni/injectionproblem2pni.hh    | 52 ++++++++-------
 test/implicit/2pni/test_box2pni.cc            | 64 +++++++++++++++++++
 test/implicit/2pni/test_box2pni.input         | 35 ++++++++++
 .../2pni/{test_2pni.cc => test_cc2pni.cc}     |  2 +-
 .../{test_2pni.input => test_cc2pni.input}    |  3 +
 6 files changed, 134 insertions(+), 27 deletions(-)
 create mode 100644 test/implicit/2pni/test_box2pni.cc
 create mode 100644 test/implicit/2pni/test_box2pni.input
 rename test/implicit/2pni/{test_2pni.cc => test_cc2pni.cc} (98%)
 rename test/implicit/2pni/{test_2pni.input => test_cc2pni.input} (96%)

diff --git a/test/implicit/2pni/Makefile.am b/test/implicit/2pni/Makefile.am
index 11103a5c67..f41884d166 100644
--- a/test/implicit/2pni/Makefile.am
+++ b/test/implicit/2pni/Makefile.am
@@ -1,8 +1,9 @@
-check_PROGRAMS = test_2pni
+check_PROGRAMS = test_box2pni test_cc2pni
 
 noinst_HEADERS = *.hh
 EXTRA_DIST=*reference.vtu *.input grids/*.dgf CMakeLists.txt
 
-test_2pni_SOURCES = test_2pni.cc
+test_box2pni_SOURCES = test_box2pni.cc
+test_cc2pni_SOURCES = test_cc2pni.cc
 
 include $(top_srcdir)/am/global-rules
diff --git a/test/implicit/2pni/injectionproblem2pni.hh b/test/implicit/2pni/injectionproblem2pni.hh
index d3b4407fbf..1b8406996f 100644
--- a/test/implicit/2pni/injectionproblem2pni.hh
+++ b/test/implicit/2pni/injectionproblem2pni.hh
@@ -53,9 +53,13 @@ class InjectionProblem2PNI;
 namespace Properties
 {
 #if !ISOTHERMAL
-NEW_TYPE_TAG(InjectionProblem2PNI, INHERITS_FROM(BoxTwoPNI, InjectionSpatialParams));
+NEW_TYPE_TAG(InjectionProblem2PNI, INHERITS_FROM(TwoPNI, InjectionSpatialParams));
+NEW_TYPE_TAG(InjectionBoxProblem2PNI, INHERITS_FROM(BoxModel, InjectionProblem2PNI));
+NEW_TYPE_TAG(InjectionCCProblem2PNI, INHERITS_FROM(CCModel, InjectionProblem2PNI));
 #else
-NEW_TYPE_TAG(InjectionProblem2PNI, INHERITS_FROM(BoxTwoP, InjectionSpatialParams));
+NEW_TYPE_TAG(InjectionProblem2PNI, INHERITS_FROM(TwoP, InjectionSpatialParams));
+NEW_TYPE_TAG(InjectionBoxProblem2PNI, INHERITS_FROM(BoxModel, InjectionProblem2PNI));
+NEW_TYPE_TAG(InjectionCCProblem2PNI, INHERITS_FROM(CCModel, InjectionProblem2PNI));
 #endif
 
 // set the GridCreator property
@@ -184,6 +188,8 @@ class InjectionProblem2PNI : public ImplicitPorousMediaProblem<TypeTag>
 
     typedef Dune::FieldVector<Scalar, dimWorld> GlobalPosition;
 
+    enum { isBox = GET_PROP_VALUE(TypeTag, ImplicitIsBox) };
+    
 public:
     /*!
      * \brief The constructor
@@ -204,6 +210,8 @@ public:
                 /*pMin=*/0.0,
                 /*pMax=*/30e6,
                 /*numP=*/300);
+        
+        name_               = GET_RUNTIME_PARAM(TypeTag, std::string, Problem.Name);
     }
 
     /*!
@@ -216,8 +224,8 @@ public:
      *
      * This is used as a prefix for files generated by the simulation.
      */
-    const char *name() const
-    { return "injection2pni"; }
+    const std::string name() const
+    { return name_; }
 
 #if ISOTHERMAL
     /*!
@@ -255,12 +263,11 @@ 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
@@ -278,14 +285,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();
-
         Scalar densityW = 1000.0;
         values[pressureIdx] = 1e5 + (maxDepth_ - globalPos[1])*densityW*9.81;
         values[saturationIdx] = 0.0;
@@ -315,10 +320,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) {
             // inject air. negative values mean injection
             values[contiNEqIdx] = -1e-3; // kg/(s*m^2)
         }
@@ -336,20 +346,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 fvElemGeom 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 &fvElemGeom,
-                 int scvIdx) const
+    void initialAtPos(PrimaryVariables &values, const GlobalPosition &globalPos) const
     {
-        const GlobalPosition &globalPos = element.geometry().corner(scvIdx);
-
         Scalar densityW = 1000.0;
         values[pressureIdx] = 1e5 + (maxDepth_ - globalPos[1])*densityW*9.81;
         values[saturationIdx] = 0.0;
@@ -365,6 +368,7 @@ public:
 private:
     Scalar maxDepth_;
     Scalar eps_;
+    std::string name_;
 };
 } //end namespace
 
diff --git a/test/implicit/2pni/test_box2pni.cc b/test/implicit/2pni/test_box2pni.cc
new file mode 100644
index 0000000000..088c422b01
--- /dev/null
+++ b/test/implicit/2pni/test_box2pni.cc
@@ -0,0 +1,64 @@
+// -*- 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 2pni box model
+ */
+#include "config.h"
+
+#include "injectionproblem2pni.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.NumberOfCellsX   Resolution in x-direction [-]\n"
+                                        "\t-Grid.NumberOfCellsY   Resolution in y-direction [-]\n"
+                                        "\t-Grid.UpperRightX      Length of the domain [m]\n"
+                                        "\t-Grid.UpperRightY      Height of the domain [m]\n";
+
+        std::cout << errorMessageOut
+                  << "\n";
+    }
+}
+
+////////////////////////
+// the main function
+////////////////////////
+int main(int argc, char** argv)
+{
+    typedef TTAG(InjectionBoxProblem2PNI) ProblemTypeTag;
+    return Dumux::start<ProblemTypeTag>(argc, argv, usage);
+}
diff --git a/test/implicit/2pni/test_box2pni.input b/test/implicit/2pni/test_box2pni.input
new file mode 100644
index 0000000000..9ad979da37
--- /dev/null
+++ b/test/implicit/2pni/test_box2pni.input
@@ -0,0 +1,35 @@
+###############################################################
+# Parameter file for test_2pni.
+# Everything behind a '#' is a comment.
+# Type "./test_2pni --help" for more information.
+###############################################################
+
+###############################################################
+# Mandatory arguments
+###############################################################
+
+[TimeManager]
+DtInitial = 250 # [s]
+TEnd = 1e4 # [s]
+
+[Grid]
+NumberOfCellsX = 24 # [-] resolution in x-direction
+NumberOfCellsY = 16 # [-] resolution in y-direction
+
+UpperRightX = 60 # [m] length of the domain
+UpperRightY = 40 # [m] height of the domain
+
+[Problem]
+Name = injection2pnibox
+
+###############################################################
+# 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/2pni/test_2pni.cc b/test/implicit/2pni/test_cc2pni.cc
similarity index 98%
rename from test/implicit/2pni/test_2pni.cc
rename to test/implicit/2pni/test_cc2pni.cc
index b4364de244..81e6f4540b 100644
--- a/test/implicit/2pni/test_2pni.cc
+++ b/test/implicit/2pni/test_cc2pni.cc
@@ -59,6 +59,6 @@ void usage(const char *progName, const std::string &errorMsg)
 ////////////////////////
 int main(int argc, char** argv)
 {
-    typedef TTAG(InjectionProblem2PNI) ProblemTypeTag;
+    typedef TTAG(InjectionCCProblem2PNI) ProblemTypeTag;
     return Dumux::start<ProblemTypeTag>(argc, argv, usage);
 }
diff --git a/test/implicit/2pni/test_2pni.input b/test/implicit/2pni/test_cc2pni.input
similarity index 96%
rename from test/implicit/2pni/test_2pni.input
rename to test/implicit/2pni/test_cc2pni.input
index c337b84d4a..6eebc39399 100644
--- a/test/implicit/2pni/test_2pni.input
+++ b/test/implicit/2pni/test_cc2pni.input
@@ -19,6 +19,9 @@ NumberOfCellsY = 16 # [-] resolution in y-direction
 UpperRightX = 60 # [m] length of the domain
 UpperRightY = 40 # [m] height of the domain
 
+[Problem]
+Name = injection2pnicc
+
 ###############################################################
 # Simulation restart
 #
-- 
GitLab