DefaultGeometryPolicy.hpp
Go to the documentation of this file.
1//===========================================================================
2//
3// File: DefaultGeometryPolicy.hpp
4//
5// Created: Tue Jun 2 16:23:01 2009
6//
7// Author(s): Atgeirr F Rasmussen <atgeirr@sintef.no>
8// Bård Skaflestad <bard.skaflestad@sintef.no>
9//
10// $Date$
11//
12// $Revision$
13//
14//===========================================================================
15
16/*
17Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
18Copyright 2009, 2010, 2022 Equinor ASA.
19
20This file is part of The Open Porous Media project (OPM).
21
22OPM is free software: you can redistribute it and/or modify
23it under the terms of the GNU General Public License as published by
24the Free Software Foundation, either version 3 of the License, or
25(at your option) any later version.
26
27OPM is distributed in the hope that it will be useful,
28but WITHOUT ANY WARRANTY; without even the implied warranty of
29MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30GNU General Public License for more details.
31
32You should have received a copy of the GNU General Public License
33along with OPM. If not, see <http://www.gnu.org/licenses/>.
34*/
35
36#ifndef OPM_DEFAULTGEOMETRYPOLICY_HEADER
37#define OPM_DEFAULTGEOMETRYPOLICY_HEADER
38
39#include "EntityRep.hpp"
40
41#include <memory>
42#include <type_traits>
43
44namespace Dune
45{
46
47class CpGrid;
48
49namespace cpgrid
50{
51template<int mydim, int dim>
52class Geometry;
56{
57 friend class CpGridData;
58 template<int mydim, int dim>
59 friend class Geometry;
60 friend class ::Dune::CpGrid;
61public:
62 // The constructors create the geometry containers, so they are defined in
63 // DefaultGeometryPolicy.cpp, where the geometries are complete.
64
68
73 const EntityVariable<cpgrid::Geometry<2, 3>, 1>& face_geom,
74 const EntityVariable<cpgrid::Geometry<0, 3>, 3>& point_geom);
75
81 template <int codim>
82 const EntityVariable<cpgrid::Geometry<3 - codim, 3>, codim>& geomVector() const
83 {
84 static_assert(codim != 2, "");
85 return geomVector(std::integral_constant<int,codim>());
86 }
87
89 const EntityVariable<cpgrid::Geometry<3, 3>, 0>& geomVector(const std::integral_constant<int, 0>&) const
90 {
91 return *cell_geom_ptr_;
92 }
94 EntityVariable<cpgrid::Geometry<3, 3>, 0>& geomVector(const std::integral_constant<int, 0>&)
95 {
96 return *cell_geom_ptr_;
97 }
99 const EntityVariable<cpgrid::Geometry<2, 3>, 1>& geomVector(const std::integral_constant<int, 1>&) const
100 {
101 return *face_geom_ptr_;
102 }
104 EntityVariable<cpgrid::Geometry<2, 3>, 1>& geomVector(const std::integral_constant<int, 1>&)
105 {
106 return *face_geom_ptr_;
107 }
108
110 template<int codim>
111 const EntityVariable<cpgrid::Geometry<0, 3>, 3>& geomVector(const std::integral_constant<int, codim>&) const
112 {
113 static_assert(codim==3, "Codim has to be 3");
114 return *point_geom_ptr_;
115 }
117 template<int codim>
118 EntityVariable<cpgrid::Geometry<0, 3>, 3>& geomVector(const std::integral_constant<int, codim>&)
119 {
120 static_assert(codim==3, "Codim has to be 3");
121 return *point_geom_ptr_;
122 }
123
125 std::shared_ptr<const EntityVariable<cpgrid::Geometry<0, 3>, 3>> pointGeometryPtr() const
126 {
127 return point_geom_ptr_;
128 }
129
130 std::shared_ptr<EntityVariable<cpgrid::Geometry<0, 3>, 3>> pointGeometryPtr()
131 {
132 return point_geom_ptr_;
133 }
134
135private:
136 std::shared_ptr<EntityVariable<cpgrid::Geometry<3, 3>, 0>> cell_geom_ptr_;
137 std::shared_ptr<EntityVariable<cpgrid::Geometry<2, 3>, 1>> face_geom_ptr_;
138 std::shared_ptr<EntityVariable<cpgrid::Geometry<0, 3>, 3>> point_geom_ptr_;
139};
140
141
142
143} // namespace cpgrid
144} // namespace Dune
145
146
147#endif // OPM_DEFAULTGEOMETRYPOLICY_HEADER
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:144
Definition: DefaultGeometryPolicy.hpp:56
const EntityVariable< cpgrid::Geometry< 3 - codim, 3 >, codim > & geomVector() const
Definition: DefaultGeometryPolicy.hpp:82
const EntityVariable< cpgrid::Geometry< 3, 3 >, 0 > & geomVector(const std::integral_constant< int, 0 > &) const
Get cell geometry.
Definition: DefaultGeometryPolicy.hpp:89
const EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > & geomVector(const std::integral_constant< int, codim > &) const
Get point geometry.
Definition: DefaultGeometryPolicy.hpp:111
DefaultGeometryPolicy(const EntityVariable< cpgrid::Geometry< 3, 3 >, 0 > &cell_geom, const EntityVariable< cpgrid::Geometry< 2, 3 >, 1 > &face_geom, const EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > &point_geom)
const EntityVariable< cpgrid::Geometry< 2, 3 >, 1 > & geomVector(const std::integral_constant< int, 1 > &) const
Get face geometry.
Definition: DefaultGeometryPolicy.hpp:99
std::shared_ptr< EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > > pointGeometryPtr()
Definition: DefaultGeometryPolicy.hpp:130
EntityVariable< cpgrid::Geometry< 3, 3 >, 0 > & geomVector(const std::integral_constant< int, 0 > &)
Get cell geometry.
Definition: DefaultGeometryPolicy.hpp:94
std::shared_ptr< const EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > > pointGeometryPtr() const
Keep the corner geometries alive when constructing cell geometries.
Definition: DefaultGeometryPolicy.hpp:125
EntityVariable< cpgrid::Geometry< 2, 3 >, 1 > & geomVector(const std::integral_constant< int, 1 > &)
Get face geometry.
Definition: DefaultGeometryPolicy.hpp:104
EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > & geomVector(const std::integral_constant< int, codim > &)
Get point geometry.
Definition: DefaultGeometryPolicy.hpp:118
A class design to hold a variable with a value for each entity of the given codimension,...
Definition: EntityRep.hpp:281
Definition: Geometry.hpp:76
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10