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_ )
54 : data_( other.data_ ), allocator_( std::move( other.allocator_ ) )
56 other.data_ =
nullptr;
61 if( data_ && (--data_->second == 0) )
68 ++other.data_->second;
69 if( data_ && (--data_->second == 0) )
72 allocator_ = other.allocator_;
78 if( data_ && (--data_->second == 0) )
81 allocator_ = std::move( other.allocator_ );
82 other.data_ =
nullptr;
86 operator bool ()
const {
return static_cast< bool >( data_ ); }
89 GeometryType
type ()
const {
return impl().type(); }
106 const Impl &
impl ()
const { assert( data_ );
return data_->first; }
107 Impl &
impl () { assert( data_ );
return data_->first; }
110 template<
class... Args >
111 Data *construct ( std::tuple< Args... > args )
113 Data *data = allocator_.allocate( 1 );
114 return new (data) Data( std::piecewise_construct, args, std::make_tuple( 1u ) );
120 allocator_.deallocate( data_, 1 );
123 Data *data_ =
nullptr;
124 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
This & operator=(const This &other)
Definition: sharedgeometry.hh:65
bool affine() const
Definition: sharedgeometry.hh:88
~SharedGeometry()
Definition: sharedgeometry.hh:59
SharedGeometry(const This &other)
Definition: sharedgeometry.hh:47
GlobalCoordinate center() const
Definition: sharedgeometry.hh:93
GlobalCoordinate global(const LocalCoordinate &local) const
Definition: sharedgeometry.hh:95
SharedGeometry(This &&other)
Definition: sharedgeometry.hh:53
Alloc Allocator
Definition: sharedgeometry.hh:27
GlobalCoordinate corner(int i) const
Definition: sharedgeometry.hh:92
SharedGeometry(Args &&... args)
Definition: sharedgeometry.hh:43
JacobianTransposed jacobianTransposed(const LocalCoordinate &local) const
Definition: sharedgeometry.hh:101
static const int coorddimension
Definition: sharedgeometry.hh:30
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Definition: sharedgeometry.hh:102
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
const Impl & impl() const
Definition: sharedgeometry.hh:106
Impl & impl()
Definition: sharedgeometry.hh:107
Implementation::GlobalCoordinate GlobalCoordinate
Definition: sharedgeometry.hh:35
Allocator allocator() const
Definition: sharedgeometry.hh:104
Implementation::JacobianInverseTransposed JacobianInverseTransposed
Definition: sharedgeometry.hh:38
ctype volume() const
Definition: sharedgeometry.hh:99
GeometryType type() const
Definition: sharedgeometry.hh:89
int corners() const
Definition: sharedgeometry.hh:91
ctype integrationElement(const LocalCoordinate &local) const
Definition: sharedgeometry.hh:98