26#ifndef DUMUX_POINTSOURCE_HH
27#define DUMUX_POINTSOURCE_HH
47template<
class PositionType,
class ValueType>
52 using Scalar = std::decay_t<decltype(std::declval<ValueType>()[0])>;
65 :
values_(0.0), pos_(pos), embeddings_(1) {}
120 template<
class Problem,
class FVElementGeometry,
class ElementVolumeVariables>
122 const typename FVElementGeometry::GridGeometry::GridView::template Codim<0>::Entity &element,
123 const FVElementGeometry &fvGeometry,
124 const ElementVolumeVariables &elemVolVars,
125 const typename FVElementGeometry::SubControlVolume &scv)
154 std::size_t embeddings_;
164template<
class GlobalPosition,
class SourceValues,
class I>
209template<
class TypeTag>
211 GetPropType<TypeTag, Properties::GridGeometry>::GridView::dimensionworld>,
212 GetPropType<TypeTag, Properties::NumEqVector>>
219 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
220 using Element =
typename GridView::template Codim<0>::Entity;
222 static const int dimworld = GridView::dimensionworld;
223 using GlobalPosition =
typename Dune::FieldVector<typename GridView::ctype, dimworld>;
225 using ValueFunction =
typename std::function<SourceValues(
const Problem &problem,
226 const Element &element,
227 const FVElementGeometry &fvGeometry,
228 const ElementVolumeVariables &elemVolVars,
229 const SubControlVolume &scv)>;
238 ValueFunction valueFunction)
239 :
ParentType(pos, SourceValues(0.0)), valueFunction_(valueFunction) {}
245 const Element &element,
246 const FVElementGeometry &fvGeometry,
247 const ElementVolumeVariables &elemVolVars,
248 const SubControlVolume &scv)
249 { this->
values_ = valueFunction_(problem, element, fvGeometry, elemVolVars, scv); }
266 ValueFunction valueFunction_;
279 template<
class Gr
idGeometry,
class Po
intSource,
class Po
intSourceMap>
281 std::vector<PointSource>& sources,
282 PointSourceMap& pointSourceMap)
286 const auto& boundingBoxTree = gridGeometry.boundingBoxTree();
288 for (
auto&& source : sources)
293 source.setEmbeddings(entities.size()*source.embeddings());
295 for (
unsigned int eIdx : entities)
300 const auto element = boundingBoxTree.entitySet().entity(eIdx);
301 auto fvGeometry =
localView(gridGeometry);
302 fvGeometry.bindElement(element);
304 const auto globalPos = source.position();
306 std::vector<unsigned int> scvIndices;
307 for (
auto&& scv : scvs(fvGeometry))
310 scvIndices.push_back(scv.indexInElement());
314 for (
auto scvIdx : scvIndices)
316 const auto key = std::make_pair(eIdx, scvIdx);
317 if (pointSourceMap.count(key))
318 pointSourceMap.at(key).push_back(source);
320 pointSourceMap.insert({key, {source}});
322 auto& s = pointSourceMap.at(key).back();
323 s.setEmbeddings(scvIndices.size()*s.embeddings());
329 const auto key = std::make_pair(eIdx, 0);
330 if (pointSourceMap.count(key))
331 pointSourceMap.at(key).push_back(source);
333 pointSourceMap.insert({key, {source}});
An axis-aligned bounding box volume hierarchy for dune grids.
Detect if a point intersects a geometry.
Algorithms that finds which geometric entites intersect.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
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:38
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:99
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
A point source base class.
Definition: pointsource.hh:49
void setEmbeddings(std::size_t embeddings)
set the number of embeddings for this point source
Definition: pointsource.hh:129
PointSource & operator*=(Scalar s)
Convenience *= operator overload modifying only the values.
Definition: pointsource.hh:82
ValueType Values
Export the value type.
Definition: pointsource.hh:56
PointSource & operator+=(Scalar s)
Convenience += operator overload modifying only the values.
Definition: pointsource.hh:68
PointSource(GlobalPosition pos)
Constructor for sol dependent point sources, when there is no.
Definition: pointsource.hh:64
std::decay_t< decltype(std::declval< ValueType >()[0])> Scalar
Export the scalar type.
Definition: pointsource.hh:52
Values values() const
return the source values
Definition: pointsource.hh:110
PositionType GlobalPosition
Export the position type.
Definition: pointsource.hh:54
Values values_
value of the point source for each equation
Definition: pointsource.hh:151
const GlobalPosition & position() const
return the source position
Definition: pointsource.hh:114
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:121
PointSource & operator-=(Scalar s)
Convenience -= operator overload modifying only the values.
Definition: pointsource.hh:75
PointSource(GlobalPosition pos, Values values)
Constructor for constant point sources.
Definition: pointsource.hh:59
PointSource & operator=(const Values &values)
Convenience = operator overload modifying only the values.
Definition: pointsource.hh:96
PointSource & operator/=(Scalar s)
Convenience /= operator overload modifying only the values.
Definition: pointsource.hh:89
std::size_t embeddings() const
get the number of embeddings for this point source
Definition: pointsource.hh:145
A point source class with an identifier to attach data.
Definition: pointsource.hh:166
I IdType
export the id type
Definition: pointsource.hh:172
IdPointSource(GlobalPosition pos, IdType id)
Constructor for sol dependent point sources, when there is no.
Definition: pointsource.hh:180
IdPointSource(GlobalPosition pos, SourceValues values, IdType id)
Constructor for constant point sources.
Definition: pointsource.hh:175
IdType id() const
return the sources identifier
Definition: pointsource.hh:184
IdPointSource & operator=(const SourceValues &values)
Convenience = operator overload modifying only the values.
Definition: pointsource.hh:188
A point source class for time dependent point sources.
Definition: pointsource.hh:213
SolDependentPointSource & operator=(const SourceValues &values)
Convenience = operator overload modifying only the values.
Definition: pointsource.hh:252
SolDependentPointSource(GlobalPosition pos, ValueFunction valueFunction)
Constructor for sol dependent point sources, when there is no.
Definition: pointsource.hh:237
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:244
A helper class calculating a sub control volume to point source map This class uses the bounding box ...
Definition: pointsource.hh:276
static void computePointSourceMap(const GridGeometry &gridGeometry, std::vector< PointSource > &sources, PointSourceMap &pointSourceMap)
calculate a DOF index to point source map from given vector of point sources
Definition: pointsource.hh:280
Declares all properties used in Dumux.