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 Statoil 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 <boost/mpl/if.hpp>
40 #include "Geometry.hpp"
41 #include "EntityRep.hpp"
42 
43 namespace Dune
44 {
45  namespace cpgrid
46  {
47 
48  struct GetCellGeom;
49  struct GetFaceGeom;
50  struct GetPointGeom;
51 
55  {
56  public:
60  {
61  }
62 
67  const EntityVariable<cpgrid::Geometry<2, 3>, 1>& face_geom,
68  const EntityVariable<cpgrid::Geometry<0, 3>, 3>& point_geom)
69  : cell_geom_(cell_geom), face_geom_(face_geom), point_geom_(point_geom)
70  {
71  }
72 
78  template <int codim>
79  const EntityVariable<cpgrid::Geometry<3 - codim, 3>, codim>& geomVector() const
80  {
81  static_assert(codim != 2, "");
82  typedef typename boost::mpl::if_c<codim == 0, GetCellGeom,
83  typename boost::mpl::if_c<codim == 1, GetFaceGeom, GetPointGeom>::type >::type selector;
84  return selector::value(*this);
85  }
86  private:
87  friend struct GetCellGeom;
88  friend struct GetFaceGeom;
89  friend struct GetPointGeom;
93  };
94 
97  struct GetCellGeom
98  {
99 
105  static const EntityVariable<cpgrid::Geometry<3, 3>, 0>&
107  {
108  return geom.cell_geom_;
109  }
110  };
111 
114  struct GetFaceGeom
115  {
121  static const EntityVariable<cpgrid::Geometry<2, 3>, 1>&
123  {
124  return geom.face_geom_;
125  }
126  };
127 
131  {
137  static const EntityVariable<cpgrid::Geometry<0, 3>, 3>&
139  {
140  return geom.point_geom_;
141  }
142  };
143 
144 
145 
146  } // namespace cpgrid
147 } // namespace Dune
148 
149 
150 #endif // OPM_DEFAULTGEOMETRYPOLICY_HEADER
DefaultGeometryPolicy()
Definition: DefaultGeometryPolicy.hpp:59
Definition: DefaultGeometryPolicy.hpp:54
static const EntityVariable< cpgrid::Geometry< 0, 3 >, 3 > & value(const DefaultGeometryPolicy &geom)
Definition: DefaultGeometryPolicy.hpp:138
Holds the implementation of the CpGrid as a pimple.
Definition: OpmParserIncludes.hpp:42
This class encapsulates geometry for both vertices, intersections and cells.
Definition: CpGridData.hpp:92
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:66
Definition: DefaultGeometryPolicy.hpp:114
static const EntityVariable< cpgrid::Geometry< 2, 3 >, 1 > & value(const DefaultGeometryPolicy &geom)
Definition: DefaultGeometryPolicy.hpp:122
Definition: DefaultGeometryPolicy.hpp:97
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:248
const EntityVariable< cpgrid::Geometry< 3 - codim, 3 >, codim > & geomVector() const
Definition: DefaultGeometryPolicy.hpp:79
static const EntityVariable< cpgrid::Geometry< 3, 3 >, 0 > & value(const DefaultGeometryPolicy &geom)
Definition: DefaultGeometryPolicy.hpp:106
Definition: DefaultGeometryPolicy.hpp:130