From b2b984da796f7ab329061d5da5c2b764e0313def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 11:51:13 +0200 Subject: [PATCH 01/17] [common] add base spatial params --- dumux/common/fvspatialparams.hh | 85 +++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 dumux/common/fvspatialparams.hh diff --git a/dumux/common/fvspatialparams.hh b/dumux/common/fvspatialparams.hh new file mode 100644 index 0000000000..4751bb62ba --- /dev/null +++ b/dumux/common/fvspatialparams.hh @@ -0,0 +1,85 @@ +// -*- 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 3 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 . * + *****************************************************************************/ +/*! + * \file + * \ingroup Common + * \ingroup SpatialParameters + * \brief Basic spatial parameters + */ +#ifndef DUMUX_COMMON_FV_SPATIAL_PARAMS_BASE_HH +#define DUMUX_COMMON_FV_SPATIAL_PARAMS_BASE_HH + +#include + +#include +#include + +namespace Dumux { + +/*! + * \ingroup SpatialParameters + * \brief The base class for spatial parameters of multi-phase problems + * using a fully implicit discretization method. + */ +template +class FVSpatialParamsBase +{ + using GridView = typename GridGeometry::GridView; + using Element = typename GridView::template Codim<0>::Entity; + + static constexpr int dimWorld = GridView::dimensionworld; + + using GlobalPosition = typename Element::Geometry::GlobalCoordinate; + using GravityVector = Dune::FieldVector; + +public: + FVSpatialParamsBase(std::shared_ptr gridGeometry) + : gridGeometry_(gridGeometry) + , gravity_(0.0) + { + if (getParam("Problem.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 Problem.EnableGravity 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 GravityVector& gravity(const GlobalPosition& pos) const + { return gravity_; } + + //! The finite volume grid geometry + const GridGeometry& gridGeometry() const + { return *gridGeometry_; } + +private: + std::shared_ptr gridGeometry_; + GravityVector gravity_; +}; + +} // namespace Dumux + +#endif -- GitLab From b210d77c76b97c75509853c8f9b087cf20f1a0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Tue, 19 Oct 2021 09:12:32 +0200 Subject: [PATCH 02/17] [spatialparamsbase] add extrusion factor interface --- dumux/common/fvspatialparams.hh | 62 +++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/dumux/common/fvspatialparams.hh b/dumux/common/fvspatialparams.hh index 4751bb62ba..156c8e3477 100644 --- a/dumux/common/fvspatialparams.hh +++ b/dumux/common/fvspatialparams.hh @@ -34,15 +34,16 @@ namespace Dumux { /*! * \ingroup SpatialParameters - * \brief The base class for spatial parameters of multi-phase problems - * using a fully implicit discretization method. + * \brief The base class for spatial parameters. */ template + class Scalar, + class Implementation> class FVSpatialParamsBase { using GridView = typename GridGeometry::GridView; using Element = typename GridView::template Codim<0>::Entity; + using SubControlVolume = typename GridGeometry::SubControlVolume; static constexpr int dimWorld = GridView::dimensionworld; @@ -58,6 +59,34 @@ public: gravity_[dimWorld-1] = -9.81; } + /*! + * \brief Return how much the domain is extruded at a given sub-control volume. + * + * This means the factor by which a lower-dimensional (1D or 2D) + * entity needs to be expanded to get a full dimensional cell. The + * default is 1.0 which means that 1D problems are actually + * thought as pipes with a cross section of 1 m^2 and 2D problems + * are assumed to extend 1 m to the back. + */ + template + Scalar extrusionFactor(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol) const + { + // forward to generic interface + return asImp_().extrusionFactorAtPos(scv.center()); + } + + /*! + * \brief Return how much the domain is extruded at a given position. + */ + Scalar extrusionFactorAtPos(const GlobalPosition& globalPos) const + { + // As a default, i.e. if the user's problem does not overload + // any extrusion factor method, return 1.0 + return 1.0; + } + /*! * \brief Returns the acceleration due to gravity \f$\mathrm{[m/s^2]}\f$. * @@ -75,11 +104,38 @@ public: const GridGeometry& gridGeometry() const { return *gridGeometry_; } +protected: + //! Returns the implementation of the spatial parameters (static polymorphism) + Implementation &asImp_() + { return *static_cast(this); } + + //! \copydoc asImp_() + const Implementation &asImp_() const + { return *static_cast(this); } + private: std::shared_ptr gridGeometry_; GravityVector gravity_; }; +/*! + * \ingroup SpatialParameters + * \brief Default spatial parameters class to be reused in models + * that solely need to define gravity and extrusion. + */ +template +class DefaultFVSpatialParams +: public FVSpatialParamsBase> +{ + using ThisType = DefaultFVSpatialParams; + using ParentType = FVSpatialParamsBase; + +public: + using ParentType::ParentType; +}; + } // namespace Dumux #endif -- GitLab From 234ebd6b01bbe9113a311b9ab4d5a0cb63170087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 12:17:27 +0200 Subject: [PATCH 03/17] [common] define spatial params in fvproblem --- dumux/common/fvproblem.hh | 32 ++++++++++++++++++- dumux/freeflow/navierstokes/mass/1p/model.hh | 8 +++++ dumux/freeflow/navierstokes/momentum/model.hh | 8 +++++ dumux/freeflow/properties.hh | 10 ++++++ dumux/porousmediumflow/problem.hh | 18 +---------- test/discretization/test_fvgridvariables.cc | 6 +++- 6 files changed, 63 insertions(+), 19 deletions(-) diff --git a/dumux/common/fvproblem.hh b/dumux/common/fvproblem.hh index b81375dca7..07a6c5d628 100644 --- a/dumux/common/fvproblem.hh +++ b/dumux/common/fvproblem.hh @@ -80,6 +80,9 @@ class FVProblem using BoundaryTypes = Dumux::BoundaryTypes; public: + //! Export spatial parameter type + using SpatialParams = GetPropType; + //! export traits of this problem struct Traits { @@ -91,16 +94,32 @@ public: /*! * \brief Constructor * \param gridGeometry The finite volume grid geometry + * \param spatialParams Spatially varying parameters * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") */ - FVProblem(std::shared_ptr gridGeometry, const std::string& paramGroup = "") + FVProblem(std::shared_ptr gridGeometry, + std::shared_ptr spatialParams, + const std::string& paramGroup = "") : gridGeometry_(gridGeometry) + , spatialParams_(spatialParams) , paramGroup_(paramGroup) { // set a default name for the problem problemName_ = getParamFromGroup(paramGroup, "Problem.Name"); } + /*! + * \brief Constructor + * \param gridGeometry The finite volume grid geometry + * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") + */ + FVProblem(std::shared_ptr gridGeometry, + const std::string& paramGroup = "") + : FVProblem(gridGeometry, + std::make_shared(gridGeometry), + paramGroup) + {} + /*! * \brief The problem name. * @@ -579,6 +598,14 @@ public: const std::string& paramGroup() const { return paramGroup_; } + //! Return the spatial parameters + SpatialParams& spatialParams() + { return *spatialParams_; } + + //! Return the spatial parameters + const SpatialParams& spatialParams() const + { return *spatialParams_; } + protected: //! Returns the implementation of the problem (i.e. static polymorphism) Implementation &asImp_() @@ -592,6 +619,9 @@ private: //! The finite volume grid geometry std::shared_ptr gridGeometry_; + //! Spatially varying parameters + std::shared_ptr spatialParams_; + //! The parameter group in which to retrieve runtime parameters std::string paramGroup_; diff --git a/dumux/freeflow/navierstokes/mass/1p/model.hh b/dumux/freeflow/navierstokes/mass/1p/model.hh index a518e299c7..3cf152bb57 100644 --- a/dumux/freeflow/navierstokes/mass/1p/model.hh +++ b/dumux/freeflow/navierstokes/mass/1p/model.hh @@ -146,6 +146,14 @@ template struct ModelTraits { using type = NavierStokesMassOnePModelTraits; }; +//! Per default, we use the base spatial parameters +template +struct SpatialParams +{ + using type = DefaultFVSpatialParams, + GetPropType>; +}; + /*! * \brief The fluid state which is used by the volume variables to * store the thermodynamic state. This should be chosen diff --git a/dumux/freeflow/navierstokes/momentum/model.hh b/dumux/freeflow/navierstokes/momentum/model.hh index a311059137..e37fad35af 100644 --- a/dumux/freeflow/navierstokes/momentum/model.hh +++ b/dumux/freeflow/navierstokes/momentum/model.hh @@ -221,6 +221,14 @@ public: using type = EmptyCouplingManager; }; +//! Per default, we use the base spatial parameters +template +struct SpatialParams +{ + using type = DefaultFVSpatialParams, + GetPropType>; +}; + //! The specific I/O fields // template // struct IOFields { using type = NavierStokesIOFields; }; diff --git a/dumux/freeflow/properties.hh b/dumux/freeflow/properties.hh index d918192b27..c6df54fe47 100644 --- a/dumux/freeflow/properties.hh +++ b/dumux/freeflow/properties.hh @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include "turbulencemodel.hh" @@ -54,6 +56,14 @@ struct FluxVariablesCacheFiller { using type = FluxVari template struct HeatConductionType { using type = FouriersLaw; }; +//! Per default, we use the base spatial parameters +template +struct SpatialParams +{ + using type = DefaultFVSpatialParams, + GetPropType>; +}; + } // namespace Properties } // namespace Dumux diff --git a/dumux/porousmediumflow/problem.hh b/dumux/porousmediumflow/problem.hh index 801f846340..3ef7d93aa4 100644 --- a/dumux/porousmediumflow/problem.hh +++ b/dumux/porousmediumflow/problem.hh @@ -67,9 +67,8 @@ public: PorousMediumFlowProblem(std::shared_ptr gridGeometry, std::shared_ptr spatialParams, const std::string& paramGroup = "") - : ParentType(gridGeometry, paramGroup) + : ParentType(gridGeometry, spatialParams, paramGroup) , gravity_(0.0) - , spatialParams_(spatialParams) { const bool enableGravity = getParamFromGroup(paramGroup, "Problem.EnableGravity"); if (enableGravity) @@ -117,26 +116,11 @@ public: DUNE_THROW(Dune::NotImplemented, "temperature() method not implemented by the user problem"); } - /*! - * \brief Returns the spatial parameters object. - */ - SpatialParams &spatialParams() - { return *spatialParams_; } - - /*! - * \brief Returns the spatial parameters object. - */ - const SpatialParams &spatialParams() const - { return *spatialParams_; } - // \} protected: //! The gravity acceleration vector GravityVector gravity_; - - // material properties of the porous medium - std::shared_ptr spatialParams_; }; } // end namespace Dumux diff --git a/test/discretization/test_fvgridvariables.cc b/test/discretization/test_fvgridvariables.cc index 5190170e01..91c0f8ce4f 100644 --- a/test/discretization/test_fvgridvariables.cc +++ b/test/discretization/test_fvgridvariables.cc @@ -27,6 +27,7 @@ #include #include #include +#include // we use the 1p type tag here in order not to be obliged // to define grid flux vars cache & vol vars cache... @@ -98,7 +99,10 @@ int main (int argc, char *argv[]) Dune::MPIHelper::instance(argc, argv); using namespace Dumux; - Dumux::Parameters::init(argc, argv); + Dumux::Parameters::init(argc, argv, [] (Dune::ParameterTree& tree) { + tree["SpatialParams.Porosity"] = "0.1"; + tree["SpatialParams.Permeability"] = "1e-12"; + }); using TypeTag = Properties::TTag::GridVariablesTestBox; using Grid = GetPropType; -- GitLab From 3911eedc28d96aafb70263624d7faf74ce8ffbbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Fri, 8 Oct 2021 10:15:39 +0000 Subject: [PATCH 04/17] [common][fvproblem] add note to constructor without spatial params --- dumux/common/fvproblem.hh | 1 + 1 file changed, 1 insertion(+) diff --git a/dumux/common/fvproblem.hh b/dumux/common/fvproblem.hh index 07a6c5d628..313b523ac0 100644 --- a/dumux/common/fvproblem.hh +++ b/dumux/common/fvproblem.hh @@ -112,6 +112,7 @@ public: * \brief Constructor * \param gridGeometry The finite volume grid geometry * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") + * \note This constructor assumes the spatial parameters to be constructible from a grid geometry */ FVProblem(std::shared_ptr gridGeometry, const std::string& paramGroup = "") -- GitLab From 7658a14ad29b50853b69e85078e7c896f01552c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 12:18:13 +0200 Subject: [PATCH 05/17] [pmflow][problem] remove obsolete gravity vector --- dumux/porousmediumflow/problem.hh | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/dumux/porousmediumflow/problem.hh b/dumux/porousmediumflow/problem.hh index 3ef7d93aa4..33915a22a9 100644 --- a/dumux/porousmediumflow/problem.hh +++ b/dumux/porousmediumflow/problem.hh @@ -50,8 +50,6 @@ class PorousMediumFlowProblem : public FVProblem using Element = typename GridView::template Codim<0>::Entity; using GlobalPosition = typename Element::Geometry::GlobalCoordinate; - using GravityVector = Dune::FieldVector; - public: //! Export spatial parameter type @@ -68,12 +66,7 @@ public: std::shared_ptr spatialParams, const std::string& paramGroup = "") : ParentType(gridGeometry, spatialParams, paramGroup) - , gravity_(0.0) - { - const bool enableGravity = getParamFromGroup(paramGroup, "Problem.EnableGravity"); - if (enableGravity) - gravity_[dimWorld-1] = -9.81; - } + {} /*! * \brief Constructor, constructing the spatial parameters. @@ -117,10 +110,6 @@ public: } // \} - -protected: - //! The gravity acceleration vector - GravityVector gravity_; }; } // end namespace Dumux -- GitLab From c67737396a11382fb01cc318fa26f9df56c85575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 12:21:01 +0200 Subject: [PATCH 06/17] [pmflow][prob] use base class ctor --- dumux/porousmediumflow/problem.hh | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/dumux/porousmediumflow/problem.hh b/dumux/porousmediumflow/problem.hh index 33915a22a9..baecbe6eb8 100644 --- a/dumux/porousmediumflow/problem.hh +++ b/dumux/porousmediumflow/problem.hh @@ -52,34 +52,9 @@ class PorousMediumFlowProblem : public FVProblem using GlobalPosition = typename Element::Geometry::GlobalCoordinate; public: - //! Export spatial parameter type - using SpatialParams = GetPropType; - /*! - * \brief Constructor, passing the spatial parameters. - * - * \param gridGeometry The finite volume grid geometry - * \param spatialParams The spatial parameter class - * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") - */ - PorousMediumFlowProblem(std::shared_ptr gridGeometry, - std::shared_ptr spatialParams, - const std::string& paramGroup = "") - : ParentType(gridGeometry, spatialParams, paramGroup) - {} - - /*! - * \brief Constructor, constructing the spatial parameters. - * - * \param gridGeometry The finite volume grid geometry - * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") - */ - PorousMediumFlowProblem(std::shared_ptr gridGeometry, - const std::string& paramGroup = "") - : PorousMediumFlowProblem(gridGeometry, - std::make_shared(gridGeometry), - paramGroup) - {} + //! Use constructors of the base class + using ParentType::ParentType; /*! * \name Physical parameters for porous media problems -- GitLab From e2511c029f01b889627af2b7d6455632672b52d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 12:29:45 +0200 Subject: [PATCH 07/17] [freeflowprob] deprecate gravity interface --- dumux/freeflow/navierstokes/problem.hh | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/dumux/freeflow/navierstokes/problem.hh b/dumux/freeflow/navierstokes/problem.hh index 092603f032..66c72957a8 100644 --- a/dumux/freeflow/navierstokes/problem.hh +++ b/dumux/freeflow/navierstokes/problem.hh @@ -82,7 +82,6 @@ class NavierStokesProblemImpl using GlobalPosition = typename SubControlVolumeFace::GlobalPosition; using VelocityVector = Dune::FieldVector; - using GravityVector = Dune::FieldVector; using CouplingManager = GetPropType; using ModelTraits = GetPropType; @@ -121,12 +120,8 @@ public: std::shared_ptr couplingManager, const std::string& paramGroup = "") : ParentType(gridGeometry, paramGroup) - , gravity_(0.0) , couplingManager_(couplingManager) { - if (getParamFromGroup(paramGroup, "Problem.EnableGravity")) - gravity_[dim-1] = -9.81; - enableInertiaTerms_ = getParamFromGroup(paramGroup, "Problem.EnableInertiaTerms"); } @@ -223,8 +218,9 @@ public: * If the Problem.EnableGravity parameter is true, this means * \f$\boldsymbol{g} = ( 0,\dots,\ -9.81)^T \f$, else \f$\boldsymbol{g} = ( 0,\dots, 0)^T \f$ */ - const GravityVector& gravity() const - { return gravity_; } + [[deprecated("Use problem.spatialParams().gravity(globalPos) instead!")]] + decltype(auto) gravity() const + { return this->spatialParams().gravity(GlobalPosition{}); } /*! * \brief Returns whether intertia terms should be considered. @@ -527,7 +523,6 @@ private: const Implementation& asImp_() const { return *static_cast(this); } - GravityVector gravity_; bool enableInertiaTerms_; std::shared_ptr couplingManager_; }; @@ -664,7 +659,7 @@ private: * \ingroup NavierStokesModel * \brief Navier-Stokes problem base class. * - * This implements gravity (if desired) and a function returning the temperature. + * This implements a function returning the temperature. * Includes a specialized method used only by the staggered grid discretization. */ template @@ -699,7 +694,6 @@ class NavierStokesProblemImpl using GlobalPosition = typename SubControlVolumeFace::GlobalPosition; using VelocityVector = Dune::FieldVector; - using GravityVector = Dune::FieldVector; public: /*! @@ -709,11 +703,7 @@ public: */ NavierStokesProblemImpl(std::shared_ptr gridGeometry, const std::string& paramGroup = "") : ParentType(gridGeometry, paramGroup) - , gravity_(0.0) { - if (getParamFromGroup(paramGroup, "Problem.EnableGravity")) - gravity_[dim-1] = -9.81; - enableInertiaTerms_ = getParamFromGroup(paramGroup, "Problem.EnableInertiaTerms"); } @@ -742,8 +732,9 @@ public: * If the Problem.EnableGravity parameter is true, this means * \f$\boldsymbol{g} = ( 0,\dots,\ -9.81)^T \f$, else \f$\boldsymbol{g} = ( 0,\dots, 0)^T \f$ */ - const GravityVector& gravity() const - { return gravity_; } + [[deprecated("Use problem.spatialParams().gravity(globalPos) instead")]] + decltype(auto) gravity() const + { return this->spatialParams().gravity(GlobalPosition{}); } /*! * \brief Returns whether interia terms should be considered. @@ -886,7 +877,6 @@ private: const Implementation &asImp_() const { return *static_cast(this); } - GravityVector gravity_; bool enableInertiaTerms_; }; -- GitLab From b5fe7960fbeeef0c2da7cb1242f8353ac6043b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 12:30:06 +0200 Subject: [PATCH 08/17] [ff][localres] avoid deprecation from call to gravity --- dumux/freeflow/navierstokes/momentum/localresidual.hh | 2 +- dumux/freeflow/navierstokes/staggered/localresidual.hh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dumux/freeflow/navierstokes/momentum/localresidual.hh b/dumux/freeflow/navierstokes/momentum/localresidual.hh index 5db4a54c62..a023f0f1c4 100644 --- a/dumux/freeflow/navierstokes/momentum/localresidual.hh +++ b/dumux/freeflow/navierstokes/momentum/localresidual.hh @@ -123,7 +123,7 @@ public: const SubControlVolume& scv) const { NumEqVector source = ParentType::computeSource(problem, element, fvGeometry, elemVolVars, scv); - source += problem.gravity()[scv.dofAxis()] * problem.density(element, scv); + source += problem.spatialParams().gravity(scv.dofPosition())[scv.dofAxis()] * problem.density(element, scv); // Axisymmetric problems in 2D feature an extra source terms arising from the transformation to cylindrical coordinates. // See Ferziger/Peric: Computational methods for fluid dynamics chapter 8. diff --git a/dumux/freeflow/navierstokes/staggered/localresidual.hh b/dumux/freeflow/navierstokes/staggered/localresidual.hh index 2e68a79bf5..aa2d555345 100644 --- a/dumux/freeflow/navierstokes/staggered/localresidual.hh +++ b/dumux/freeflow/navierstokes/staggered/localresidual.hh @@ -177,7 +177,7 @@ public: { FacePrimaryVariables source(0.0); const auto& insideVolVars = elemVolVars[scvf.insideScvIdx()]; - source += problem.gravity()[scvf.directionIndex()] * insideVolVars.density(); + source += problem.spatialParams().gravity(scvf.ipGlobal())[scvf.directionIndex()] * insideVolVars.density(); source += problem.source(element, fvGeometry, elemVolVars, elemFaceVars, scvf)[Indices::velocity(scvf.directionIndex())]; // Axisymmetric problems in 2D feature an extra source terms arising from the transformation to cylindrical coordinates. -- GitLab From 1dde420190dbfb217cf9bc7efcdc871c35f7adb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 12:33:26 +0200 Subject: [PATCH 09/17] [pmflow] inherit from base spatial params --- dumux/material/spatialparams/fv1p.hh | 31 ++++------------------------ 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/dumux/material/spatialparams/fv1p.hh b/dumux/material/spatialparams/fv1p.hh index d638f82598..19f773a243 100644 --- a/dumux/material/spatialparams/fv1p.hh +++ b/dumux/material/spatialparams/fv1p.hh @@ -30,6 +30,7 @@ #include #include +#include #include namespace Dumux { @@ -73,8 +74,9 @@ struct hasPorosityAtPos * using a fully implicit discretization method. */ template -class FVSpatialParamsOneP +class FVSpatialParamsOneP : public FVSpatialParamsBase { + using ParentType = FVSpatialParamsBase; using GridView = typename GridGeometry::GridView; using FVElementGeometry = typename GridGeometry::LocalView; using SubControlVolume = typename GridGeometry::SubControlVolume; @@ -89,13 +91,8 @@ class FVSpatialParamsOneP public: FVSpatialParamsOneP(std::shared_ptr gridGeometry) - : gridGeometry_(gridGeometry) - , gravity_(0.0) + : ParentType(gridGeometry) { - const bool enableGravity = getParam("Problem.EnableGravity"); - if (enableGravity) - gravity_[dimWorld-1] = -9.81; - /* \brief default forchheimer coefficient * Source: Ward, J.C. 1964 Turbulent flow in porous media. ASCE J. Hydraul. Div 90 \cite ward1964 . * Actually the Forchheimer coefficient is also a function of the dimensions of the @@ -105,19 +102,6 @@ public: forchCoeffDefault_ = getParam("SpatialParams.ForchCoeff", 0.55); } - /*! - * \brief Returns the acceleration due to gravity \f$\mathrm{[m/s^2]}\f$. - * - * The default behaviour is a constant gravity vector; - * if the Problem.EnableGravity 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 Harmonic average of a discontinuous scalar field at discontinuity interface * (for compatibility reasons with the function below) @@ -325,11 +309,6 @@ public: return forchCoeffDefault_; } - //! The finite volume grid geometry - const GridGeometry& gridGeometry() const - { return *gridGeometry_; } - - protected: Implementation &asImp_() { return *static_cast(this); } @@ -338,8 +317,6 @@ protected: { return *static_cast(this); } private: - std::shared_ptr gridGeometry_; - GlobalPosition gravity_; //!< The gravity vector Scalar forchCoeffDefault_; }; -- GitLab From a95870ca4f10f0cc19efd7c700fa067b0aa81823 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 13:03:27 +0200 Subject: [PATCH 10/17] [pmflow] move 1p spatial params --- dumux/material/spatialparams/fv1p.hh | 294 +------------------ dumux/porousmediumflow/fvspatialparams.hh | 325 ++++++++++++++++++++++ 2 files changed, 329 insertions(+), 290 deletions(-) create mode 100644 dumux/porousmediumflow/fvspatialparams.hh diff --git a/dumux/material/spatialparams/fv1p.hh b/dumux/material/spatialparams/fv1p.hh index 19f773a243..c6d30dd8ec 100644 --- a/dumux/material/spatialparams/fv1p.hh +++ b/dumux/material/spatialparams/fv1p.hh @@ -25,300 +25,14 @@ #ifndef DUMUX_FV_SPATIAL_PARAMS_ONE_P_HH #define DUMUX_FV_SPATIAL_PARAMS_ONE_P_HH -#include -#include - -#include -#include -#include -#include +#include namespace Dumux { -#ifndef DOXYGEN -namespace Detail { -// helper struct detecting if the user-defined spatial params class has a permeabilityAtPos function -// for g++ > 5.3, this can be replaced by a lambda -template -struct hasPermeabilityAtPos -{ - template - auto operator()(const SpatialParams& a) - -> decltype(a.permeabilityAtPos(std::declval())) - {} -}; - -template -struct hasInertVolumeFractionAtPos -{ - template - auto operator()(const SpatialParams& a) - -> decltype(a.template inertVolumeFractionAtPos(std::declval(), 0)) - {} -}; - -template -struct hasPorosityAtPos -{ - template - auto operator()(const SpatialParams& a) - -> decltype(a.porosityAtPos(std::declval())) - {} -}; -} // end namespace Detail -#endif - -/*! - * \ingroup SpatialParameters - * \brief The base class for spatial parameters of one-phase problems - * using a fully implicit discretization method. - */ template -class FVSpatialParamsOneP : public FVSpatialParamsBase -{ - using ParentType = FVSpatialParamsBase; - using GridView = typename GridGeometry::GridView; - using FVElementGeometry = typename GridGeometry::LocalView; - using SubControlVolume = typename GridGeometry::SubControlVolume; - using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace; - using Element = typename GridView::template Codim<0>::Entity; - - enum { dim = GridView::dimension }; - enum { dimWorld = GridView::dimensionworld }; - using DimWorldMatrix = Dune::FieldMatrix; - - using GlobalPosition = typename Element::Geometry::GlobalCoordinate; - -public: - FVSpatialParamsOneP(std::shared_ptr gridGeometry) - : ParentType(gridGeometry) - { - /* \brief default forchheimer coefficient - * Source: Ward, J.C. 1964 Turbulent flow in porous media. ASCE J. Hydraul. Div 90 \cite ward1964 . - * Actually the Forchheimer coefficient is also a function of the dimensions of the - * porous medium. Taking it as a constant is only a first approximation - * (Nield, Bejan, Convection in porous media, 2006, p. 10 \cite nield2006 ) - */ - forchCoeffDefault_ = getParam("SpatialParams.ForchCoeff", 0.55); - } - - /*! - * \brief Harmonic average of a discontinuous scalar field at discontinuity interface - * (for compatibility reasons with the function below) - * \return the averaged scalar - * \param T1 first scalar parameter - * \param T2 second scalar parameter - * \param normal The unit normal vector of the interface - */ - Scalar harmonicMean(const Scalar T1, - const Scalar T2, - const GlobalPosition& normal) const - { return Dumux::harmonicMean(T1, T2); } - - /*! - * \brief Harmonic average of a discontinuous tensorial field at discontinuity interface - * \note We do a harmonic average of the part normal to the interface (alpha*I) and - * an arithmetic average of the tangential part (T - alpha*I). - * \return the averaged tensor - * \param T1 first tensor - * \param T2 second tensor - * \param normal The unit normal vector of the interface - */ - DimWorldMatrix harmonicMean(const DimWorldMatrix& T1, - const DimWorldMatrix& T2, - const GlobalPosition& normal) const - { - // determine nT*k*n - GlobalPosition tmp; - GlobalPosition tmp2; - T1.mv(normal, tmp); - T2.mv(normal, tmp2); - const Scalar alpha1 = tmp*normal; - const Scalar alpha2 = tmp2*normal; - - const Scalar alphaHarmonic = Dumux::harmonicMean(alpha1, alpha2); - const Scalar alphaAverage = 0.5*(alpha1 + alpha2); - - DimWorldMatrix T(0.0); - for (int i = 0; i < dimWorld; ++i) - { - for (int j = 0; j < dimWorld; ++j) - { - T[i][j] += 0.5*(T1[i][j] + T2[i][j]); - if (i == j) - T[i][j] += alphaHarmonic - alphaAverage; - } - } - - return T; - } - - /*! - * \brief Function for defining the (intrinsic) permeability \f$[m^2]\f$ - * \note It is possibly solution dependent. - * - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - * \return permeability - */ - template - decltype(auto) permeability(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol) const - { - static_assert(decltype(isValid(Detail::hasPermeabilityAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " const PermeabilityType& permeabilityAtPos(const GlobalPosition& globalPos) const\n\n" - " or overload this function\n\n" - " template\n" - " const PermeabilityType& permeability(const Element& element,\n" - " const SubControlVolume& scv,\n" - " const ElementSolution& elemSol) const\n\n"); - - return asImp_().permeabilityAtPos(scv.center()); - } - - /*! - * \brief If the permeability should be evaluated directly at the scvf integration point - * (for convergence tests with analytical and continuous perm functions) or is evaluated - * at the scvs (for permeability fields with discontinuities) -> default - */ - static constexpr bool evaluatePermeabilityAtScvfIP() - { return false; } - - /*! - * \brief Function for defining the porosity. - * That is possibly solution dependent. - * \note this can only be used for solids with one inert component - * (see inertVolumeFraction for the more general interface) - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - * \return the porosity - */ - template - Scalar porosity(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol) const - { - static_assert(decltype(isValid(Detail::hasPorosityAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n" - " or overload this function\n\n" - " template\n" - " Scalar porosity(const Element& element,\n" - " const SubControlVolume& scv,\n" - " const ElementSolution& elemSol) const\n\n"); - - return asImp_().porosityAtPos(scv.center()); - } - - /*! - * \brief Function for defining the solid volume fraction. - * That is possibly solution dependent. - * - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - * \param compIdx The solid component index - * \return the volume fraction of the inert solid component with index compIdx - * - * \note this overload is enable if there is only one inert solid component and the - * user didn't choose to implement a inertVolumeFractionAtPos overload. - * It then forwards to the simpler porosity interface. - * With more than one solid components or active solid components (i.e. dissolution) - * please overload the more general inertVolumeFraction/inertVolumeFractionAtPos interface. - */ - template())(std::declval()))::value, - int> = 0> - Scalar inertVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { - return 1.0 - asImp_().porosity(element, scv, elemSol); - } - - // specialization if there are no inert components at all - template = 0> - Scalar inertVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { - return 0.0; - } - - // the more general interface forwarding to inertVolumeFractionAtPos - template 1) || - ( - (SolidSystem::numInertComponents > 0) && - ( - !SolidSystem::isInert() - || decltype(isValid(Detail::hasInertVolumeFractionAtPos()) - (std::declval()))::value - ) - ), - int> = 0> - Scalar inertVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { - static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " template\n" - " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n" - " or overload this function\n\n" - " template\n" - " Scalar inertVolumeFraction(const Element& element,\n" - " const SubControlVolume& scv,\n" - " const ElementSolution& elemSol,\n" - " int compIdx) const\n\n"); - - return asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); - } - - /*! - * \brief Function for defining the Beavers-Joseph coefficient for multidomain - * problems\f$\mathrm{[-]}\f$. - * - * \return Beavers-Joseph coefficient \f$\mathrm{[-]}\f$ - * \param globalPos The global position - */ - Scalar beaversJosephCoeffAtPos(const GlobalPosition& globalPos) const - { - DUNE_THROW(Dune::InvalidStateException, - "The spatial parameters do not provide a beaversJosephCoeffAtPos() method."); - } - - /*! - * \brief Apply the Forchheimer coefficient for inertial forces - * calculation. - * \param scvf The sub-control volume face where the - * intrinsic velocity ought to be calculated. - */ - Scalar forchCoeff(const SubControlVolumeFace &scvf) const - { - return forchCoeffDefault_; - } - -protected: - Implementation &asImp_() - { return *static_cast(this); } - - const Implementation &asImp_() const - { return *static_cast(this); } - -private: - Scalar forchCoeffDefault_; -}; +using FVSpatialParamsOneP +[[deprecated("Use FVPorousMediumSpatialParamsOneP in dumux/porousmediumflow/fvspatialparams.hh instead!")]] + = FVPorousMediumSpatialParamsOneP; } // namespace Dumux diff --git a/dumux/porousmediumflow/fvspatialparams.hh b/dumux/porousmediumflow/fvspatialparams.hh new file mode 100644 index 0000000000..23ec22d38e --- /dev/null +++ b/dumux/porousmediumflow/fvspatialparams.hh @@ -0,0 +1,325 @@ +// -*- 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 3 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 . * + *****************************************************************************/ +/*! + * \file + * \ingroup SpatialParameters + * \brief The base class for spatial parameters in porous-medium-flow problems. + */ +#ifndef DUMUX_POROUS_MEDIUM_FLOW_FV_SPATIAL_PARAMS_HH +#define DUMUX_POROUS_MEDIUM_FLOW_FV_SPATIAL_PARAMS_HH + +#include +#include + +#include +#include +#include +#include + +namespace Dumux { + +#ifndef DOXYGEN +namespace Detail { +// helper struct detecting if the user-defined spatial params class has a permeabilityAtPos function +// for g++ > 5.3, this can be replaced by a lambda +template +struct hasPermeabilityAtPos +{ + template + auto operator()(const SpatialParams& a) + -> decltype(a.permeabilityAtPos(std::declval())) + {} +}; + +template +struct hasInertVolumeFractionAtPos +{ + template + auto operator()(const SpatialParams& a) + -> decltype(a.template inertVolumeFractionAtPos(std::declval(), 0)) + {} +}; + +template +struct hasPorosityAtPos +{ + template + auto operator()(const SpatialParams& a) + -> decltype(a.porosityAtPos(std::declval())) + {} +}; +} // end namespace Detail +#endif + +/*! + * \ingroup SpatialParameters + * \brief The base class for spatial parameters of one-phase problems + * using a fully implicit discretization method. + */ +template +class FVPorousMediumSpatialParamsOneP +: public FVSpatialParamsBase +{ + using ParentType = FVSpatialParamsBase; + using GridView = typename GridGeometry::GridView; + using FVElementGeometry = typename GridGeometry::LocalView; + using SubControlVolume = typename GridGeometry::SubControlVolume; + using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace; + using Element = typename GridView::template Codim<0>::Entity; + + enum { dim = GridView::dimension }; + enum { dimWorld = GridView::dimensionworld }; + using DimWorldMatrix = Dune::FieldMatrix; + + using GlobalPosition = typename Element::Geometry::GlobalCoordinate; + +public: + FVPorousMediumSpatialParamsOneP(std::shared_ptr gridGeometry) + : ParentType(gridGeometry) + { + /* \brief default forchheimer coefficient + * Source: Ward, J.C. 1964 Turbulent flow in porous media. ASCE J. Hydraul. Div 90 \cite ward1964 . + * Actually the Forchheimer coefficient is also a function of the dimensions of the + * porous medium. Taking it as a constant is only a first approximation + * (Nield, Bejan, Convection in porous media, 2006, p. 10 \cite nield2006 ) + */ + forchCoeffDefault_ = getParam("SpatialParams.ForchCoeff", 0.55); + } + + /*! + * \brief Harmonic average of a discontinuous scalar field at discontinuity interface + * (for compatibility reasons with the function below) + * \return the averaged scalar + * \param T1 first scalar parameter + * \param T2 second scalar parameter + * \param normal The unit normal vector of the interface + */ + Scalar harmonicMean(const Scalar T1, + const Scalar T2, + const GlobalPosition& normal) const + { return Dumux::harmonicMean(T1, T2); } + + /*! + * \brief Harmonic average of a discontinuous tensorial field at discontinuity interface + * \note We do a harmonic average of the part normal to the interface (alpha*I) and + * an arithmetic average of the tangential part (T - alpha*I). + * \return the averaged tensor + * \param T1 first tensor + * \param T2 second tensor + * \param normal The unit normal vector of the interface + */ + DimWorldMatrix harmonicMean(const DimWorldMatrix& T1, + const DimWorldMatrix& T2, + const GlobalPosition& normal) const + { + // determine nT*k*n + GlobalPosition tmp; + GlobalPosition tmp2; + T1.mv(normal, tmp); + T2.mv(normal, tmp2); + const Scalar alpha1 = tmp*normal; + const Scalar alpha2 = tmp2*normal; + + const Scalar alphaHarmonic = Dumux::harmonicMean(alpha1, alpha2); + const Scalar alphaAverage = 0.5*(alpha1 + alpha2); + + DimWorldMatrix T(0.0); + for (int i = 0; i < dimWorld; ++i) + { + for (int j = 0; j < dimWorld; ++j) + { + T[i][j] += 0.5*(T1[i][j] + T2[i][j]); + if (i == j) + T[i][j] += alphaHarmonic - alphaAverage; + } + } + + return T; + } + + /*! + * \brief Function for defining the (intrinsic) permeability \f$[m^2]\f$ + * \note It is possibly solution dependent. + * + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + * \return permeability + */ + template + decltype(auto) permeability(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol) const + { + static_assert(decltype(isValid(Detail::hasPermeabilityAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " const PermeabilityType& permeabilityAtPos(const GlobalPosition& globalPos) const\n\n" + " or overload this function\n\n" + " template\n" + " const PermeabilityType& permeability(const Element& element,\n" + " const SubControlVolume& scv,\n" + " const ElementSolution& elemSol) const\n\n"); + + return asImp_().permeabilityAtPos(scv.center()); + } + + /*! + * \brief If the permeability should be evaluated directly at the scvf integration point + * (for convergence tests with analytical and continuous perm functions) or is evaluated + * at the scvs (for permeability fields with discontinuities) -> default + */ + static constexpr bool evaluatePermeabilityAtScvfIP() + { return false; } + + /*! + * \brief Function for defining the porosity. + * That is possibly solution dependent. + * \note this can only be used for solids with one inert component + * (see inertVolumeFraction for the more general interface) + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + * \return the porosity + */ + template + Scalar porosity(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol) const + { + static_assert(decltype(isValid(Detail::hasPorosityAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n" + " or overload this function\n\n" + " template\n" + " Scalar porosity(const Element& element,\n" + " const SubControlVolume& scv,\n" + " const ElementSolution& elemSol) const\n\n"); + + return asImp_().porosityAtPos(scv.center()); + } + + /*! + * \brief Function for defining the solid volume fraction. + * That is possibly solution dependent. + * + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + * \param compIdx The solid component index + * \return the volume fraction of the inert solid component with index compIdx + * + * \note this overload is enable if there is only one inert solid component and the + * user didn't choose to implement a inertVolumeFractionAtPos overload. + * It then forwards to the simpler porosity interface. + * With more than one solid components or active solid components (i.e. dissolution) + * please overload the more general inertVolumeFraction/inertVolumeFractionAtPos interface. + */ + template())(std::declval()))::value, + int> = 0> + Scalar inertVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { + return 1.0 - asImp_().porosity(element, scv, elemSol); + } + + // specialization if there are no inert components at all + template = 0> + Scalar inertVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { + return 0.0; + } + + // the more general interface forwarding to inertVolumeFractionAtPos + template 1) || + ( + (SolidSystem::numInertComponents > 0) && + ( + !SolidSystem::isInert() + || decltype(isValid(Detail::hasInertVolumeFractionAtPos()) + (std::declval()))::value + ) + ), + int> = 0> + Scalar inertVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { + static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " template\n" + " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n" + " or overload this function\n\n" + " template\n" + " Scalar inertVolumeFraction(const Element& element,\n" + " const SubControlVolume& scv,\n" + " const ElementSolution& elemSol,\n" + " int compIdx) const\n\n"); + + return asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); + } + + /*! + * \brief Function for defining the Beavers-Joseph coefficient for multidomain + * problems\f$\mathrm{[-]}\f$. + * + * \return Beavers-Joseph coefficient \f$\mathrm{[-]}\f$ + * \param globalPos The global position + */ + Scalar beaversJosephCoeffAtPos(const GlobalPosition& globalPos) const + { + DUNE_THROW(Dune::InvalidStateException, + "The spatial parameters do not provide a beaversJosephCoeffAtPos() method."); + } + + /*! + * \brief Apply the Forchheimer coefficient for inertial forces + * calculation. + * \param scvf The sub-control volume face where the + * intrinsic velocity ought to be calculated. + */ + Scalar forchCoeff(const SubControlVolumeFace &scvf) const + { + return forchCoeffDefault_; + } + +protected: + Implementation &asImp_() + { return *static_cast(this); } + + const Implementation &asImp_() const + { return *static_cast(this); } + +private: + Scalar forchCoeffDefault_; +}; + +} // namespace Dumux + +#endif -- GitLab From 89f277f85a703a658f7f91b1ee70f82027ffbd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 13:06:57 +0200 Subject: [PATCH 11/17] [pmflow] move 2p spatial params --- dumux/material/spatialparams/fv.hh | 96 +---------------------- dumux/porousmediumflow/fvspatialparams.hh | 90 ++++++++++++++++++++- 2 files changed, 92 insertions(+), 94 deletions(-) diff --git a/dumux/material/spatialparams/fv.hh b/dumux/material/spatialparams/fv.hh index 520098da68..52fe195f61 100644 --- a/dumux/material/spatialparams/fv.hh +++ b/dumux/material/spatialparams/fv.hh @@ -25,102 +25,14 @@ #ifndef DUMUX_FV_SPATIAL_PARAMS_HH #define DUMUX_FV_SPATIAL_PARAMS_HH -#include -#include -#include "fv1p.hh" +#include namespace Dumux { -#ifndef DOXYGEN -namespace Detail { -// helper struct detecting if the user-defined spatial params class -// has a fluidMatrixInteractionAtPos function -template -struct hasFluidMatrixInteractionAtPos -{ - template - auto operator()(const SpatialParams& a) - -> decltype(a.fluidMatrixInteractionAtPos(std::declval())) - {} -}; -} // end namespace Detail -#endif - -/*! - * \ingroup SpatialParameters - * \brief The base class for spatial parameters of multi-phase problems - * using a fully implicit discretization method. - */ template -class FVSpatialParams : public FVSpatialParamsOneP -{ - using ParentType = FVSpatialParamsOneP; - using GridView = typename GridGeometry::GridView; - using FVElementGeometry = typename GridGeometry::LocalView; - using SubControlVolume = typename GridGeometry::SubControlVolume; - using Element = typename GridView::template Codim<0>::Entity; - - using GlobalPosition = typename Element::Geometry::GlobalCoordinate; - -public: - FVSpatialParams(std::shared_ptr gridGeometry) - : ParentType(gridGeometry) - {} - - /*! - * \brief Function for defining the parameters needed by constitutive relationships (kr-sw, pc-sw, etc.). - * - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - */ - template - decltype(auto) fluidMatrixInteraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol) const - { - static_assert(decltype(isValid(Detail::hasFluidMatrixInteractionAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " auto fluidMatrixInteractionAtPos(const GlobalPosition& globalPos) const\n\n" - " or overload this function\n\n" - " template\n" - " auto fluidMatrixInteraction(const Element& element,\n" - " const SubControlVolume& scv,\n" - " const ElementSolution& elemSol) const\n\n"); - - return this->asImp_().fluidMatrixInteractionAtPos(scv.center()); - } - - /*! - * \brief Function for defining which phase is to be considered as the wetting phase. - * - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - * \return the wetting phase index - */ - template - int wettingPhase(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol) const - { - return this->asImp_().template wettingPhaseAtPos(scv.center()); - } - - /*! - * \brief Function for defining which phase is to be considered as the wetting phase. - * - * \return the wetting phase index - * \param globalPos The global position - */ - template - int wettingPhaseAtPos(const GlobalPosition& globalPos) const - { - DUNE_THROW(Dune::InvalidStateException, - "The spatial parameters do not provide " - "a wettingPhaseAtPos() method."); - } -}; +using FVSpatialParams +[[deprecated("Use FVPorousMediumSpatialParams in dumux/porousmediumflow/fvspatialparams.hh instead!")]] += FVPorousMediumSpatialParams; } // namespace Dumux diff --git a/dumux/porousmediumflow/fvspatialparams.hh b/dumux/porousmediumflow/fvspatialparams.hh index 23ec22d38e..d1fd3293dd 100644 --- a/dumux/porousmediumflow/fvspatialparams.hh +++ b/dumux/porousmediumflow/fvspatialparams.hh @@ -64,13 +64,23 @@ struct hasPorosityAtPos -> decltype(a.porosityAtPos(std::declval())) {} }; + +// helper struct detecting if the user-defined spatial params class +// has a fluidMatrixInteractionAtPos function +template +struct hasFluidMatrixInteractionAtPos +{ + template + auto operator()(const SpatialParams& a) + -> decltype(a.fluidMatrixInteractionAtPos(std::declval())) + {} +}; } // end namespace Detail #endif /*! * \ingroup SpatialParameters - * \brief The base class for spatial parameters of one-phase problems - * using a fully implicit discretization method. + * \brief The base class for spatial parameters of single-phase problems */ template class FVPorousMediumSpatialParamsOneP @@ -320,6 +330,82 @@ private: Scalar forchCoeffDefault_; }; +/*! + * \ingroup SpatialParameters + * \brief The base class for spatial parameters of multi-phase problems + */ +template +class FVPorousMediumSpatialParams +: public FVPorousMediumSpatialParamsOneP +{ + using ParentType = FVPorousMediumSpatialParamsOneP; + using GridView = typename GridGeometry::GridView; + using FVElementGeometry = typename GridGeometry::LocalView; + using SubControlVolume = typename GridGeometry::SubControlVolume; + using Element = typename GridView::template Codim<0>::Entity; + + using GlobalPosition = typename Element::Geometry::GlobalCoordinate; + +public: + FVPorousMediumSpatialParams(std::shared_ptr gridGeometry) + : ParentType(gridGeometry) + {} + + /*! + * \brief Function for defining the parameters needed by constitutive relationships (kr-sw, pc-sw, etc.). + * + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + */ + template + decltype(auto) fluidMatrixInteraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol) const + { + static_assert(decltype(isValid(Detail::hasFluidMatrixInteractionAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " auto fluidMatrixInteractionAtPos(const GlobalPosition& globalPos) const\n\n" + " or overload this function\n\n" + " template\n" + " auto fluidMatrixInteraction(const Element& element,\n" + " const SubControlVolume& scv,\n" + " const ElementSolution& elemSol) const\n\n"); + + return this->asImp_().fluidMatrixInteractionAtPos(scv.center()); + } + + /*! + * \brief Function for defining which phase is to be considered as the wetting phase. + * + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + * \return the wetting phase index + */ + template + int wettingPhase(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol) const + { + return this->asImp_().template wettingPhaseAtPos(scv.center()); + } + + /*! + * \brief Function for defining which phase is to be considered as the wetting phase. + * + * \return the wetting phase index + * \param globalPos The global position + */ + template + int wettingPhaseAtPos(const GlobalPosition& globalPos) const + { + DUNE_THROW(Dune::InvalidStateException, + "The spatial parameters do not provide " + "a wettingPhaseAtPos() method."); + } +}; + } // namespace Dumux #endif -- GitLab From 4782258a14dba570d27c02543f03bb4bd31bf028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 13:11:37 +0200 Subject: [PATCH 12/17] [pmflow] move 1pconstant spatial params --- dumux/material/spatialparams/fv1pconstant.hh | 42 +---------- .../fv1pconstantspatialparams.hh | 73 +++++++++++++++++++ 2 files changed, 77 insertions(+), 38 deletions(-) create mode 100644 dumux/porousmediumflow/fv1pconstantspatialparams.hh diff --git a/dumux/material/spatialparams/fv1pconstant.hh b/dumux/material/spatialparams/fv1pconstant.hh index aed9102405..5db9816973 100644 --- a/dumux/material/spatialparams/fv1pconstant.hh +++ b/dumux/material/spatialparams/fv1pconstant.hh @@ -24,48 +24,14 @@ #ifndef DUMUX_FV_CONSTANT_SPATIAL_PARAMS_ONE_P_HH #define DUMUX_FV_CONSTANT_SPATIAL_PARAMS_ONE_P_HH -#include -#include +#include namespace Dumux { -/*! - * \ingroup SpatialParameters - * \brief A spatial params implementation for 1p problem with constant properties - */ template -class FVSpatialParamsOnePConstant -: public FVSpatialParamsOneP> -{ - using ThisType = FVSpatialParamsOnePConstant; - using ParentType = FVSpatialParamsOneP; - using GlobalPosition = typename GridGeometry::GridView::template Codim<0>::Geometry::GlobalCoordinate; - -public: - using PermeabilityType = Scalar; - - FVSpatialParamsOnePConstant(std::shared_ptr gridGeometry) - : ParentType(gridGeometry) - , porosity_(getParam("SpatialParams.Porosity")) - , permeability_(getParam("SpatialParams.Permeability")) - {} - - /*! - * \brief The (intrinsic) permeability \f$[m^2]\f$ - */ - PermeabilityType permeabilityAtPos(const GlobalPosition& globalPos) const - { return permeability_; } - - /*! - * \brief The porosity \f$[-]\f$ - */ - Scalar porosityAtPos(const GlobalPosition& globalPos) const - { return porosity_; } - -private: - const Scalar porosity_; - const Scalar permeability_; -}; +using FVSpatialParamsOnePConstant +[[deprecated("Use FVSpatialParamsOnePConstant in dumux/porousmediumflow/fv1pconstantspatialparams.hh instead!")]] += FVPorousMediumOnePConstantSpatialParams; } // end namespace Dumux diff --git a/dumux/porousmediumflow/fv1pconstantspatialparams.hh b/dumux/porousmediumflow/fv1pconstantspatialparams.hh new file mode 100644 index 0000000000..1631219f12 --- /dev/null +++ b/dumux/porousmediumflow/fv1pconstantspatialparams.hh @@ -0,0 +1,73 @@ +// -*- 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 3 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 . * + *****************************************************************************/ +/*! + * \file + * \ingroup PorousMediumFlow + * \ingroup SpatialParameters + * \brief A spatial params implementation for 1p problem with constant properties + */ +#ifndef DUMUX_POROUS_MEDIUM_FLOW_FV_CONSTANT_SPATIAL_PARAMS_ONE_P_HH +#define DUMUX_POROUS_MEDIUM_FLOW_FV_CONSTANT_SPATIAL_PARAMS_ONE_P_HH + +#include +#include "fvspatialparams.hh" + +namespace Dumux { + +/*! + * \ingroup SpatialParameters + * \brief A spatial params implementation for 1p problem with constant properties + */ +template +class FVPorousMediumOnePConstantSpatialParams +: public FVPorousMediumSpatialParamsOneP> +{ + using ThisType = FVPorousMediumOnePConstantSpatialParams; + using ParentType = FVPorousMediumSpatialParamsOneP; + using GlobalPosition = typename GridGeometry::GridView::template Codim<0>::Geometry::GlobalCoordinate; + +public: + using PermeabilityType = Scalar; + + FVPorousMediumOnePConstantSpatialParams(std::shared_ptr gridGeometry) + : ParentType(gridGeometry) + , porosity_(getParam("SpatialParams.Porosity")) + , permeability_(getParam("SpatialParams.Permeability")) + {} + + /*! + * \brief The (intrinsic) permeability \f$[m^2]\f$ + */ + PermeabilityType permeabilityAtPos(const GlobalPosition& globalPos) const + { return permeability_; } + + /*! + * \brief The porosity \f$[-]\f$ + */ + Scalar porosityAtPos(const GlobalPosition& globalPos) const + { return porosity_; } + +private: + const Scalar porosity_; + const Scalar permeability_; +}; + +} // end namespace Dumux + +#endif -- GitLab From 23022dd0795f3abcef510611aa41b860398c96ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Wed, 29 Sep 2021 13:13:20 +0200 Subject: [PATCH 13/17] [pmflow][spatialparams] deprecate headers --- dumux/material/spatialparams/fv.hh | 1 + dumux/material/spatialparams/fv1p.hh | 1 + dumux/material/spatialparams/fv1pconstant.hh | 1 + 3 files changed, 3 insertions(+) diff --git a/dumux/material/spatialparams/fv.hh b/dumux/material/spatialparams/fv.hh index 52fe195f61..ce593b9b7c 100644 --- a/dumux/material/spatialparams/fv.hh +++ b/dumux/material/spatialparams/fv.hh @@ -25,6 +25,7 @@ #ifndef DUMUX_FV_SPATIAL_PARAMS_HH #define DUMUX_FV_SPATIAL_PARAMS_HH +#warning "This header will be removed after 3.5 in favor of dumux/porousmediumflow/fvspatialparams.hh" #include namespace Dumux { diff --git a/dumux/material/spatialparams/fv1p.hh b/dumux/material/spatialparams/fv1p.hh index c6d30dd8ec..a6a1a34e02 100644 --- a/dumux/material/spatialparams/fv1p.hh +++ b/dumux/material/spatialparams/fv1p.hh @@ -25,6 +25,7 @@ #ifndef DUMUX_FV_SPATIAL_PARAMS_ONE_P_HH #define DUMUX_FV_SPATIAL_PARAMS_ONE_P_HH +#warning "This header will be removed after 3.5 in favor of dumux/porousmediumflow/fvspatialparams.hh" #include namespace Dumux { diff --git a/dumux/material/spatialparams/fv1pconstant.hh b/dumux/material/spatialparams/fv1pconstant.hh index 5db9816973..0cd4ae366c 100644 --- a/dumux/material/spatialparams/fv1pconstant.hh +++ b/dumux/material/spatialparams/fv1pconstant.hh @@ -24,6 +24,7 @@ #ifndef DUMUX_FV_CONSTANT_SPATIAL_PARAMS_ONE_P_HH #define DUMUX_FV_CONSTANT_SPATIAL_PARAMS_ONE_P_HH +#warning "This header will be removed after 3.5 in favor of dumux/porousmediumflow/fv1pconstantspatialparams.hh" #include namespace Dumux { -- GitLab From 8aa5ca683dfe8a2c4f98d55242fbec0842e29684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Tue, 19 Oct 2021 08:45:34 +0200 Subject: [PATCH 14/17] [freeflow][problem] add ctors with params --- dumux/freeflow/navierstokes/problem.hh | 75 ++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/dumux/freeflow/navierstokes/problem.hh b/dumux/freeflow/navierstokes/problem.hh index 66c72957a8..d20f9a88b2 100644 --- a/dumux/freeflow/navierstokes/problem.hh +++ b/dumux/freeflow/navierstokes/problem.hh @@ -88,6 +88,7 @@ class NavierStokesProblemImpl static constexpr bool isCoupled_ = !std::is_empty_v; public: + using typename ParentType::SpatialParams; //! Export traits of this problem struct Traits @@ -125,6 +126,23 @@ public: enableInertiaTerms_ = getParamFromGroup(paramGroup, "Problem.EnableInertiaTerms"); } + /*! + * \brief The constructor + * \param gridGeometry The finite volume grid geometry + * \param spatialParams Spatially varying parameters + * \param couplingManager The coupling manager (couples mass and momentum equations) + * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") + */ + NavierStokesProblemImpl(std::shared_ptr gridGeometry, + std::shared_ptr spatialParams, + std::shared_ptr couplingManager, + const std::string& paramGroup = "") + : ParentType(gridGeometry, spatialParams, paramGroup) + , couplingManager_(couplingManager) + { + enableInertiaTerms_ = getParamFromGroup(paramGroup, "Problem.EnableInertiaTerms"); + } + /*! * \brief The constructor for usage without a coupling manager * \param gridGeometry The finite volume grid geometry @@ -135,6 +153,18 @@ public: : NavierStokesProblemImpl(gridGeometry, {}, paramGroup) {} + /*! + * \brief The constructor for usage without a coupling manager + * \param gridGeometry The finite volume grid geometry + * \param spatialParams Spatially varying parameters + * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") + */ + NavierStokesProblemImpl(std::shared_ptr gridGeometry, + std::shared_ptr spatialParams, + const std::string& paramGroup = "") + : NavierStokesProblemImpl(gridGeometry, spatialParams, {}, paramGroup) + {} + /*! * \brief Evaluate the source term for all phases within a given * sub-control-volume. @@ -548,6 +578,8 @@ class NavierStokesProblemImpl static constexpr bool isCoupled_ = !std::is_empty_v; public: + using typename ParentType::SpatialParams; + //! Export traits of this problem struct Traits { @@ -581,6 +613,21 @@ public: , couplingManager_(couplingManager) {} + /*! + * \brief The constructor + * \param gridGeometry The finite volume grid geometry + * \param spatialParams Spatially varying parameters + * \param couplingManager The coupling manager (couples mass and momentum equations) + * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") + */ + NavierStokesProblemImpl(std::shared_ptr gridGeometry, + std::shared_ptr spatialParams, + std::shared_ptr couplingManager, + const std::string& paramGroup = "") + : ParentType(gridGeometry, spatialParams, paramGroup) + , couplingManager_(couplingManager) + {} + /*! * \brief The constructor for usage without a coupling manager * \param gridGeometry The finite volume grid geometry @@ -591,6 +638,18 @@ public: : NavierStokesProblemImpl(gridGeometry, {}, paramGroup) {} + /*! + * \brief The constructor for usage without a coupling manager + * \param gridGeometry The finite volume grid geometry + * \param spatialParams Spatially varying parameters + * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") + */ + NavierStokesProblemImpl(std::shared_ptr gridGeometry, + std::shared_ptr spatialParams, + const std::string& paramGroup = "") + : NavierStokesProblemImpl(gridGeometry, {}, paramGroup) + {} + /*! * \brief Returns the normal velocity at a given sub control volume face. @@ -696,6 +755,8 @@ class NavierStokesProblemImpl using VelocityVector = Dune::FieldVector; public: + using typename ParentType::SpatialParams; + /*! * \brief The constructor * \param gridGeometry The finite volume grid geometry @@ -707,6 +768,20 @@ public: enableInertiaTerms_ = getParamFromGroup(paramGroup, "Problem.EnableInertiaTerms"); } + /*! + * \brief The constructor + * \param gridGeometry The finite volume grid geometry + * \param spatialParams Spatially varying parameters + * \param paramGroup The parameter group in which to look for runtime parameters first (default is "") + */ + NavierStokesProblemImpl(std::shared_ptr gridGeometry, + std::shared_ptr spatialParams, + const std::string& paramGroup = "") + : ParentType(gridGeometry, spatialParams, paramGroup) + { + enableInertiaTerms_ = getParamFromGroup(paramGroup, "Problem.EnableInertiaTerms"); + } + /*! * \brief Returns the temperature \f$\mathrm{[K]}\f$ at a given global position. * -- GitLab From 02521b5a762e687e3478536fec06d3ec50944603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Tue, 19 Oct 2021 13:30:18 +0200 Subject: [PATCH 15/17] [geomechanics] reuse base spatial params --- dumux/material/spatialparams/fvelastic.hh | 53 +++------------- dumux/material/spatialparams/fvporoelastic.hh | 60 ++++--------------- 2 files changed, 22 insertions(+), 91 deletions(-) diff --git a/dumux/material/spatialparams/fvelastic.hh b/dumux/material/spatialparams/fvelastic.hh index ed89b81e16..a1c98ccb59 100644 --- a/dumux/material/spatialparams/fvelastic.hh +++ b/dumux/material/spatialparams/fvelastic.hh @@ -29,6 +29,7 @@ #include #include +#include #include namespace Dumux { @@ -55,38 +56,16 @@ struct hasLameParamsAtPos */ template class FVSpatialParamsElastic +: public FVSpatialParamsBase { + using ParentType = FVSpatialParamsBase + using Element = typename GridGeometry::GridView::template Codim<0>::Entity; using FVElementGeometry = typename GridGeometry::LocalView; using SubControlVolume = typename GridGeometry::SubControlVolume; - using GridView = typename GridGeometry::GridView; - 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 gridGeometry) - : gridGeometry_(gridGeometry) - , gravity_(0.0) - { - const bool enableGravity = getParam("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 Problem.EnableGravity 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_; } + using ParentType::ParentType; /*! * \brief Function for defining the solid volume fraction. @@ -111,7 +90,7 @@ public: return 1.0; // otherwise we require the user to define the solid composition - return asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); + return this->asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); } /*! @@ -155,23 +134,9 @@ public: " const ElemVolVars& elemVolVars,\n" " const FluxVarsCache& fluxVarsCache) const\n\n"); - return asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal()); + return this->asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal()); } - - //! The finite volume grid geometry - const GridGeometry& gridGeometry() const - { return *gridGeometry_; } - -protected: - Implementation &asImp_() - { return *static_cast(this); } - - const Implementation &asImp_() const - { return *static_cast(this); } - -private: - std::shared_ptr gridGeometry_; - GlobalPosition gravity_; //!< The gravity vector }; -} // end namespace Dumuxs + +} // end namespace Dumux #endif diff --git a/dumux/material/spatialparams/fvporoelastic.hh b/dumux/material/spatialparams/fvporoelastic.hh index 22e7532cef..b6306ded2f 100644 --- a/dumux/material/spatialparams/fvporoelastic.hh +++ b/dumux/material/spatialparams/fvporoelastic.hh @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -76,38 +77,16 @@ struct hasBiotCoeffAtPos */ template class FVSpatialParamsPoroElastic +: public FVSpatialParamsBase { + using ParentType = FVSpatialParamsBase; + using Element = typename GridGeometry::GridView::template Codim<0>::Entity; using FVElementGeometry = typename GridGeometry::LocalView; using SubControlVolume = typename GridGeometry::SubControlVolume; - using GridView = typename GridGeometry::GridView; - 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 gridGeometry) - : gridGeometry_(gridGeometry) - , gravity_(0.0) - { - const bool enableGravity = getParam("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 Problem.EnableGravity 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_; } + using ParentType::ParentType; /*! * \brief Function for defining the porosity. @@ -133,7 +112,7 @@ public: " const SubControlVolume& scv,\n" " const ElementSolution& elemSol) const\n\n"); - return asImp_().porosityAtPos(scv.center()); + return this->asImp_().porosityAtPos(scv.center()); } /*! @@ -161,7 +140,7 @@ public: const SubControlVolume& scv, const ElementSolution& elemSol, int compIdx) const - { return 1.0 - asImp_().porosity(element, scv, elemSol); } + { return 1.0 - this->asImp_().porosity(element, scv, elemSol); } // specialization if there are no inert components at all template = 0> @@ -198,7 +177,7 @@ public: " const ElementSolution& elemSol,\n" " int compIdx) const\n\n"); - return asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); + return this->asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); } /*! @@ -246,7 +225,7 @@ public: " const ElementSolution& elemSol,\n" " int compIdx) const\n\n"); - return asImp_().template reactiveVolumeFractionAtPos(scv.center(), compIdx); + return this->asImp_().template reactiveVolumeFractionAtPos(scv.center(), compIdx); } /*! @@ -278,7 +257,7 @@ public: " const ElemVolVars& elemVolVars,\n" " const FluxVarsCache& fluxVarsCache) const\n\n"); - return asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal()); + return this->asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal()); } /*! @@ -310,23 +289,10 @@ public: " const ElemVolVars& elemVolVars,\n" " const FluxVarsCache& fluxVarsCache) const\n\n"); - return asImp_().biotCoefficientAtPos(fluxVarsCache.ipGlobal()); + return this->asImp_().biotCoefficientAtPos(fluxVarsCache.ipGlobal()); } - - //! The finite volume grid geometry - const GridGeometry& gridGeometry() const - { return *gridGeometry_; } - -protected: - Implementation &asImp_() - { return *static_cast(this); } - - const Implementation &asImp_() const - { return *static_cast(this); } - -private: - std::shared_ptr gridGeometry_; - GlobalPosition gravity_; //!< The gravity vector }; + } // end namespace Dumux + #endif -- GitLab From e186d4ad446e9643d0e314ae3972783a8eb7caab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Tue, 19 Oct 2021 13:38:21 +0200 Subject: [PATCH 16/17] [geomechanics] move spatial params headers --- dumux/geomechanics/elastic/fvspatialparams.hh | 142 +++++++++ .../poroelastic/fvspatialparams.hh | 298 ++++++++++++++++++ dumux/material/spatialparams/fvelastic.hh | 120 +------ dumux/material/spatialparams/fvporoelastic.hh | 276 +--------------- 4 files changed, 448 insertions(+), 388 deletions(-) create mode 100644 dumux/geomechanics/elastic/fvspatialparams.hh create mode 100644 dumux/geomechanics/poroelastic/fvspatialparams.hh diff --git a/dumux/geomechanics/elastic/fvspatialparams.hh b/dumux/geomechanics/elastic/fvspatialparams.hh new file mode 100644 index 0000000000..a1c98ccb59 --- /dev/null +++ b/dumux/geomechanics/elastic/fvspatialparams.hh @@ -0,0 +1,142 @@ +// -*- 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 3 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 . * + *****************************************************************************/ +/*! + * \file + * \ingroup SpatialParameters + * \brief The base class for spatial parameters of linear elastic geomechanical problems + */ +#ifndef DUMUX_GEOMECHANICS_ELASTIC_FV_SPATIAL_PARAMS_HH +#define DUMUX_GEOMECHANICS_ELASTIC_FV_SPATIAL_PARAMS_HH + +#include + +#include + +#include +#include +#include + +namespace Dumux { + +#ifndef DOXYGEN +namespace Detail { +// helper struct detecting if the user-defined spatial params class has a lameParamsAtPos function +// for g++ > 5.3, this can be replaced by a lambda +template +struct hasLameParamsAtPos +{ + template + auto operator()(const SpatialParams& a) + -> decltype(a.lameParamsAtPos(std::declval())) + {} +}; + +} // end namespace Detail +#endif + +/*! + * \ingroup SpatialParameters + * \brief The base class for spatial parameters of linear elastic geomechanical problems + */ +template +class FVSpatialParamsElastic +: public FVSpatialParamsBase +{ + using ParentType = FVSpatialParamsBase + using Element = typename GridGeometry::GridView::template Codim<0>::Entity; + using FVElementGeometry = typename GridGeometry::LocalView; + using SubControlVolume = typename GridGeometry::SubControlVolume; + using GlobalPosition = typename Element::Geometry::GlobalCoordinate; + +public: + using ParentType::ParentType; + + /*! + * \brief Function for defining the solid volume fraction. + * That is possibly solution dependent. + * + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + * \param compIdx The solid component index + * \return the volume fraction of the inert solid component with index compIdx + */ + template + Scalar inertVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { + static_assert(SolidSystem::isInert(), "Elastic model can only be used with inert solid systems"); + + // when there is only one component, the volume fraction must be one + if (SolidSystem::numInertComponents == 1) + return 1.0; + + // otherwise we require the user to define the solid composition + return this->asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); + } + + /*! + * \brief Function for defining the solid volume fraction. + * That is possibly solution dependent. + * + * \param globalPos The global position + * \param compIdx The solid component index + * \return the volume fraction of the inert solid component with index compIdx + */ + template + Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const + { DUNE_THROW(Dune::InvalidStateException, "The spatial parameters do not provide inertVolumeFractionAtPos() method."); } + + /*! + * \brief Define the Lame parameters + * \note These are possibly solution dependent and are evaluated + * for an integration point inside the element. Therefore, + * a flux variables cache object is passed to this function + * containing data on shape functions at the integration point. + * + * \param element The current element + * \param fvGeometry The local finite volume geometry + * \param elemVolVars Primary/Secondary variables inside the element + * \param fluxVarsCache Contains data on shape functions at the integration point + * \return lame parameters + */ + template + decltype(auto) lameParams(const Element& element, + const FVElementGeometry& fvGeometry, + const ElemVolVars& elemVolVars, + const FluxVarsCache& fluxVarsCache) const + { + static_assert(decltype(isValid(Detail::hasLameParamsAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " const LameParams& lameParamsAtPos(const GlobalPosition& globalPos) const\n\n" + " or overload this function\n\n" + " template\n" + " const LameParams& lameParams(const Element& element,\n" + " const FVElementGeometry& fvGeometry,\n" + " const ElemVolVars& elemVolVars,\n" + " const FluxVarsCache& fluxVarsCache) const\n\n"); + + return this->asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal()); + } +}; + +} // end namespace Dumux +#endif diff --git a/dumux/geomechanics/poroelastic/fvspatialparams.hh b/dumux/geomechanics/poroelastic/fvspatialparams.hh new file mode 100644 index 0000000000..92ca7c25b8 --- /dev/null +++ b/dumux/geomechanics/poroelastic/fvspatialparams.hh @@ -0,0 +1,298 @@ +// -*- 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 3 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 . * + *****************************************************************************/ +/*! + * \file + * \ingroup SpatialParameters + * \brief The base class for spatial parameters of poro-elastic geomechanical problems + */ +#ifndef DUMUX_GEOMECHANICS_POROELASTIC_FV_SPATIAL_PARAMS_HH +#define DUMUX_GEOMECHANICS_POROELASTIC_FV_SPATIAL_PARAMS_HH + +#include + +#include +#include +#include +#include + +namespace Dumux { + +#ifndef DOXYGEN +namespace Detail { +// helper struct detecting if the user-defined spatial params class has a lameParamsAtPos function +// for g++ > 5.3, this can be replaced by a lambda +template +struct hasLameParamsAtPos +{ + template + auto operator()(const SpatialParams& a) + -> decltype(a.lameParamsAtPos(std::declval())) + {} +}; + +// helper struct detecting if the user-defined spatial params class has a reactiveVolumeFractionAtPos function +// for g++ > 5.3, this can be replaced by a lambda +template +struct hasReactiveVolumeFractionAtPos +{ + template + auto operator()(const SpatialParams& a) + -> decltype(a.template reactiveVolumeFractionAtPos(std::declval(), 0)) + {} +}; + +// helper struct detecting if the user-defined spatial params class has a biotCoefficientAtPos function +// for g++ > 5.3, this can be replaced by a lambda +template +struct hasBiotCoeffAtPos +{ + template + auto operator()(const SpatialParams& a) + -> decltype(a.biotCoefficientAtPos(std::declval())) + {} +}; + +} // end namespace Detail +#endif + +/*! + * \ingroup SpatialParameters + * \brief The base class for spatial parameters of poro-elastic geomechanical problems + */ +template +class FVSpatialParamsPoroElastic +: public FVSpatialParamsBase +{ + using ParentType = FVSpatialParamsBase; + using Element = typename GridGeometry::GridView::template Codim<0>::Entity; + using FVElementGeometry = typename GridGeometry::LocalView; + using SubControlVolume = typename GridGeometry::SubControlVolume; + using GlobalPosition = typename Element::Geometry::GlobalCoordinate; + +public: + using ParentType::ParentType; + + /*! + * \brief Function for defining the porosity. + * That is possibly solution dependent. + * \note this can only be used for solids with one inert component + * (see inertVolumeFraction for the more general interface) + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + * \return the porosity + */ + template + Scalar porosity(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol) const + { + static_assert(decltype(isValid(Detail::hasPorosityAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n" + " or overload this function\n\n" + " template\n" + " Scalar porosity(const Element& element,\n" + " const SubControlVolume& scv,\n" + " const ElementSolution& elemSol) const\n\n"); + + return this->asImp_().porosityAtPos(scv.center()); + } + + /*! + * \brief Function for defining the solid volume fraction. + * That is possibly solution dependent. + * + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + * \param compIdx The solid component index + * \return the volume fraction of the inert solid component with index compIdx + * + * \note this overload is enabled if there is only one inert solid component and the + * user didn't choose to implement an inertVolumeFractionAtPos overload. + * It then forwards to the simpler porosity interface. + * With more than one solid components or active solid components (i.e. dissolution) + * please overload the more general inertVolumeFraction/inertVolumeFractionAtPos interface. + */ + template()) + (std::declval()))::value, int> = 0> + Scalar inertVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { return 1.0 - this->asImp_().porosity(element, scv, elemSol); } + + // specialization if there are no inert components at all + template = 0> + Scalar inertVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { return 0.0; } + + // the more general interface forwarding to inertVolumeFractionAtPos + template 1) || + ( + (SolidSystem::numInertComponents > 0) && + ( + !SolidSystem::isInert() + || decltype(isValid(Detail::hasInertVolumeFractionAtPos()) + (std::declval()))::value + ) + ), int> = 0> + Scalar inertVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { + static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " template\n" + " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n" + " or overload this function\n\n" + " template\n" + " Scalar inertVolumeFraction(const Element& element,\n" + " const SubControlVolume& scv,\n" + " const ElementSolution& elemSol,\n" + " int compIdx) const\n\n"); + + return this->asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); + } + + /*! + * \brief Function for defining the solid volume fraction of a solid + * component that takes part in some sort of reaction. + * + * \param element The current element + * \param scv The sub-control volume inside the element. + * \param elemSol The solution at the dofs connected to the element. + * \param compIdx The solid component index + * \return the volume fraction of the inert solid component with index compIdx + * + * \note This overload is enabled if there are only inert solid components + * and the user did not choose to implement a reactiveVolumeFractionAtPos + * function. The reactive volume fraction is zero in this case. + */ + template()) + (std::declval()))::value, int > = 0 > + Scalar reactiveVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { return 0.0; } + + //! overload for the case of reactive solids or user-provided overload + template()) + (std::declval()))::value, int > = 0 > + Scalar reactiveVolumeFraction(const Element& element, + const SubControlVolume& scv, + const ElementSolution& elemSol, + int compIdx) const + { + static_assert(decltype(isValid(Detail::hasReactiveVolumeFractionAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " template\n" + " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n" + " or overload this function\n\n" + " template\n" + " Scalar inertVolumeFraction(const Element& element,\n" + " const SubControlVolume& scv,\n" + " const ElementSolution& elemSol,\n" + " int compIdx) const\n\n"); + + return this->asImp_().template reactiveVolumeFractionAtPos(scv.center(), compIdx); + } + + /*! + * \brief Define the Lame parameters + * \note These are possibly solution dependent and are evaluated + * for an integration point inside the element. Therefore, + * a flux variables cache object is passed to this function + * containing data on shape functions at the integration point. + * + * \param element The current element + * \param fvGeometry The local finite volume geometry + * \param elemVolVars Primary/Secondary variables inside the element + * \param fluxVarsCache Contains data on shape functions at the integration point + * \return lame parameters + */ + template + decltype(auto) lameParams(const Element& element, + const FVElementGeometry& fvGeometry, + const ElemVolVars& elemVolVars, + const FluxVarsCache& fluxVarsCache) const + { + static_assert(decltype(isValid(Detail::hasLameParamsAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " const LameParams& lameParamsAtPos(const GlobalPosition& globalPos) const\n\n" + " or overload this function\n\n" + " template\n" + " const LameParams& lameParams(const Element& element,\n" + " const FVElementGeometry& fvGeometry,\n" + " const ElemVolVars& elemVolVars,\n" + " const FluxVarsCache& fluxVarsCache) const\n\n"); + + return this->asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal()); + } + + /*! + * \brief Returns the Biot coefficient in an element + * \note This is possibly solution dependent and is evaluated + * for an integration point inside the element. Therefore, + * a flux variables cache object is passed to this function + * containing data on shape functions at the integration point. + * + * \param element The current element + * \param fvGeometry The local finite volume geometry + * \param elemVolVars Primary/Secondary variables inside the element + * \param fluxVarsCache Contains data on shape functions at the integration point + * \return Biot coefficient + */ + template + Scalar biotCoefficient(const Element& element, + const FVElementGeometry& fvGeometry, + const ElemVolVars& elemVolVars, + const FluxVarsCache& fluxVarsCache) const + { + static_assert(decltype(isValid(Detail::hasBiotCoeffAtPos())(this->asImp_()))::value," \n\n" + " Your spatial params class has to either implement\n\n" + " const LameParams& biotCoefficientAtPos(const GlobalPosition& globalPos) const\n\n" + " or overload this function\n\n" + " template\n" + " const LameParams& biotCoefficient(const Element& element,\n" + " const FVElementGeometry& fvGeometry,\n" + " const ElemVolVars& elemVolVars,\n" + " const FluxVarsCache& fluxVarsCache) const\n\n"); + + return this->asImp_().biotCoefficientAtPos(fluxVarsCache.ipGlobal()); + } +}; + +} // end namespace Dumux + +#endif diff --git a/dumux/material/spatialparams/fvelastic.hh b/dumux/material/spatialparams/fvelastic.hh index a1c98ccb59..a0aead1de9 100644 --- a/dumux/material/spatialparams/fvelastic.hh +++ b/dumux/material/spatialparams/fvelastic.hh @@ -21,122 +21,10 @@ * \ingroup SpatialParameters * \brief The base class for spatial parameters of linear elastic geomechanical problems */ -#ifndef DUMUX_GEOMECHANICS_ELASTIC_FV_SPATIAL_PARAMS_HH -#define DUMUX_GEOMECHANICS_ELASTIC_FV_SPATIAL_PARAMS_HH +#ifndef DUMUX_MATERIAL_ELASTIC_SPATIAL_PARAMS_HH +#define DUMUX_MATERIAL_ELASTIC_SPATIAL_PARAMS_HH -#include +#warning "This header will be removed after 3.5 in favor of dumux/geomechanics/elastic/fvspatialparams.hh" +#include -#include - -#include -#include -#include - -namespace Dumux { - -#ifndef DOXYGEN -namespace Detail { -// helper struct detecting if the user-defined spatial params class has a lameParamsAtPos function -// for g++ > 5.3, this can be replaced by a lambda -template -struct hasLameParamsAtPos -{ - template - auto operator()(const SpatialParams& a) - -> decltype(a.lameParamsAtPos(std::declval())) - {} -}; - -} // end namespace Detail -#endif - -/*! - * \ingroup SpatialParameters - * \brief The base class for spatial parameters of linear elastic geomechanical problems - */ -template -class FVSpatialParamsElastic -: public FVSpatialParamsBase -{ - using ParentType = FVSpatialParamsBase - using Element = typename GridGeometry::GridView::template Codim<0>::Entity; - using FVElementGeometry = typename GridGeometry::LocalView; - using SubControlVolume = typename GridGeometry::SubControlVolume; - using GlobalPosition = typename Element::Geometry::GlobalCoordinate; - -public: - using ParentType::ParentType; - - /*! - * \brief Function for defining the solid volume fraction. - * That is possibly solution dependent. - * - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - * \param compIdx The solid component index - * \return the volume fraction of the inert solid component with index compIdx - */ - template - Scalar inertVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { - static_assert(SolidSystem::isInert(), "Elastic model can only be used with inert solid systems"); - - // when there is only one component, the volume fraction must be one - if (SolidSystem::numInertComponents == 1) - return 1.0; - - // otherwise we require the user to define the solid composition - return this->asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); - } - - /*! - * \brief Function for defining the solid volume fraction. - * That is possibly solution dependent. - * - * \param globalPos The global position - * \param compIdx The solid component index - * \return the volume fraction of the inert solid component with index compIdx - */ - template - Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const - { DUNE_THROW(Dune::InvalidStateException, "The spatial parameters do not provide inertVolumeFractionAtPos() method."); } - - /*! - * \brief Define the Lame parameters - * \note These are possibly solution dependent and are evaluated - * for an integration point inside the element. Therefore, - * a flux variables cache object is passed to this function - * containing data on shape functions at the integration point. - * - * \param element The current element - * \param fvGeometry The local finite volume geometry - * \param elemVolVars Primary/Secondary variables inside the element - * \param fluxVarsCache Contains data on shape functions at the integration point - * \return lame parameters - */ - template - decltype(auto) lameParams(const Element& element, - const FVElementGeometry& fvGeometry, - const ElemVolVars& elemVolVars, - const FluxVarsCache& fluxVarsCache) const - { - static_assert(decltype(isValid(Detail::hasLameParamsAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " const LameParams& lameParamsAtPos(const GlobalPosition& globalPos) const\n\n" - " or overload this function\n\n" - " template\n" - " const LameParams& lameParams(const Element& element,\n" - " const FVElementGeometry& fvGeometry,\n" - " const ElemVolVars& elemVolVars,\n" - " const FluxVarsCache& fluxVarsCache) const\n\n"); - - return this->asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal()); - } -}; - -} // end namespace Dumux #endif diff --git a/dumux/material/spatialparams/fvporoelastic.hh b/dumux/material/spatialparams/fvporoelastic.hh index b6306ded2f..b1d6df3116 100644 --- a/dumux/material/spatialparams/fvporoelastic.hh +++ b/dumux/material/spatialparams/fvporoelastic.hh @@ -21,278 +21,10 @@ * \ingroup SpatialParameters * \brief The base class for spatial parameters of poro-elastic geomechanical problems */ -#ifndef DUMUX_GEOMECHANICS_POROELASTIC_FV_SPATIAL_PARAMS_HH -#define DUMUX_GEOMECHANICS_POROELASTIC_FV_SPATIAL_PARAMS_HH +#ifndef DUMUX_MATERIAL_POROELASTIC_SPATIAL_PARAMS_HH +#define DUMUX_MATERIAL_POROELASTIC_SPATIAL_PARAMS_HH -#include - -#include -#include -#include -#include - -namespace Dumux { - -#ifndef DOXYGEN -namespace Detail { -// helper struct detecting if the user-defined spatial params class has a lameParamsAtPos function -// for g++ > 5.3, this can be replaced by a lambda -template -struct hasLameParamsAtPos -{ - template - auto operator()(const SpatialParams& a) - -> decltype(a.lameParamsAtPos(std::declval())) - {} -}; - -// helper struct detecting if the user-defined spatial params class has a reactiveVolumeFractionAtPos function -// for g++ > 5.3, this can be replaced by a lambda -template -struct hasReactiveVolumeFractionAtPos -{ - template - auto operator()(const SpatialParams& a) - -> decltype(a.template reactiveVolumeFractionAtPos(std::declval(), 0)) - {} -}; - -// helper struct detecting if the user-defined spatial params class has a biotCoefficientAtPos function -// for g++ > 5.3, this can be replaced by a lambda -template -struct hasBiotCoeffAtPos -{ - template - auto operator()(const SpatialParams& a) - -> decltype(a.biotCoefficientAtPos(std::declval())) - {} -}; - -} // end namespace Detail -#endif - -/*! - * \ingroup SpatialParameters - * \brief The base class for spatial parameters of poro-elastic geomechanical problems - */ -template -class FVSpatialParamsPoroElastic -: public FVSpatialParamsBase -{ - using ParentType = FVSpatialParamsBase; - using Element = typename GridGeometry::GridView::template Codim<0>::Entity; - using FVElementGeometry = typename GridGeometry::LocalView; - using SubControlVolume = typename GridGeometry::SubControlVolume; - using GlobalPosition = typename Element::Geometry::GlobalCoordinate; - -public: - using ParentType::ParentType; - - /*! - * \brief Function for defining the porosity. - * That is possibly solution dependent. - * \note this can only be used for solids with one inert component - * (see inertVolumeFraction for the more general interface) - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - * \return the porosity - */ - template - Scalar porosity(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol) const - { - static_assert(decltype(isValid(Detail::hasPorosityAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " Scalar porosityAtPos(const GlobalPosition& globalPos) const\n\n" - " or overload this function\n\n" - " template\n" - " Scalar porosity(const Element& element,\n" - " const SubControlVolume& scv,\n" - " const ElementSolution& elemSol) const\n\n"); - - return this->asImp_().porosityAtPos(scv.center()); - } - - /*! - * \brief Function for defining the solid volume fraction. - * That is possibly solution dependent. - * - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - * \param compIdx The solid component index - * \return the volume fraction of the inert solid component with index compIdx - * - * \note this overload is enabled if there is only one inert solid component and the - * user didn't choose to implement an inertVolumeFractionAtPos overload. - * It then forwards to the simpler porosity interface. - * With more than one solid components or active solid components (i.e. dissolution) - * please overload the more general inertVolumeFraction/inertVolumeFractionAtPos interface. - */ - template()) - (std::declval()))::value, int> = 0> - Scalar inertVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { return 1.0 - this->asImp_().porosity(element, scv, elemSol); } - - // specialization if there are no inert components at all - template = 0> - Scalar inertVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { return 0.0; } - - // the more general interface forwarding to inertVolumeFractionAtPos - template 1) || - ( - (SolidSystem::numInertComponents > 0) && - ( - !SolidSystem::isInert() - || decltype(isValid(Detail::hasInertVolumeFractionAtPos()) - (std::declval()))::value - ) - ), int> = 0> - Scalar inertVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { - static_assert(decltype(isValid(Detail::hasInertVolumeFractionAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " template\n" - " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n" - " or overload this function\n\n" - " template\n" - " Scalar inertVolumeFraction(const Element& element,\n" - " const SubControlVolume& scv,\n" - " const ElementSolution& elemSol,\n" - " int compIdx) const\n\n"); - - return this->asImp_().template inertVolumeFractionAtPos(scv.center(), compIdx); - } - - /*! - * \brief Function for defining the solid volume fraction of a solid - * component that takes part in some sort of reaction. - * - * \param element The current element - * \param scv The sub-control volume inside the element. - * \param elemSol The solution at the dofs connected to the element. - * \param compIdx The solid component index - * \return the volume fraction of the inert solid component with index compIdx - * - * \note This overload is enabled if there are only inert solid components - * and the user did not choose to implement a reactiveVolumeFractionAtPos - * function. The reactive volume fraction is zero in this case. - */ - template()) - (std::declval()))::value, int > = 0 > - Scalar reactiveVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { return 0.0; } - - //! overload for the case of reactive solids or user-provided overload - template()) - (std::declval()))::value, int > = 0 > - Scalar reactiveVolumeFraction(const Element& element, - const SubControlVolume& scv, - const ElementSolution& elemSol, - int compIdx) const - { - static_assert(decltype(isValid(Detail::hasReactiveVolumeFractionAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " template\n" - " Scalar inertVolumeFractionAtPos(const GlobalPosition& globalPos, int compIdx) const\n\n" - " or overload this function\n\n" - " template\n" - " Scalar inertVolumeFraction(const Element& element,\n" - " const SubControlVolume& scv,\n" - " const ElementSolution& elemSol,\n" - " int compIdx) const\n\n"); - - return this->asImp_().template reactiveVolumeFractionAtPos(scv.center(), compIdx); - } - - /*! - * \brief Define the Lame parameters - * \note These are possibly solution dependent and are evaluated - * for an integration point inside the element. Therefore, - * a flux variables cache object is passed to this function - * containing data on shape functions at the integration point. - * - * \param element The current element - * \param fvGeometry The local finite volume geometry - * \param elemVolVars Primary/Secondary variables inside the element - * \param fluxVarsCache Contains data on shape functions at the integration point - * \return lame parameters - */ - template - decltype(auto) lameParams(const Element& element, - const FVElementGeometry& fvGeometry, - const ElemVolVars& elemVolVars, - const FluxVarsCache& fluxVarsCache) const - { - static_assert(decltype(isValid(Detail::hasLameParamsAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " const LameParams& lameParamsAtPos(const GlobalPosition& globalPos) const\n\n" - " or overload this function\n\n" - " template\n" - " const LameParams& lameParams(const Element& element,\n" - " const FVElementGeometry& fvGeometry,\n" - " const ElemVolVars& elemVolVars,\n" - " const FluxVarsCache& fluxVarsCache) const\n\n"); - - return this->asImp_().lameParamsAtPos(fluxVarsCache.ipGlobal()); - } - - /*! - * \brief Returns the Biot coefficient in an element - * \note This is possibly solution dependent and is evaluated - * for an integration point inside the element. Therefore, - * a flux variables cache object is passed to this function - * containing data on shape functions at the integration point. - * - * \param element The current element - * \param fvGeometry The local finite volume geometry - * \param elemVolVars Primary/Secondary variables inside the element - * \param fluxVarsCache Contains data on shape functions at the integration point - * \return Biot coefficient - */ - template - Scalar biotCoefficient(const Element& element, - const FVElementGeometry& fvGeometry, - const ElemVolVars& elemVolVars, - const FluxVarsCache& fluxVarsCache) const - { - static_assert(decltype(isValid(Detail::hasBiotCoeffAtPos())(this->asImp_()))::value," \n\n" - " Your spatial params class has to either implement\n\n" - " const LameParams& biotCoefficientAtPos(const GlobalPosition& globalPos) const\n\n" - " or overload this function\n\n" - " template\n" - " const LameParams& biotCoefficient(const Element& element,\n" - " const FVElementGeometry& fvGeometry,\n" - " const ElemVolVars& elemVolVars,\n" - " const FluxVarsCache& fluxVarsCache) const\n\n"); - - return this->asImp_().biotCoefficientAtPos(fluxVarsCache.ipGlobal()); - } -}; - -} // end namespace Dumux +#warning "This header will be removed after 3.5 in favor of dumux/geomechanics/poroelastic/fvspatialparams.hh" +#include #endif -- GitLab From 47df77f00ce6294285641186e17ed886c33d9a7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= Date: Tue, 19 Oct 2021 09:22:36 +0200 Subject: [PATCH 17/17] [common][fvprob] deprecate extrusion factor --- dumux/common/fvproblem.hh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dumux/common/fvproblem.hh b/dumux/common/fvproblem.hh index 313b523ac0..10b3b9acea 100644 --- a/dumux/common/fvproblem.hh +++ b/dumux/common/fvproblem.hh @@ -565,6 +565,7 @@ public: * are assumed to extend 1 m to the back. */ template + [[deprecated("Use problem.spatialParams().extrusionFactor() instead!")]] Scalar extrusionFactor(const Element& element, const SubControlVolume& scv, const ElementSolution& elemSol) const @@ -582,6 +583,7 @@ public: * thought as pipes with a cross section of 1 m^2 and 2D problems * are assumed to extend 1 m to the back. */ + [[deprecated("Use problem.spatialParams().extrusionFactorAtPos() instead!")]] Scalar extrusionFactorAtPos(const GlobalPosition &globalPos) const { // As a default, i.e. if the user's problem does not overload -- GitLab