12#ifndef DUMUX_NAVIERSTOKES_STAGGERED_VELOCITYRECONSTRUCTION_HH
13#define DUMUX_NAVIERSTOKES_STAGGERED_VELOCITYRECONSTRUCTION_HH
17#include <dune/common/reservedvector.hh>
29 template<
class VelocityHelper,
class FVElementGeometry>
31 const FVElementGeometry& fvGeometry)
34 using VelocityVector =
typename FVElementGeometry::GridGeometry::GlobalCoordinate;
35 VelocityVector result(0.0);
39 return std::find_if(vector.begin(), vector.end(), [](
const auto& x) { return std::abs(x) > 1e-8; } ) - vector.begin();
42 for (
const auto& scvf : scvfs(fvGeometry))
45 result[dirIdx] += 0.5*getFaceVelocity(fvGeometry, scvf)[dirIdx];
51 template<
class SubControlVolume,
class FVElementGeometry,
class VelocityHelper>
53 const FVElementGeometry& fvGeometry,
54 const VelocityHelper& getNormalVelocityDofValue)
56 int axis = scv.dofAxis();
57 const int dim = FVElementGeometry::GridGeometry::GridView::dimension;
58 using Scalar =
typename SubControlVolume::Traits::Scalar;
59 using GlobalPosition =
typename FVElementGeometry::GridGeometry::GlobalCoordinate;
60 using VelocityVector =
typename FVElementGeometry::GridGeometry::GlobalCoordinate;
61 VelocityVector faceVelocityVector(0.0);
64 std::array<Dune::ReservedVector<Scalar, 2>, dim> normalVelocities;
65 if (scv.boundary() && !fvGeometry.gridGeometry().dofOnPeriodicBoundary(scv.dofIndex()))
68 for (
const auto& scvf : scvfs(fvGeometry, scv))
74 const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
75 const auto& lateralScv = fvGeometry.scv(orthogonalScvf.insideScvIdx());
76 auto lateralAxis = lateralScv.dofAxis();
77 normalVelocities[lateralAxis].push_back( getNormalVelocityDofValue(lateralScv) ) ;
83 const GlobalPosition selfPosition = scv.dofPosition();
84 GlobalPosition outsideSelfPosition = selfPosition;
85 if (fvGeometry.gridGeometry().dofOnPeriodicBoundary(scv.dofIndex()))
86 outsideSelfPosition = fvGeometry.outsidePeriodicScv(scv).dofPosition();
89 for (
const auto& scvf : scvfs(fvGeometry, scv))
95 const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf);
96 const auto& insideLateralScv = fvGeometry.scv(orthogonalScvf.insideScvIdx());
97 const auto& outsideLateralScv = fvGeometry.scv(orthogonalScvf.outsideScvIdx());
98 const auto& lateralAxis = insideLateralScv.dofAxis();
101 const auto& insideNormalVelocity = getNormalVelocityDofValue(insideLateralScv);
102 const auto& insideNormalPosition = insideLateralScv.dofPosition()[axis];
105 const auto& outsideNormalVelocity = getNormalVelocityDofValue(outsideLateralScv);
106 const auto& outsideNormalPosition = outsideLateralScv.dofPosition()[axis];
109 const auto& innerDistance = std::abs(insideNormalPosition - selfPosition[axis]);
110 const auto& totalDistance = std::abs(outsideNormalPosition - outsideSelfPosition[axis]) + innerDistance;
111 const auto& velDiff = outsideNormalVelocity - insideNormalVelocity;
113 normalVelocities[lateralAxis].push_back(insideNormalVelocity + (velDiff * innerDistance / totalDistance));
117 for (
int i = 0; i < faceVelocityVector.size(); i++)
120 faceVelocityVector[i] = getNormalVelocityDofValue(scv);
122 faceVelocityVector[i] = std::accumulate(normalVelocities[i].begin(), normalVelocities[i].end(), 0.0) / normalVelocities[i].size();
125 return faceVelocityVector;
static unsigned int directionIndex(Vector &&vector)
Returns the direction index of the facet (0 = x, 1 = y, 2 = z)
Definition: staggeredgeometryhelper.hh:121
The available discretization methods in Dumux.
constexpr CCTpfa cctpfa
Definition: method.hh:145
Helper class for reconstructing the velocity.
Definition: velocityreconstruction.hh:27
static auto cellCenterVelocity(const VelocityHelper &getFaceVelocity, const FVElementGeometry &fvGeometry)
Return the velocity vector at the center of the primal grid.
Definition: velocityreconstruction.hh:30
static auto faceVelocity(const SubControlVolume &scv, const FVElementGeometry &fvGeometry, const VelocityHelper &getNormalVelocityDofValue)
Return the velocity vector at dof position given an scv.
Definition: velocityreconstruction.hh:52