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> >;
102 problemName_ = getParamFromGroup<std::string>(
paramGroup,
"Problem.Name");
112 const std::string&
name()
const
128 problemName_ = newName;
144 const SubControlVolume &scv)
const
146 if (!isBox && !isPQ1Bubble)
147 DUNE_THROW(Dune::InvalidStateException,
148 "boundaryTypes(..., scv) called for cell-centered method.");
151 return asImp_().boundaryTypesAtPos(scv.dofPosition());
162 const SubControlVolumeFace &scvf)
const
164 if (isBox || isPQ1Bubble)
165 DUNE_THROW(Dune::InvalidStateException,
166 "boundaryTypes(..., scvf) called for box method.");
169 return asImp_().boundaryTypesAtPos(scvf.ipGlobal());
195 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolumeFace &scvf)
const
198 if (isBox || isPQ1Bubble)
200 DUNE_THROW(Dune::InvalidStateException,
"dirichlet(scvf) called for box method.");
203 return asImp_().dirichletAtPos(scvf.ipGlobal());
214 PrimaryVariables
dirichlet(
const Element &element,
const SubControlVolume &scv)
const
217 if (!isBox && !isStaggered && !isPQ1Bubble)
219 DUNE_THROW(Dune::InvalidStateException,
"dirichlet(scv) called for other than box or staggered method.");
222 return asImp_().dirichletAtPos(scv.dofPosition());
237 DUNE_THROW(Dune::InvalidStateException,
238 "The problem specifies that some boundary "
239 "segments are dirichlet, but does not provide "
240 "a dirichlet() or a dirichletAtPos() method.");
278 template<
class ElementVolumeVariables,
class ElementFluxVariablesCache>
280 const FVElementGeometry& fvGeometry,
281 const ElementVolumeVariables& elemVolVars,
282 const ElementFluxVariablesCache& elemFluxVarsCache,
283 const SubControlVolumeFace& scvf)
const
286 return asImp_().neumannAtPos(scvf.ipGlobal());
302 return NumEqVector(0.0);
323 template<
class ElementVolumeVariables>
324 NumEqVector
source(
const Element &element,
325 const FVElementGeometry& fvGeometry,
326 const ElementVolumeVariables& elemVolVars,
327 const SubControlVolume &scv)
const
330 return asImp_().sourceAtPos(scv.center());
350 return NumEqVector(0.0);
387 template<
class ElementVolumeVariables>
389 const Element &element,
390 const FVElementGeometry& fvGeometry,
391 const ElementVolumeVariables& elemVolVars,
392 const SubControlVolume &scv)
const
414 const GlobalPosition &globalPos)
const {}
420 template<
class MatrixBlock,
class VolumeVariables>
422 const Element& element,
423 const FVElementGeometry& fvGeometry,
424 const VolumeVariables& volVars,
425 const SubControlVolume& scv)
const {}
433 template<
class ElementVolumeVariables>
435 const FVElementGeometry& fvGeometry,
436 const ElementVolumeVariables& elemVolVars,
437 const SubControlVolume &scv)
const
440 auto scvIdx = scv.indexInElement();
441 auto key = std::make_pair(gridGeometry_->elementMapper().index(element), scvIdx);
442 if (pointSourceMap_.count(key))
449 for (
const auto& ps : pointSourceMap_.at(key))
484 pointSourceMap_.clear();
487 std::vector<PointSource> sources;
488 asImp_().addPointSources(sources);
491 if (!sources.empty())
492 PointSourceHelper::computePointSourceMap(*gridGeometry_, sources, pointSourceMap_,
paramGroup());
499 {
return pointSourceMap_; }
505 template<
class SolutionVector>
518 template<
class Entity>
519 PrimaryVariables
initial(
const Entity& entity)
const
521 static_assert(int(Entity::codimension) == 0 || int(Entity::codimension) == dim,
"Entity must be element or vertex");
522 return asImp_().initialAtPos(entity.geometry().center());
534 DUNE_THROW(Dune::InvalidStateException,
535 "The problem does not provide "
536 "an initial() or an initialAtPos() method.");
541 {
return *gridGeometry_; }
545 {
return paramGroup_; }
550 {
return *
static_cast<Implementation *
>(
this); }
554 {
return *
static_cast<const Implementation *
>(
this); }
558 std::shared_ptr<const GridGeometry> gridGeometry_;
561 std::string paramGroup_;
564 std::string problemName_;
567 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.
Helper classes to compute the integration elements.
The available discretization methods in Dumux.
auto volume(const Geometry &geo, unsigned int integrationOrder=4)
The volume of a given geometry.
Definition: volume.hh:171
void assembleInitialSolution(SolutionVector &sol, const Problem &problem)
Set a solution vector to the initial solution provided by the problem.
Definition: initialsolution.hh:39
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
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:251
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
constexpr Box box
Definition: method.hh:136
constexpr Staggered staggered
Definition: method.hh:138
constexpr PQ1Bubble pq1bubble
Definition: method.hh:137
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:481
const std::string & name() const
The problem name.
Definition: common/fvproblem.hh:112
const std::string & paramGroup() const
The parameter group in which to retrieve runtime parameters.
Definition: common/fvproblem.hh:544
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition: common/fvproblem.hh:506
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a neumann boundary segment.
Definition: common/fvproblem.hh:298
void setName(const std::string &newName)
Set the problem name.
Definition: common/fvproblem.hh:126
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:519
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition: common/fvproblem.hh:346
const Implementation & asImp_() const
Returns the implementation of the problem (i.e. static polymorphism)
Definition: common/fvproblem.hh:553
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:421
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:279
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:161
PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition: common/fvproblem.hh:214
FVProblem(std::shared_ptr< const GridGeometry > gridGeometry, const std::string ¶mGroup="")
Constructor.
Definition: common/fvproblem.hh:97
void addPointSources(std::vector< PointSource > &pointSources) const
Applies a vector of point sources. The point sources are possibly solution dependent.
Definition: common/fvproblem.hh:366
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet control volume face.
Definition: common/fvproblem.hh:195
const PointSourceMap & pointSourceMap() const
Get the point source map. It stores the point sources per scv.
Definition: common/fvproblem.hh:498
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition: common/fvproblem.hh:540
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:143
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:324
Implementation & asImp_()
Returns the implementation of the problem (i.e. static polymorphism)
Definition: common/fvproblem.hh:549
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition: common/fvproblem.hh:233
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:178
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:413
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:388
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluate the initial value for a control volume.
Definition: common/fvproblem.hh:530
static constexpr bool enableInternalDirichletConstraints()
If internal Dirichlet constraints are enabled Enables / disables internal (non-boundary) Dirichlet co...
Definition: common/fvproblem.hh:259
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:434
export traits of this problem
Definition: common/fvproblem.hh:86
FVProblem::PrimaryVariables PrimaryVariables
Definition: common/fvproblem.hh:88
FVProblem::Scalar Scalar
Definition: common/fvproblem.hh:87
FVProblem::NumEqVector NumEqVector
Definition: common/fvproblem.hh:89
Class to specify the type of a boundary.
Declares all properties used in Dumux.