compatibility.hh
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  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
23 #ifndef EWOMS_DUNE_COMPATIBILITY_HH
24 #define EWOMS_DUNE_COMPATIBILITY_HH
25 
26 #if HAVE_DUNE_FEM
27 #include <dune/fem/gridpart/common/gridpart.hh>
28 #include <dune/fem/misc/compatibility.hh>
29 #include <dune/fem/io/streams/streams.hh>
30 
31 namespace Dune
32 {
33 
34  namespace cpgrid
35  {
36  template <int codim>
37  class Entity;
38 
39  template <int codim>
40  class EntityPointer;
41 
42  }
43 
44  // specialization of dune-fem compatiblity functions for CpGrid, since CpGrid does not use the interface classes.
45  namespace Fem
46  {
47 
49  //
50  // make_entity for CpGrid entities
51  //
53  template <int codim>
54  inline Dune::cpgrid::Entity< codim > make_entity ( const Dune::cpgrid::EntityPointer< codim >& entityPointer )
55  {
56  return *entityPointer;
57  }
58 
59  template <int codim>
60  inline Dune::cpgrid::Entity<codim> make_entity ( Dune::cpgrid::Entity<codim> entity )
61  {
62  return std::move( entity );
63  }
64 
66  //
67  // GridEntityAccess for CpGrid entities
68  //
70  template< int codim >
71  struct GridEntityAccess< Dune::cpgrid::Entity< codim > >
72  {
73 
74  typedef Dune::cpgrid::Entity< codim > EntityType;
75  typedef EntityType GridEntityType;
76 
77  static const GridEntityType& gridEntity ( const EntityType& entity )
78  {
79  return entity;
80  }
81  };
82 
84  //
85  // operator << and operator >> for __float128
86  //
88 #if HAVE_QUAD
89  template< class Traits >
90  inline OutStreamInterface< Traits > &
91  operator<< ( OutStreamInterface< Traits >& out,
92  const __float128 value )
93  {
94  double val = double( value );
95  out.writeDouble( val );
96  return out;
97  }
98 
99  template< class Traits >
100  inline InStreamInterface< Traits > &
101  operator>> ( InStreamInterface< Traits >& in,
102  __float128& value )
103  {
104  double val;
105  in.readDouble( val );
106  value = val;
107  return in;
108  }
109 #endif
110 
111  } // namespace Fem
112 
113 } // end namespace Dune
114 
115 #endif // #if HAVE_DUNE_FEM
116 
117 #endif // #ifndef EWOMS_DUNE_COMPATIBILITY_HH