1#ifndef DUNE_FEM_GRIDPART_COMMON_SHAREDGEOMETRY_HH
2#define DUNE_FEM_GRIDPART_COMMON_SHAREDGEOMETRY_HH
8#include <dune/common/fmatrix.hh>
10#include <dune/grid/common/geometry.hh>
18 template<
class Impl,
class Alloc = std::allocator< Impl > >
23 typedef std::pair< Impl, std::size_t > Data;
32 typedef typename Implementation::ctype
ctype;
42 template<
class... Args, std::enable_if_t< std::is_constructible< Impl, Args &&... >::value,
int > = 0 >
44 : data_( construct(
std::forward_as_tuple< Args... >( args... ) ) )
48 : data_( other.data_ ), allocator_( other.allocator_ )
55 : data_( other.data_ ), allocator_(
std::move( other.allocator_ ) )
57 other.data_ =
nullptr;
62 if( data_ && (--data_->second == 0) )
69 ++other.data_->second;
70 if( data_ && (--data_->second == 0) )
73 allocator_ = other.allocator_;
79 if( data_ && (--data_->second == 0) )
82 allocator_ = std::move( other.allocator_ );
83 other.data_ =
nullptr;
87 operator bool ()
const {
return static_cast< bool >( data_ ); }
90 GeometryType
type ()
const {
return impl().type(); }
107 const Impl &
impl ()
const { assert( data_ );
return data_->first; }
108 Impl &
impl () { assert( data_ );
return data_->first; }
111 template<
class... Args >
112 Data *construct ( std::tuple< Args... > args )
114 Data *data = allocator_.allocate( 1 );
115 return new (data) Data( std::piecewise_construct, args, std::make_tuple( 1u ) );
121 allocator_.deallocate( data_, 1 );
124 Data *data_ =
nullptr;
125 typename std::allocator_traits< Allocator >::template rebind_alloc< Data > allocator_;
Definition: bindguard.hh:11
Definition: sharedgeometry.hh:20
Implementation::ctype ctype
Definition: sharedgeometry.hh:32
bool affine() const
Definition: sharedgeometry.hh:89
~SharedGeometry()
Definition: sharedgeometry.hh:60
SharedGeometry(const This &other)
Definition: sharedgeometry.hh:47
const Impl & impl() const
Definition: sharedgeometry.hh:107
GlobalCoordinate center() const
Definition: sharedgeometry.hh:94
GlobalCoordinate global(const LocalCoordinate &local) const
Definition: sharedgeometry.hh:96
SharedGeometry(This &&other)
Definition: sharedgeometry.hh:54
Alloc Allocator
Definition: sharedgeometry.hh:27
GlobalCoordinate corner(int i) const
Definition: sharedgeometry.hh:93
SharedGeometry(Args &&... args)
Definition: sharedgeometry.hh:43
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Definition: sharedgeometry.hh:102
static const int coorddimension
Definition: sharedgeometry.hh:30
Impl & impl()
Definition: sharedgeometry.hh:108
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Definition: sharedgeometry.hh:103
Implementation::JacobianTransposed JacobianTransposed
Definition: sharedgeometry.hh:37
Implementation::LocalCoordinate LocalCoordinate
Definition: sharedgeometry.hh:34
static const int mydimension
Definition: sharedgeometry.hh:29
Impl Implementation
Definition: sharedgeometry.hh:26
Implementation::GlobalCoordinate GlobalCoordinate
Definition: sharedgeometry.hh:35
Allocator allocator() const
Definition: sharedgeometry.hh:105
Implementation::JacobianInverseTransposed JacobianInverseTransposed
Definition: sharedgeometry.hh:38
ctype volume() const
Definition: sharedgeometry.hh:100
GeometryType type() const
Definition: sharedgeometry.hh:90
This & operator=(const This &other)
Definition: sharedgeometry.hh:66
int corners() const
Definition: sharedgeometry.hh:92
ctype integrationElement(const LocalCoordinate &local) const
Definition: sharedgeometry.hh:99