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>
52template<
class TypeTag>
58 using FVElementGeometry =
typename GridGeometry::LocalView;
59 using GridView =
typename GridGeometry::GridView;
60 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
61 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
63 using Element =
typename GridView::template Codim<0>::Entity;
64 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
66 enum { dim = GridView::dimension };
70 using PointSourceMap = std::map< std::pair<std::size_t, std::size_t>,
71 std::vector<PointSource> >;
100 problemName_ = getParamFromGroup<std::string>(
paramGroup,
"Problem.Name");
110 const std::string&
name()
const
126 problemName_ = newName;
142 const SubControlVolume &scv)
const
145 DUNE_THROW(Dune::InvalidStateException,
146 "boundaryTypes(..., scv) called for cell-centered method.");
149 return asImp_().boundaryTypesAtPos(scv.dofPosition());
160 const SubControlVolumeFace &scvf)
const
163 DUNE_THROW(Dune::InvalidStateException,
164 "boundaryTypes(..., scvf) called for box method.");
167 return asImp_().boundaryTypesAtPos(scvf.ipGlobal());
193 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolumeFace &scvf)
const
198 DUNE_THROW(Dune::InvalidStateException,
"dirichlet(scvf) called for box method.");
201 return asImp_().dirichletAtPos(scvf.ipGlobal());
212 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolume &scv)
const
215 if (!isBox && !isStaggered)
217 DUNE_THROW(Dune::InvalidStateException,
"dirichlet(scv) called for other than box or staggered method.");
220 return asImp_().dirichletAtPos(scv.dofPosition());
235 DUNE_THROW(Dune::InvalidStateException,
236 "The problem specifies that some boundary "
237 "segments are dirichlet, but does not provide "
238 "a dirichlet() or a dirichletAtPos() method.");
276 template<
class ElementVolumeVariables,
class ElementFluxVariablesCache>
278 const FVElementGeometry& fvGeometry,
279 const ElementVolumeVariables& elemVolVars,
280 const ElementFluxVariablesCache& elemFluxVarsCache,
281 const SubControlVolumeFace& scvf)
const
284 return asImp_().neumannAtPos(scvf.ipGlobal());
300 return NumEqVector(0.0);
321 template<
class ElementVolumeVariables>
322 NumEqVector
source(
const Element &element,
323 const FVElementGeometry& fvGeometry,
324 const ElementVolumeVariables& elemVolVars,
325 const SubControlVolume &scv)
const
328 return asImp_().sourceAtPos(scv.center());
348 return NumEqVector(0.0);
385 template<
class ElementVolumeVariables>
387 const Element &element,
388 const FVElementGeometry& fvGeometry,
389 const ElementVolumeVariables& elemVolVars,
390 const SubControlVolume &scv)
const
412 const GlobalPosition &globalPos)
const {}
418 template<
class MatrixBlock,
class VolumeVariables>
420 const Element& element,
421 const FVElementGeometry& fvGeometry,
422 const VolumeVariables& volVars,
423 const SubControlVolume& scv)
const {}
431 template<
class ElementVolumeVariables>
433 const FVElementGeometry& fvGeometry,
434 const ElementVolumeVariables& elemVolVars,
435 const SubControlVolume &scv)
const
438 auto scvIdx = scv.indexInElement();
439 auto key = std::make_pair(gridGeometry_->elementMapper().index(element), scvIdx);
440 if (pointSourceMap_.count(key))
445 const auto volume = Extrusion::volume(scv)*elemVolVars[scv].extrusionFactor();
447 for (
const auto& ps : pointSourceMap_.at(key))
482 pointSourceMap_.clear();
485 std::vector<PointSource> sources;
486 asImp_().addPointSources(sources);
489 if (!sources.empty())
490 PointSourceHelper::computePointSourceMap(*gridGeometry_, sources, pointSourceMap_,
paramGroup());
497 {
return pointSourceMap_; }
503 template<
class SolutionVector>
516 template<
class Entity>
517 PrimaryVariables
initial(
const Entity& entity)
const
519 static_assert(int(Entity::codimension) == 0 || int(Entity::codimension) == dim,
"Entity must be element or vertex");
520 return asImp_().initialAtPos(entity.geometry().center());
532 DUNE_THROW(Dune::InvalidStateException,
533 "The problem does not provide "
534 "an initial() or an initialAtPos() method.");
546 template<
class ElementSolution>
548 const SubControlVolume& scv,
549 const ElementSolution& elemSol)
const
552 return asImp_().extrusionFactorAtPos(scv.center());
575 {
return *gridGeometry_; }
579 {
return paramGroup_; }
584 {
return *
static_cast<Implementation *
>(
this); }
588 {
return *
static_cast<const Implementation *
>(
this); }
592 std::shared_ptr<const GridGeometry> gridGeometry_;
595 std::string paramGroup_;
598 std::string problemName_;
601 PointSourceMap pointSourceMap_;
Function to create initial solution vectors.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
The available discretization methods in Dumux.
Helper classes to compute the integration elements.
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 (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:149
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:54
void computePointSourceMap()
Compute the point source map, i.e. which scvs have point source contributions.
Definition: common/fvproblem.hh:479
const std::string & name() const
The problem name.
Definition: common/fvproblem.hh:110
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:578
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: common/fvproblem.hh:504
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a neumann boundary segment.
Definition: common/fvproblem.hh:296
void setName(const std::string &newName)
Set the problem name.
Definition: common/fvproblem.hh:124
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:517
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: common/fvproblem.hh:344
const Implementation & asImp_() const
Returns the implementation of the problem (i.e. static polymorphism)
Definition: common/fvproblem.hh:587
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:419
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:277
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:159
PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition: common/fvproblem.hh:212
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:547
FVProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string ¶mGroup="")
Constructor.
Definition: common/fvproblem.hh:95
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources. The point sources are possibly solution dependent.
Definition: common/fvproblem.hh:364
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet control volume face.
Definition: common/fvproblem.hh:193
const PointSourceMap & pointSourceMap() const
Get the point source map. It stores the point sources per scv.
Definition: common/fvproblem.hh:496
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:574
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:141
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:322
Implementation & asImp_()
Returns the implementation of the problem (i.e. static polymorphism)
Definition: common/fvproblem.hh:583
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition: common/fvproblem.hh:231
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:176
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:411
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:386
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluate the initial value for a control volume.
Definition: common/fvproblem.hh:528
static constexpr bool enableInternalDirichletConstraints()
If internal Dirichlet contraints are enabled Enables / disables internal (non-boundary) Dirichlet con...
Definition: common/fvproblem.hh:257
Scalar extrusionFactorAtPos(const GlobalPosition &globalPos) const
Return how much the domain is extruded at a given position.
Definition: common/fvproblem.hh:564
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:432
export traits of this problem
Definition: common/fvproblem.hh:84
FVProblem::PrimaryVariables PrimaryVariables
Definition: common/fvproblem.hh:86
FVProblem::Scalar Scalar
Definition: common/fvproblem.hh:85
FVProblem::NumEqVector NumEqVector
Definition: common/fvproblem.hh:87
Class to specify the type of a boundary.
Declares all properties used in Dumux.