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> >;
 
   99    const std::string& 
name()
 const 
 
  111        problemName_ = newName;
 
 
  127                       const SubControlVolume &scv)
 const 
  130            DUNE_THROW(Dune::InvalidStateException,
 
  131                       "boundaryTypes(..., scv) called for non-CVFE method.");
 
  134        return asImp_().boundaryTypesAtPos(scv.dofPosition());
 
 
  145                       const SubControlVolumeFace &scvf)
 const 
  148            DUNE_THROW(Dune::InvalidStateException,
 
  149                       "boundaryTypes(..., scvf) called for CVFE method.");
 
  152        return asImp_().boundaryTypesAtPos(scvf.ipGlobal());
 
 
  165        BoundaryTypes bcTypes;
 
 
  178    PrimaryVariables 
dirichlet(
const Element &element, 
const SubControlVolumeFace &scvf)
 const 
  183            DUNE_THROW(Dune::InvalidStateException, 
"dirichlet(scvf) called for CVFE method.");
 
  186            return asImp_().dirichletAtPos(scvf.ipGlobal());
 
 
  197    PrimaryVariables 
dirichlet(
const Element &element, 
const SubControlVolume &scv)
 const 
  200        if (!isCVFE && !isStaggered)
 
  202            DUNE_THROW(Dune::InvalidStateException, 
"dirichlet(scv) called for other than CVFE or staggered method.");
 
  205            return asImp_().dirichletAtPos(scv.dofPosition());
 
 
  220        DUNE_THROW(Dune::InvalidStateException,
 
  221                   "The problem specifies that some boundary " 
  222                   "segments are dirichlet, but does not provide " 
  223                   "a dirichlet() or a dirichletAtPos() method.");
 
 
  261    template<
class ElementVolumeVariables, 
class ElementFluxVariablesCache>
 
  263                        const FVElementGeometry& fvGeometry,
 
  264                        const ElementVolumeVariables& elemVolVars,
 
  265                        const ElementFluxVariablesCache& elemFluxVarsCache,
 
  266                        const SubControlVolumeFace& scvf)
 const 
  269        return asImp_().neumannAtPos(scvf.ipGlobal());
 
 
  285        return NumEqVector(0.0);
 
 
  306    template<
class ElementVolumeVariables>
 
  307    NumEqVector 
source(
const Element &element,
 
  308                       const FVElementGeometry& fvGeometry,
 
  309                       const ElementVolumeVariables& elemVolVars,
 
  310                       const SubControlVolume &scv)
 const 
  313        return asImp_().sourceAtPos(scv.center());
 
 
  333        return NumEqVector(0.0);
 
 
  370    template<
class ElementVolumeVariables>
 
  372                     const Element &element,
 
  373                     const FVElementGeometry& fvGeometry,
 
  374                     const ElementVolumeVariables& elemVolVars,
 
  375                     const SubControlVolume &scv)
 const 
 
  397                          const GlobalPosition &globalPos)
 const {}
 
 
  403    template<
class MatrixBlock, 
class VolumeVariables>
 
  405                              const Element& element,
 
  406                              const FVElementGeometry& fvGeometry,
 
  407                              const VolumeVariables& volVars,
 
  408                              const SubControlVolume& scv)
 const {}
 
 
  416    template<
class ElementVolumeVariables>
 
  418                                const FVElementGeometry& fvGeometry,
 
  419                                const ElementVolumeVariables& elemVolVars,
 
  420                                const SubControlVolume &scv)
 const 
  423        auto scvIdx = scv.indexInElement();
 
  424        auto key = std::make_pair(gridGeometry_->elementMapper().index(element), scvIdx);
 
  425        if (pointSourceMap_.count(key))
 
  430            const auto volume = Extrusion::volume(fvGeometry, scv)*elemVolVars[scv].extrusionFactor();
 
  432            for (
const auto& ps : pointSourceMap_.at(key))
 
 
  467        pointSourceMap_.clear();
 
  470        std::vector<PointSource> sources;
 
  471        asImp_().addPointSources(sources);
 
  474        if (!sources.empty())
 
  475            PointSourceHelper::computePointSourceMap(*gridGeometry_, sources, pointSourceMap_, 
paramGroup());
 
 
  482    { 
return pointSourceMap_; }
 
 
  488    template<
class SolutionVector>
 
  499    template<
class Entity>
 
  500    PrimaryVariables 
initial(
const Entity& entity)
 const 
  502        return asImp_().initialAtPos(entity.geometry().center());
 
 
  514        DUNE_THROW(Dune::InvalidStateException,
 
  515                   "The problem does not provide " 
  516                   "an initial() or an initialAtPos() method.");
 
 
  521    { 
return *gridGeometry_; }
 
 
  525    { 
return paramGroup_; }
 
 
  530    { 
return *
static_cast<Implementation *
>(
this); }
 
 
  534    { 
return *
static_cast<const Implementation *
>(
this); }
 
 
  538    std::shared_ptr<const GridGeometry> gridGeometry_;
 
  541    std::string paramGroup_;
 
  544    std::string problemName_;
 
  547    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
void computePointSourceMap()
Compute the point source map, i.e. which scvs have point source contributions.
Definition common/fvproblem.hh:464
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:524
void applyInitialSolution(SolutionVector &sol) const
Applies the initial solution for all degrees of freedom of the grid.
Definition common/fvproblem.hh:489
NumEqVector neumannAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a neumann boundary segment.
Definition common/fvproblem.hh:281
void setName(const std::string &newName)
Set the problem name.
Definition common/fvproblem.hh:109
PrimaryVariables initial(const Entity &entity) const
Evaluate the initial value for a entity.
Definition common/fvproblem.hh:500
NumEqVector sourceAtPos(const GlobalPosition &globalPos) const
Evaluate the source term for all phases within a given sub-control-volume.
Definition common/fvproblem.hh:329
const Implementation & asImp_() const
Returns the implementation of the problem (i.e. static polymorphism)
Definition common/fvproblem.hh:533
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:404
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:262
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:144
PrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition common/fvproblem.hh:197
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:349
PrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const
Evaluate the boundary conditions for a dirichlet control volume face.
Definition common/fvproblem.hh:178
const PointSourceMap & pointSourceMap() const
Get the point source map. It stores the point sources per scv.
Definition common/fvproblem.hh:481
const GridGeometry & gridGeometry() const
The finite volume grid geometry.
Definition common/fvproblem.hh:520
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:126
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:307
Implementation & asImp_()
Returns the implementation of the problem (i.e. static polymorphism)
Definition common/fvproblem.hh:529
PrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const
Evaluate the boundary conditions for a dirichlet control volume.
Definition common/fvproblem.hh:216
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:161
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:396
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:371
PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const
Evaluate the initial value for a control volume.
Definition common/fvproblem.hh:510
static constexpr bool enableInternalDirichletConstraints()
If internal Dirichlet constraints are enabled Enables / disables internal (non-boundary) Dirichlet co...
Definition common/fvproblem.hh:242
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:417
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
T getParamFromGroup(Args &&... args)
A free function to get a parameter from the parameter tree singleton with a model group.
Definition parameters.hh:149
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
constexpr bool isCVFE
Definition method.hh:67
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