12#ifndef DUMUX_COMMON_FV_PROBLEM_HH
13#define DUMUX_COMMON_FV_PROBLEM_HH
18#include <dune/common/fvector.hh>
19#include <dune/grid/common/gridenums.hh>
41template<
class TypeTag>
47 using FVElementGeometry =
typename GridGeometry::LocalView;
48 using GridView =
typename GridGeometry::GridView;
49 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
50 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
52 using Element =
typename GridView::template Codim<0>::Entity;
53 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
55 enum { dim = GridView::dimension };
59 using PointSourceMap = std::map< std::pair<std::size_t, std::size_t>,
60 std::vector<PointSource> >;
62 static constexpr bool isCVFE = DiscretizationMethods::isCVFE<typename GridGeometry::DiscretizationMethod>;
89 problemName_ = getParamFromGroup<std::string>(
paramGroup,
"Problem.Name");
99 const std::string&
name()
const
115 problemName_ = newName;
131 const SubControlVolume &scv)
const
134 DUNE_THROW(Dune::InvalidStateException,
135 "boundaryTypes(..., scv) called for non-CVFE method.");
138 return asImp_().boundaryTypesAtPos(scv.dofPosition());
149 const SubControlVolumeFace &scvf)
const
152 DUNE_THROW(Dune::InvalidStateException,
153 "boundaryTypes(..., scvf) called for CVFE method.");
156 return asImp_().boundaryTypesAtPos(scvf.ipGlobal());
182 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolumeFace &scvf)
const
187 DUNE_THROW(Dune::InvalidStateException,
"dirichlet(scvf) called for CVFE method.");
190 return asImp_().dirichletAtPos(scvf.ipGlobal());
201 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolume &scv)
const
204 if (!isCVFE && !isStaggered)
206 DUNE_THROW(Dune::InvalidStateException,
"dirichlet(scv) called for other than CVFE or staggered method.");
209 return asImp_().dirichletAtPos(scv.dofPosition());
224 DUNE_THROW(Dune::InvalidStateException,
225 "The problem specifies that some boundary "
226 "segments are dirichlet, but does not provide "
227 "a dirichlet() or a dirichletAtPos() method.");
265 template<
class ElementVolumeVariables,
class ElementFluxVariablesCache>
267 const FVElementGeometry& fvGeometry,
268 const ElementVolumeVariables& elemVolVars,
269 const ElementFluxVariablesCache& elemFluxVarsCache,
270 const SubControlVolumeFace& scvf)
const
273 return asImp_().neumannAtPos(scvf.ipGlobal());
289 return NumEqVector(0.0);
310 template<
class ElementVolumeVariables>
311 NumEqVector
source(
const Element &element,
312 const FVElementGeometry& fvGeometry,
313 const ElementVolumeVariables& elemVolVars,
314 const SubControlVolume &scv)
const
317 return asImp_().sourceAtPos(scv.center());
337 return NumEqVector(0.0);
374 template<
class ElementVolumeVariables>
376 const Element &element,
377 const FVElementGeometry& fvGeometry,
378 const ElementVolumeVariables& elemVolVars,
379 const SubControlVolume &scv)
const
401 const GlobalPosition &globalPos)
const {}
407 template<
class MatrixBlock,
class VolumeVariables>
409 const Element& element,
410 const FVElementGeometry& fvGeometry,
411 const VolumeVariables& volVars,
412 const SubControlVolume& scv)
const {}
420 template<
class ElementVolumeVariables>
422 const FVElementGeometry& fvGeometry,
423 const ElementVolumeVariables& elemVolVars,
424 const SubControlVolume &scv)
const
427 auto scvIdx = scv.indexInElement();
428 auto key = std::make_pair(gridGeometry_->elementMapper().index(element), scvIdx);
429 if (pointSourceMap_.count(key))
436 for (
const auto& ps : pointSourceMap_.at(key))
471 pointSourceMap_.clear();
474 std::vector<PointSource> sources;
475 asImp_().addPointSources(sources);
478 if (!sources.empty())
479 PointSourceHelper::computePointSourceMap(*gridGeometry_, sources, pointSourceMap_,
paramGroup());
486 {
return pointSourceMap_; }
492 template<
class SolutionVector>
503 template<
class Entity>
504 PrimaryVariables
initial(
const Entity& entity)
const
506 return asImp_().initialAtPos(entity.geometry().center());
518 DUNE_THROW(Dune::InvalidStateException,
519 "The problem does not provide "
520 "an initial() or an initialAtPos() method.");
525 {
return *gridGeometry_; }
529 {
return paramGroup_; }
534 {
return *
static_cast<Implementation *
>(
this); }
538 {
return *
static_cast<const Implementation *
>(
this); }
542 std::shared_ptr<const GridGeometry> gridGeometry_;
545 std::string paramGroup_;
548 std::string problemName_;
551 PointSourceMap pointSourceMap_;
Class to specify the type of a boundary.
Definition: common/boundarytypes.hh:26
void setAllDirichlet()
Set all boundary conditions to Dirichlet.
Definition: common/boundarytypes.hh:99
Base class for all finite-volume problems.
Definition: common/fvproblem.hh:43
void computePointSourceMap()
Compute the point source map, i.e. which scvs have point source contributions.
Definition: common/fvproblem.hh:468
const std::string & name() const
The problem name.
Definition: common/fvproblem.hh:99
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:528
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: common/fvproblem.hh:493
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a neumann boundary segment.
Definition: common/fvproblem.hh:285
void setName(const std::string &newName)
Set the problem name.
Definition: common/fvproblem.hh:113
PrimaryVariables initial(const Entity &entity) const
Evaluate the initial value for a entity.
Definition: common/fvproblem.hh:504
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: common/fvproblem.hh:333
const Implementation & asImp_() const
Returns the implementation of the problem (i.e. static polymorphism)
Definition: common/fvproblem.hh:537
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:408
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:266
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:148
PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition: common/fvproblem.hh:201
FVProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string ¶mGroup="")
Constructor.
Definition: common/fvproblem.hh:84
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources. The point sources are possibly solution dependent.
Definition: common/fvproblem.hh:353
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet control volume face.
Definition: common/fvproblem.hh:182
const PointSourceMap & pointSourceMap() const
Get the point source map. It stores the point sources per scv.
Definition: common/fvproblem.hh:485
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:524
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:130
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:311
Implementation & asImp_()
Returns the implementation of the problem (i.e. static polymorphism)
Definition: common/fvproblem.hh:533
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition: common/fvproblem.hh:220
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:165
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:400
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:375
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluate the initial value for a control volume.
Definition: common/fvproblem.hh:514
static constexpr bool enableInternalDirichletConstraints()
If internal Dirichlet constraints are enabled Enables / disables internal (non-boundary) Dirichlet co...
Definition: common/fvproblem.hh:246
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:421
Class to specify the type of a boundary.
Defines all properties used in Dumux.
Helper classes to compute the integration elements.
void assembleInitialSolution(SolutionVector &sol, const Problem &problem)
Set a solution vector to the initial solution provided by the problem.
Definition: initialsolution.hh:27
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
auto volume(const Geometry &geo, unsigned int integrationOrder=4)
The volume of a given geometry.
Definition: volume.hh:159
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:296
Function to create initial solution vectors.
The available discretization methods in Dumux.
constexpr Staggered staggered
Definition: method.hh:149
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:166
A helper to deduce a vector with the same size as numbers of equations.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
export traits of this problem
Definition: common/fvproblem.hh:73
FVProblem::PrimaryVariables PrimaryVariables
Definition: common/fvproblem.hh:75
FVProblem::Scalar Scalar
Definition: common/fvproblem.hh:74
FVProblem::NumEqVector NumEqVector
Definition: common/fvproblem.hh:76