Commit 7d93c65c authored by Timo Koch's avatar Timo Koch Committed by Ned Coltman
Browse files

[fickslawcoeffs] Remove specialization for tracer model

parent ef97a4d5
......@@ -74,11 +74,7 @@ class FicksLawImplementation<TypeTag, DiscretizationMethod::box, referenceSystem
using ComponentFluxVector = Dune::FieldVector<Scalar, numComponents>;
public:
template <bool onlyTracers = false>
using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar,
numPhases,
numComponents,
onlyTracers>;
using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar, numPhases, numComponents>;
//return the reference system
static constexpr ReferenceSystemFormulation referenceSystemFormulation()
......
......@@ -71,7 +71,6 @@ 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 <bool onlyTracers = false>
using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, numFluidPhases, numComponents>;
//return the reference system
......
......@@ -172,12 +172,8 @@ public:
// state the type for the corresponding cache and its filler
using Cache = MpfaFicksLawCache;
//export the diffusion container
template <bool onlyTracers = false>
using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar,
numPhases,
numComponents,
onlyTracers>;
// export the diffusion container
using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar, numPhases, numComponents>;
//! Compute the diffusive flux across an scvf
static ComponentFluxVector flux(const Problem& problem,
......
......@@ -127,11 +127,7 @@ public:
//! state the type for the corresponding cache and its filler
using Cache = TpfaFicksLawCache;
template<bool onlyTracers = false>
using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar,
numPhases,
numComponents,
onlyTracers>;
using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar, numPhases, numComponents>;
//! return diffusive fluxes for all components in a phase
static ComponentFluxVector flux(const Problem& problem,
......
......@@ -80,7 +80,6 @@ public:
static constexpr ReferenceSystemFormulation referenceSystemFormulation()
{ return referenceSystem; }
template<bool onlyTracers = false>
using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, numPhases, numComponents>;
//! state the type for the corresponding cache and its filler
......
......@@ -38,20 +38,9 @@ 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, 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>
class FickianDiffusionCoefficients
{
public:
template<class DiffCoeffFunc>
......@@ -103,36 +92,6 @@ private:
{ if (compIIdx != std::min(phaseIdx, numComponents-1)) std::swap(compIIdx, compJIdx); }
};
//! Specialization for mpnc & compositions that only contain tracers
template <class Scalar, int numPhases, int numComponents>
class FickianDiffusionCoefficients<Scalar, numPhases, numComponents, true>
{
public:
template<class DiffCoeffFunc>
void update(const DiffCoeffFunc& computeDiffCoeff)
{
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
for (int compIdx = 0; compIdx < numComponents; ++compIdx)
diffCoeff_[getIndex_(phaseIdx, compIdx)]
= computeDiffCoeff(phaseIdx, phaseIdx, compIdx);
}
Scalar operator() (int phaseIdx, int compIIdx, int compJIdx) const
{
sortComponentIndices_(phaseIdx, compIIdx, compJIdx);
return diffCoeff_[getIndex_(phaseIdx, compJIdx)];
}
private:
std::array<Scalar, numPhases*numComponents> diffCoeff_;
constexpr int getIndex_(int phaseIdx, int compJIdx) const
{ return phaseIdx * numComponents + compJIdx; }
void sortComponentIndices_(int phaseIdx, int& compIIdx, int& compJIdx) const
{ if (compIIdx != phaseIdx) std::swap(compIIdx, compJIdx); }
};
} // end namespace Dumux
#endif
......@@ -80,11 +80,7 @@ public:
//! We don't cache anything for this law
using Cache = FluxVariablesCaching::EmptyDiffusionCache;
template <bool onlyTracers = false>
using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar,
numPhases,
numComponents,
onlyTracers>;
using DiffusionCoefficientsContainer = FickianDiffusionCoefficients<Scalar, numPhases, numComponents>;
template<class Problem, class ElementVolumeVariables>
static NumEqVector flux(const Problem& problem,
......
......@@ -84,7 +84,6 @@ public:
using Cache = FluxVariablesCaching::EmptyDiffusionCache;
using CacheFiller = FluxVariablesCaching::EmptyCacheFiller;
template <bool onlyTracers = false>
using DiffusionCoefficientsContainer = MaxwellStefanDiffusionCoefficients<Scalar, numPhases, numComponents>;
template<class ElementVolumeVariables>
......
......@@ -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<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
public:
//! export the underlying fluid system
......
......@@ -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<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
enum
{
......
......@@ -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<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
public:
//! The type of the object returned by the fluidState() method
using FluidState = typename Traits::FluidState;
......
......@@ -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<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
public:
//! Export fluid state type
......
......@@ -86,7 +86,7 @@ class ThreePThreeCVolumeVariables
};
using EffDiffModel = typename Traits::EffectiveDiffusivityModel;
using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
public:
//! export fluid state type
......
......@@ -87,7 +87,7 @@ class ThreePWaterOilVolumeVariables
};
using EffDiffModel = typename Traits::EffectiveDiffusivityModel;
using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
public:
//! The type of the object returned by the fluidState() method
......
......@@ -88,7 +88,7 @@ class TwoPTwoCCO2VolumeVariables
// type used for the diffusion coefficients
using EffDiffModel = typename Traits::EffectiveDiffusivityModel;
using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
public:
//! The type of the object returned by the fluidState() method
......
......@@ -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<>;
using DiffusionCoefficients = typename Traits::DiffusionType::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<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
public:
//! Export the underlying fluid system
......
......@@ -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<>;
using DiffusionCoefficients = typename Traits::DiffusionType::DiffusionCoefficientsContainer;
public:
//! Export type of the fluid system
......
......@@ -60,9 +60,6 @@ class TracerVolumeVariables
using EffDiffModel = typename Traits::EffectiveDiffusivityModel;
static constexpr int numFluidComps = ParentType::numFluidComponents();
static constexpr bool onlyTracerComponents = true;
using DiffusionCoefficients = typename Traits::DiffusionType::template DiffusionCoefficientsContainer<onlyTracerComponents>;
public:
//! Export fluid system type
using FluidSystem = typename Traits::FluidSystem;
......@@ -86,36 +83,21 @@ public:
// update parent type sets primary variables
ParentType::update(elemSol, problem, element, scv);
updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, ParentType::numFluidComponents());
// dispersivity_ = problem.spatialParams().dispersivity(element, scv, elemSol);
updateSolidVolumeFractions(elemSol, problem, element, scv, solidState_, numFluidComps);
// the spatial params special to the tracer model
fluidDensity_ = problem.spatialParams().fluidDensity(element, scv);
fluidMolarMass_ = problem.spatialParams().fluidMolarMass(element, scv);
fluidSaturation_ = saturation_(problem, element, scv);
if constexpr (Detail::hasSaturation<Problem, Element, Scv>())
fluidSaturation_ = problem.spatialParams().saturation(element, scv);
for (int compIdx = 0; compIdx < ParentType::numFluidComponents(); ++compIdx)
{
moleOrMassFraction_[compIdx] = this->priVars()[compIdx];
diffCoeff_[compIdx] = FluidSystem::binaryDiffusionCoefficient(compIdx, problem, element, scv);
effectiveDiffCoeff_[compIdx] = EffDiffModel::effectiveDiffusionCoefficient(*this, 0, 0, compIdx);
}
// Update the binary diffusion and effective diffusion coefficients.
auto getDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx)
{
return FluidSystem::binaryDiffusionCoefficient(compIIdx,
compJIdx,
problem,
element,
scv);
};
auto getEffectiveDiffusionCoefficient = [&](int phaseIdx, int compIIdx, int compJIdx)
{
return EffDiffModel::effectiveDiffusionCoefficient(*this, phaseIdx, compIIdx, compJIdx);
};
diffCoeff_.update(getDiffusionCoefficient);
effectiveDiffCoeff_.update(getEffectiveDiffusionCoefficient);
}
/*!
......@@ -206,26 +188,28 @@ public:
*/
[[deprecated("Signature deprecated. Use diffusionCoefficient(phaseIdx, compIIdx, compJIdx)!")]]
Scalar diffusionCoefficient(int phaseIdx, int compIdx) const
{ return diffCoeff_(0, 0, compIdx); }
{ return diffCoeff_[compIdx]; }
/*!
* \brief Returns the binary diffusion coefficients for a phase in \f$[m^2/s]\f$.
*/
Scalar diffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
{ return diffCoeff_(phaseIdx, compIIdx, compJIdx); }
{
if (phaseIdx != compIIdx) std::swap(compIIdx, compJIdx);
assert(phaseIdx == 0);
assert(phaseIdx == compIIdx);
return diffCoeff_[compJIdx]; }
/*!
* \brief Returns the effective diffusion coefficients for a phase in \f$[m^2/s]\f$.
*/
Scalar effectiveDiffusionCoefficient(int phaseIdx, int compIIdx, int compJIdx) const
{ return effectiveDiffCoeff_(phaseIdx, compIIdx, compJIdx); }
// /*!
// * \brief Returns the dispersivity of the fluid's streamlines.
// * \todo implement me
// */
// const DispersivityType &dispersivity() const
// { return dispersivity_; }
{
if (phaseIdx != compIIdx) std::swap(compIIdx, compJIdx);
assert(phaseIdx == 0);
assert(phaseIdx == compIIdx);
return effectiveDiffCoeff_[compJIdx];
}
/*!
* \brief Return the average porosity \f$\mathrm{[-]}\f$ within the control volume.
......@@ -237,45 +221,10 @@ protected:
SolidState solidState_;
Scalar fluidDensity_, fluidMolarMass_;
Scalar fluidSaturation_ = 1.0;
/*!
* \brief Gets the saturation in an scv.
*
* \param problem the problem to solve
* \param element the element (codim-0-entity) the scv belongs to
* \param scv the sub control volume
* \note this gets selected if the user uses the multiphase tracer
*/
template<class Problem, class Element, class Scv,
std::enable_if_t<Detail::hasSaturation<Problem, Element, Scv>(), int> = 0>
Scalar saturation_(const Problem& problem,
const Element& element,
const Scv& scv)
{ return problem.spatialParams().saturation(element, scv); }
/*!
* \brief Gets the saturation in an scv.
*
* \param problem the problem to solve
* \param element the element (codim-0-entity) the scv belongs to
* \param scv the sub control volume
* \note this gets selected if the user a single phase tracer
*/
template<class Problem, class Element, class Scv,
std::enable_if_t<!Detail::hasSaturation<Problem, Element, Scv>(), int> = 0>
Scalar saturation_(const Problem& problem,
const Element &element,
const Scv &scv)
{ return 1.0; }
// DispersivityType dispersivity_;
// Binary diffusion coefficient
DiffusionCoefficients diffCoeff_;
// Effective diffusion coefficients for the phases
DiffusionCoefficients effectiveDiffCoeff_;
std::array<Scalar, ParentType::numFluidComponents()> moleOrMassFraction_;
std::array<Scalar, numFluidComps> diffCoeff_;
std::array<Scalar, numFluidComps> effectiveDiffCoeff_;
std::array<Scalar, numFluidComps> moleOrMassFraction_;
};
} // end namespace Dumux
......
......@@ -47,7 +47,7 @@ struct TestFluidSystem
}
};
template<class Container, int numPhases, int numComponents, bool onlyTracers = false>
template<class Container, int numPhases, int numComponents>
void testFickianContainer()
{
TestFluidSystem<numPhases, numComponents> fs;
......@@ -65,7 +65,7 @@ void testFickianContainer()
{
for (int compIIdx = std::min(phaseIdx, numComponents-1), compJIdx = 0; compJIdx < numComponents; ++compJIdx)
{
if (onlyTracers || compIIdx != compJIdx)
if (compIIdx != compJIdx)
{
const auto refD = fs.binaryDiffusionCoefficient(phaseIdx, compIIdx, compJIdx);
const auto D = diffCoeff(phaseIdx, compIIdx, compJIdx);
......@@ -123,9 +123,6 @@ void testMSContainer()
template<int numComponents, int numPhases>
using FickDC = Dumux::FickianDiffusionCoefficients<int, numComponents, numPhases>;
template<int numComponents, int numPhases>
using FickDCTracer = Dumux::FickianDiffusionCoefficients<int, numComponents, numPhases, true>;
template<int numComponents, int numPhases>
using MSDC = Dumux::MaxwellStefanDiffusionCoefficients<int, numComponents, numPhases>;
......@@ -138,10 +135,6 @@ int main(int argc, char* argv[]) try
testFickianContainer<FickDC<3, 8>, 3, 8>();
testFickianContainer<FickDC<3, 2>, 3, 2>();
testFickianContainer<FickDCTracer<1, 1>, 1, 1, true>();
testFickianContainer<FickDCTracer<1, 2>, 1, 2, true>();
testFickianContainer<FickDCTracer<1, 3>, 1, 3, true>();
testMSContainer<MSDC<1, 1>, 1, 1>();
testMSContainer<MSDC<1, 2>, 1, 2>();
testMSContainer<MSDC<1, 3>, 1, 3>();
......
......@@ -105,8 +105,7 @@ public:
//! Binary diffusion coefficient
//! (might depend on spatial parameters like pressure / temperature)
static Scalar binaryDiffusionCoefficient(unsigned int compIIdx,
unsigned int compJIdx,
static Scalar binaryDiffusionCoefficient(unsigned int compIdx,
const Problem& problem,
const Element& element,
const SubControlVolume& scv)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment