Commit efdbf9a9 authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[mpfa][fluxvarcache] use the fact that mixed BCS are no longer allowed

That means, that the transmissibilities are the same for each phase and we
do not need to store them for each phase. The interface, however, stays the same
in case one desires to implement a specialization of that (or mixed BC).
parent 3144024e
......@@ -88,22 +88,30 @@ public:
auto advectionUpwindFunction = [eqIdx](const VolumeVariables& volVars) { return volVars.density(eqIdx)/volVars.viscosity(eqIdx); };
iv.assembleNeumannFluxes(advectionUpwindFunction, eqIdx);
// update flux variables cache
auto& cache = fluxVarsCache[scvf.index()];
cache.updateBoundaryAdvection(problem, element, fvGeometry, elemVolVars, scvf, iv, eqIdx);
cache.setUpdated();
// update flux variables cache, only the neumann fluxes have to be set for each phase
const auto scvfIdx = scvf.index();
auto& cache = fluxVarsCache[scvfIdx];
if (eqIdx == 0)
{
cache.updateAdvection(problem, element, fvGeometry, elemVolVars, scvf, iv);
cache.setUpdated();
}
cache.updatePhaseNeumannFlux(problem, element, fvGeometry, elemVolVars, scvf, iv, eqIdx);
// update flux variable caches of the other scvfs of the interaction volume
for (const auto& scvfIdx : iv.globalScvfs())
for (const auto scvfIdxJ : iv.globalScvfs())
{
if (scvfIdx != scvf.index())
if (scvfIdxJ != scvfIdx)
{
const auto& scvfJ = fvGeometry.scvf(scvfIdx);
const auto& scvfJ = fvGeometry.scvf(scvfIdxJ);
const auto elementJ = problem.model().globalFvGeometry().element(scvfJ.insideScvIdx());
auto& cacheJ = fluxVarsCache[scvfIdx];
cacheJ.updateBoundaryAdvection(problem, elementJ, fvGeometry, elemVolVars, scvfJ, iv, eqIdx);
if (eqIdx == numEq - 1)
auto& cacheJ = fluxVarsCache[scvfIdxJ];
if (eqIdx == 0)
{
cacheJ.updateAdvection(problem, elementJ, fvGeometry, elemVolVars, scvfJ, iv);
cacheJ.setUpdated();
}
cacheJ.updatePhaseNeumannFlux(problem, elementJ, fvGeometry, elemVolVars, scvfJ, iv, eqIdx);
}
}
}
......
......@@ -193,59 +193,55 @@ class PorousMediumMpfaFluxVariablesCache<TypeTag, true, false, false>
public:
// the constructor
PorousMediumMpfaFluxVariablesCache() : isUpdated_(false) {}
PorousMediumMpfaFluxVariablesCache() : isUpdated_(false)
{
for (auto& nFlux : phaseNeumannFluxes_)
nFlux = 0.0;
}
// update cached objects
void updateBoundaryAdvection(const Problem& problem,
const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvf,
const BoundaryInteractionVolume& interactionVolume,
const unsigned int phaseIdx)
void updateAdvection(const Problem& problem,
const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvf,
const InteractionVolume& interactionVolume)
{
phaseVolVarsStencil_[phaseIdx] = interactionVolume.volVarsStencil();
phaseVolVarsPositions_[phaseIdx] = interactionVolume.volVarsPositions();
const auto& localIndexPair = interactionVolume.getLocalIndexPair(scvf);
const auto& volVarsStencil = interactionVolume.volVarsStencil();
const auto& volVarsPositions = interactionVolume.volVarsPositions();
auto localIndexPair = interactionVolume.getLocalIndexPair(scvf);
phaseTij_[phaseIdx] = interactionVolume.getTransmissibilities(localIndexPair);
phaseNeumannFluxes_[phaseIdx] = interactionVolume.getNeumannFlux(localIndexPair);
// the types coming from the inner interaction volumes might differ (thus, = assignment is not possible)
const auto numVolVars = volVarsStencil.size();
volVarsStencil_.clear();
volVarsStencil_.reserve(numVolVars);
volVarsPositions_.clear();
volVarsPositions_.reserve(numVolVars);
volVarsStencil_.insert(volVarsStencil_.begin(), volVarsStencil.begin(), volVarsStencil.end());
volVarsPositions_.insert(volVarsPositions_.begin(), volVarsPositions.begin(), volVarsPositions.end());
tij_ = interactionVolume.getTransmissibilities(localIndexPair);
}
void updateInnerAdvection(const Problem& problem,
const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvf,
const InteractionVolume& interactionVolume)
void updatePhaseNeumannFlux(const Problem& problem,
const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace &scvf,
const InteractionVolume& interactionVolume,
const unsigned int phaseIdx)
{
const auto& volVarsStencil = interactionVolume.volVarsStencil();
const auto& volVarsPositions = interactionVolume.volVarsPositions();
const auto& localIndexPair = interactionVolume.getLocalIndexPair(scvf);
const auto& tij = interactionVolume.getTransmissibilities(localIndexPair);
for (unsigned int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
{
// the types coming from the inner interaction volumes might differ (thus, = assignment is not possible)
phaseVolVarsStencil_[phaseIdx].insert(phaseVolVarsStencil_[phaseIdx].begin(), volVarsStencil.begin(), volVarsStencil.end());
phaseVolVarsPositions_[phaseIdx].insert(phaseVolVarsPositions_[phaseIdx].begin(), volVarsPositions.begin(), volVarsPositions.end());
// resize the transmissibilities and copy the values
phaseTij_[phaseIdx].resize(tij.size());
for (std::size_t i = 0; i < tij.size(); ++i)
phaseTij_[phaseIdx][i] = tij[i];
phaseNeumannFluxes_[phaseIdx] = 0.0;
}
phaseNeumannFluxes_[phaseIdx] = interactionVolume.getNeumannFlux(localIndexPair);
}
const Stencil& advectionVolVarsStencil(const unsigned int phaseIdx) const
{ return phaseVolVarsStencil_[phaseIdx]; }
{ return volVarsStencil_; }
const PositionVector& advectionVolVarsPositions(const unsigned int phaseIdx) const
{ return phaseVolVarsPositions_[phaseIdx]; }
{ return volVarsPositions_; }
const TransmissibilityVector& advectionTij(const unsigned int phaseIdx) const
{ return phaseTij_[phaseIdx]; }
{ return tij_; }
Scalar advectionNeumannFlux(const unsigned int phaseIdx) const
{ return phaseNeumannFluxes_[phaseIdx]; }
......@@ -260,9 +256,9 @@ public:
private:
bool isUpdated_;
std::array<Stencil, numPhases> phaseVolVarsStencil_;
std::array<PositionVector, numPhases> phaseVolVarsPositions_;
std::array<TransmissibilityVector, numPhases> phaseTij_;
Stencil volVarsStencil_;
PositionVector volVarsPositions_;
TransmissibilityVector tij_;
std::array<Scalar, numPhases> phaseNeumannFluxes_;
};
......
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