From f8a560a6f02e34616840fcfef8731a2c6bf3c10e Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Wed, 13 Jan 2016 15:59:32 +0100 Subject: [PATCH] [pointsources] Hand over const reference to helper instead of shared_ptr, it's a static method --- dumux/common/pointsource.hh | 6 +++--- dumux/implicit/common/implicitproblem.hh | 12 +++--------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/dumux/common/pointsource.hh b/dumux/common/pointsource.hh index 3bab135457..b5cbe73ea6 100644 --- a/dumux/common/pointsource.hh +++ b/dumux/common/pointsource.hh @@ -258,14 +258,14 @@ class PointSourceHelper public: //! calculate a DOF index to point source map from given vector of point sources static void computePointSourceMap(const Problem& problem, - const std::shared_ptr<BoundingBoxTree>& boundingBoxTree, + const BoundingBoxTree& boundingBoxTree, std::vector<PointSource>& sources, std::map<std::pair<unsigned int, unsigned int>, std::vector<PointSource> >& pointSourceMap) { for (auto&& source : sources) { // compute in which elements the point source falls - std::vector<unsigned int> entities = boundingBoxTree->computeEntityCollisions(source.position()); + std::vector<unsigned int> entities = boundingBoxTree.computeEntityCollisions(source.position()); // split the source values equally among all concerned entities source.embeddings_ *= entities.size(); // loop over all concernes elements @@ -274,7 +274,7 @@ public: if(isBox) { // check in which subcontrolvolume(s) we are - const auto element = boundingBoxTree->entity(eIdx); + const auto element = boundingBoxTree.entity(eIdx); FVElementGeometry fvGeometry; fvGeometry.update(problem.gridView(), element); const auto globalPos = source.position(); diff --git a/dumux/implicit/common/implicitproblem.hh b/dumux/implicit/common/implicitproblem.hh index ecb07894b2..8fdffb83fc 100644 --- a/dumux/implicit/common/implicitproblem.hh +++ b/dumux/implicit/common/implicitproblem.hh @@ -155,12 +155,10 @@ public: // if there are point sources compute the DOF to point source map if (!sources.empty()) { - // build the bounding box tree for fast point in element search - boundingBoxTree_ = std::make_shared<BoundingBoxTree>(gridView_); - // calculate point source locations and save them in a map + // this builds the bounding box tree if it doesn't exist yet Dumux::PointSourceHelper<TypeTag>::computePointSourceMap(asImp_(), - boundingBoxTree_, + this->boundingBoxTree(), sources, pointSourceMap_); } @@ -596,14 +594,10 @@ public: // if there are point sources compute the DOF to point source map if (!sources.empty()) { - // in the unlikely case it doesn't exist build it - // who knows what the user does in the problem - if(!boundingBoxTree_) - boundingBoxTree_ = std::make_shared<BoundingBoxTree>(gridView_); // calculate point source locations and save them in a map pointSourceMap_.clear(); Dumux::PointSourceHelper<TypeTag>::computePointSourceMap(asImp_(), - boundingBoxTree_, + this->boundingBoxTree(), sources, pointSourceMap_); } -- GitLab