From 82c2c92a3240ff8fa89d279f267493cdd7fe8caf Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Thu, 25 Jan 2018 16:53:26 +0100 Subject: [PATCH 1/3] [pointsource] Explicitly divide by source embeddings for better transparency --- dumux/common/fvproblem.hh | 2 +- dumux/common/pointsource.hh | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/dumux/common/fvproblem.hh b/dumux/common/fvproblem.hh index a9857b41d0..c8b534f55f 100644 --- a/dumux/common/fvproblem.hh +++ b/dumux/common/fvproblem.hh @@ -418,7 +418,7 @@ public: // call convienience problem interface function asImp_().pointSource(pointSource, element, fvGeometry, elemVolVars, scv); // at last take care about multiplying with the correct volume - pointSource /= volume; + pointSource /= volume*pointSource.embeddings(); // add the point source values to the local residual source += pointSource.values(); } diff --git a/dumux/common/pointsource.hh b/dumux/common/pointsource.hh index ac4efb84f9..c20c52bd69 100644 --- a/dumux/common/pointsource.hh +++ b/dumux/common/pointsource.hh @@ -115,14 +115,8 @@ public: } //! return the source values - // don't forget to call this when it's overloaded - // in the derived class PrimaryVariables values() const - { - auto values = PrimaryVariables(values_); - values /= embeddings_; - return values; - } + { return values_; } //! return the source position const GlobalPosition& position() const @@ -144,7 +138,17 @@ public: embeddings_ = embeddings; } - //! get the number of embeddings for this point source + /*! + * \brief get the number of embeddings for this point source + * \note A point source might be located on the intersection between several scvs. + * If so, there are point sources for every neighboring scv with the same position. + * `embeddings` returns the number of neighboring scvs. + * Example: If I want to inject 1kg/s at a location that is on the inner face of an scv + * the point source exists in both scvs. Both have a value of 1kg/s. + * We then divide the value by the number of embeddings to not inject 2kg/s but 1kg/s. + * \note This division is done in the problem.scvPointSources() if this behaviour is not explicitly + * changed by e.g. overloading this function in the problem implementation. + */ std::size_t embeddings() const { return embeddings_; -- GitLab From 7b2848d13a321e7d8eed7092d67ba4047b0e9095 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Thu, 25 Jan 2018 16:55:14 +0100 Subject: [PATCH 2/3] [fvproblem] Introduce getter function for point source map --- dumux/common/fvproblem.hh | 17 +++++++++++++---- dumux/common/pointsource.hh | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/dumux/common/fvproblem.hh b/dumux/common/fvproblem.hh index c8b534f55f..1dd4a57920 100644 --- a/dumux/common/fvproblem.hh +++ b/dumux/common/fvproblem.hh @@ -25,6 +25,7 @@ #define DUMUX_FV_PROBLEM_HH #include +#include #include #include @@ -75,6 +76,9 @@ class FVProblem static constexpr bool isBox = GET_PROP_VALUE(TypeTag, DiscretizationMethod) == DiscretizationMethods::Box; + using PointSourceMap = std::map, + std::vector >; + public: /*! * \brief Constructor @@ -431,7 +435,7 @@ public: * \brief Compute the point source map, i.e. which scvs have point source contributions * \note Call this on the problem before assembly if you want to enable point sources set * via the addPointSources member function. - */ + */ void computePointSourceMap() { // clear the given point source maps in case it's not empty @@ -451,10 +455,16 @@ public: } } + /*! + * \brief Get the point source map. It stores the point sources per scv + */ + const PointSourceMap& pointSourceMap() const + { return pointSourceMap_; } + /*! * \brief Applies the initial solution for all degrees of freedom of the grid. * \param sol the initial solution vector - */ + */ void applyInitialSolution(SolutionVector& sol) const { // set the initial values by forwarding to a specialized method @@ -569,8 +579,7 @@ private: std::string problemName_; //! A map from an scv to a vector of point sources - std::map, - std::vector > pointSourceMap_; + PointSourceMap pointSourceMap_; }; } // end namespace Dumux diff --git a/dumux/common/pointsource.hh b/dumux/common/pointsource.hh index c20c52bd69..271228fe8e 100644 --- a/dumux/common/pointsource.hh +++ b/dumux/common/pointsource.hh @@ -290,9 +290,10 @@ class BoundingBoxTreePointSourceHelper public: //! calculate a DOF index to point source map from given vector of point sources + template static void computePointSourceMap(const FVGridGeometry& fvGridGeometry, std::vector& sources, - std::map, std::vector >& pointSourceMap) + PointSourceMap& pointSourceMap) { const auto& boundingBoxTree = fvGridGeometry.boundingBoxTree(); -- GitLab From 4d8f466407cf5b34ea88b1f4916acf2f086da16c Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Thu, 25 Jan 2018 16:55:31 +0100 Subject: [PATCH 3/3] [fvproblem] Fix comment formatting --- dumux/common/fvproblem.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dumux/common/fvproblem.hh b/dumux/common/fvproblem.hh index 1dd4a57920..dd8b8956a8 100644 --- a/dumux/common/fvproblem.hh +++ b/dumux/common/fvproblem.hh @@ -527,8 +527,8 @@ public: */ Scalar extrusionFactorAtPos(const GlobalPosition &globalPos) const { - //! As a default, i.e. if the user's problem does not overload any extrusion factor method - //! return 1.0 + // As a default, i.e. if the user's problem does not overload + // any extrusion factor method, return 1.0 return 1.0; } -- GitLab