15#ifndef DUMUX_NAVIERSTOKES_MASS_ONEP_FE_LOCAL_RESIDUAL_HH
16#define DUMUX_NAVIERSTOKES_MASS_ONEP_FE_LOCAL_RESIDUAL_HH
22#include <dumux/common/typetraits/localdofs_.hh>
32template<
class TypeTag>
39 using GridVariablesCache =
typename GridVariables::GridVariablesCache;
40 using ElementVariables =
typename GridVariablesCache::LocalView;
45 using ElementDiscretization =
typename GridGeometry::LocalView;
46 using GridView =
typename GridGeometry::GridView;
47 using Element =
typename GridView::template Codim<0>::Entity;
50 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
54 using ParentType::ParentType;
66 const Problem& problem,
67 const Element& element,
68 const ElementDiscretization& elemDisc,
69 const ElementVariables& elemVars,
70 bool isPreviousTimeLevel)
const
72 if constexpr (Detail::LocalDofs::hasNonCVLocalDofsInterface<ElementDiscretization>())
74 if (nonCVLocalDofs(elemDisc).empty())
78 std::vector<Scalar> integralShapeFunctions(Detail::LocalDofs::numLocalDofs(elemDisc), 0.0);
81 const auto& shapeValues = cache(elemVars, qpData.ipData()).shapeValues();
82 for (
const auto& localDof : nonCVLocalDofs(elemDisc))
83 integralShapeFunctions[localDof.index()] += qpData.weight()*shapeValues[localDof.index()][0];
86 for (
const auto& localDof : nonCVLocalDofs(elemDisc))
88 const auto localDofIdx = localDof.index();
89 storage[localDofIdx][Indices::conti0EqIdx]
90 += integralShapeFunctions[localDofIdx]*elemVars[localDofIdx].density();
106 const Problem& problem,
107 const Element& element,
108 const ElementDiscretization& elemDisc,
109 const ElementVariables& elemVars)
const
111 if constexpr (Detail::LocalDofs::hasNonCVLocalDofsInterface<ElementDiscretization>())
113 if (nonCVLocalDofs(elemDisc).empty())
118 const auto& ipData = qpData.ipData();
119 const auto& ipCache = cache(elemVars, ipData);
120 const auto& shapeValues = ipCache.shapeValues();
122 const Scalar divV = problem.velocityDivergence(elemDisc, ipData);
124 Scalar density = 0.0;
125 GlobalPosition gradDensity(0.0);
126 for (
const auto& localDof :
localDofs(elemDisc))
128 const auto localDensity = elemVars[localDof.index()].density();
129 density += localDensity*shapeValues[localDof.index()][0];
130 gradDensity.axpy(localDensity, ipCache.gradN(localDof.index()));
133 const auto velocity = problem.velocity(elemDisc, ipData);
134 const auto source = problem.source(elemDisc, elemVars, ipData);
135 const Scalar divMassFlux = density*divV + (velocity*gradDensity);
137 for (
const auto& localDof : nonCVLocalDofs(elemDisc))
139 const auto localDofIdx = localDof.index();
140 residual[localDofIdx][Indices::conti0EqIdx]
141 += qpData.weight() * shapeValues[localDofIdx]
142 * (divMassFlux - source[Indices::conti0EqIdx]);
Element-wise FE continuity residual for the one-phase mass subdomain.
Definition mass/1p/felocalresidual.hh:35
typename ParentType::ElementResidualVector ElementResidualVector
Definition mass/1p/felocalresidual.hh:53
void addToElementFluxAndSourceResidual(ElementResidualVector &residual, const Problem &problem, const Element &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars) const
Adds the continuity residual.
Definition mass/1p/felocalresidual.hh:105
void addToElementStorage(ElementResidualVector &storage, const Problem &problem, const Element &element, const ElementDiscretization &elemDisc, const ElementVariables &elemVars, bool isPreviousTimeLevel) const
Adds the storage at one time level.
Definition mass/1p/felocalresidual.hh:65
Defines all properties used in Dumux.
The default local operator than can be specialized for each discretization scheme.
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition propertysystem.hh:296
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition quadraturerules.hh:159
typename Detail::DiscretizationDefaultLocalOperator< TypeTag >::type DiscretizationDefaultLocalOperator
Definition defaultlocaloperator.hh:26
auto localDofs(const FVElementGeometry &fvGeometry)
range over local dofs
Definition localdof.hh:50
A helper to deduce a vector with the same size as numbers of equations.
Quadrature rules over sub-control volumes and sub-control volume faces.