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
41namespace Dune
42{
43
44class CpGrid;
45
46namespace cpgrid
47{
48template<int mydim, int dim>
49class Geometry;
53{
54 friend class CpGridData;
55 template<int mydim, int dim>
56 friend class Geometry;
57 friend class ::Dune::CpGrid;
58public:
62 : cell_geom_ptr_(std::make_shared<EntityVariable<cpgrid::Geometry<3, 3>, 0>>()),
63 face_geom_ptr_(std::make_shared<EntityVariable<cpgrid::Geometry<2, 3>, 1>>()),
64 point_geom_ptr_(std::make_shared<EntityVariable<cpgrid::Geometry<0, 3>, 3>>())
65 {
66 }
67
72 const EntityVariable<cpgrid::Geometry<2, 3>, 1>& face_geom,
73 const EntityVariable<cpgrid::Geometry<0, 3>, 3>& point_geom)
74 : cell_geom_ptr_(std::make_shared<EntityVariable<cpgrid::Geometry<3, 3>, 0>>(cell_geom)),
75 face_geom_ptr_(std::make_shared<EntityVariable<cpgrid::Geometry<2, 3>, 1>>(face_geom)),
76 point_geom_ptr_(std::make_shared<EntityVariable<cpgrid::Geometry<0, 3>, 3>>(point_geom))
77 {
78 }
79
85 template <int codim>
86 const EntityVariable<cpgrid::Geometry<3 - codim, 3>, codim>& geomVector() const
87 {
88 static_assert(codim != 2, "");
89 return *geomVector(std::integral_constant<int,codim>());
90 }
91
93 std::shared_ptr<const EntityVariable<cpgrid::Geometry<3, 3>, 0>> geomVector(const std::integral_constant<int, 0>&) const
94 {
95 return cell_geom_ptr_;
96 }
98 std::shared_ptr<EntityVariable<cpgrid::Geometry<3, 3>, 0>> geomVector(const std::integral_constant<int, 0>&)
99 {
100 return cell_geom_ptr_;
101 }
103 std::shared_ptr<const EntityVariable<cpgrid::Geometry<2, 3>, 1>> geomVector(const std::integral_constant<int, 1>&) const
104 {
105 return face_geom_ptr_;
106 }
108 std::shared_ptr<EntityVariable<cpgrid::Geometry<2, 3>, 1>> geomVector(const std::integral_constant<int, 1>&)
109 {
110 return face_geom_ptr_;
111 }
112
114 template<int codim>
115 std::shared_ptr<const EntityVariable<cpgrid::Geometry<0, 3>, 3>> geomVector(const std::integral_constant<int, codim>&) const
116 {
117 static_assert(codim==3, "Codim has to be 3");
118 return point_geom_ptr_;
119 }
121 template<int codim>
122 std::shared_ptr<EntityVariable<cpgrid::Geometry<0, 3>, 3>> geomVector(const std::integral_constant<int, codim>&)
123 {
124 static_assert(codim==3, "Codim has to be 3");
125 return point_geom_ptr_;
126 }
127
128private:
129 std::shared_ptr<EntityVariable<cpgrid::Geometry<3, 3>, 0>> cell_geom_ptr_;
130 std::shared_ptr<EntityVariable<cpgrid::Geometry<2, 3>, 1>> face_geom_ptr_;
131 std::shared_ptr<EntityVariable<cpgrid::Geometry<0, 3>, 3>> point_geom_ptr_;
132};
133
134
135
136} // namespace cpgrid
137} // namespace Dune
138
139
140#endif // OPM_DEFAULTGEOMETRYPOLICY_HEADER
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:131
Definition: DefaultGeometryPolicy.hpp:53
std::shared_ptr< const EntityVariable< cpgrid::Geometry< 3, 3 >, 0 > > geomVector(const std::integral_constant< int, 0 > &) const
Get cell geometry.
Definition: DefaultGeometryPolicy.hpp:93
const EntityVariable< cpgrid::Geometry< 3 - codim, 3 >, codim > & geomVector() const
Definition: DefaultGeometryPolicy.hpp:86
DefaultGeometryPolicy()
Definition: DefaultGeometryPolicy.hpp:61
std::shared_ptr< EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > > geomVector(const std::integral_constant< int, codim > &)
Get point geometry.
Definition: DefaultGeometryPolicy.hpp:122
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)
Definition: DefaultGeometryPolicy.hpp:71
std::shared_ptr< EntityVariable< cpgrid::Geometry< 3, 3 >, 0 > > geomVector(const std::integral_constant< int, 0 > &)
Get cell geometry.
Definition: DefaultGeometryPolicy.hpp:98
std::shared_ptr< EntityVariable< cpgrid::Geometry< 2, 3 >, 1 > > geomVector(const std::integral_constant< int, 1 > &)
Get face geometry.
Definition: DefaultGeometryPolicy.hpp:108
std::shared_ptr< const EntityVariable< cpgrid::Geometry< 2, 3 >, 1 > > geomVector(const std::integral_constant< int, 1 > &) const
Get face geometry.
Definition: DefaultGeometryPolicy.hpp:103
std::shared_ptr< const EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > > geomVector(const std::integral_constant< int, codim > &) const
Get point geometry.
Definition: DefaultGeometryPolicy.hpp:115
A class design to hold a variable with a value for each entity of the given codimension,...
Definition: EntityRep.hpp:267
Definition: Geometry.hpp:75
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10
STL namespace.