diff --git a/dumux/common/deprecated.hh b/dumux/common/deprecated.hh index 42744d3fad3cf1b5de9d7d50fed0bbe2ddba01fc..b3eed110cec0adf0be176ac91d3871c01f3a6d23 100644 --- a/dumux/common/deprecated.hh +++ b/dumux/common/deprecated.hh @@ -69,11 +69,11 @@ static constexpr bool hasHasWallBC() { return Dune::Std::is_detected<HasWallBCDetector, BcTypes>::value; } template <typename ModelTraits> -using HasEnableDispersionDetector = decltype(ModelTraits::enableDispersion()); +using HasEnableCompositionalDispersionDetector = decltype(ModelTraits::enableCompositionalDispersion()); template<class ModelTraits> -static constexpr bool hasEnableDispersion() -{ return Dune::Std::is_detected<HasEnableDispersionDetector, ModelTraits>::value; } +static constexpr bool hasEnableCompositionalDispersion() +{ return Dune::Std::is_detected<HasEnableCompositionalDispersionDetector, ModelTraits>::value; } } // end namespace Deprecated #endif diff --git a/dumux/porousmediumflow/1pnc/model.hh b/dumux/porousmediumflow/1pnc/model.hh index 18024763d0a89a365f32536f610fd4f9727b6838..986b99ad67e7b0b920839be644e39755a141d03a 100644 --- a/dumux/porousmediumflow/1pnc/model.hh +++ b/dumux/porousmediumflow/1pnc/model.hh @@ -85,7 +85,7 @@ namespace Dumux { * * \tparam nComp the number of components to be considered. */ -template<int nComp, bool useM, int repCompEqIdx = nComp> +template<int nComp, bool useM, int enableCompDisp, int repCompEqIdx = nComp> struct OnePNCModelTraits { using Indices = OnePNCIndices; @@ -98,6 +98,7 @@ struct OnePNCModelTraits static constexpr bool useMoles() { return useM; } static constexpr bool enableAdvection() { return true; } static constexpr bool enableMolecularDiffusion() { return true; } + static constexpr bool enableCompositionalDispersion() { return enableCompDisp; } static constexpr bool enableEnergyBalance() { return false; } }; @@ -128,8 +129,12 @@ struct BaseModelTraits<TypeTag, TTag::OnePNC> { private: using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>; + public: - using type = OnePNCModelTraits<FluidSystem::numComponents, getPropValue<TypeTag, Properties::UseMoles>(), getPropValue<TypeTag, Properties::ReplaceCompEqIdx>()>; + using type = OnePNCModelTraits<FluidSystem::numComponents, + getPropValue<TypeTag, Properties::UseMoles>(), + getPropValue<TypeTag, Properties::EnableCompositionalDispersion>(), + getPropValue<TypeTag, Properties::ReplaceCompEqIdx>()>; }; template<class TypeTag> struct ModelTraits<TypeTag, TTag::OnePNC> { using type = GetPropType<TypeTag, Properties::BaseModelTraits>; }; //!< default the actually used traits to the base traits @@ -183,17 +188,19 @@ private: static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state"); using BaseTraits = OnePVolumeVariablesTraits<PV, FSY, FST, SSY, SST, PT, MT>; + using DTT = GetPropType<TypeTag, Properties::DispersionTensorType>; using DT = GetPropType<TypeTag, Properties::MolecularDiffusionType>; using EDM = GetPropType<TypeTag, Properties::EffectiveDiffusivityModel>; - template<class BaseTraits, class DT, class EDM> + template<class BaseTraits, class DTT, class DT, class EDM> struct NCTraits : public BaseTraits { + using DispersionTensorType = DTT; using DiffusionType = DT; using EffectiveDiffusivityModel = EDM; }; public: - using type = OnePNCVolumeVariables<NCTraits<BaseTraits, DT, EDM>>; + using type = OnePNCVolumeVariables<NCTraits<BaseTraits, DTT, DT, EDM>>; }; //! Set the vtk output fields specific to this model @@ -240,6 +247,7 @@ private: static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state"); using BaseTraits = OnePVolumeVariablesTraits<PV, FSY, FST, SSY, SST, PT, MT>; + using DTT = GetPropType<TypeTag, Properties::DispersionTensorType>; using DT = GetPropType<TypeTag, Properties::MolecularDiffusionType>; using EDM = GetPropType<TypeTag, Properties::EffectiveDiffusivityModel>; using ETCM = GetPropType< TypeTag, Properties:: ThermalConductivityModel>; @@ -310,7 +318,10 @@ struct EquilibriumModelTraits<TypeTag, TTag::OnePNCNonEquil> { private: using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>; - using EquilibriumTraits = OnePNCModelTraits<FluidSystem::numComponents, getPropValue<TypeTag, Properties::UseMoles>(), getPropValue<TypeTag, Properties::ReplaceCompEqIdx>()>; + using EquilibriumTraits = OnePNCModelTraits<FluidSystem::numComponents, + getPropValue<TypeTag, Properties::UseMoles>(), + getPropValue<TypeTag, Properties::EnableCompositionalDispersion>(), + getPropValue<TypeTag, Properties::ReplaceCompEqIdx>()>; public: using type = OnePNCUnconstrainedModelTraits<EquilibriumTraits>; }; diff --git a/dumux/porousmediumflow/1pnc/volumevariables.hh b/dumux/porousmediumflow/1pnc/volumevariables.hh index 58e84c9ba00799d972111150e765a3047eb09c51..ac3a4cbd7eb7ff4628151694c3ceab9b9d39b00b 100644 --- a/dumux/porousmediumflow/1pnc/volumevariables.hh +++ b/dumux/porousmediumflow/1pnc/volumevariables.hh @@ -64,6 +64,8 @@ class OnePNCVolumeVariables }; public: + //! Export the dispersion tensor law + using DispersionTensorType = typename Traits::DispersionTensorType; //! Export fluid state type using FluidState = typename Traits::FluidState; //! Export fluid system type diff --git a/dumux/porousmediumflow/1pncmin/model.hh b/dumux/porousmediumflow/1pncmin/model.hh index dbeb9e94104637ff33dcbd3b9c3a4b3fb01cfda0..21c066bbf2797d158154b559aa583f218aac061a 100644 --- a/dumux/porousmediumflow/1pncmin/model.hh +++ b/dumux/porousmediumflow/1pncmin/model.hh @@ -115,20 +115,20 @@ private: static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state"); using BaseTraits = OnePVolumeVariablesTraits<PV, FSY, FST, SSY, SST, PT, MT>; - using DTL = GetPropType<TypeTag, Properties::DispersionTensorLaw>; + using DTT = GetPropType<TypeTag, Properties::DispersionTensorType>; using DT = GetPropType<TypeTag, Properties::MolecularDiffusionType>; using EDM = GetPropType<TypeTag, Properties::EffectiveDiffusivityModel>; - template<class BaseTraits, class DTL, class DT, class EDM> + template<class BaseTraits, class DTT, class DT, class EDM> struct NCTraits : public BaseTraits { - using DispersionTensorLaw = DTL; + using DispersionTensorType = DTT; using DiffusionType = DT; using EffectiveDiffusivityModel = EDM; }; - using NonMinVolVars = OnePNCVolumeVariables<NCTraits<BaseTraits, DTL, DT, EDM>>; + using NonMinVolVars = OnePNCVolumeVariables<NCTraits<BaseTraits, DTT, DT, EDM>>; public: - using type = MineralizationVolumeVariables<NCTraits<BaseTraits, DTL, DT, EDM>, NonMinVolVars>; + using type = MineralizationVolumeVariables<NCTraits<BaseTraits, DTT, DT, EDM>, NonMinVolVars>; }; // Use the mineralization local residual @@ -203,21 +203,21 @@ private: static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state"); using BaseTraits = OnePVolumeVariablesTraits<PV, FSY, FST, SSY, SST, PT, MT>; - using DTL = GetPropType<TypeTag, Properties::DispersionTensorLaw>; + using DTT = GetPropType<TypeTag, Properties::DispersionTensorType>; using DT = GetPropType<TypeTag, Properties::MolecularDiffusionType>; using EDM = GetPropType<TypeTag, Properties::EffectiveDiffusivityModel>; using ETCM = GetPropType< TypeTag, Properties:: ThermalConductivityModel>; - template<class BaseTraits, class DTL, class DT, class EDM, class ETCM> + template<class BaseTraits, class DTT, class DT, class EDM, class ETCM> struct NCNITraits : public BaseTraits { - using DispersionTensorLaw = DTL; + using DispersionTensorType = DTT; using DiffusionType = DT; using EffectiveDiffusivityModel = EDM; using EffectiveThermalConductivityModel = ETCM; }; - using NonMinVolVars = OnePNCVolumeVariables<NCNITraits<BaseTraits, DTL, DT, EDM, ETCM>>; + using NonMinVolVars = OnePNCVolumeVariables<NCNITraits<BaseTraits, DTT, DT, EDM, ETCM>>; public: - using type = MineralizationVolumeVariables<NCNITraits<BaseTraits, DTL, DT, EDM, ETCM>, NonMinVolVars>; + using type = MineralizationVolumeVariables<NCNITraits<BaseTraits, DTT, DT, EDM, ETCM>, NonMinVolVars>; }; //! Use the average for effective conductivities template<class TypeTag> diff --git a/dumux/porousmediumflow/compositional/localresidual.hh b/dumux/porousmediumflow/compositional/localresidual.hh index f5cb7a2c20a2817cfa12bf7ae33625bd9189e92e..d06028eeb6fe6565f36cf92e9a431a9ce6de6e0c 100644 --- a/dumux/porousmediumflow/compositional/localresidual.hh +++ b/dumux/porousmediumflow/compositional/localresidual.hh @@ -28,6 +28,7 @@ #include <vector> #include <dune/common/exceptions.hh> +#include <dumux/common/deprecated.hh> #include <dumux/common/properties.hh> #include <dumux/common/numeqvector.hh> #include <dumux/flux/referencesystemformulation.hh> @@ -211,6 +212,25 @@ public: //! Add advective phase energy fluxes. For isothermal model the contribution is zero. EnergyLocalResidual::heatConvectionFlux(flux, fluxVars, phaseIdx); + + if constexpr (Deprecated::hasEnableCompositionalDispersion<ModelTraits>()) + { + if constexpr (ModelTraits::enableCompositionalDispersion()) + { + if constexpr (FVElementGeometry::GridGeometry::discMethod == DiscretizationMethods::box && numPhases == 1) + { + const auto dispersionFluxes = fluxVars.compositionalDispersionFlux(phaseIdx); + for (int compIdx = 0; compIdx < numComponents; ++compIdx) + { + flux[compIdx] += dispersionFluxes[compIdx]; + } + } + else + DUNE_THROW(Dune::NotImplemented, "Dispersion Fluxes are only implemented for single phase flows using the Box method."); + } + } + else + enableCompositionalDispersionMissing_<ModelTraits>(); } //! Add diffusive energy fluxes. For isothermal model the contribution is zero. @@ -225,6 +245,11 @@ protected: const Implementation *asImp_() const { return static_cast<const Implementation *> (this); } + + template <class T = ModelTraits> + [[deprecated("All compositional models must specifiy if dispersion is enabled." + "Please add enableCompositionalDispersion to the ModelTraits in your model header.")]] + void enableCompositionalDispersionMissing_() const {} }; } // end namespace Dumux