14#ifndef DUMUX_POINTSOURCE_HH
15#define DUMUX_POINTSOURCE_HH
19#include <dune/common/reservedvector.hh>
37template<
class PositionType,
class ValueType>
42 using Scalar = std::decay_t<decltype(std::declval<ValueType>()[0])>;
55 :
values_(0.0), pos_(pos), embeddings_(1) {}
110 template<
class Problem,
class FVElementGeometry,
class ElementVolumeVariables>
112 const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity &element,
113 const FVElementGeometry &fvGeometry,
114 const ElementVolumeVariables &elemVolVars,
115 const typename FVElementGeometry::SubControlVolume &scv)
144 std::size_t embeddings_;
154template<
class GlobalPosition,
class SourceValues,
class I>
199template<
class TypeTag>
201 GetPropType<TypeTag, Properties::GridGeometry>::GridView::dimensionworld>,
202 Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>>
209 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
210 using Element =
typename GridView::template Codim<0>::Entity;
212 static const int dimworld = GridView::dimensionworld;
213 using GlobalPosition =
typename Dune::FieldVector<typename GridView::ctype, dimworld>;
215 using ValueFunction =
typename std::function<SourceValues(
const Problem &problem,
216 const Element &element,
217 const FVElementGeometry &fvGeometry,
218 const ElementVolumeVariables &elemVolVars,
219 const SubControlVolume &scv)>;
228 ValueFunction valueFunction)
229 :
ParentType(pos, SourceValues(0.0)), valueFunction_(valueFunction) {}
235 const Element &element,
236 const FVElementGeometry &fvGeometry,
237 const ElementVolumeVariables &elemVolVars,
238 const SubControlVolume &scv)
239 { this->
values_ = valueFunction_(problem, element, fvGeometry, elemVolVars, scv); }
256 ValueFunction valueFunction_;
269 template<
class Gr
idGeometry,
class Po
intSource,
class Po
intSourceMap>
271 const std::vector<PointSource>& sources,
272 PointSourceMap& pointSourceMap,
273 const std::string& paramGroup =
"")
275 const auto& boundingBoxTree = gridGeometry.boundingBoxTree();
277 for (
const auto& s : sources)
283 if (entities.empty())
290 source.setEmbeddings(entities.size()*source.embeddings());
296 auto fvGeometry =
localView(gridGeometry);
297 for (
const auto eIdx : entities)
300 const auto element = boundingBoxTree.entitySet().entity(eIdx);
301 fvGeometry.bindElement(element);
303 const auto globalPos = source.position();
305 constexpr int dim = GridGeometry::GridView::dimension;
306 Dune::ReservedVector<std::size_t, 1<<dim> scvIndices;
307 for (
const auto& scv : scvs(fvGeometry))
309 scvIndices.push_back(scv.indexInElement());
313 for (
const auto scvIdx : scvIndices)
315 const auto key = std::make_pair(eIdx, scvIdx);
316 if (pointSourceMap.count(key))
317 pointSourceMap.at(key).push_back(source);
319 pointSourceMap.insert({key, {source}});
321 auto& s = pointSourceMap.at(key).back();
322 s.setEmbeddings(scvIndices.size()*s.embeddings());
328 for (
const auto eIdx : entities)
331 const auto key = std::make_pair(eIdx, 0);
332 if (pointSourceMap.count(key))
333 pointSourceMap.at(key).push_back(source);
335 pointSourceMap.insert({key, {source}});
An axis-aligned bounding box volume hierarchy for dune grids.
A helper class calculating a sub control volume to point source map This class uses the bounding box ...
Definition: pointsource.hh:266
static void computePointSourceMap(const GridGeometry &gridGeometry, const std::vector< PointSource > &sources, PointSourceMap &pointSourceMap, const std::string ¶mGroup="")
calculate a DOF index to point source map from given vector of point sources
Definition: pointsource.hh:270
A point source class with an identifier to attach data.
Definition: pointsource.hh:156
I IdType
export the id type
Definition: pointsource.hh:162
IdPointSource(GlobalPosition pos, IdType id)
Constructor for sol dependent point sources, when there is no.
Definition: pointsource.hh:170
IdPointSource(GlobalPosition pos, SourceValues values, IdType id)
Constructor for constant point sources.
Definition: pointsource.hh:165
IdType id() const
return the sources identifier
Definition: pointsource.hh:174
IdPointSource & operator=(const SourceValues &values)
Convenience = operator overload modifying only the values.
Definition: pointsource.hh:178
A point source base class.
Definition: pointsource.hh:39
void setEmbeddings(std::size_t embeddings)
set the number of embeddings for this point source
Definition: pointsource.hh:119
PointSource & operator*=(Scalar s)
Convenience *= operator overload modifying only the values.
Definition: pointsource.hh:72
ValueType Values
Export the value type.
Definition: pointsource.hh:46
PointSource & operator+=(Scalar s)
Convenience += operator overload modifying only the values.
Definition: pointsource.hh:58
PointSource(GlobalPosition pos)
Constructor for sol dependent point sources, when there is no.
Definition: pointsource.hh:54
std::decay_t< decltype(std::declval< ValueType >()[0])> Scalar
Export the scalar type.
Definition: pointsource.hh:42
Values values() const
return the source values
Definition: pointsource.hh:100
PositionType GlobalPosition
Export the position type.
Definition: pointsource.hh:44
Values values_
value of the point source for each equation
Definition: pointsource.hh:141
const GlobalPosition & position() const
return the source position
Definition: pointsource.hh:104
void update(const Problem &problem, const typename FVElementGeometry::GridGeometry::GridView::template Codim< 0 >::Entity &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const typename FVElementGeometry::SubControlVolume &scv)
an update function called before adding the value
Definition: pointsource.hh:111
PointSource & operator-=(Scalar s)
Convenience -= operator overload modifying only the values.
Definition: pointsource.hh:65
PointSource(GlobalPosition pos, Values values)
Constructor for constant point sources.
Definition: pointsource.hh:49
PointSource & operator=(const Values &values)
Convenience = operator overload modifying only the values.
Definition: pointsource.hh:86
PointSource & operator/=(Scalar s)
Convenience /= operator overload modifying only the values.
Definition: pointsource.hh:79
std::size_t embeddings() const
get the number of embeddings for this point source
Definition: pointsource.hh:135
A point source class for time dependent point sources.
Definition: pointsource.hh:203
SolDependentPointSource & operator=(const SourceValues &values)
Convenience = operator overload modifying only the values.
Definition: pointsource.hh:242
SolDependentPointSource(GlobalPosition pos, ValueFunction valueFunction)
Constructor for sol dependent point sources, when there is no.
Definition: pointsource.hh:227
void update(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv)
an update function called before adding the value
Definition: pointsource.hh:234
Defines all properties used in Dumux.
typename NumEqVectorTraits< PrimaryVariables >::type NumEqVector
A vector with the same size as numbers of equations This is the default implementation and has to be ...
Definition: numeqvector.hh:34
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:26
bool intersectsPointGeometry(const Dune::FieldVector< ctype, dimworld > &point, const Geometry &g)
Find out whether a point is inside a three-dimensional geometry.
Definition: intersectspointgeometry.hh:28
std::vector< std::size_t > intersectingEntities(const Dune::FieldVector< ctype, dimworld > &point, const BoundingBoxTree< EntitySet > &tree, bool isCartesianGrid=false)
Compute all intersections between entities and a point.
Definition: intersectingentities.hh:102
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
Algorithms that finds which geometric entities intersect.
Detect if a point intersects a geometry.
The available discretization methods in Dumux.
constexpr FCDiamond fcdiamond
Definition: method.hh:152
constexpr Box box
Definition: method.hh:147
A helper to deduce a vector with the same size as numbers of equations.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.