diff --git a/dumux/common/basicproperties.hh b/dumux/common/basicproperties.hh index e99725717581404cd20b0b0caa456b661b90839f..1e46316d6b59064137c3fe360994a0c528cb879f 100644 --- a/dumux/common/basicproperties.hh +++ b/dumux/common/basicproperties.hh @@ -79,6 +79,9 @@ NEW_PROP_TAG(Model); //! Property defining the type of point source used NEW_PROP_TAG(PointSource); +//! Property defining the class that computes which sub control volume point sources belong to +NEW_PROP_TAG(PointSourceHelper); + /*! * \brief Specify the maximum size of a time integration [s]. * @@ -150,6 +153,9 @@ SET_TYPE_PROP(NumericModel, GridCreator, Dumux::GridCreator<TypeTag>); //! Use the minimal point source implementation as default SET_TYPE_PROP(NumericModel, PointSource, Dumux::PointSource<TypeTag>); +//! Use the point source helper using the bounding box tree as a default +SET_TYPE_PROP(NumericModel, PointSourceHelper, Dumux::BoundingBoxTreePointSourceHelper<TypeTag>); + //! Set default output level to 0 -> only primary variables are added to output SET_INT_PROP(NumericModel, VtkOutputLevel, 0); diff --git a/dumux/common/pointsource.hh b/dumux/common/pointsource.hh index 2afe091b746be3c6d3fae6b7925be63e5a2bb845..aeb923c306949993feed85858e141ad587ca7c1d 100644 --- a/dumux/common/pointsource.hh +++ b/dumux/common/pointsource.hh @@ -68,8 +68,6 @@ class PointSource static const int dimworld = GridView::dimensionworld; typedef typename Dune::FieldVector<Scalar, dimworld> GlobalPosition; - friend class Dumux::PointSourceHelper<TypeTag>; - public: //! Constructor for constant point sources PointSource(GlobalPosition pos, PrimaryVariables values) @@ -146,6 +144,18 @@ public: const ElementVolumeVariables &elemVolVars) {} + //! set the number of embeddings for this point source + void setEmbeddings(std::size_t embeddings) + { + embeddings_ = embeddings; + } + + //! get the number of embeddings for this point source + std::size_t embeddings() const + { + return embeddings_; + } + protected: PrimaryVariables values_; //! value of the point source for each equation private: @@ -182,6 +192,20 @@ public: IdType id() const { return id_; } + //! Convenience = operator overload modifying only the values + IdPointSource& operator= (const PrimaryVariables& values) + { + ParentType::operator=(values); + return *this; + } + + //! Convenience = operator overload modifying only the values + IdPointSource& operator= (Scalar s) + { + ParentType::operator=(s); + return *this; + } + private: IdType id_; }; @@ -231,16 +255,32 @@ public: const ElementVolumeVariables &elemVolVars) { this->values_ = valueFunction_(problem.timeManager(), this->position()); } + //! Convenience = operator overload modifying only the values + TimeDependentPointSource& operator= (const PrimaryVariables& values) + { + ParentType::operator=(values); + return *this; + } + + //! Convenience = operator overload modifying only the values + TimeDependentPointSource& operator= (Scalar s) + { + ParentType::operator=(s); + return *this; + } + private: ValueFunction valueFunction_; }; /*! * \ingroup Common - * \brief A helper class calculating a DOF-index to point source map + * \brief A helper class calculating a sub control volume to point source map + * This class uses the bounding box tree implementation to indentify in which + * sub control volume(s) a point source falls. */ template<class TypeTag> -class PointSourceHelper +class BoundingBoxTreePointSourceHelper { typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem; typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView; @@ -267,7 +307,7 @@ public: // compute in which elements the point source falls std::vector<unsigned int> entities = boundingBoxTree.computeEntityCollisions(source.position()); // split the source values equally among all concerned entities - source.embeddings_ *= entities.size(); + source.setEmbeddings(entities.size()*source.embeddings()); // loop over all concernes elements for (unsigned int eIdx : entities) { @@ -296,7 +336,8 @@ public: else pointSourceMap.insert({key, {source}}); // split equally on the number of matched scvs - pointSourceMap.at(key).back().embeddings_ *= scvs.size(); + auto& s = pointSourceMap.at(key).back(); + s.setEmbeddings(scvs.size()*s.embeddings()); } } else @@ -313,6 +354,27 @@ public: } }; +template <class TypeTag> +class PointSourceHelper : public BoundingBoxTreePointSourceHelper<TypeTag> +{ + typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem; + typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView; + typedef typename GET_PROP_TYPE(TypeTag, PointSource) PointSource; + using ParentType = BoundingBoxTreePointSourceHelper<TypeTag>; + typedef Dumux::BoundingBoxTree<GridView> BoundingBoxTree; + +public: + // this seems to be the only deprecation working. The compiler warning will be slightly misleading but the message should clear things up + DUNE_DEPRECATED_MSG("PointSourceHelper<TypeTag> will be removed after the 2.10 release. Use BoundingBoxTreePointSourceHelper<TypeTag> instead.") + static void computePointSourceMap(const Problem& problem, + const BoundingBoxTree& boundingBoxTree, + std::vector<PointSource>& sources, + std::map<std::pair<unsigned int, unsigned int>, std::vector<PointSource> >& pointSourceMap) + { + ParentType::computePointSourceMap(problem, boundingBoxTree, sources, pointSourceMap); + } +} DUNE_DEPRECATED_MSG("PointSourceHelper<TypeTag> will be removed after the 2.10 release. Use BoundingBoxTreePointSourceHelper<TypeTag> instead."); + } // end namespace Dumux #endif diff --git a/dumux/implicit/problem.hh b/dumux/implicit/problem.hh index 2e1c21e1aea861e34204e4dfc98cc593f7cd8619..96c1677be313f73e64c290f594f8a407d74c9eb7 100644 --- a/dumux/implicit/problem.hh +++ b/dumux/implicit/problem.hh @@ -67,6 +67,7 @@ private: typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry; typedef typename GET_PROP_TYPE(TypeTag, BoundaryTypes) BoundaryTypes; typedef typename GET_PROP_TYPE(TypeTag, PointSource) PointSource; + typedef typename GET_PROP_TYPE(TypeTag, PointSourceHelper) PointSourceHelper; enum { dim = GridView::dimension, @@ -157,10 +158,10 @@ public: { // 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_(), - this->boundingBoxTree(), - sources, - pointSourceMap_); + PointSourceHelper::computePointSourceMap(asImp_(), + this->boundingBoxTree(), + sources, + pointSourceMap_); } } @@ -607,10 +608,10 @@ public: { // calculate point source locations and save them in a map pointSourceMap_.clear(); - Dumux::PointSourceHelper<TypeTag>::computePointSourceMap(asImp_(), - this->boundingBoxTree(), - sources, - pointSourceMap_); + PointSourceHelper::computePointSourceMap(asImp_(), + this->boundingBoxTree(), + sources, + pointSourceMap_); } } }