version 3.8
maxwellstefandiffusioncoefficients.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
14#ifndef DUMUX_FLUX_MAXWELLSTEFAN_DIFFUSION_COEFFICIENTS_HH
15#define DUMUX_FLUX_MAXWELLSTEFAN_DIFFUSION_COEFFICIENTS_HH
16
17#include <array>
18#include <cassert>
19
20namespace Dumux {
21
31template <class Scalar, int numPhases, int numComponents>
33{
34public:
35 template<class DiffCoeffFunc>
36 void update(const DiffCoeffFunc& computeDiffCoeff)
37 {
38 for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx)
39 for (int compIIdx = 0; compIIdx < numComponents; ++compIIdx)
40 for (int compJIdx = compIIdx+1; compJIdx < numComponents; ++compJIdx)
41 diffCoeff_[getIndex_(phaseIdx, compIIdx, compJIdx)]
42 = computeDiffCoeff(phaseIdx, compIIdx, compJIdx);
43 }
44
45 Scalar operator() (int phaseIdx, int compIIdx, int compJIdx) const
46 {
47 sortComponentIndices_(compIIdx, compJIdx);
48 assert(compIIdx != compJIdx);
49 return diffCoeff_[getIndex_(phaseIdx, compIIdx, compJIdx)];
50 }
51
52private:
63 std::array<Scalar, (numPhases * ((numComponents * (numComponents - 1)) / 2))> diffCoeff_;
64
76 constexpr int getIndex_(int phaseIdx, int compIIdx, int compJIdx) const
77 {
78 return phaseIdx * ((numComponents * (numComponents - 1)) / 2)
79 + compIIdx * numComponents
80 - ((compIIdx * (compIIdx + 1)) / 2)
81 + compJIdx - (compIIdx +1);
82 }
83
84 void sortComponentIndices_(int& compIIdx, int& compJIdx) const
85 { if (compIIdx > compJIdx) std::swap(compIIdx, compJIdx); }
86};
87
88} // end namespace Dumux
89
90#endif
Container storing the diffusion coefficients required by the Maxwell- Stefan diffusion law....
Definition: maxwellstefandiffusioncoefficients.hh:33
void update(const DiffCoeffFunc &computeDiffCoeff)
Definition: maxwellstefandiffusioncoefficients.hh:36
Scalar operator()(int phaseIdx, int compIIdx, int compJIdx) const
Definition: maxwellstefandiffusioncoefficients.hh:45
Definition: adapt.hh:17