From f8ad7006d3ade513676e0315a29c55a816f6f598 Mon Sep 17 00:00:00 2001 From: Ned Coltman <edward.coltman@iws.uni-stuttgart.de> Date: Thu, 12 Mar 2020 17:39:36 +0100 Subject: [PATCH] [DiffusionCoeffcientContainers] Replace template arguments with bool onlyTracers --- dumux/flux/box/fickslaw.hh | 5 ++-- dumux/flux/box/maxwellstefanslaw.hh | 8 ++++--- dumux/flux/ccmpfa/fickslaw.hh | 8 +++++-- dumux/flux/cctpfa/fickslaw.hh | 4 ++-- dumux/flux/cctpfa/maxwellstefanslaw.hh | 4 ++-- dumux/flux/fickiandiffusioncoefficients.hh | 24 +++++++++---------- .../maxwellstefandiffusioncoefficients.hh | 9 ++++++- dumux/flux/staggered/freeflow/fickslaw.hh | 6 +++-- .../staggered/freeflow/maxwellstefanslaw.hh | 5 ++-- .../freeflow/compositional/volumevariables.hh | 2 +- .../porousmediumflow/1pnc/volumevariables.hh | 2 +- .../porousmediumflow/2p2c/volumevariables.hh | 2 +- .../porousmediumflow/2pnc/volumevariables.hh | 2 +- .../porousmediumflow/3p3c/volumevariables.hh | 2 +- .../3pwateroil/volumevariables.hh | 2 +- dumux/porousmediumflow/co2/volumevariables.hh | 2 +- .../porousmediumflow/mpnc/volumevariables.hh | 4 ++-- .../richardsnc/volumevariables.hh | 2 +- .../tracer/volumevariables.hh | 14 ++++++----- examples/1ptracer/problem_tracer.hh | 3 ++- 20 files changed, 64 insertions(+), 46 deletions(-) diff --git a/dumux/flux/box/fickslaw.hh b/dumux/flux/box/fickslaw.hh index 8bc2cfa8aa..785e447ee0 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 b065aff562..4b0bdba111 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 e4c69a4a7e..0e92453d12 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 b41c2ed11b..09de3fae6d 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 73d8a8160f..3c0f9f532d 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 cba9c93bda..5d45f77404 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 53b8e0687c..37e2728b46 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 e204c20075..77562d4cbf 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 254966a69b..c11afe7265 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 bf362043c0..cbb2fee79b 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 22ffbbe0e3..962120bde1 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 85353f07e2..b6355a72c4 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 688a84b714..ce84b0cde1 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 4c4dc7c82b..0a83648dc4 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 4b9180c826..8394b7a437 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 afe402e722..3d5a77faa1 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 45149b0416..3ff7621bd3 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 15d43fcae0..204e71ea93 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 fbd1ec6fba..9c072e2770 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 804d5ae6bf..c38ebed6ac 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) -- GitLab