24#ifndef DUMUX_NAVIERSTOKES_STAGGERED_VELOCITYGRADIENTS_HH
25#define DUMUX_NAVIERSTOKES_STAGGERED_VELOCITYGRADIENTS_HH
37template<
class Scalar,
class Gr
idGeometry,
class BoundaryTypes,
class Indices>
40 using FVElementGeometry =
typename GridGeometry::LocalView;
41 using GridView =
typename GridGeometry::GridView;
42 using Element =
typename GridView::template Codim<0>::Entity;
43 using SubControlVolumeFace =
typename FVElementGeometry::SubControlVolumeFace;
44 using GlobalPosition =
typename Element::Geometry::GlobalCoordinate;
63 template<
class FaceVariables>
65 const FaceVariables& faceVars)
68 const Scalar velocitySelf = faceVars.velocitySelf();
69 const Scalar velocityOpposite = faceVars.velocityOpposite();
71 return ((velocityOpposite - velocitySelf) / scvf.selfToOppositeDistance()) * scvf.directionSign();
117 template<
class Problem,
class FaceVariables>
119 const Element& element,
120 const FVElementGeometry& fvGeometry,
121 const SubControlVolumeFace& scvf,
122 const FaceVariables& faceVars,
123 const std::optional<BoundaryTypes>& currentScvfBoundaryTypes,
124 const std::optional<BoundaryTypes>& lateralFaceBoundaryTypes,
125 const std::size_t localSubFaceIdx)
127 const auto eIdx = scvf.insideScvIdx();
128 const auto& lateralScvf = fvGeometry.scvf(eIdx, scvf.pairData(localSubFaceIdx).localLateralFaceIdx);
132 const Scalar innerParallelVelocity = faceVars.velocitySelf();
134 const auto outerParallelVelocity = [&]()
136 if (!lateralScvf.boundary())
137 return faceVars.velocityParallel(localSubFaceIdx, 0);
138 else if (lateralFaceBoundaryTypes->isDirichlet(Indices::velocity(scvf.directionIndex())))
141 const auto& lateralBoundaryFacePos = lateralStaggeredFaceCenter_(scvf, localSubFaceIdx);
143 return problem.dirichlet(element, lateralBoundaryFace)[Indices::velocity(scvf.directionIndex())];
145 else if (lateralFaceBoundaryTypes->isBeaversJoseph(Indices::velocity(scvf.directionIndex())))
148 currentScvfBoundaryTypes, lateralFaceBoundaryTypes, localSubFaceIdx);
151 DUNE_THROW(Dune::InvalidStateException,
"Invalid lateral boundary type at " << lateralScvf.center());
157 return (outerParallelVelocity - innerParallelVelocity)
158 / scvf.parallelDofsDistance(localSubFaceIdx, 0) * lateralScvf.directionSign();
192 template<
class Problem,
class FaceVariables>
194 const Element& element,
195 const FVElementGeometry& fvGeometry,
196 const SubControlVolumeFace& scvf,
197 const FaceVariables& faceVars,
198 const std::optional<BoundaryTypes>& currentScvfBoundaryTypes,
199 const std::optional<BoundaryTypes>& lateralFaceBoundaryTypes,
200 const std::size_t localSubFaceIdx)
202 const auto eIdx = scvf.insideScvIdx();
203 const auto& lateralScvf = fvGeometry.scvf(eIdx, scvf.pairData(localSubFaceIdx).localLateralFaceIdx);
206 if (currentScvfBoundaryTypes && currentScvfBoundaryTypes->isDirichlet(Indices::pressureIdx))
213 const Scalar innerLateralVelocity = faceVars.velocityLateralInside(localSubFaceIdx);
214 const Scalar outerLateralVelocity = [&]()
216 if (!scvf.boundary())
217 return faceVars.velocityLateralOutside(localSubFaceIdx);
218 else if (currentScvfBoundaryTypes->isDirichlet(Indices::velocity(lateralScvf.directionIndex())))
221 const auto& lateralBoundaryFacePos = lateralStaggeredFaceCenter_(scvf, localSubFaceIdx);
223 return problem.dirichlet(element, lateralBoundaryFace)[Indices::velocity(lateralScvf.directionIndex())];
225 else if (currentScvfBoundaryTypes->isBeaversJoseph(Indices::velocity(lateralScvf.directionIndex())))
228 currentScvfBoundaryTypes, lateralFaceBoundaryTypes, localSubFaceIdx);
231 DUNE_THROW(Dune::InvalidStateException,
"Invalid lateral boundary types at " << lateralScvf.center());
235 const Scalar lateralDeltaV = scvf.normalInPosCoordDir()
236 ? (outerLateralVelocity - innerLateralVelocity)
237 : (innerLateralVelocity - outerLateralVelocity);
239 return lateralDeltaV / scvf.pairData(localSubFaceIdx).lateralDistance;
262 template<
class Problem,
class FaceVariables>
264 const Element& element,
265 const FVElementGeometry& fvGeometry,
266 const SubControlVolumeFace& scvf,
267 const FaceVariables& faceVars,
268 const std::optional<BoundaryTypes>& currentScvfBoundaryTypes,
269 const std::optional<BoundaryTypes>& lateralFaceBoundaryTypes,
270 const std::size_t localSubFaceIdx)
272 const auto eIdx = scvf.insideScvIdx();
273 const auto& lateralScvf = fvGeometry.scvf(eIdx, scvf.pairData(localSubFaceIdx).localLateralFaceIdx);
274 const Scalar innerLateralVelocity = faceVars.velocityLateralInside(localSubFaceIdx);
276 const auto tangentialVelocityGradient = [&]()
281 static const bool unsymmetrizedGradientForBJ = getParamFromGroup<bool>(problem.paramGroup(),
282 "FreeFlow.EnableUnsymmetrizedVelocityGradientForBeaversJoseph",
false);
284 if (unsymmetrizedGradientForBJ)
287 if (lateralScvf.boundary())
289 if (lateralFaceBoundaryTypes->isDirichlet(Indices::pressureIdx) ||
290 lateralFaceBoundaryTypes->isBeaversJoseph(Indices::velocity(scvf.directionIndex())))
294 return velocityGradIJ(problem, element, fvGeometry, scvf, faceVars, currentScvfBoundaryTypes, lateralFaceBoundaryTypes, localSubFaceIdx);
297 return problem.beaversJosephVelocity(element,
298 fvGeometry.scv(scvf.insideScvIdx()),
301 innerLateralVelocity,
302 tangentialVelocityGradient);
322 template<
class Problem,
class FaceVariables>
324 const Element& element,
325 const FVElementGeometry& fvGeometry,
326 const SubControlVolumeFace& scvf,
327 const FaceVariables& faceVars,
328 const std::optional<BoundaryTypes>& currentScvfBoundaryTypes,
329 const std::optional<BoundaryTypes>& lateralFaceBoundaryTypes,
330 const std::size_t localSubFaceIdx)
332 const auto eIdx = scvf.insideScvIdx();
333 const auto& lateralScvf = fvGeometry.scvf(eIdx, scvf.pairData(localSubFaceIdx).localLateralFaceIdx);
334 const Scalar innerParallelVelocity = faceVars.velocitySelf();
336 const auto tangentialVelocityGradient = [&]()
341 static const bool unsymmetrizedGradientForBJ = getParamFromGroup<bool>(problem.paramGroup(),
342 "FreeFlow.EnableUnsymmetrizedVelocityGradientForBeaversJoseph",
false);
344 if (unsymmetrizedGradientForBJ)
349 if (currentScvfBoundaryTypes->isDirichlet(Indices::pressureIdx) ||
350 currentScvfBoundaryTypes->isBeaversJoseph(Indices::velocity(lateralScvf.directionIndex())))
354 return velocityGradJI(problem, element, fvGeometry, scvf, faceVars, currentScvfBoundaryTypes, lateralFaceBoundaryTypes, localSubFaceIdx);
357 return problem.beaversJosephVelocity(element,
358 fvGeometry.scv(scvf.insideScvIdx()),
361 innerParallelVelocity,
362 tangentialVelocityGradient);
381 static const GlobalPosition& lateralStaggeredFaceCenter_(
const SubControlVolumeFace& scvf,
const int localSubFaceIdx)
383 return scvf.pairData(localSubFaceIdx).lateralStaggeredFaceCenter;
Some exceptions thrown in DuMux
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
SubControlVolumeFace makeStaggeredBoundaryFace(const SubControlVolumeFace &scvf, const typename SubControlVolumeFace::GlobalPosition &newCenter)
Helper function to turn a given cell scvface into a fake boundary face.
Definition: discretization/staggered/freeflow/subcontrolvolumeface.hh:104
Helper class for calculating the velocity gradients for the Navier-Stokes model using the staggered g...
Definition: velocitygradients.hh:39
static Scalar velocityGradIJ(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf, const FaceVariables &faceVars, const std::optional< BoundaryTypes > ¤tScvfBoundaryTypes, const std::optional< BoundaryTypes > &lateralFaceBoundaryTypes, const std::size_t localSubFaceIdx)
Returns the velocity gradient perpendicular to the orientation of our current scvf.
Definition: velocitygradients.hh:118
static Scalar beaversJosephVelocityAtLateralScvf(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf, const FaceVariables &faceVars, const std::optional< BoundaryTypes > ¤tScvfBoundaryTypes, const std::optional< BoundaryTypes > &lateralFaceBoundaryTypes, const std::size_t localSubFaceIdx)
Returns the Beavers-Jospeh slip velocity for a lateral scvf which lies on the boundary.
Definition: velocitygradients.hh:323
static Scalar velocityGradII(const SubControlVolumeFace &scvf, const FaceVariables &faceVars)
Returns the in-axis velocity gradient.
Definition: velocitygradients.hh:64
static Scalar velocityGradJI(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf, const FaceVariables &faceVars, const std::optional< BoundaryTypes > ¤tScvfBoundaryTypes, const std::optional< BoundaryTypes > &lateralFaceBoundaryTypes, const std::size_t localSubFaceIdx)
Returns the velocity gradient in line with our current scvf.
Definition: velocitygradients.hh:193
static Scalar beaversJosephVelocityAtCurrentScvf(const Problem &problem, const Element &element, const FVElementGeometry &fvGeometry, const SubControlVolumeFace &scvf, const FaceVariables &faceVars, const std::optional< BoundaryTypes > ¤tScvfBoundaryTypes, const std::optional< BoundaryTypes > &lateralFaceBoundaryTypes, const std::size_t localSubFaceIdx)
Returns the Beavers-Jospeh slip velocity for a scvf which lies on the boundary itself.
Definition: velocitygradients.hh:263