mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Transmissibility: add a cache for centroids and use this in update()
The loops repeatedly calls distanceVector which recalculates the centroid for a cell. This is not a trivial calculation
This commit is contained in:
parent
635d7d77dd
commit
9a97bf41c5
@ -284,6 +284,7 @@ protected:
|
|||||||
const CartesianIndexMapper& cartMapper_;
|
const CartesianIndexMapper& cartMapper_;
|
||||||
const Grid& grid_;
|
const Grid& grid_;
|
||||||
std::function<std::array<double,dimWorld>(int)> centroids_;
|
std::function<std::array<double,dimWorld>(int)> centroids_;
|
||||||
|
std::vector<std::array<double,dimWorld>> centroids_cache_;
|
||||||
Scalar transmissibilityThreshold_;
|
Scalar transmissibilityThreshold_;
|
||||||
std::map<std::pair<unsigned, unsigned>, Scalar> transBoundary_;
|
std::map<std::pair<unsigned, unsigned>, Scalar> transBoundary_;
|
||||||
std::map<std::pair<unsigned, unsigned>, Scalar> thermalHalfTransBoundary_;
|
std::map<std::pair<unsigned, unsigned>, Scalar> thermalHalfTransBoundary_;
|
||||||
|
@ -236,6 +236,13 @@ update(bool global, const TransUpdateQuantities update_quantities,
|
|||||||
comm.broadcast(&pinchActive, 1, 0);
|
comm.broadcast(&pinchActive, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fill the centroids cache to avoid repeated calculations in loops below
|
||||||
|
centroids_cache_.resize(gridView_.size(0));
|
||||||
|
for (const auto& elem : elements(gridView_)) {
|
||||||
|
const unsigned elemIdx = elemMapper.index(elem);
|
||||||
|
centroids_cache_[elemIdx] = centroids_(elemIdx);
|
||||||
|
}
|
||||||
|
|
||||||
// compute the transmissibilities for all intersections
|
// compute the transmissibilities for all intersections
|
||||||
for (const auto& elem : elements(gridView_)) {
|
for (const auto& elem : elements(gridView_)) {
|
||||||
unsigned elemIdx = elemMapper.index(elem);
|
unsigned elemIdx = elemMapper.index(elem);
|
||||||
@ -529,6 +536,8 @@ update(bool global, const TransUpdateQuantities update_quantities,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
centroids_cache_.clear();
|
||||||
|
|
||||||
// Potentially overwrite and/or modify transmissibilities based on input from deck
|
// Potentially overwrite and/or modify transmissibilities based on input from deck
|
||||||
this->updateFromEclState_(global);
|
this->updateFromEclState_(global);
|
||||||
|
|
||||||
@ -1321,7 +1330,8 @@ Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>::
|
|||||||
distanceVector_(const DimVector& faceCenter,
|
distanceVector_(const DimVector& faceCenter,
|
||||||
const unsigned& cellIdx) const
|
const unsigned& cellIdx) const
|
||||||
{
|
{
|
||||||
const auto& cellCenter = centroids_(cellIdx);
|
const auto& cellCenter = centroids_cache_.empty() ? centroids_(cellIdx)
|
||||||
|
: centroids_cache_[cellIdx];
|
||||||
DimVector x = faceCenter;
|
DimVector x = faceCenter;
|
||||||
for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx)
|
for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx)
|
||||||
x[dimIdx] -= cellCenter[dimIdx];
|
x[dimIdx] -= cellCenter[dimIdx];
|
||||||
|
Loading…
Reference in New Issue
Block a user