diff --git a/dumux/material/fluidmatrixinteractions/porosityprecipitation.hh b/dumux/material/fluidmatrixinteractions/porosityprecipitation.hh index 68e3491e61d81c30effa9b7cc0c58ea1be9325a8..cdf9af827f3a265dc6893497a7c07b9f0d5a1a2e 100644 --- a/dumux/material/fluidmatrixinteractions/porosityprecipitation.hh +++ b/dumux/material/fluidmatrixinteractions/porosityprecipitation.hh @@ -24,7 +24,6 @@ #ifndef DUMUX_POROSITY_PRECIPITATION_HH #define DUMUX_POROSITY_PRECIPITATION_HH -#include <dumux/common/properties.hh> #include <dumux/discretization/evalsolution.hh> namespace Dumux { @@ -32,58 +31,39 @@ namespace Dumux { /*! * \ingroup Fluidmatrixinteractions * \brief Calculates the porosity depending on the volume fractions of precipitated minerals. + * + * \tparam Scalar The type used for scalar values + * \numComp The number of components in the fluid phases + * \numSolidPhases The number of precipitating solid phases */ -template<class TypeTag> +template<class Scalar, int numComp, int numSolidPhases> class PorosityPrecipitation { - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - using SpatialParams = typename GET_PROP_TYPE(TypeTag, SpatialParams); - using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry)::LocalView; - using SubControlVolume = typename FVElementGeometry::SubControlVolume; - - static const int dim = GridView::dimension; - static const int dimWorld = GridView::dimensionworld; - static const int numComponents = GET_PROP_TYPE(TypeTag, ModelTraits)::numComponents(); - static const int numSolidPhases = GET_PROP_TYPE(TypeTag, ModelTraits)::numSPhases(); - - using Element = typename GridView::template Codim<0>:: Entity; - public: - void init(const SpatialParams& spatialParams) - { - spatialParamsPtr_ = &spatialParams; - } - /*! * \brief calculates the porosity in a sub-control volume * \param element element * \param elemSol the element solution * \param scv sub control volume + * \param refPoro The solid matrix porosity without precipitates + * \param minPoro A minimum porosity value */ - template<class ElementSolution> + template<class Element, class SubControlVolume, class ElemSol> Scalar evaluatePorosity(const Element& element, const SubControlVolume& scv, - const ElementSolution& elemSol) const + const ElemSol& elemSol, + Scalar refPoro, + Scalar minPoro = 0.0) const { auto priVars = evalSolution(element, element.geometry(), elemSol, scv.center()); Scalar sumPrecipitates = 0.0; for (unsigned int solidPhaseIdx = 0; solidPhaseIdx < numSolidPhases; ++solidPhaseIdx) - sumPrecipitates += priVars[numComponents + solidPhaseIdx]; - - auto minPoro = spatialParams_().minPorosity(element, scv); + sumPrecipitates += priVars[numComp + solidPhaseIdx]; using std::max; - return max(minPoro, spatialParams_().referencePorosity(element, scv) - sumPrecipitates); + return max(minPoro, refPoro - sumPrecipitates); } - -private: - const SpatialParams& spatialParams_() const - { return *spatialParamsPtr_; } - - const SpatialParams* spatialParamsPtr_; }; } // namespace Dumux diff --git a/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hh b/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hh index 5ad810c65607c1cd52433f5faee5460dcbb53328..c6b0164a0efc417aad2cf5afb7aee29a8d4cc136 100644 --- a/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hh +++ b/test/porousmediumflow/2pncmin/implicit/dissolutionspatialparams.hh @@ -83,7 +83,8 @@ class DissolutionSpatialparams : public FVSpatialParams<TypeTag> using SubControlVolume = typename FVElementGeometry::SubControlVolume; using Element = typename GridView::template Codim<0>::Entity; - using PorosityLaw = PorosityPrecipitation<TypeTag>; + using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); + using PorosityLaw = PorosityPrecipitation<Scalar, ModelTraits::numComponents(), ModelTraits::numSPhases()>; using PermeabilityLaw = PermeabilityKozenyCarman<TypeTag>; public: @@ -110,7 +111,6 @@ public: materialParams_.setLambda(bcLambda1_); //! Initialize the parameter laws - poroLaw_.init(*this); permLaw_.init(*this); } @@ -145,7 +145,7 @@ public: Scalar porosity(const Element& element, const SubControlVolume& scv, const ElementSolution& elemSol) const - { return poroLaw_.evaluatePorosity(element, scv, elemSol); } + { return poroLaw_.evaluatePorosity(element, scv, elemSol, referencePorosity_, 1e-5); } /*! * \brief Define the reference permeability \f$[m^2]\f$ distribution