13#ifndef DUMUX_FLUX_FICKIAN_DIFFUSION_COEFFICIENTS_HH
14#define DUMUX_FLUX_FICKIAN_DIFFUSION_COEFFICIENTS_HH
30template <
class Scalar,
int numPhases,
int numComponents>
34 template<
class DiffCoeffFunc>
35 void update(
const DiffCoeffFunc& computeDiffCoeff)
41 static_assert(numPhases <= numComponents || (numPhases == 3 && numComponents == 2),
42 "This combination of numPhases and numComponents is not supported!");
43 for (
int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx)
44 for (
int compIIdx = std::min(phaseIdx, numComponents-1), compJIdx = 0; compJIdx < numComponents; ++compJIdx)
45 if (compIIdx != compJIdx)
46 diffCoeff_[getIndex_(phaseIdx, compIIdx, compJIdx)] = computeDiffCoeff(phaseIdx, compIIdx, compJIdx);
49 Scalar
operator() (
int phaseIdx,
int compIIdx,
int compJIdx)
const
51 sortComponentIndices_(phaseIdx, compIIdx, compJIdx);
52 assert(compIIdx != compJIdx);
53 return diffCoeff_[getIndex_(phaseIdx, compIIdx, compJIdx)];
63 std::array<Scalar, numPhases * (numComponents - 1)> diffCoeff_;
76 constexpr int getIndex_(
int phaseIdx,
int compIIdx,
int compJIdx)
const
77 {
return (phaseIdx * (numComponents-1)) + compJIdx -
static_cast<int>(phaseIdx < compJIdx); }
79 void sortComponentIndices_(
int phaseIdx,
int& compIIdx,
int& compJIdx)
const
80 {
if (compIIdx != std::min(phaseIdx, numComponents-1)) std::swap(compIIdx, compJIdx); }
Container storing the diffusion coefficients required by Fick's law. Uses the minimal possible contai...
Definition: fickiandiffusioncoefficients.hh:32
Scalar operator()(int phaseIdx, int compIIdx, int compJIdx) const
Definition: fickiandiffusioncoefficients.hh:49
void update(const DiffCoeffFunc &computeDiffCoeff)
Definition: fickiandiffusioncoefficients.hh:35