diff --git a/exercises/exercise-biomineralization/biominproblem.hh b/exercises/exercise-biomineralization/biominproblem.hh index 41061e68ff542f0d033ddb9a770b6c5e91268a73..489d26576f5f77b491a31a52a176463debffecfc 100644 --- a/exercises/exercise-biomineralization/biominproblem.hh +++ b/exercises/exercise-biomineralization/biominproblem.hh @@ -53,7 +53,7 @@ namespace Properties //! Create new type tag for the problem // Create new type tags namespace TTag { -struct ExerciseFourBioMin { using InheritsFrom = std::tuple<BioMinSpatialparams, TwoPNCMin>; }; +struct ExerciseFourBioMin { using InheritsFrom = std::tuple<TwoPNCMin>; }; struct ExerciseFourBioMinCCTpfa { using InheritsFrom = std::tuple<ExerciseFourBioMin, CCTpfaModel>; }; } // end namespace TTag @@ -92,6 +92,14 @@ struct SolidSystem<TypeTag, TTag::ExerciseFourBioMin> using type = SolidSystems::BiominSolidPhase<Scalar>; }; +// Set the spatial parameters +template<class TypeTag> +struct SpatialParams<TypeTag, TTag::ExerciseFourBioMin> { + using MT = GetPropType<TypeTag, ModelTraits>; + static constexpr int numFluidComps = MT::numFluidComponents(); + static constexpr int numActiveSolidComps = MT::numSolidComps() - MT::numInertSolidComps(); + using type = BioMinSpatialparams<GetPropType<TypeTag, FVGridGeometry>, GetPropType<TypeTag, Scalar>, numFluidComps, numActiveSolidComps>; +}; template<class TypeTag> struct EnableFVGridGeometryCache<TypeTag, TTag::ExerciseFourBioMin> { static constexpr bool value = false; }; diff --git a/exercises/exercise-biomineralization/biominspatialparams.hh b/exercises/exercise-biomineralization/biominspatialparams.hh index 12be491883ddd47bb5e96e5495b4f101b7e37520..393bd57d708f468f5bd3e62d0978184bdbb112d8 100644 --- a/exercises/exercise-biomineralization/biominspatialparams.hh +++ b/exercises/exercise-biomineralization/biominspatialparams.hh @@ -33,39 +33,20 @@ #include <dumux/discretization/method.hh> -namespace Dumux -{ -//forward declaration -template<class TypeTag> -class BioMinSpatialparams; - -namespace Properties -{ -// The spatial parameters TypeTag -NEW_TYPE_TAG(BioMinSpatialparams); - -// Set the spatial parameters -template<class TypeTag> -struct SpatialParams<TypeTag, TTag::BioMinSpatialparams> { using type = BioMinSpatialparams<TypeTag>; }; -} // end namespace Properties +namespace Dumux { /*! * \brief Definition of the spatial parameters for the biomineralisation problem * with geostatistically distributed initial permeability. */ -template<class TypeTag> +template<class FVGridGeometry, class Scalar, int numFluidComps, int numActiveSolidComps> class BioMinSpatialparams -: public FVSpatialParams<GetPropType<TypeTag, Properties::FVGridGeometry>, - GetPropType<TypeTag, Properties::Scalar>, - BioMinSpatialparams<TypeTag>> +: public FVSpatialParams<FVGridGeometry, Scalar, BioMinSpatialparams<FVGridGeometry, Scalar, numFluidComps, numActiveSolidComps>> { - using Scalar = GetPropType<TypeTag, Properties::Scalar>; - using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>; using FVElementGeometry = typename FVGridGeometry::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; - using ParentType = FVSpatialParams<FVGridGeometry, Scalar, BioMinSpatialparams<TypeTag>>; + using ParentType = FVSpatialParams<FVGridGeometry, Scalar, BioMinSpatialparams<FVGridGeometry, Scalar, numFluidComps, numActiveSolidComps>>; using EffectiveLaw = RegularizedBrooksCorey<Scalar>; - using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>; using GridView = typename FVGridGeometry::GridView; using CoordScalar = typename GridView::ctype; @@ -75,8 +56,9 @@ class BioMinSpatialparams using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>; using Tensor = Dune::FieldMatrix<CoordScalar, dimWorld, dimWorld>; + using PoroLaw = PorosityPrecipitation<Scalar, numFluidComps, numActiveSolidComps>; + public: - using SolidSystem = GetPropType<TypeTag, Properties::SolidSystem>; using PermeabilityType = Tensor; using MaterialLaw = EffToAbsLaw<EffectiveLaw>; using MaterialLawParams = typename MaterialLaw::Params; @@ -156,6 +138,7 @@ public: * \param fvGridGeometry The fvGridGeometry * \param sol The (initial) solution vector */ + template<class SolutionVector> void computeReferencePorosity(const FVGridGeometry& fvGridGeometry, const SolutionVector& sol) { @@ -174,6 +157,7 @@ public: const auto& dofPosition = scv.dofPosition(); const bool isInAquitardNotFaultZone = isInAquitard_(dofPosition) && !isFaultZone_(dofPosition); auto phi = isInAquitardNotFaultZone ? aquitardPorosity_ : initialPorosity_; + auto phiEvaluated = poroLaw_.evaluatePorosity(element, scv, elemSol, phi); referencePorosity_[eIdx][scv.indexInElement()] = calculatephiRef(phi, phiEvaluated); } @@ -226,6 +210,7 @@ public: * \param fvGridGeometry The fvGridGeometry * \param sol The (initial) solution vector */ + template<class SolutionVector> void computeReferencePermeability(const FVGridGeometry& fvGridGeometry, const SolutionVector& sol) { @@ -332,10 +317,8 @@ private: bool isFaultZone_(const GlobalPosition &globalPos) const { return globalPos[dimWorld-2] > 2 - eps_ && globalPos[dimWorld-2] < 3 + eps_;} - using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; - PorosityPrecipitation<Scalar, ModelTraits::numFluidComponents(), ModelTraits::numSolidComps()> poroLaw_; PermeabilityKozenyCarman<PermeabilityType> permLaw_; - + PoroLaw poroLaw_; Scalar initialPorosity_; std::vector< std::vector<Scalar> > referencePorosity_; diff --git a/exercises/solution/exercise-biomineralization/biominproblem.hh b/exercises/solution/exercise-biomineralization/biominproblem.hh index 311b06bdc7702ede95696c69c0b19ba830f69bbf..672b544f177e1411734e508208bd7ef56cf617b7 100644 --- a/exercises/solution/exercise-biomineralization/biominproblem.hh +++ b/exercises/solution/exercise-biomineralization/biominproblem.hh @@ -54,7 +54,7 @@ namespace Properties //! Create new type tag for the problem // Create new type tags namespace TTag { -struct ExerciseFourBioMin { using InheritsFrom = std::tuple<BioMinSpatialparams, TwoPNCMin>; }; +struct ExerciseFourBioMin { using InheritsFrom = std::tuple<TwoPNCMin>; }; struct ExerciseFourBioMinCCTpfa { using InheritsFrom = std::tuple<ExerciseFourBioMin, CCTpfaModel>; }; } // end namespace TTag @@ -93,6 +93,14 @@ struct SolidSystem<TypeTag, TTag::ExerciseFourBioMin> using type = SolidSystems::BiominSolidPhase<Scalar>; }; +// Set the spatial parameters +template<class TypeTag> +struct SpatialParams<TypeTag, TTag::ExerciseFourBioMin> { + using MT = GetPropType<TypeTag, ModelTraits>; + static constexpr int numFluidComps = MT::numFluidComponents(); + static constexpr int numActiveSolidComps = MT::numSolidComps() - MT::numInertSolidComps(); + using type = BioMinSpatialparams<GetPropType<TypeTag, FVGridGeometry>, GetPropType<TypeTag, Scalar>, numFluidComps, numActiveSolidComps>; +}; template<class TypeTag> struct EnableFVGridGeometryCache<TypeTag, TTag::ExerciseFourBioMin> { static constexpr bool value = false; }; diff --git a/exercises/solution/exercise-biomineralization/biominspatialparams.hh b/exercises/solution/exercise-biomineralization/biominspatialparams.hh index 12be491883ddd47bb5e96e5495b4f101b7e37520..393bd57d708f468f5bd3e62d0978184bdbb112d8 100644 --- a/exercises/solution/exercise-biomineralization/biominspatialparams.hh +++ b/exercises/solution/exercise-biomineralization/biominspatialparams.hh @@ -33,39 +33,20 @@ #include <dumux/discretization/method.hh> -namespace Dumux -{ -//forward declaration -template<class TypeTag> -class BioMinSpatialparams; - -namespace Properties -{ -// The spatial parameters TypeTag -NEW_TYPE_TAG(BioMinSpatialparams); - -// Set the spatial parameters -template<class TypeTag> -struct SpatialParams<TypeTag, TTag::BioMinSpatialparams> { using type = BioMinSpatialparams<TypeTag>; }; -} // end namespace Properties +namespace Dumux { /*! * \brief Definition of the spatial parameters for the biomineralisation problem * with geostatistically distributed initial permeability. */ -template<class TypeTag> +template<class FVGridGeometry, class Scalar, int numFluidComps, int numActiveSolidComps> class BioMinSpatialparams -: public FVSpatialParams<GetPropType<TypeTag, Properties::FVGridGeometry>, - GetPropType<TypeTag, Properties::Scalar>, - BioMinSpatialparams<TypeTag>> +: public FVSpatialParams<FVGridGeometry, Scalar, BioMinSpatialparams<FVGridGeometry, Scalar, numFluidComps, numActiveSolidComps>> { - using Scalar = GetPropType<TypeTag, Properties::Scalar>; - using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>; using FVElementGeometry = typename FVGridGeometry::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; - using ParentType = FVSpatialParams<FVGridGeometry, Scalar, BioMinSpatialparams<TypeTag>>; + using ParentType = FVSpatialParams<FVGridGeometry, Scalar, BioMinSpatialparams<FVGridGeometry, Scalar, numFluidComps, numActiveSolidComps>>; using EffectiveLaw = RegularizedBrooksCorey<Scalar>; - using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>; using GridView = typename FVGridGeometry::GridView; using CoordScalar = typename GridView::ctype; @@ -75,8 +56,9 @@ class BioMinSpatialparams using GlobalPosition = Dune::FieldVector<CoordScalar, dimWorld>; using Tensor = Dune::FieldMatrix<CoordScalar, dimWorld, dimWorld>; + using PoroLaw = PorosityPrecipitation<Scalar, numFluidComps, numActiveSolidComps>; + public: - using SolidSystem = GetPropType<TypeTag, Properties::SolidSystem>; using PermeabilityType = Tensor; using MaterialLaw = EffToAbsLaw<EffectiveLaw>; using MaterialLawParams = typename MaterialLaw::Params; @@ -156,6 +138,7 @@ public: * \param fvGridGeometry The fvGridGeometry * \param sol The (initial) solution vector */ + template<class SolutionVector> void computeReferencePorosity(const FVGridGeometry& fvGridGeometry, const SolutionVector& sol) { @@ -174,6 +157,7 @@ public: const auto& dofPosition = scv.dofPosition(); const bool isInAquitardNotFaultZone = isInAquitard_(dofPosition) && !isFaultZone_(dofPosition); auto phi = isInAquitardNotFaultZone ? aquitardPorosity_ : initialPorosity_; + auto phiEvaluated = poroLaw_.evaluatePorosity(element, scv, elemSol, phi); referencePorosity_[eIdx][scv.indexInElement()] = calculatephiRef(phi, phiEvaluated); } @@ -226,6 +210,7 @@ public: * \param fvGridGeometry The fvGridGeometry * \param sol The (initial) solution vector */ + template<class SolutionVector> void computeReferencePermeability(const FVGridGeometry& fvGridGeometry, const SolutionVector& sol) { @@ -332,10 +317,8 @@ private: bool isFaultZone_(const GlobalPosition &globalPos) const { return globalPos[dimWorld-2] > 2 - eps_ && globalPos[dimWorld-2] < 3 + eps_;} - using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; - PorosityPrecipitation<Scalar, ModelTraits::numFluidComponents(), ModelTraits::numSolidComps()> poroLaw_; PermeabilityKozenyCarman<PermeabilityType> permLaw_; - + PoroLaw poroLaw_; Scalar initialPorosity_; std::vector< std::vector<Scalar> > referencePorosity_;