24#ifndef DUMUX_FV_LOCAL_ASSEMBLER_BASE_HH
25#define DUMUX_FV_LOCAL_ASSEMBLER_BASE_HH
27#include <dune/common/reservedvector.hh>
28#include <dune/grid/common/gridenums.hh>
29#include <dune/istl/matrixindexset.hh>
46template<
class TypeTag,
class Assembler,
class Implementation,
bool useImplicitAssembly>
54 using SolutionVector =
typename Assembler::ResidualType;
57 using SubControlVolume =
typename FVElementGeometry::SubControlVolume;
58 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
63 using Element =
typename GridView::template Codim<0>::Entity;
75 const SolutionVector&
curSol)
92 const SolutionVector&
curSol,
114 {
return useImplicitAssembly; }
123 if (this->
assembler().isStationaryProblem())
124 DUNE_THROW(Dune::InvalidStateException,
"Using explicit jacobian assembler with stationary local residual");
168 return localResidual_.evalFluxAndSource(element_, fvGeometry_, elemVolVars, elemFluxVarsCache_, elemBcTypes_);
178 return localResidual_.evalStorage(element_, fvGeometry_, prevElemVolVars_, curElemVolVars_);
190 const auto& prevSol = this->
assembler().prevSol();
203 if (!this->
assembler().isStationaryProblem())
217 template<
typename ApplyFunction,
class P = Problem,
typename std::enable_if_t<P::enableInternalDirichletConstra
ints(),
int> = 0>
222 for (
const auto& scvI : scvs(this->
fvGeometry()))
224 if (this->
problem().hasInternalDirichletConstraint(this->
element(), scvI))
226 const auto dirichletValues = this->
problem().internalDirichlet(this->
element(), scvI);
228 for (
int eqIdx = 0; eqIdx < numEq; ++eqIdx)
229 applyDirichlet(scvI, dirichletValues, eqIdx, eqIdx);
234 template<
typename ApplyFunction,
class P = Problem,
typename std::enable_if_t<!P::enableInternalDirichletConstra
ints(),
int> = 0>
240 {
return assembler_.problem(); }
244 {
return assembler_; }
252 {
return elementIsGhost_; }
260 {
return fvGeometry_; }
264 {
return curElemVolVars_; }
268 {
return prevElemVolVars_; }
272 {
return elemFluxVarsCache_; }
276 {
return localResidual_; }
280 {
return elemBcTypes_; }
284 {
return fvGeometry_; }
288 {
return curElemVolVars_; }
292 {
return prevElemVolVars_; }
296 {
return elemFluxVarsCache_; }
300 {
return elemBcTypes_; }
304 {
return localResidual_; }
308 {
return *
static_cast<Implementation*
>(
this); }
311 {
return *
static_cast<const Implementation*
>(
this); }
313 template<class T = TypeTag, typename std::enable_if_t<!getPropValue<T, Properties::EnableGridVolumeVariablesCache>(),
int> = 0>
314 VolumeVariables&
getVolVarAccess(GridVolumeVariables& gridVolVars, ElementVolumeVariables& elemVolVars,
const SubControlVolume& scv)
315 {
return elemVolVars[scv]; }
317 template<class T = TypeTag, typename std::enable_if_t<getPropValue<T, Properties::EnableGridVolumeVariablesCache>(),
int> = 0>
318 VolumeVariables&
getVolVarAccess(GridVolumeVariables& gridVolVars, ElementVolumeVariables& elemVolVars,
const SubControlVolume& scv)
319 {
return gridVolVars.volVars(scv); }
323 const Assembler& assembler_;
324 const Element& element_;
325 const SolutionVector& curSol_;
327 FVElementGeometry fvGeometry_;
328 ElementVolumeVariables curElemVolVars_;
329 ElementVolumeVariables prevElemVolVars_;
330 ElementFluxVariablesCache elemFluxVarsCache_;
331 ElementBoundaryTypes elemBcTypes_;
334 bool elementIsGhost_;
An enum class to define various differentiation methods available in order to compute the derivatives...
A arithmetic block vector type based on DUNE's reserved vector.
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
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
Definition: common/pdesolver.hh:35
A base class for all local assemblers.
Definition: fvlocalassemblerbase.hh:48
const ElementVolumeVariables & prevElemVolVars() const
The element volume variables of the provious time step.
Definition: fvlocalassemblerbase.hh:291
void bindLocalViews()
Convenience function bind and prepare all relevant variables required for the evaluation of the local...
Definition: fvlocalassemblerbase.hh:185
ElementResidualVector evalLocalResidual(const ElementVolumeVariables &elemVolVars) const
Evaluates the complete local residual for the current element.
Definition: fvlocalassemblerbase.hh:137
ElementVolumeVariables & curElemVolVars()
The current element volume variables.
Definition: fvlocalassemblerbase.hh:263
typename LocalResidual::ElementResidualVector ElementResidualVector
Definition: fvlocalassemblerbase.hh:68
ElementBoundaryTypes & elemBcTypes()
The element's boundary types.
Definition: fvlocalassemblerbase.hh:279
Implementation & asImp_()
Definition: fvlocalassemblerbase.hh:307
ElementVolumeVariables & prevElemVolVars()
The element volume variables of the provious time step.
Definition: fvlocalassemblerbase.hh:267
ElementResidualVector evalLocalResidual() const
Convenience function to evaluate the complete local residual for the current element....
Definition: fvlocalassemblerbase.hh:120
const Problem & problem() const
The problem.
Definition: fvlocalassemblerbase.hh:239
const ElementBoundaryTypes & elemBcTypes() const
The element's boundary types.
Definition: fvlocalassemblerbase.hh:299
const ElementFluxVariablesCache & elemFluxVarsCache() const
The element flux variables cache.
Definition: fvlocalassemblerbase.hh:295
const Implementation & asImp_() const
Definition: fvlocalassemblerbase.hh:310
FVLocalAssemblerBase(const Assembler &assembler, const Element &element, const SolutionVector &curSol, const FVElementGeometry &fvGeometry, const ElementVolumeVariables &curElemVolVars, const ElementVolumeVariables &prevElemVolVars, const ElementFluxVariablesCache &elemFluxVarsCache, const LocalResidual &localResidual, const bool elementIsGhost)
The constructor. General version explicitly expecting each argument.
Definition: fvlocalassemblerbase.hh:90
const ElementVolumeVariables & curElemVolVars() const
The current element volume variables.
Definition: fvlocalassemblerbase.hh:287
FVLocalAssemblerBase(const Assembler &assembler, const Element &element, const SolutionVector &curSol)
The constructor. Delegates to the general constructor.
Definition: fvlocalassemblerbase.hh:73
const LocalResidual & localResidual() const
The local residual for the current element.
Definition: fvlocalassemblerbase.hh:303
FVElementGeometry & fvGeometry()
The global finite volume geometry.
Definition: fvlocalassemblerbase.hh:259
ElementResidualVector evalLocalFluxAndSourceResidual(const ElementVolumeVariables &elemVolVars) const
Evaluates the flux and source terms (i.e, the terms without a time derivative) of the local residual ...
Definition: fvlocalassemblerbase.hh:166
const Assembler & assembler() const
The assembler.
Definition: fvlocalassemblerbase.hh:243
ElementFluxVariablesCache & elemFluxVarsCache()
The element flux variables cache.
Definition: fvlocalassemblerbase.hh:271
bool elementIsGhost() const
Returns if element is a ghost entity.
Definition: fvlocalassemblerbase.hh:251
LocalResidual & localResidual()
The local residual for the current element.
Definition: fvlocalassemblerbase.hh:275
static constexpr bool isImplicit()
Returns true if the assembler considers implicit assembly.
Definition: fvlocalassemblerbase.hh:113
ElementResidualVector evalLocalFluxAndSourceResidual() const
Convenience function to evaluate the flux and source terms (i.e, the terms without a time derivative)...
Definition: fvlocalassemblerbase.hh:154
void enforceInternalDirichletConstraints(const ApplyFunction &applyDirichlet)
Enforces Dirichlet constraints if enabled in the problem.
Definition: fvlocalassemblerbase.hh:218
const Element & element() const
The current element.
Definition: fvlocalassemblerbase.hh:247
VolumeVariables & getVolVarAccess(GridVolumeVariables &gridVolVars, ElementVolumeVariables &elemVolVars, const SubControlVolume &scv)
Definition: fvlocalassemblerbase.hh:314
const FVElementGeometry & fvGeometry() const
The finite volume geometry.
Definition: fvlocalassemblerbase.hh:283
GetPropType< TypeTag, Properties::LocalResidual > LocalResidual
Definition: fvlocalassemblerbase.hh:67
ElementResidualVector evalLocalStorageResidual() const
Convenience function to evaluate storage term (i.e, the term with a time derivative) of the local res...
Definition: fvlocalassemblerbase.hh:176
const SolutionVector & curSol() const
The current solution.
Definition: fvlocalassemblerbase.hh:255
Declares all properties used in Dumux.