diff --git a/dumux/flux/box/fickslaw.hh b/dumux/flux/box/fickslaw.hh index 8bc2cfa8aa8a0ff092d3ecf741a312e0c15d3e60..785e447ee0a350df6fbb4cf2b99be722539175d3 100644 --- a/dumux/flux/box/fickslaw.hh +++ b/dumux/flux/box/fickslaw.hh @@ -74,12 +74,11 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::box, referenceSystem using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>; public: - - template<int numPhases, int numComponents> + template <bool onlyTracers = false> using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar, numPhases, numComponents, - FluidSystem::isTracerFluidSystem()>; + onlyTracers>; //return the reference system static constexpr ReferenceSystemFormulation referenceSystemFormulation() diff --git a/dumux/flux/box/maxwellstefanslaw.hh b/dumux/flux/box/maxwellstefanslaw.hh index b065aff5622285ab7cda3fe20b5d8528086e9fe3..4b0bdba1118adae19f14ef25c1be5eeab3f4c484 100644 --- a/dumux/flux/box/maxwellstefanslaw.hh +++ b/dumux/flux/box/maxwellstefanslaw.hh @@ -71,9 +71,11 @@ class MaxwellStefansLawImplementation<TypeTag, DiscretizationMethod::box, refere static_assert(referenceSystem == ReferenceSystemFormulation::massAveraged, "only the mass averaged reference system is supported for the Maxwell-Stefan formulation"); public: - - template<int numFluidPhases, int numComponents> - using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, numFluidPhases, numComponents>; + template <bool onlyTracers = false> + using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, + numFluidPhases, + numComponents, + onlyTracers>; //return the reference system static constexpr ReferenceSystemFormulation referenceSystemFormulation() diff --git a/dumux/flux/ccmpfa/fickslaw.hh b/dumux/flux/ccmpfa/fickslaw.hh index e4c69a4a7ee6df973235f9da319942e87d0aef0f..0e92453d12c6930d343660994545ef00e8fde4c5 100644 --- a/dumux/flux/ccmpfa/fickslaw.hh +++ b/dumux/flux/ccmpfa/fickslaw.hh @@ -62,6 +62,7 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::ccmpfa, referenceSys using BalanceEqOpts = GetPropType<TypeTag, Properties::BalanceEqOpts>; static constexpr int numComponents = GetPropType<TypeTag, Properties::ModelTraits>::numFluidComponents(); + static constexpr int numPhases = GetPropType<TypeTag, Properties::ModelTraits>::numFluidPhases(); using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>; //! Class that fills the cache corresponding to mpfa Fick's Law @@ -163,17 +164,20 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::ccmpfa, referenceSys public: // state the discretization method this implementation belongs to static const DiscretizationMethod discMethod = DiscretizationMethod::ccmpfa; + //return the reference system static constexpr ReferenceSystemFormulation referenceSystemFormulation() { return referenceSystem; } + // state the type for the corresponding cache and its filler using Cache = MpfaFicksLawCache; + //export the diffusion container - template<int numPhases, int numComponents> + template <bool onlyTracers = false> using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar, numPhases, numComponents, - FluidSystem::isTracerFluidSystem()>; + onlyTracers>; //! Compute the diffusive flux across an scvf static ComponentFluxVector flux(const Problem& problem, diff --git a/dumux/flux/cctpfa/fickslaw.hh b/dumux/flux/cctpfa/fickslaw.hh index b41c2ed11b345920d8094daf96ada305574ead96..09de3fae6d7d70d82b6237a7a2437704e79b7c8e 100644 --- a/dumux/flux/cctpfa/fickslaw.hh +++ b/dumux/flux/cctpfa/fickslaw.hh @@ -127,11 +127,11 @@ public: //! state the type for the corresponding cache and its filler using Cache = TpfaFicksLawCache; - template<int numPhases, int numComponents> + template<bool onlyTracers = false> using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar, numPhases, numComponents, - FluidSystem::isTracerFluidSystem()>; + onlyTracers>; //! return diffusive fluxes for all components in a phase static ComponentFluxVector flux(const Problem& problem, diff --git a/dumux/flux/cctpfa/maxwellstefanslaw.hh b/dumux/flux/cctpfa/maxwellstefanslaw.hh index 73d8a8160fbab776ba9384f0962f27698b07b1db..3c0f9f532dc533e34bdb62d101bf7367aedc921c 100644 --- a/dumux/flux/cctpfa/maxwellstefanslaw.hh +++ b/dumux/flux/cctpfa/maxwellstefanslaw.hh @@ -80,8 +80,8 @@ public: static constexpr ReferenceSystemFormulation referenceSystemFormulation() { return referenceSystem; } - template<int numFluidPhases, int numComponents> - using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, numFluidPhases, numComponents>; + template<bool onlyTracers = false> + using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, numPhases, numComponents, onlyTracers>; //! state the type for the corresponding cache and its filler //! We don't cache anything for this law diff --git a/dumux/flux/fickiandiffusioncoefficients.hh b/dumux/flux/fickiandiffusioncoefficients.hh index cba9c93bda904c1fb98c9f7657ff01389a567d04..5d45f77404269f40544d1e39aca9a31ba660b458 100644 --- a/dumux/flux/fickiandiffusioncoefficients.hh +++ b/dumux/flux/fickiandiffusioncoefficients.hh @@ -36,20 +36,20 @@ namespace Dumux { * \tparam Scalar The type used for scalar values * \tparam numPhases Number of phases in the fluid composition * \tparam numComponents Number of components in the fluid composition - * \tparam allTracerComponents If false, this means that the main component of - * a phase is part of the components. In this case, - * the storage container is optimized with respect to - * memory consumption as diffusion coefficients of the - * main component of a phase in itself are not stored. - * If true, all diffusion coefficients of all components - * are stored + * \tparam onlyTracers If false, this means that the main component of + * a phase is part of the components. In this case, + * the storage container is optimized with respect to + * memory consumption as diffusion coefficients of the + * main component of a phase in itself are not stored. + * If true, all diffusion coefficients of all components + * are stored */ -template <class Scalar, int numPhases, int numComponents, bool allTracerComponents> +template <class Scalar, int numPhases, int numComponents, bool onlyTracers = false> class FickianDiffusionCoefficients; //! General case (mpnc), for compositions containing the phases' main components template <class Scalar, int numPhases, int numComponents> -class FickianDiffusionCoefficients<Scalar, numPhases, numComponents, false> +class FickianDiffusionCoefficients<Scalar, numPhases, numComponents> { public: template<class DiffCoeffFunc> @@ -83,7 +83,7 @@ private: //! Specialization for 1pnc & compositions containing the phases' main components template <class Scalar, int numComponents> -class FickianDiffusionCoefficients<Scalar, 1, numComponents, false> +class FickianDiffusionCoefficients<Scalar, 1, numComponents> { public: template<class DiffCoeffFunc> @@ -114,7 +114,7 @@ private: //! Specialization for 2p2c & compositions containing the phases' main components template <class Scalar> -class FickianDiffusionCoefficients<Scalar, 2, 2, false> +class FickianDiffusionCoefficients<Scalar, 2, 2> { public: template<class DiffCoeffFunc> @@ -138,7 +138,7 @@ private: //! Specialization for 3p2c & compositions containing the phases' main components template <class Scalar> -class FickianDiffusionCoefficients<Scalar, 3, 2, false> +class FickianDiffusionCoefficients<Scalar, 3, 2> { public: template<class DiffCoeffFunc> diff --git a/dumux/flux/maxwellstefandiffusioncoefficients.hh b/dumux/flux/maxwellstefandiffusioncoefficients.hh index 53b8e0687c83935d1578382e016e4614a248ec9d..37e2728b461211950202e96923de57e95bee98d5 100644 --- a/dumux/flux/maxwellstefandiffusioncoefficients.hh +++ b/dumux/flux/maxwellstefandiffusioncoefficients.hh @@ -38,8 +38,15 @@ namespace Dumux { * \tparam Scalar The type used for scalar values * \tparam numPhases Number of phases in the fluid composition * \tparam numComponents Number of components in the fluid composition + * \tparam onlyTracers If false, this means that the main component of + * a phase is part of the components. In this case, + * the storage container is optimized with respect to + * memory consumption as diffusion coefficients of the + * main component of a phase in itself are not stored. + * If true, all diffusion coefficients of all components + * are stored */ -template <class Scalar, int numPhases, int numComponents> +template <class Scalar, int numPhases, int numComponents, bool onlyTracers = false> class MaxwellStefanDiffusionCoefficients { public: diff --git a/dumux/flux/staggered/freeflow/fickslaw.hh b/dumux/flux/staggered/freeflow/fickslaw.hh index e204c20075162ba10dc3adfae8340040aef27d70..77562d4cbfaee37a8508dcac7341f306b31a5e19 100644 --- a/dumux/flux/staggered/freeflow/fickslaw.hh +++ b/dumux/flux/staggered/freeflow/fickslaw.hh @@ -63,6 +63,8 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::staggered, reference using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>; static constexpr int numComponents = ModelTraits::numFluidComponents(); + static constexpr int numPhases = ModelTraits::numFluidPhases(); + using NumEqVector = Dune::FieldVector<Scalar, numComponents>; static_assert(ModelTraits::numFluidPhases() == 1, "Only one phase supported!"); @@ -78,11 +80,11 @@ public: //! We don't cache anything for this law using Cache = FluxVariablesCaching::EmptyDiffusionCache; - template<int numPhases, int numComponents> + template <bool onlyTracers = false> using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar, numPhases, numComponents, - FluidSystem::isTracerFluidSystem()>; + onlyTracers>; template<class Problem, class ElementVolumeVariables> static NumEqVector flux(const Problem& problem, diff --git a/dumux/flux/staggered/freeflow/maxwellstefanslaw.hh b/dumux/flux/staggered/freeflow/maxwellstefanslaw.hh index 254966a69be535045dcf6adeb4cbf08a335f971f..c11afe7265ccb126ab05396420a48892c4807156 100644 --- a/dumux/flux/staggered/freeflow/maxwellstefanslaw.hh +++ b/dumux/flux/staggered/freeflow/maxwellstefanslaw.hh @@ -62,6 +62,7 @@ class MaxwellStefansLawImplementation<TypeTag, DiscretizationMethod::staggered, using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>; static const int numComponents = ModelTraits::numFluidComponents(); + static const int numPhases = ModelTraits::numFluidPhases(); static constexpr bool useMoles = getPropValue<TypeTag, Properties::UseMoles>(); using ReducedComponentVector = Dune::FieldVector<Scalar, numComponents-1>; @@ -83,8 +84,8 @@ public: using Cache = FluxVariablesCaching::EmptyDiffusionCache; using CacheFiller = FluxVariablesCaching::EmptyCacheFiller; - template<int numPhases, int numComponents> - using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, numPhases, numComponents>; + template <bool onlyTracers = false> + using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, numPhases, numComponents, onlyTracers>; template<class ElementVolumeVariables> static CellCenterPrimaryVariables flux(const Problem& problem, diff --git a/dumux/freeflow/compositional/volumevariables.hh b/dumux/freeflow/compositional/volumevariables.hh index bf362043c0a2669b70fdc3888dbbe7516383e12e..cbb2fee79b1803282fb170d6999f77c712283c6f 100644 --- a/dumux/freeflow/compositional/volumevariables.hh +++ b/dumux/freeflow/compositional/volumevariables.hh @@ -45,7 +45,7 @@ class FreeflowNCVolumeVariables : public FreeFlowVolumeVariables< Traits, Freefl static constexpr bool useMoles = Traits::ModelTraits::useMoles(); static constexpr int numFluidComps = ParentType::numFluidComponents(); - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<1, numFluidComps>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! export the underlying fluid system diff --git a/dumux/porousmediumflow/1pnc/volumevariables.hh b/dumux/porousmediumflow/1pnc/volumevariables.hh index 22ffbbe0e35e68d6e391bbd410b9cd9999ccde3d..962120bde1f7ff8e6b4bb3161f5f2ea8d0dc6404 100644 --- a/dumux/porousmediumflow/1pnc/volumevariables.hh +++ b/dumux/porousmediumflow/1pnc/volumevariables.hh @@ -55,7 +55,7 @@ class OnePNCVolumeVariables using EffDiffModel = typename Traits::EffectiveDiffusivityModel; using Idx = typename Traits::ModelTraits::Indices; static constexpr int numFluidComps = ParentType::numFluidComponents(); - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<1, numFluidComps>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; enum { diff --git a/dumux/porousmediumflow/2p2c/volumevariables.hh b/dumux/porousmediumflow/2p2c/volumevariables.hh index 85353f07e2b31f2d0196ddc39b172dd7a229cc8a..b6355a72c4da3bd8d94447b704e8dbddb82c257c 100644 --- a/dumux/porousmediumflow/2p2c/volumevariables.hh +++ b/dumux/porousmediumflow/2p2c/volumevariables.hh @@ -101,7 +101,7 @@ class TwoPTwoCVolumeVariablesBase using ComputeFromReferencePhase = Dumux::ComputeFromReferencePhase<Scalar, typename Traits::FluidSystem>; using MiscibleMultiPhaseComposition = Dumux::MiscibleMultiPhaseComposition< Scalar, typename Traits::FluidSystem >; using EffDiffModel = typename Traits::EffectiveDiffusivityModel; - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<2, 2>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! The type of the object returned by the fluidState() method using FluidState = typename Traits::FluidState; diff --git a/dumux/porousmediumflow/2pnc/volumevariables.hh b/dumux/porousmediumflow/2pnc/volumevariables.hh index 688a84b714b59007942a24bed2ad8150e3d98021..ce84b0cde1d45d7f47379eb16b471f3fae2388b0 100644 --- a/dumux/porousmediumflow/2pnc/volumevariables.hh +++ b/dumux/porousmediumflow/2pnc/volumevariables.hh @@ -91,7 +91,7 @@ class TwoPNCVolumeVariables using MiscibleMultiPhaseComposition = Dumux::MiscibleMultiPhaseComposition<Scalar, FS>; using ComputeFromReferencePhase = Dumux::ComputeFromReferencePhase<Scalar, FS>; using EffDiffModel = typename Traits::EffectiveDiffusivityModel; - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<2, numFluidComps>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! Export fluid state type diff --git a/dumux/porousmediumflow/3p3c/volumevariables.hh b/dumux/porousmediumflow/3p3c/volumevariables.hh index 4c4dc7c82b4c63faae3be1f3f71c7daa5f01706d..0a83648dc48e5304f6de6865e94eeac045e9e0b3 100644 --- a/dumux/porousmediumflow/3p3c/volumevariables.hh +++ b/dumux/porousmediumflow/3p3c/volumevariables.hh @@ -86,7 +86,7 @@ class ThreePThreeCVolumeVariables }; using EffDiffModel = typename Traits::EffectiveDiffusivityModel; - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<3, 3>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! export fluid state type diff --git a/dumux/porousmediumflow/3pwateroil/volumevariables.hh b/dumux/porousmediumflow/3pwateroil/volumevariables.hh index 4b9180c8267752ae1d02ac9c66838f0311769fb2..8394b7a437ce22e0d501446d381b041239505fe7 100644 --- a/dumux/porousmediumflow/3pwateroil/volumevariables.hh +++ b/dumux/porousmediumflow/3pwateroil/volumevariables.hh @@ -87,7 +87,7 @@ class ThreePWaterOilVolumeVariables }; using EffDiffModel = typename Traits::EffectiveDiffusivityModel; - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<3, 2>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! The type of the object returned by the fluidState() method diff --git a/dumux/porousmediumflow/co2/volumevariables.hh b/dumux/porousmediumflow/co2/volumevariables.hh index afe402e7222eab0f490fc4bf298440b6ba2d7fa7..3d5a77faa1dac6c9fe5422ddf8bbf6295c994cc3 100644 --- a/dumux/porousmediumflow/co2/volumevariables.hh +++ b/dumux/porousmediumflow/co2/volumevariables.hh @@ -88,7 +88,7 @@ class TwoPTwoCCO2VolumeVariables // type used for the diffusion coefficients using EffDiffModel = typename Traits::EffectiveDiffusivityModel; - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<2, 2>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! The type of the object returned by the fluidState() method diff --git a/dumux/porousmediumflow/mpnc/volumevariables.hh b/dumux/porousmediumflow/mpnc/volumevariables.hh index 45149b0416237dda36fc680c84acc6713bd9bdb8..3ff7621bd34fcde46a1d1c89b0f4eba0ed532498 100644 --- a/dumux/porousmediumflow/mpnc/volumevariables.hh +++ b/dumux/porousmediumflow/mpnc/volumevariables.hh @@ -70,7 +70,7 @@ class MPNCVolumeVariablesImplementation<Traits, false> using ComponentVector = Dune::FieldVector<Scalar, ModelTraits::numFluidComponents()>; using CompositionFromFugacities = Dumux::CompositionFromFugacities<Scalar, typename Traits::FluidSystem>; using EffDiffModel = typename Traits::EffectiveDiffusivityModel; - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<ModelTraits::numFluidPhases(), ParentType::numFluidComponents()>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! Export the type encapsulating primary variable indices @@ -535,7 +535,7 @@ class MPNCVolumeVariablesImplementation<Traits, true> using CompositionFromFugacities = Dumux::CompositionFromFugacities<Scalar, typename Traits::FluidSystem>; using ParameterCache = typename Traits::FluidSystem::ParameterCache; using EffDiffModel = typename Traits::EffectiveDiffusivityModel; - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<ModelTraits::numFluidPhases(), ParentType::numFluidComponents()>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! Export the underlying fluid system diff --git a/dumux/porousmediumflow/richardsnc/volumevariables.hh b/dumux/porousmediumflow/richardsnc/volumevariables.hh index 15d43fcae0ed8fd36a358a124464dd5b8202fdea..204e71ea93f1725a07ec6a04f3ae857160c2ffa7 100644 --- a/dumux/porousmediumflow/richardsnc/volumevariables.hh +++ b/dumux/porousmediumflow/richardsnc/volumevariables.hh @@ -55,7 +55,7 @@ class RichardsNCVolumeVariables static constexpr bool useMoles = Traits::ModelTraits::useMoles(); using EffDiffModel = typename Traits::EffectiveDiffusivityModel; - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<2, numFluidComps>; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>; public: //! Export type of the fluid system diff --git a/dumux/porousmediumflow/tracer/volumevariables.hh b/dumux/porousmediumflow/tracer/volumevariables.hh index fbd1ec6fbaf504ca95e5a18955008abcfe710736..9c072e277099ccc6aecc96b1201bda52ca94de6a 100644 --- a/dumux/porousmediumflow/tracer/volumevariables.hh +++ b/dumux/porousmediumflow/tracer/volumevariables.hh @@ -59,7 +59,9 @@ class TracerVolumeVariables static constexpr bool useMoles = Traits::ModelTraits::useMoles(); using EffDiffModel = typename Traits::EffectiveDiffusivityModel; static constexpr int numFluidComps = ParentType::numFluidComponents(); - using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<1, numFluidComps>; + + static constexpr bool onlyTracerComponents = true; + using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<onlyTracerComponents>; public: //! Export fluid system type @@ -100,11 +102,11 @@ public: // Update the binary diffusion and effective diffusion coefficients. auto getDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx) { - return FluidSystem::binaryDiffusionCoefficient( compIIdx, - compJIdx, - problem, - element, - scv); + return FluidSystem::binaryDiffusionCoefficient(compIIdx, + compJIdx, + problem, + element, + scv); }; auto getEffectiveDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx) diff --git a/examples/1ptracer/problem_tracer.hh b/examples/1ptracer/problem_tracer.hh index 804d5ae6bf1a78cd892a762d7f4c11d7b386ba79..c38ebed6ac7d88d172c0b274e02d1ebfbe38fe40 100644 --- a/examples/1ptracer/problem_tracer.hh +++ b/examples/1ptracer/problem_tracer.hh @@ -133,7 +133,8 @@ public: // We set the value for the binary diffusion coefficient. This // might depend on spatial parameters like pressure / temperature. // But, in this case we neglect diffusion and return 0.0: - static Scalar binaryDiffusionCoefficient(unsigned int compIdx, + static Scalar binaryDiffusionCoefficient(unsigned int compIdxI, + unsigned int compIdxJ, const Problem& problem, const Element& element, const SubControlVolume& scv)