version 3.7
discretization/porenetwork/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_PNM_SUBCONTROLVOLUME_HH
13#define DUMUX_DISCRETIZATION_PNM_SUBCONTROLVOLUME_HH
14
15#include <dune/geometry/affinegeometry.hh>
16#include <dumux/common/math.hh>
19
20namespace Dumux::PoreNetwork {
21
27template<class GridView>
29{
30 using Grid = typename GridView::Grid;
31
32 static const int dim = Grid::dimension;
33 static const int dimWorld = Grid::dimensionworld;
34
37 using Scalar = typename Grid::ctype;
38 using GlobalPosition = Dune::FieldVector<Scalar, dimWorld>;
39 using CornerStorage = std::array<GlobalPosition, 2>;
40 using Geometry = Dune::AffineGeometry<Scalar, 1, dimWorld>;
41};
42
49template<class GV,
52: public Dumux::SubControlVolumeBase<PNMSubControlVolume<GV, T>, T>
53{
56 using GridIndexType = typename T::GridIndexType;
57 using LocalIndexType = typename T::LocalIndexType;
58 using Scalar = typename T::Scalar;
59 using CornerStorage = typename T::CornerStorage;
60 using Geometry = typename T::Geometry;
61
62public:
64 using GlobalPosition = typename T::GlobalPosition;
66 using Traits = T;
67
70
71 // the constructor in the box case
72 template<class Corners>
74 LocalIndexType scvIdx,
75 GridIndexType elementIndex,
76 Corners&& corners,
77 const Scalar volume)
78 : center_((corners[0]+corners[1])/2.0),
79 corners_(std::forward<CornerStorage>(corners)),
80 volume_(volume),
81 elementIndex_(elementIndex),
82 localDofIdx_(scvIdx),
83 dofIndex_(dofIndex)
84 {}
85
88 const GlobalPosition& center() const
89 { return center_; }
90
92 Scalar volume() const
93 { return volume_; }
94
96 LocalIndexType localDofIndex() const
97 { return localDofIdx_; }
98
100 LocalIndexType indexInElement() const
101 { return localDofIdx_; }
102
104 GridIndexType dofIndex() const
105 { return dofIndex_; }
106
107 // The position of the dof this scv is embedded in
109 { return corners_[0]; }
110
112 GridIndexType elementIndex() const
113 { return elementIndex_; }
114
116 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scv).corner(i).")]]
117 const GlobalPosition& corner(LocalIndexType localIdx) const
118 {
119 assert(localIdx < corners_.size() && "provided index exceeds the number of corners");
120 return corners_[localIdx];
121 }
122
124 [[deprecated("Will be removed after 3.7. Use fvGeometry.geometry(scv).")]]
125 Geometry geometry() const
126 {
127 return Geometry(Dune::GeometryTypes::simplex(1), corners_);
128 }
129
130private:
131 GlobalPosition center_;
132 CornerStorage corners_;
133 Scalar volume_;
134 GridIndexType elementIndex_;
135 LocalIndexType localDofIdx_;
136 GridIndexType dofIndex_;
137};
138
139} // end namespace Dumux::PoreNetwork
140
141#endif
the sub control volume for porenetworks
Definition: discretization/porenetwork/subcontrolvolume.hh:53
Geometry geometry() const
The geometry of the sub control volume e.g. for integration.
Definition: discretization/porenetwork/subcontrolvolume.hh:125
T Traits
state the traits public and thus export all types
Definition: discretization/porenetwork/subcontrolvolume.hh:66
LocalIndexType localDofIndex() const
The element-local index of the dof this scv is embedded in.
Definition: discretization/porenetwork/subcontrolvolume.hh:96
GridIndexType dofIndex() const
The index of the dof this scv is embedded in.
Definition: discretization/porenetwork/subcontrolvolume.hh:104
const GlobalPosition & corner(LocalIndexType localIdx) const
Return the corner for the given local index.
Definition: discretization/porenetwork/subcontrolvolume.hh:117
GridIndexType elementIndex() const
The global index of the element this scv is embedded in.
Definition: discretization/porenetwork/subcontrolvolume.hh:112
const GlobalPosition & center() const
Definition: discretization/porenetwork/subcontrolvolume.hh:88
Scalar volume() const
The volume of the sub control volume (part of a pore)
Definition: discretization/porenetwork/subcontrolvolume.hh:92
PNMSubControlVolume(GridIndexType dofIndex, LocalIndexType scvIdx, GridIndexType elementIndex, Corners &&corners, const Scalar volume)
Definition: discretization/porenetwork/subcontrolvolume.hh:73
PNMSubControlVolume()=default
The default constructor.
typename T::GlobalPosition GlobalPosition
export the type used for global coordinates
Definition: discretization/porenetwork/subcontrolvolume.hh:64
LocalIndexType indexInElement() const
The element-local index of this scv.
Definition: discretization/porenetwork/subcontrolvolume.hh:100
const GlobalPosition & dofPosition() const
Definition: discretization/porenetwork/subcontrolvolume.hh:108
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: discretization/porenetwork/fvelementgeometry.hh:24
typename GridView::IndexSet::IndexType GridIndex
Definition: indextraits.hh:27
unsigned int LocalIndex
Definition: indextraits.hh:28
Default traits class.
Definition: discretization/porenetwork/subcontrolvolume.hh:29
static const int dim
Definition: discretization/porenetwork/subcontrolvolume.hh:32
typename GridView::Grid Grid
Definition: discretization/porenetwork/subcontrolvolume.hh:30
typename Grid::ctype Scalar
Definition: discretization/porenetwork/subcontrolvolume.hh:37
std::array< GlobalPosition, 2 > CornerStorage
Definition: discretization/porenetwork/subcontrolvolume.hh:39
Dune::AffineGeometry< Scalar, 1, dimWorld > Geometry
Definition: discretization/porenetwork/subcontrolvolume.hh:40
static const int dimWorld
Definition: discretization/porenetwork/subcontrolvolume.hh:33
Dune::FieldVector< Scalar, dimWorld > GlobalPosition
Definition: discretization/porenetwork/subcontrolvolume.hh:38
typename IndexTraits< GridView >::LocalIndex LocalIndexType
Definition: discretization/porenetwork/subcontrolvolume.hh:36
typename IndexTraits< GridView >::GridIndex GridIndexType
Definition: discretization/porenetwork/subcontrolvolume.hh:35
Base class for a sub control volume.