version 3.11-dev
discretization/box/subcontrolvolume.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUME_HH
13#define DUMUX_DISCRETIZATION_BOX_SUBCONTROLVOLUME_HH
14
15#include <dune/geometry/type.hh>
16#include <dune/geometry/multilineargeometry.hh>
17
18#include <dumux/common/math.hh>
23
24namespace Dumux {
25
32template<class GridView>
34{
35 using Grid = typename GridView::Grid;
36
37 static const int dim = Grid::dimension;
38 static const int dimWorld = Grid::dimensionworld;
39
42 using Scalar = typename Grid::ctype;
44 using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, GeometryTraits>;
45 using CornerStorage = typename GeometryTraits::template CornerStorage<dim, dimWorld>::Type;
46 using GlobalPosition = typename Geometry::GlobalCoordinate;
47};
48
55template<class GV,
58{
60 using Geometry = typename T::Geometry;
61 using GridIndexType = typename T::GridIndexType;
62 using LocalIndexType = typename T::LocalIndexType;
63 using Scalar = typename T::Scalar;
64 static constexpr int dim = Geometry::mydimension;
65
66public:
68 using GlobalPosition = typename T::GlobalPosition;
70 using Traits = T;
71
74
75 // the constructor in the box case
76 template<class Corners>
77 BoxSubControlVolume(const Corners& corners,
78 LocalIndexType scvIdx,
79 GridIndexType elementIndex,
80 GridIndexType dofIndex)
81 : dofPosition_(corners[0])
82 , center_(Dumux::center(corners))
83 , elementIndex_(elementIndex)
84 , localDofIdx_(scvIdx)
85 , dofIndex_(dofIndex)
86 {
87 // The corner list is defined such that the first entry is the vertex itself
88 volume_ = Dumux::convexPolytopeVolume<dim>(
89 Dune::GeometryTypes::cube(dim),
90 [&](unsigned int i){ return corners[i]; }
91 );
92 }
93
95 const GlobalPosition& center() const
96 {
97 return center_;
98 }
99
101 Scalar volume() const
102 {
103 return volume_;
104 }
105
107 LocalIndexType localDofIndex() const
108 {
109 return localDofIdx_;
110 }
111
114 LocalIndexType indexInElement() const
115 {
116 return localDofIdx_;
117 }
118
120 GridIndexType dofIndex() const
121 {
122 return dofIndex_;
123 }
124
125 // The position of the dof this scv is embedded in
127 {
128 return dofPosition_;
129 }
130
132 GridIndexType elementIndex() const
133 {
134 return elementIndex_;
135 }
136
137private:
138 GlobalPosition dofPosition_;
139 GlobalPosition center_;
140 Scalar volume_;
141 GridIndexType elementIndex_;
142 LocalIndexType localDofIdx_;
143 GridIndexType dofIndex_;
144};
145
146} // end namespace Dumux
147
148#endif
Helper class constructing the dual grid finite volume geometries for the box discretizazion method.
Compute the center point of a convex polytope geometry or a random-access container of corner points.
the sub control volume for the box scheme
Definition: discretization/box/subcontrolvolume.hh:58
BoxSubControlVolume(const Corners &corners, LocalIndexType scvIdx, GridIndexType elementIndex, GridIndexType dofIndex)
Definition: discretization/box/subcontrolvolume.hh:77
T Traits
state the traits public and thus export all types
Definition: discretization/box/subcontrolvolume.hh:70
LocalIndexType localDofIndex() const
The element-local index of the dof this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:107
const GlobalPosition & center() const
The center of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:95
BoxSubControlVolume()=default
The default constructor.
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/box/subcontrolvolume.hh:68
LocalIndexType indexInElement() const
Definition: discretization/box/subcontrolvolume.hh:114
GridIndexType elementIndex() const
The global index of the element this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:132
GridIndexType dofIndex() const
The index of the dof this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:120
Scalar volume() const
The volume of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:101
const GlobalPosition & dofPosition() const
Definition: discretization/box/subcontrolvolume.hh:126
Defines the index types used for grid and local indices.
Define some often used mathematical functions.
Definition: adapt.hh:17
Default traits class to be used for the sub-control volumes for the box scheme.
Definition: discretization/box/subcontrolvolume.hh:34
typename GridView::Grid Grid
Definition: discretization/box/subcontrolvolume.hh:35
Dune::MultiLinearGeometry< Scalar, dim, dimWorld, GeometryTraits > Geometry
Definition: discretization/box/subcontrolvolume.hh:44
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/box/subcontrolvolume.hh:40
typename Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/box/subcontrolvolume.hh:46
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/box/subcontrolvolume.hh:41
static const int dim
Definition: discretization/box/subcontrolvolume.hh:37
static const int dimWorld
Definition: discretization/box/subcontrolvolume.hh:38
typename Grid::ctype Scalar
Definition: discretization/box/subcontrolvolume.hh:42
typename GeometryTraits::template CornerStorage< dim, dimWorld >::Type CornerStorage
Definition: discretization/box/subcontrolvolume.hh:45
Traits for an efficient corner storage for box method sub control volumes.
Definition: boxgeometryhelper.hh:33
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28
Compute the volume of several common geometry types.