opm-grid
DefaultGeometryPolicy.hpp
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 /*
17 Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
18 Copyright 2009, 2010, 2022 Equinor ASA.
19 
20 This file is part of The Open Porous Media project (OPM).
21 
22 OPM is free software: you can redistribute it and/or modify
23 it under the terms of the GNU General Public License as published by
24 the Free Software Foundation, either version 3 of the License, or
25 (at your option) any later version.
26 
27 OPM is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31 
32 You should have received a copy of the GNU General Public License
33 along 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 namespace Dune
42 {
43 
44 class CpGrid;
45 
46 namespace cpgrid
47 {
48 template<int mydim, int dim>
49 class Geometry;
53 {
54  friend class CpGridData;
55  template<int mydim, int dim>
56  friend class Geometry;
57  friend class ::Dune::CpGrid;
58 public:
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 
128 private:
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
DefaultGeometryPolicy()
Definition: DefaultGeometryPolicy.hpp:61
Definition: DefaultGeometryPolicy.hpp:52
The namespace Dune is the main namespace for all Dune code.
Definition: CartesianIndexMapper.hpp:9
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
Definition: Intersection.hpp:329
This class encapsulates geometry for vertices, intersections, and cells.
Definition: CpGridData.hpp:94
Struct that hods all the data needed to represent a Cpgrid.
Definition: CpGridData.hpp:117
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< 2, 3 >, 1 > > geomVector(const std::integral_constant< int, 1 > &)
Get face geometry.
Definition: DefaultGeometryPolicy.hpp:108
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< const EntityVariable< cpgrid::Geometry< 2, 3 >, 1 > > geomVector(const std::integral_constant< int, 1 > &) const
Get face geometry.
Definition: DefaultGeometryPolicy.hpp:103
A class design to hold a variable with a value for each entity of the given codimension, where the variable is not changing in sign with orientation.
Definition: EntityRep.hpp:270
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
std::shared_ptr< EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > > geomVector(const std::integral_constant< int, codim > &)
Get point geometry.
Definition: DefaultGeometryPolicy.hpp:122