diff --git a/dumux/boxmodels/2p/2plocalresidual.hh b/dumux/boxmodels/2p/2plocalresidual.hh index f3f01ef4c5ac2a1b7b3ad0f3793a338c0f03f25d..85ad39212d8f8790892e259d5fa7f8e7ab03c6cc 100644 --- a/dumux/boxmodels/2p/2plocalresidual.hh +++ b/dumux/boxmodels/2p/2plocalresidual.hh @@ -46,7 +46,7 @@ namespace Dumux * that it uses static polymorphism. */ template<class TypeTag> -class TwoPLocalResidual: public BoxLocalResidual<TypeTag> +class TwoPLocalResidual : public BoxLocalResidual<TypeTag> { protected: typedef typename GET_PROP_TYPE(TypeTag, PTAG(LocalResidual)) Implementation; @@ -83,14 +83,24 @@ protected: typedef typename GET_PROP_TYPE(TypeTag, PTAG(VolumeVariables)) VolumeVariables; typedef typename GET_PROP_TYPE(TypeTag, PTAG(FluxVariables)) FluxVariables; typedef typename GET_PROP_TYPE(TypeTag, PTAG(ElementVolumeVariables)) ElementVolumeVariables; + typedef typename GET_PROP(TypeTag, PTAG(ParameterTree)) Params; typedef Dune::FieldVector<Scalar, dimWorld> Vector; typedef Dune::FieldMatrix<Scalar, dim, dim> Tensor; - static constexpr Scalar mobilityUpwindAlpha = - GET_PROP_VALUE(TypeTag, PTAG(MobilityUpwindAlpha)); + Scalar mobilityUpwindAlpha_; + public: + TwoPLocalResidual() + { + // retrieve the upwind weight for the mobility. Use the value + // specified via the property system as default, and overwrite + // it by the run-time parameter from the Dune::ParameterTree + mobilityUpwindAlpha_ = GET_PROP_VALUE(TypeTag, PTAG(MobilityUpwindAlpha)); + mobilityUpwindAlpha_ = Params::tree().get("MobilityUpwindAlpha", mobilityUpwindAlpha_); + }; + /*! * \brief Evaluate the amount all conservation quantities * (e.g. phase mass) within a finite sub-control volume. @@ -176,9 +186,9 @@ public: flux[eqIdx] += normalFlux * - (( mobilityUpwindAlpha)*up.density(phaseIdx)*up.mobility(phaseIdx) + (( mobilityUpwindAlpha_)*up.density(phaseIdx)*up.mobility(phaseIdx) + - (1 - mobilityUpwindAlpha)*dn.density(phaseIdx)*dn.mobility(phaseIdx)); + (1 - mobilityUpwindAlpha_)*dn.density(phaseIdx)*dn.mobility(phaseIdx)); } } diff --git a/dumux/common/basicproperties.hh b/dumux/common/basicproperties.hh index ef2cd2447f96648ee89b3cd1d4c1c07d2a381820..898f44be070e02208c07a8af4b222c6d8733540f 100644 --- a/dumux/common/basicproperties.hh +++ b/dumux/common/basicproperties.hh @@ -28,6 +28,8 @@ #include <dumux/common/propertysystem.hh> +#include <dune/common/parametertree.hh> + namespace Dumux { namespace Properties @@ -61,6 +63,9 @@ NEW_TYPE_TAG(ExplicitModel, INHERITS_FROM(NumericModel)); //! Property to specify the type of scalar values. NEW_PROP_TAG(Scalar); +//! Property which provides a Dune::ParameterTree. +NEW_PROP_TAG(ParameterTree); + /////////////////////////////////// // Default values for properties: // @@ -70,6 +75,43 @@ NEW_PROP_TAG(Scalar); //! Set the default type of scalar values to double SET_TYPE_PROP(NumericModel, Scalar, double); +//! Set the ParameterTree property +SET_PROP(NumericModel, ParameterTree) +{ + typedef Dune::ParameterTree type; + + static Dune::ParameterTree &tree() + { + if (initFinished_) { + DUNE_THROW(Dune::InvalidStateException, + "The ParameterTree cannot be accessed after " + "the initialization phase of the simulation!"); + } + + return parameterTree_; + }; + + static void initFinished() + { initFinished_ = true; } + + +private: + static Dune::ParameterTree parameterTree_; + static bool initFinished_; +}; + +// allocate space for the static parameter tree object +template<class TypeTag> +Dune::ParameterTree + Property<TypeTag, + TTAG(NumericModel), + PTAG(ParameterTree)>::parameterTree_; + +template<class TypeTag> +bool Property<TypeTag, + TTAG(NumericModel), + PTAG(ParameterTree)>::initFinished_ = false; + } // namespace Properties } // namespace Dumux diff --git a/dumux/common/propertysystem.hh b/dumux/common/propertysystem.hh index f8a2977ed07f0fc951537c76172c6a23cdf9003e..ef74c736b2782c85ddb750860c8d658fc71dca36 100644 --- a/dumux/common/propertysystem.hh +++ b/dumux/common/propertysystem.hh @@ -17,7 +17,6 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * *****************************************************************************/ - /*! * \file * \brief Provides the magic behind the DuMuX property system.