5#ifndef DUNE_GEOGRID_GEOMETRY_HH
6#define DUNE_GEOGRID_GEOMETRY_HH
10#include <dune/common/typetraits.hh>
12#include <dune/geometry/multilineargeometry.hh>
13#include <dune/geometry/referenceelements.hh>
14#include <dune/geometry/type.hh>
28 template<
class hasSingleGeometryType,
int dim,
int mydim >
32 static const unsigned int id = hasSingleGeometryType::topologyId;
33 static const unsigned int idMask = (1u << mydim) - 1u;
36 static const bool v = hasSingleGeometryType::v && ((mydim == dim) || ((
id | 1u) == 1u) || ((
id | 1u) == idMask));
37 static const unsigned int topologyId = (
v ?
id & idMask : ~0u);
40 template<
class hasSingleGeometryType,
int dim >
43 static const bool v =
true;
44 static const unsigned int topologyId = GeometryTypes::cube(1).id();
47 template<
class hasSingleGeometryType,
int dim >
50 static const bool v =
true;
51 static const unsigned int topologyId = GeometryTypes::cube(1).id();
59 template<
class Gr
id >
62 typedef typename std::remove_const< Grid >::type::Traits
Traits;
64 typedef typename Traits::ctype
ctype;
68 static ctype tolerance () {
return 16 * std::numeric_limits< ctype >::epsilon(); }
70 template<
int mydim,
int cdim >
87 template<
int mydim,
int cdim,
class Gr
id >
92 typedef typename std::remove_const< Grid >::type::Traits Traits;
94 template<
int,
int,
class >
friend class Geometry;
97 typedef typename Traits::ctype
ctype;
105 typedef CachedMultiLinearGeometry< ctype, mydimension, coorddimension, GeometryTraits< Grid > >
BasicMapping;
110 template<
class CoordVector >
120 unsigned int refCount_;
133 Geometry () : grid_( nullptr ), mapping_( nullptr ) {}
137 template<
class CoordVector >
142 void *mappingStorage =
grid.allocateStorage(
sizeof(
Mapping ) );
143 mapping_ =
new( mappingStorage )
Mapping(
type, coords );
148 : grid_( other.grid_ ),
149 mapping_( other.mapping_ )
156 : grid_( other.grid_ ),
157 mapping_( other.mapping_ )
159 other.grid_ =
nullptr;
160 other.mapping_ =
nullptr;
176 mapping_ = other.mapping_;
183 swap( grid_, other.grid_ );
184 swap( mapping_, other.mapping_ );
188 explicit operator bool ()
const {
return bool( mapping_ ); }
190 bool affine ()
const {
return mapping_->affine(); }
193 int corners ()
const {
return mapping_->corners(); }
209 const Grid &
grid ()
const { assert( grid_ );
return *grid_; }
212 void destroyMapping ()
214 mapping_->~Mapping();
215 grid().deallocateStorage( mapping_,
sizeof( Mapping ) );
void swap(Dune::PersistentContainer< G, T > &a, Dune::PersistentContainer< G, T > &b)
Definition: utility/persistentcontainer.hh:83
Include standard header files.
Definition: agrid.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Grid abstract base class.
Definition: common/grid.hh:375
Definition: cornerstorage.hh:22
Definition: cornerstorage.hh:174
Definition: geometrygrid/geometry.hh:30
static const unsigned int topologyId
Definition: geometrygrid/geometry.hh:37
static const bool v
Definition: geometrygrid/geometry.hh:36
Definition: geometrygrid/geometry.hh:61
Traits::ctype ctype
Definition: geometrygrid/geometry.hh:64
Impl::FieldMatrixHelper< ctype > MatrixHelper
Definition: geometrygrid/geometry.hh:66
static ctype tolerance()
Definition: geometrygrid/geometry.hh:68
std::remove_const< Grid >::type::Traits Traits
Definition: geometrygrid/geometry.hh:62
Definition: geometrygrid/geometry.hh:72
GeoGrid::CornerStorage< mydim, cdim, Grid > Type
Definition: geometrygrid/geometry.hh:73
Definition: geometrygrid/geometry.hh:79
Definition: geometrygrid/geometry.hh:89
GlobalCoordinate global(const LocalCoordinate &local) const
Definition: geometrygrid/geometry.hh:197
Geometry(const Grid &grid)
Definition: geometrygrid/geometry.hh:135
int corners() const
Definition: geometrygrid/geometry.hh:193
static const int codimension
Definition: geometrygrid/geometry.hh:102
Traits::ctype ctype
Definition: geometrygrid/geometry.hh:97
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Definition: geometrygrid/geometry.hh:204
Geometry(const Grid &grid, const GeometryType &type, const CoordVector &coords)
Definition: geometrygrid/geometry.hh:138
static const int dimension
Definition: geometrygrid/geometry.hh:101
Mapping::Jacobian Jacobian
Definition: geometrygrid/geometry.hh:129
Geometry(const This &other)
Definition: geometrygrid/geometry.hh:147
static const int mydimension
Definition: geometrygrid/geometry.hh:99
CachedMultiLinearGeometry< ctype, mydimension, coorddimension, GeometryTraits< Grid > > BasicMapping
Definition: geometrygrid/geometry.hh:105
bool affine() const
Definition: geometrygrid/geometry.hh:190
Geometry(This &&other)
Definition: geometrygrid/geometry.hh:155
Mapping::JacobianInverse JacobianInverse
Definition: geometrygrid/geometry.hh:130
GlobalCoordinate corner(const int i) const
Definition: geometrygrid/geometry.hh:194
Geometry()
Definition: geometrygrid/geometry.hh:133
JacobianInverse jacobianInverse(const LocalCoordinate &local) const
Definition: geometrygrid/geometry.hh:207
static const int coorddimension
Definition: geometrygrid/geometry.hh:100
Jacobian jacobian(const LocalCoordinate &local) const
Definition: geometrygrid/geometry.hh:206
Mapping::JacobianTransposed JacobianTransposed
Definition: geometrygrid/geometry.hh:127
GeometryType type() const
Definition: geometrygrid/geometry.hh:191
ctype volume() const
Definition: geometrygrid/geometry.hh:201
GlobalCoordinate center() const
Definition: geometrygrid/geometry.hh:195
const Grid & grid() const
Definition: geometrygrid/geometry.hh:209
~Geometry()
Definition: geometrygrid/geometry.hh:163
ctype integrationElement(const LocalCoordinate &local) const
Definition: geometrygrid/geometry.hh:200
const This & operator=(const This &other)
Definition: geometrygrid/geometry.hh:169
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Definition: geometrygrid/geometry.hh:203
Mapping::GlobalCoordinate GlobalCoordinate
Definition: geometrygrid/geometry.hh:125
Mapping::JacobianInverseTransposed JacobianInverseTransposed
Definition: geometrygrid/geometry.hh:128
Mapping::LocalCoordinate LocalCoordinate
Definition: geometrygrid/geometry.hh:124
Definition: geometrygrid/geometry.hh:109
Mapping(const GeometryType &type, const CoordVector &coords)
Definition: geometrygrid/geometry.hh:111
bool removeReference()
Definition: geometrygrid/geometry.hh:117
void addReference()
Definition: geometrygrid/geometry.hh:116
A set of traits classes to store static information about grid implementation.