From c007b1f3f32bb070235df130f052aa7363896c86 Mon Sep 17 00:00:00 2001
From: Alexander Jaust <alexander.jaust@ipvs.uni-stuttgart.de>
Date: Wed, 18 Dec 2019 10:04:32 +0100
Subject: [PATCH] added files for reverse coupling of preCICE and DuMuX

---
 .../iterative-reversed/1pspatialparams.hh     | 91 +++++++++++++++++++
 ...recice-config-serial-implicit-reversed.xml | 86 ++++++++++++++++++
 2 files changed, 177 insertions(+)
 create mode 100644 appl/coupling-ff-pm/iterative-reversed/1pspatialparams.hh
 create mode 100644 appl/coupling-ff-pm/iterative-reversed/precice-config-serial-implicit-reversed.xml

diff --git a/appl/coupling-ff-pm/iterative-reversed/1pspatialparams.hh b/appl/coupling-ff-pm/iterative-reversed/1pspatialparams.hh
new file mode 100644
index 0000000..a042388
--- /dev/null
+++ b/appl/coupling-ff-pm/iterative-reversed/1pspatialparams.hh
@@ -0,0 +1,91 @@
+// -*- 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
+ * \ingroup OnePTests
+ * \brief The spatial parameters class for the test problem using the 1p cc model
+ */
+#ifndef DUMUX_1P_TEST_SPATIALPARAMS_HH
+#define DUMUX_1P_TEST_SPATIALPARAMS_HH
+
+#include <dumux/material/spatialparams/fv1p.hh>
+
+namespace Dumux {
+
+/*!
+ * \ingroup OnePModel
+ *
+ * \brief The spatial parameters class for the test problem using the
+ *        1p cc model
+ */
+template<class FVGridGeometry, class Scalar>
+class OnePSpatialParams
+: public FVSpatialParamsOneP<FVGridGeometry, Scalar, OnePSpatialParams<FVGridGeometry, Scalar>>
+{
+    using GridView = typename FVGridGeometry::GridView;
+    using ParentType = FVSpatialParamsOneP<FVGridGeometry, Scalar, OnePSpatialParams<FVGridGeometry, Scalar>>;
+
+    using Element = typename GridView::template Codim<0>::Entity;
+    using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
+
+public:
+    // export permeability type
+    using PermeabilityType = Scalar;
+
+    OnePSpatialParams(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
+    : ParentType(fvGridGeometry)
+    {
+        permeability_ = getParam<Scalar>("Darcy.SpatialParams.Permeability");
+        porosity_ = getParam<Scalar>("Darcy.SpatialParams.Porosity");
+        alphaBJ_ = getParam<Scalar>("Darcy.SpatialParams.AlphaBeaversJoseph");
+    }
+
+    /*!
+     * \brief Function for defining the (intrinsic) permeability \f$[m^2]\f$.
+     *
+     * \param globalPos The global position
+     * \return the intrinsic permeability
+     */
+    PermeabilityType permeabilityAtPos(const GlobalPosition& globalPos) const
+    { return permeability_; }
+
+    /*! \brief Define the porosity in [-].
+     *
+     * \param globalPos The global position
+     */
+    Scalar porosityAtPos(const GlobalPosition& globalPos) const
+    { return porosity_; }
+
+    /*! \brief Define the Beavers-Joseph coefficient in [-].
+     *
+     * \param globalPos The global position
+     */
+    Scalar beaversJosephCoeffAtPos(const GlobalPosition& globalPos) const
+    { return alphaBJ_; }
+
+
+private:
+    Scalar permeability_;
+    Scalar porosity_;
+    Scalar alphaBJ_;
+};
+
+} // end namespace
+
+#endif
diff --git a/appl/coupling-ff-pm/iterative-reversed/precice-config-serial-implicit-reversed.xml b/appl/coupling-ff-pm/iterative-reversed/precice-config-serial-implicit-reversed.xml
new file mode 100644
index 0000000..4df0f6f
--- /dev/null
+++ b/appl/coupling-ff-pm/iterative-reversed/precice-config-serial-implicit-reversed.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+
+<precice-configuration>
+  <log>
+    <sink type="stream" output="stdout"  filter= "(%Severity% > debug) or (%Severity% >= trace and %Module% contains SolverInterfaceImpl)"  enabled="false" /> 
+    <sink type="stream" output="stdout"  enabled="false" /> 
+  </log> 
+
+  <solver-interface dimensions="2">
+
+    <data:scalar name="Velocity"/>
+    <data:scalar name="Pressure"/>
+
+    <mesh name="FreeFlowMesh">
+      <use-data name="Velocity" />
+      <use-data name="Pressure" />
+    </mesh>
+
+    <mesh name="DarcyMesh">
+      <use-data name="Velocity" />
+      <use-data name="Pressure" />
+    </mesh>
+
+    <participant name="FreeFlow">
+      <use-mesh name="FreeFlowMesh" provide="yes"/>
+      <use-mesh name="DarcyMesh" from="Darcy"/>
+
+      <read-data name="Velocity" mesh="FreeFlowMesh"/>
+      <write-data name="Pressure" mesh="FreeFlowMesh"/>
+
+      <mapping:nearest-neighbor direction="write" from="FreeFlowMesh" to="DarcyMesh" constraint="consistent"/>       
+      <mapping:nearest-neighbor direction="read" from="DarcyMesh" to="FreeFlowMesh" constraint="consistent"/> 
+      
+    </participant>
+
+    <participant name="Darcy">
+      <use-mesh name="DarcyMesh" provide="yes"/>
+      <read-data name="Pressure" mesh="DarcyMesh"/>
+      <write-data name="Velocity" mesh="DarcyMesh"/>
+    </participant>
+
+    <m2n:sockets from="FreeFlow" to="Darcy" distribution-type="gather-scatter" network="lo" exchange-directory="/tmp/coupling" />
+    
+    
+    <coupling-scheme:serial-implicit>
+      <max-time value="100"/>
+      <timestep-length value="1" />
+      <max-iterations value="100"/>
+
+
+      <participants first="FreeFlow" second="Darcy"/>
+
+      <!--      
+      <participants first="Darcy" second="FreeFlow"/>
+      -->      
+
+      <exchange data="Pressure" mesh="FreeFlowMesh" from="FreeFlow" to="Darcy" initialize="false" />
+      <exchange data="Velocity" mesh="FreeFlowMesh" from="Darcy" to="FreeFlow" initialize="true" />
+      
+      <!--      
+      <relative-convergence-measure limit="1.0e-6" data="Velocity" mesh="FreeFlowMesh"/>
+      -->
+       
+      <relative-convergence-measure limit="1.0e-8" data="Pressure" mesh="DarcyMesh"/>
+      <relative-convergence-measure limit="1.0e-8" data="Velocity" mesh="DarcyMesh"/>
+
+             
+       <!--
+       <relative-convergence-measure limit="1.0e-2" data="Velocity" mesh="FreeFlowMesh"/>
+       -->
+       <!--
+        <extrapolation-order value="0"/>
+
+        <post-processing:IQN-ILS>
+            <data mesh="DarcyMesh" name="Velocity" />
+            <initial-relaxation value="0.1" />
+            <max-used-iterations value="9" />
+            <timesteps-reused value="10" />
+            <filter type="QR2" limit="1e-3" />
+        </post-processing:IQN-ILS>
+        -->
+           
+    </coupling-scheme:serial-implicit>
+  </solver-interface>
+</precice-configuration>
+
-- 
GitLab