24#ifndef DUMUX_DISCRETIZATION_STAGGERED_FREE_FLOW_SUBCONTROLVOLUMEFACE_HH
25#define DUMUX_DISCRETIZATION_STAGGERED_FREE_FLOW_SUBCONTROLVOLUMEFACE_HH
29#include <dune/common/fvector.hh>
30#include <dune/geometry/type.hh>
31#include <dune/geometry/multilineargeometry.hh>
49 template<
class Container>
50 auto operator()(Container&& c)
51 ->
decltype(c.resize(1))
64template<
class Gr
idView,
int upwindSchemeOrder>
69 using Scalar =
typename GridView::ctype;
74 using Grid =
typename GridView::Grid;
75 static constexpr int dim = Grid::dimension;
76 static constexpr int dimWorld = Grid::dimensionworld;
84 template<
int mydim,
int cdim >
87 using Type = std::array< Dune::FieldVector< ct, cdim >, (1<<(
dim-1)) >;
102 int upwindSchemeOrder,
109 using Geometry =
typename T::Geometry;
112 using CornerStorage =
typename T::CornerStorage;
114 using PairData =
typename T::PairData;
115 using AxisData =
typename T::AxisData;
117 using Scalar =
typename T::Scalar;
118 static const int dim = GV::dimension;
120 static constexpr int numPairs = 2 * (dim - 1);
122 static constexpr bool useHigherOrder = upwindSchemeOrder > 1;
134 template <
class Intersection,
class GeometryHelper>
136 const typename Intersection::Geometry& isGeometry,
137 GridIndexType scvfIndex,
138 const std::vector<GridIndexType>& scvIndices,
139 const GeometryHelper& geometryHelper)
141 geomType_(isGeometry.type()),
142 area_(isGeometry.volume()),
143 center_(isGeometry.
center()),
144 unitOuterNormal_(is.centerUnitOuterNormal()),
145 scvfIndex_(scvfIndex),
146 scvIndices_(scvIndices),
149 axisData_(geometryHelper.
axisData()),
150 pairData_(std::move(geometryHelper.
pairData())),
151 localFaceIdx_(geometryHelper.localFaceIndex()),
156 using HasResize =
decltype(
isValid(Detail::hasResize())(corners_));
157 maybeResizeCornerStorage_(HasResize{}, isGeometry.corners());
158 for (
int i = 0; i < isGeometry.corners(); ++i)
159 corners_[i] = isGeometry.corner(i);
196 return unitOuterNormal_;
202 return scvIndices_[0];
208 return scvIndices_[1];
220 assert(localIdx < corners_.size() &&
"provided index exceeds the number of corners");
221 return corners_[localIdx];
227 return Geometry(geomType_, corners_);
233 return localFaceIdx_;
251 return outerNormalSign_;
257 return pairData_[idx];
261 const std::array<PairData, numPairs>&
pairData()
const
283 if (localSubFaceIdx < 2)
300 return pairData(localSubFaceIdx).hasParallelNeighbor[parallelDegreeIdx];
310 return pairData(localSubFaceIdx).hasOuterLateral;
318 template<
bool enable = useHigherOrder, std::enable_if_t<enable,
int> = 0>
321 return axisData().hasBackwardNeighbor[backwardIdx];
329 template<
bool enable = useHigherOrder, std::enable_if_t<enable,
int> = 0>
332 return axisData().hasForwardNeighbor[forwardIdx];
350 return axisData().inAxisForwardDofs[0];
356 return axisData().inAxisBackwardDofs[0];
362 return axisData().selfToOppositeDistance;
373 if (parallelDegreeIdx == 0)
374 return (
faceLength(localSubFaceIdx) +
pairData(localSubFaceIdx).parallelCellWidths[0]) * 0.5;
378 assert((parallelDegreeIdx == 1) &&
"Only the width of the first two parallel cells (indicies 0 and 1) is stored for each scvf.");
379 return (
pairData(localSubFaceIdx).parallelCellWidths[0] +
pairData(localSubFaceIdx).parallelCellWidths[1]) * 0.5;
393 boundaryFace.center_ = pos;
394 boundaryFace.boundary_ =
true;
395 boundaryFace.isGhostFace_ =
true;
400 void maybeResizeCornerStorage_(std::true_type , std::size_t size)
401 { corners_.resize(size); }
403 void maybeResizeCornerStorage_(std::false_type , std::size_t size)
406 Dune::GeometryType geomType_;
407 CornerStorage corners_;
411 GridIndexType scvfIndex_;
412 std::vector<GridIndexType> scvIndices_;
415 Scalar selfToOppositeDistance_;
417 std::array<PairData, numPairs> pairData_;
420 unsigned int dirIdx_;
421 int outerNormalSign_;
A helper function for class member function introspection.
Defines the index types used for grid and local indices.
Helper class constructing the dual grid finite volume geometries for the free flow staggered discreti...
Base class for a sub control volume face.
constexpr int sign(const ValueType &value) noexcept
Sign or signum function.
Definition math.hh:618
constexpr auto isValid(const Expression &t)
A function that creates a test functor to do class member introspection at compile time.
Definition isvalid.hh:93
typename GridView::IndexSet::IndexType GridIndex
Definition indextraits.hh:39
unsigned int LocalIndex
Definition indextraits.hh:40
Detail::AxisData< GridView, upwindSchemeOrder > AxisData
Definition staggeredgeometryhelper.hh:147
Detail::PairData< GridView, upwindSchemeOrder > PairData
Definition staggeredgeometryhelper.hh:146
Default traits class to be used for the sub-control volume faces for the free-flow staggered finite v...
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:66
static constexpr int dimWorld
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:76
typename ScvfMLGTraits< Scalar >::template CornerStorage< dim-1, dimWorld >::Type CornerStorage
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:92
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:67
static constexpr int dim
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:75
typename GridView::Grid Grid
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:74
typename CornerStorage::value_type GlobalPosition
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:93
Dune::MultiLinearGeometry< Scalar, dim-1, dimWorld, ScvfMLGTraits< Scalar > > Geometry
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:91
typename FreeFlowStaggeredGeometryHelper< GridView, upwindSchemeOrder >::AxisData AxisData
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:71
typename GridView::ctype Scalar
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:69
typename FreeFlowStaggeredGeometryHelper< GridView, upwindSchemeOrder >::PairData PairData
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:70
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:68
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:81
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:86
std::array< Dune::FieldVector< ct, cdim >,(1<<(dim-1)) > Type
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:87
LocalIndexType localFaceIdx() const
The local index of this sub control volume face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:231
const GlobalPosition & center() const
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:163
GridIndexType dofIndex() const
Returns the dof of the face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:336
const AxisData & axisData() const
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:267
bool hasOuterLateral(const int localSubFaceIdx) const
Check if the face has an outer normal neighbor.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:308
GridIndexType dofIndexForwardFace() const
Returns the dof the first forward face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:348
bool normalInPosCoordDir() const
Returns whether the unitNormal of the face points in positive coordinate direction.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:243
FreeFlowStaggeredSubControlVolumeFace()=default
const std::array< PairData, numPairs > & pairData() const
Return an array of all pair data.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:261
GridIndexType dofIndexOpposingFace() const
Returns the dof of the opposing face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:342
const Geometry geometry() const
The geometry of the sub control volume face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:225
Scalar parallelDofsDistance(const int localSubFaceIdx, const int parallelDegreeIdx) const
Returns the distance between the parallel dofs.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:371
Scalar selfToOppositeDistance() const
Returns the distance between the face and the opposite one.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:360
const GlobalPosition & ipGlobal() const
The integration point for flux evaluations in global coordinates.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:175
unsigned int directionIndex() const
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:237
bool isGhostFace() const
Returns true if the face is a ghost face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:273
const GlobalPosition & unitOuterNormal() const
The unit outer normal vector.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:194
FreeFlowStaggeredSubControlVolumeFace(const Intersection &is, const typename Intersection::Geometry &isGeometry, GridIndexType scvfIndex, const std::vector< GridIndexType > &scvIndices, const GeometryHelper &geometryHelper)
Constructor with intersection.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:135
int directionSign() const
Returns the sign of the unit outer normal's vector.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:249
FreeFlowStaggeredSubControlVolumeFace makeBoundaryFace(const GlobalPosition &pos) const
Returns a copy of the own scvf whith a user-specified center position. This is needed for retrieving ...
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:390
bool hasForwardNeighbor(const int forwardIdx) const
Check if the face has a forward neighbor.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:330
GridIndexType outsideScvIdx() const
index of the outside sub control volume for spatial param evaluation
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:206
typename FreeFlowStaggeredDefaultScvfGeometryTraits< GridView, upwindSchemeOrder >::GlobalPosition GlobalPosition
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:125
const GlobalPosition & corner(unsigned int localIdx) const
The positions of the corners.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:218
bool hasBackwardNeighbor(const int backwardIdx) const
Check if the face has a backward neighbor.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:319
FreeFlowStaggeredDefaultScvfGeometryTraits< GridView, upwindSchemeOrder > Traits
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:128
bool boundary() const
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:188
const PairData & pairData(const int idx) const
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:255
const GlobalPosition & dofPosition() const
The position of the dof living on the face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:169
GridIndexType index() const
The global index of this sub control volume face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:212
GridIndexType dofIndexBackwardFace() const
Returns the dof of the first backward face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:354
Scalar faceLength(const int localSubFaceIdx) const
Returns the length of the face in a certain direction (adaptation of area() for 3d).
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:279
Scalar area() const
The area of the sub control volume face.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:182
bool hasParallelNeighbor(const int localSubFaceIdx, const int parallelDegreeIdx) const
Check if the face has a parallel neighbor.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:298
GridIndexType insideScvIdx() const
Index of the inside sub control volume for spatial param evaluation.
Definition discretization/staggered/freeflow/subcontrolvolumeface.hh:200
Base class for a sub control volume face, i.e a part of the boundary of a sub control volume we compu...
Definition subcontrolvolumefacebase.hh:41
Class for a sub control volume face in the staggered method, i.e a part of the boundary of a sub cont...