Commit 6dcf673b authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[mpfa][elemfluxvarcache] do not sort indices, use find instead

Originally it was thought that the list of scvf indices might not be unique,
which is why we sorted and made the entries unique. This is not the case though.
parent 80d3160f
......@@ -18,7 +18,7 @@
* \file
* \brief The global object of flux var caches
* \brief The local object of flux var caches
......@@ -32,7 +32,8 @@ namespace Dumux
* \ingroup ImplicitModel
* \brief Base class for the stencil local flux variables cache
* \brief Base class for the local flux variables cache.
* Prepares the cache on all the faces in the stencil.
template<class TypeTag, bool EnableGlobalFluxVariablesCache>
class CCMpfaElementFluxVariablesCache;
......@@ -135,7 +136,8 @@ public:
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars)
const auto& problem = globalFluxVarsCache().problem_();
const auto& globalFvGeometry = problem.model().globalFvGeometry();
......@@ -143,8 +145,10 @@ public:
const auto& assemblyMap = problem.model().localJacobian().assemblyMap();
const auto globalI = problem.elementMapper().index(element);
// reserve initial guess of memory (won't be enough though - several scvfs per neighbor will be required)
globalScvfIndices_.reserve(fvGeometry.numScvf() + assemblyMap[globalI].size());
// reserve memory
auto numNeighborScvfs = 0;
for (auto&& facesInNeighbor : assemblyMap[globalI]) numNeighborScvfs += facesInNeighbor.size();
globalScvfIndices_.reserve(fvGeometry.numScvf() + numNeighborScvfs);
// first add all the indices inside the element
for (auto&& scvf : scvfs(fvGeometry))
......@@ -155,17 +159,11 @@ public:
for (auto fluxVarIdx : assemblyMap[globalI][j])
// make global indices unique
std::sort(globalScvfIndices_.begin(), globalScvfIndices_.end());
globalScvfIndices_.erase(std::unique(globalScvfIndices_.begin(), globalScvfIndices_.end()), globalScvfIndices_.end());
// prepare all the caches of the scvfs inside the corresponding interaction volumes using helper class
for (auto&& scvf : scvfs(fvGeometry))
if (!(*this)[scvf].isUpdated())
FluxVariablesCacheFiller::fillFluxVarCache(problem, element, fvGeometry, elemVolVars, scvf, *this);
// prepare the caches in the remaining neighbors
unsigned int j = 0;
......@@ -215,12 +213,6 @@ public:
const GlobalFluxVariablesCache* globalFluxVarsCachePtr_;
void clear()
// This function updates the transmissibilities after the solution has been deflected during jacobian assembly
void update(const Element& element,
const FVElementGeometry& fvGeometry,
......@@ -230,16 +222,14 @@ private:
for (auto&& scvf : scvfs(fvGeometry))
if (!(*this)[scvf].isUpdated())
FluxVariablesCacheFiller::updateFluxVarCache(globalFluxVarsCache().problem_(), element, fvGeometry, elemVolVars, scvf, *this);
// get index of scvf in the local container
// get index of an scvf in the local container
int getLocalScvfIdx_(const int scvfIdx) const
auto it = std::lower_bound(globalScvfIndices_.begin(), globalScvfIndices_.end(), scvfIdx);
auto it = std::find(globalScvfIndices_.begin(), globalScvfIndices_.end(), scvfIdx);
assert(globalScvfIndices_[std::distance(globalScvfIndices_.begin(), it)] == scvfIdx && "Could not find the flux vars cache for scvfIdx");
return std::distance(globalScvfIndices_.begin(), it);
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