From 7f25526526b0c2d1c7fb4e18e13511b313d9ad24 Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Wed, 1 May 2019 22:28:59 +0200
Subject: [PATCH] [spatialparams] Add gravity to the (poro)elastic spatial
 params

---
 dumux/material/spatialparams/fvelastic.hh     | 24 ++++++++++++++++++-
 dumux/material/spatialparams/fvporoelastic.hh | 24 ++++++++++++++++++-
 2 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/dumux/material/spatialparams/fvelastic.hh b/dumux/material/spatialparams/fvelastic.hh
index 15127b4bc5..351625d467 100644
--- a/dumux/material/spatialparams/fvelastic.hh
+++ b/dumux/material/spatialparams/fvelastic.hh
@@ -28,6 +28,7 @@
 
 #include <dune/common/exceptions.hh>
 
+#include <dumux/common/parameters.hh>
 #include <dumux/common/typetraits/isvalid.hh>
 
 namespace Dumux {
@@ -61,11 +62,31 @@ class FVSpatialParamsElastic
     using Element = typename GridView::template Codim<0>::Entity;
     using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
 
+    enum { dimWorld = GridView::dimensionworld };
+
 public:
     //! The constructor
     FVSpatialParamsElastic(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
     : fvGridGeometry_(fvGridGeometry)
-    {}
+    , gravity_(0.0)
+    {
+        const bool enableGravity = getParam<bool>("Problem.EnableGravity");
+        if (enableGravity)
+            gravity_[dimWorld-1]  = -9.81;
+    }
+
+    /*!
+     * \brief Returns the acceleration due to gravity \f$\mathrm{[m/s^2]}\f$.
+     *
+     * The default behaviour is a constant gravity vector;
+     * if the <tt>Problem.EnableGravity</tt> parameter is true,
+     * \f$\boldsymbol{g} = ( 0,\dots,\ -9.81)^T \f$,
+     * else \f$\boldsymbol{g} = ( 0,\dots, 0)^T \f$.
+     *
+     * \param pos the spatial position at which to evaulate the gravity vector
+     */
+    const GlobalPosition& gravity(const GlobalPosition &pos) const
+    { return gravity_; }
 
     /*!
      * \brief Function for defining the solid volume fraction.
@@ -149,6 +170,7 @@ protected:
 
 private:
     std::shared_ptr<const FVGridGeometry> fvGridGeometry_;
+    GlobalPosition gravity_; //!< The gravity vector
 };
 } // end namespace Dumuxs
 #endif
diff --git a/dumux/material/spatialparams/fvporoelastic.hh b/dumux/material/spatialparams/fvporoelastic.hh
index a0725c29d4..e87d7803ce 100644
--- a/dumux/material/spatialparams/fvporoelastic.hh
+++ b/dumux/material/spatialparams/fvporoelastic.hh
@@ -26,6 +26,7 @@
 
 #include <memory>
 
+#include <dumux/common/parameters.hh>
 #include <dumux/common/typetraits/isvalid.hh>
 #include <dumux/material/spatialparams/fv1p.hh>
 
@@ -82,11 +83,31 @@ class FVSpatialParamsPoroElastic
     using Element = typename GridView::template Codim<0>::Entity;
     using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
 
+    enum { dimWorld = GridView::dimensionworld };
+
 public:
     //! The constructor
     FVSpatialParamsPoroElastic(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
     : fvGridGeometry_(fvGridGeometry)
-    {}
+    , gravity_(0.0)
+    {
+        const bool enableGravity = getParam<bool>("Problem.EnableGravity");
+        if (enableGravity)
+            gravity_[dimWorld-1]  = -9.81;
+    }
+
+    /*!
+     * \brief Returns the acceleration due to gravity \f$\mathrm{[m/s^2]}\f$.
+     *
+     * The default behaviour is a constant gravity vector;
+     * if the <tt>Problem.EnableGravity</tt> parameter is true,
+     * \f$\boldsymbol{g} = ( 0,\dots,\ -9.81)^T \f$,
+     * else \f$\boldsymbol{g} = ( 0,\dots, 0)^T \f$.
+     *
+     * \param pos the spatial position at which to evaulate the gravity vector
+     */
+    const GlobalPosition& gravity(const GlobalPosition &pos) const
+    { return gravity_; }
 
     /*!
      * \brief Function for defining the porosity.
@@ -304,6 +325,7 @@ protected:
 
 private:
     std::shared_ptr<const FVGridGeometry> fvGridGeometry_;
+    GlobalPosition gravity_; //!< The gravity vector
 };
 } // end namespace Dumux
 #endif
-- 
GitLab