version 3.8
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-FileCopyrightInfo: 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>
24
25namespace Dumux {
26
33template<class GridView>
35{
36 using Grid = typename GridView::Grid;
37
38 static const int dim = Grid::dimension;
39 static const int dimWorld = Grid::dimensionworld;
40
43 using Scalar = typename Grid::ctype;
45 using Geometry = Dune::MultiLinearGeometry<Scalar, dim, dimWorld, GeometryTraits>;
46 using CornerStorage = typename GeometryTraits::template CornerStorage<dim, dimWorld>::Type;
47 using GlobalPosition = typename Geometry::GlobalCoordinate;
48};
49
56template<class GV,
59: public SubControlVolumeBase<BoxSubControlVolume<GV, T>, T>
60{
63 using Geometry = typename T::Geometry;
64 using GridIndexType = typename T::GridIndexType;
65 using LocalIndexType = typename T::LocalIndexType;
66 using Scalar = typename T::Scalar;
67 static constexpr int dim = Geometry::mydimension;
68
69public:
71 using GlobalPosition = typename T::GlobalPosition;
73 using Traits = T;
74
77
78 // the constructor in the box case
79 template<class Corners>
80 BoxSubControlVolume(const Corners& corners,
81 LocalIndexType scvIdx,
82 GridIndexType elementIndex,
83 GridIndexType dofIndex)
84 : dofPosition_(corners[0])
85 , center_(Dumux::center(corners))
86 , elementIndex_(elementIndex)
87 , localDofIdx_(scvIdx)
88 , dofIndex_(dofIndex)
89 {
90 // The corner list is defined such that the first entry is the vertex itself
91 volume_ = Dumux::convexPolytopeVolume<dim>(
92 Dune::GeometryTypes::cube(dim),
93 [&](unsigned int i){ return corners[i]; }
94 );
95 }
96
98 const GlobalPosition& center() const
99 {
100 return center_;
101 }
102
104 Scalar volume() const
105 {
106 return volume_;
107 }
108
110 LocalIndexType localDofIndex() const
111 {
112 return localDofIdx_;
113 }
114
117 LocalIndexType indexInElement() const
118 {
119 return localDofIdx_;
120 }
121
123 GridIndexType dofIndex() const
124 {
125 return dofIndex_;
126 }
127
128 // The position of the dof this scv is embedded in
130 {
131 return dofPosition_;
132 }
133
135 GridIndexType elementIndex() const
136 {
137 return elementIndex_;
138 }
139
140private:
141 GlobalPosition dofPosition_;
142 GlobalPosition center_;
143 Scalar volume_;
144 GridIndexType elementIndex_;
145 LocalIndexType localDofIdx_;
146 GridIndexType dofIndex_;
147};
148
149} // end namespace Dumux
150
151#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:60
BoxSubControlVolume(const Corners &corners, LocalIndexType scvIdx, GridIndexType elementIndex, GridIndexType dofIndex)
Definition: discretization/box/subcontrolvolume.hh:80
T Traits
state the traits public and thus export all types
Definition: discretization/box/subcontrolvolume.hh:73
LocalIndexType localDofIndex() const
The element-local index of the dof this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:110
const GlobalPosition & center() const
The center of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:98
BoxSubControlVolume()=default
The default constructor.
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/box/subcontrolvolume.hh:71
LocalIndexType indexInElement() const
Definition: discretization/box/subcontrolvolume.hh:117
GridIndexType elementIndex() const
The global index of the element this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:135
GridIndexType dofIndex() const
The index of the dof this scv is embedded in.
Definition: discretization/box/subcontrolvolume.hh:123
Scalar volume() const
The volume of the sub control volume.
Definition: discretization/box/subcontrolvolume.hh:104
const GlobalPosition & dofPosition() const
Definition: discretization/box/subcontrolvolume.hh:129
Base class for a sub control volume, i.e a part of the control volume we are making the balance for....
Definition: subcontrolvolumebase.hh:26
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:35
typename GridView::Grid Grid
Definition: discretization/box/subcontrolvolume.hh:36
Dune::MultiLinearGeometry< Scalar, dim, dimWorld, GeometryTraits > Geometry
Definition: discretization/box/subcontrolvolume.hh:45
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/box/subcontrolvolume.hh:41
typename Geometry::GlobalCoordinate GlobalPosition
Definition: discretization/box/subcontrolvolume.hh:47
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/box/subcontrolvolume.hh:42
static const int dim
Definition: discretization/box/subcontrolvolume.hh:38
static const int dimWorld
Definition: discretization/box/subcontrolvolume.hh:39
typename Grid::ctype Scalar
Definition: discretization/box/subcontrolvolume.hh:43
typename GeometryTraits::template CornerStorage< dim, dimWorld >::Type CornerStorage
Definition: discretization/box/subcontrolvolume.hh:46
Traits for an efficient corner storage for box method sub control volumes.
Definition: boxgeometryhelper.hh:32
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28
Base class for a sub control volume.
Compute the volume of several common geometry types.