24#ifndef DUMUX_COMMON_FV_PROBLEM_HH
25#define DUMUX_COMMON_FV_PROBLEM_HH
30#include <dune/common/fvector.hh>
31#include <dune/grid/common/gridenums.hh>
53template<
class TypeTag>
59 using FVElementGeometry =
typename GridGeometry::LocalView;
60 using GridView =
typename GridGeometry::GridView;
61 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
62 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
64 using Element =
typename GridView::template Codim<0>::Entity;
65 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
67 enum { dim = GridView::dimension };
71 using PointSourceMap = std::map< std::pair<std::size_t, std::size_t>,
72 std::vector<PointSource> >;
101 problemName_ = getParamFromGroup<std::string>(
paramGroup,
"Problem.Name");
111 const std::string&
name()
const
127 problemName_ = newName;
143 const SubControlVolume &scv)
const
146 DUNE_THROW(Dune::InvalidStateException,
147 "boundaryTypes(..., scv) called for cell-centered method.");
150 return asImp_().boundaryTypesAtPos(scv.dofPosition());
161 const SubControlVolumeFace &scvf)
const
164 DUNE_THROW(Dune::InvalidStateException,
165 "boundaryTypes(..., scvf) called for box method.");
168 return asImp_().boundaryTypesAtPos(scvf.ipGlobal());
194 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolumeFace &scvf)
const
199 DUNE_THROW(Dune::InvalidStateException,
"dirichlet(scvf) called for box method.");
202 return asImp_().dirichletAtPos(scvf.ipGlobal());
213 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolume &scv)
const
216 if (!isBox && !isStaggered)
218 DUNE_THROW(Dune::InvalidStateException,
"dirichlet(scv) called for other than box or staggered method.");
221 return asImp_().dirichletAtPos(scv.dofPosition());
236 DUNE_THROW(Dune::InvalidStateException,
237 "The problem specifies that some boundary "
238 "segments are dirichlet, but does not provide "
239 "a dirichlet() or a dirichletAtPos() method.");
277 template<
class ElementVolumeVariables,
class ElementFluxVariablesCache>
279 const FVElementGeometry& fvGeometry,
280 const ElementVolumeVariables& elemVolVars,
281 const ElementFluxVariablesCache& elemFluxVarsCache,
282 const SubControlVolumeFace& scvf)
const
285 return asImp_().neumannAtPos(scvf.ipGlobal());
301 return NumEqVector(0.0);
322 template<
class ElementVolumeVariables>
323 NumEqVector
source(
const Element &element,
324 const FVElementGeometry& fvGeometry,
325 const ElementVolumeVariables& elemVolVars,
326 const SubControlVolume &scv)
const
329 return asImp_().sourceAtPos(scv.center());
349 return NumEqVector(0.0);
386 template<
class ElementVolumeVariables>
388 const Element &element,
389 const FVElementGeometry& fvGeometry,
390 const ElementVolumeVariables& elemVolVars,
391 const SubControlVolume &scv)
const
413 const GlobalPosition &globalPos)
const {}
419 template<
class MatrixBlock,
class VolumeVariables>
421 const Element& element,
422 const FVElementGeometry& fvGeometry,
423 const VolumeVariables& volVars,
424 const SubControlVolume& scv)
const {}
432 template<
class ElementVolumeVariables>
434 const FVElementGeometry& fvGeometry,
435 const ElementVolumeVariables& elemVolVars,
436 const SubControlVolume &scv)
const
439 auto scvIdx = scv.indexInElement();
440 auto key = std::make_pair(gridGeometry_->elementMapper().index(element), scvIdx);
441 if (pointSourceMap_.count(key))
448 for (
const auto& ps : pointSourceMap_.at(key))
483 pointSourceMap_.clear();
486 std::vector<PointSource> sources;
487 asImp_().addPointSources(sources);
490 if (!sources.empty())
491 PointSourceHelper::computePointSourceMap(*gridGeometry_, sources, pointSourceMap_,
paramGroup());
498 {
return pointSourceMap_; }
504 template<
class SolutionVector>
517 template<
class Entity>
518 PrimaryVariables
initial(
const Entity& entity)
const
520 static_assert(int(Entity::codimension) == 0 || int(Entity::codimension) == dim,
"Entity must be element or vertex");
521 return asImp_().initialAtPos(entity.geometry().center());
533 DUNE_THROW(Dune::InvalidStateException,
534 "The problem does not provide "
535 "an initial() or an initialAtPos() method.");
547 template<
class ElementSolution>
549 const SubControlVolume& scv,
550 const ElementSolution& elemSol)
const
553 return asImp_().extrusionFactorAtPos(scv.center());
576 {
return *gridGeometry_; }
580 {
return paramGroup_; }
585 {
return *
static_cast<Implementation *
>(
this); }
589 {
return *
static_cast<const Implementation *
>(
this); }
593 std::shared_ptr<const GridGeometry> gridGeometry_;
596 std::string paramGroup_;
599 std::string problemName_;
602 PointSourceMap pointSourceMap_;
Function to create initial solution vectors.
A helper to deduce a vector with the same size as numbers of equations.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
Helper classes to compute the integration elements.
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:46
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:177
void assembleInitialSolution(SolutionVector &sol, const Problem &problem)
Definition: initialsolution.hh:40
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:150
Scalar volume(Shape shape, Scalar inscribedRadius)
Returns the volume of a given geometry based on the inscribed radius.
Definition: poreproperties.hh:73
Class to specify the type of a boundary.
Definition: common/boundarytypes.hh:38
void setAllDirichlet()
Set all boundary conditions to Dirichlet.
Definition: common/boundarytypes.hh:111
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:55
void computePointSourceMap()
Compute the point source map, i.e. which scvs have point source contributions.
Definition: common/fvproblem.hh:480
const std::string & name() const
The problem name.
Definition: common/fvproblem.hh:111
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:579
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: common/fvproblem.hh:505
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a neumann boundary segment.
Definition: common/fvproblem.hh:297
void setName(const std::string &newName)
Set the problem name.
Definition: common/fvproblem.hh:125
PrimaryVariables initial(const Entity &entity) const
Evaluate the initial value for an element (for cell-centered models) or vertex (for box / vertex-cent...
Definition: common/fvproblem.hh:518
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: common/fvproblem.hh:345
const Implementation & asImp_() const
Returns the implementation of the problem (i.e. static polymorphism)
Definition: common/fvproblem.hh:588
void addSourceDerivatives(MatrixBlock &block, const Element &element, const FVElementGeometry &fvGeometry, const VolumeVariables &volVars, const SubControlVolume &scv) const
Add source term derivative to the Jacobian.
Definition: common/fvproblem.hh:420
NumEqVector neumann(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a neumann boundary segment.
Definition: common/fvproblem.hh:278
auto boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: common/fvproblem.hh:160
PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition: common/fvproblem.hh:213
Scalar extrusionFactor(const Element &element, const SubControlVolume &scv, const ElementSolution &elemSol) const
Return how much the domain is extruded at a given sub-control volume.
Definition: common/fvproblem.hh:548
FVProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string ¶mGroup="")
Constructor.
Definition: common/fvproblem.hh:96
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources. The point sources are possibly solution dependent.
Definition: common/fvproblem.hh:365
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet control volume face.
Definition: common/fvproblem.hh:194
const PointSourceMap & pointSourceMap() const
Get the point source map. It stores the point sources per scv.
Definition: common/fvproblem.hh:497
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:575
auto boundaryTypes(const Element &element, const SubControlVolume &scv) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: common/fvproblem.hh:142
NumEqVector source(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: common/fvproblem.hh:323
Implementation & asImp_()
Returns the implementation of the problem (i.e. static polymorphism)
Definition: common/fvproblem.hh:584
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition: common/fvproblem.hh:232
BoundaryTypes boundaryTypesAtPos(const GlobalPosition &globalPos) const
Specifies which kind of boundary condition should be used for which equation on a given boundary segm...
Definition: common/fvproblem.hh:177
void pointSourceAtPos(PointSource &pointSource, const GlobalPosition &globalPos) const
Evaluate the point sources (added by addPointSources) for all phases within a given sub-control-volum...
Definition: common/fvproblem.hh:412
void pointSource(PointSource &source, const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Evaluate the point sources (added by addPointSources) for all phases within a given sub-control-volum...
Definition: common/fvproblem.hh:387
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluate the initial value for a control volume.
Definition: common/fvproblem.hh:529
static constexpr bool enableInternalDirichletConstraints()
If internal Dirichlet contraints are enabled Enables / disables internal (non-boundary) Dirichlet con...
Definition: common/fvproblem.hh:258
Scalar extrusionFactorAtPos(const GlobalPosition &globalPos) const
Return how much the domain is extruded at a given position.
Definition: common/fvproblem.hh:565
NumEqVector scvPointSources(const Element &element, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &elemVolVars, const SubControlVolume &scv) const
Adds contribution of point sources for a specific sub control volume to the values....
Definition: common/fvproblem.hh:433
export traits of this problem
Definition: common/fvproblem.hh:85
FVProblem::PrimaryVariables PrimaryVariables
Definition: common/fvproblem.hh:87
FVProblem::Scalar Scalar
Definition: common/fvproblem.hh:86
FVProblem::NumEqVector NumEqVector
Definition: common/fvproblem.hh:88
Class to specify the type of a boundary.
Declares all properties used in Dumux.