1#ifndef DUNE_FEM_GRIDPART_COMMON_SHAREDGEOMETRY_HH
2#define DUNE_FEM_GRIDPART_COMMON_SHAREDGEOMETRY_HH
18 template<
class Impl,
class Alloc = std::allocator< Impl > >
21 typedef SharedGeometry< Impl, Alloc > This;
23 typedef std::pair< Impl, std::size_t > Data;
26 typedef Impl Implementation;
27 typedef Alloc Allocator;
29 static const int mydimension = Implementation::mydimension;
30 static const int coorddimension = Implementation::coorddimension;
32 typedef typename Implementation::ctype ctype;
34 typedef typename Implementation::LocalCoordinate LocalCoordinate;
35 typedef typename Implementation::GlobalCoordinate GlobalCoordinate;
37 typedef typename Implementation::JacobianTransposed JacobianTransposed;
38 typedef typename Implementation::JacobianInverseTransposed JacobianInverseTransposed;
40 typedef typename Implementation::Jacobian Jacobian;
41 typedef typename Implementation::JacobianInverse JacobianInverse;
43 SharedGeometry () =
default;
45 template<
class... Args, std::enable_if_t< std::is_constructible< Impl, Args &&... >::value,
int > = 0 >
46 SharedGeometry ( Args &&... args )
47 : data_( construct(
std::forward_as_tuple< Args... >( args... ) ) )
50 SharedGeometry (
const This &other )
51 : data_( other.data_ ), allocator_( other.allocator_ )
57 SharedGeometry ( This &&other )
58 : data_( other.data_ ), allocator_(
std::move( other.allocator_ ) )
60 other.data_ =
nullptr;
65 if( data_ && (--data_->second == 0) )
69 This &operator= (
const This &other )
72 ++other.data_->second;
73 if( data_ && (--data_->second == 0) )
76 allocator_ = other.allocator_;
80 This &operator= ( This &&other )
82 if( data_ && (--data_->second == 0) )
85 allocator_ = std::move( other.allocator_ );
86 other.data_ =
nullptr;
90 operator bool ()
const {
return static_cast< bool >( data_ ); }
92 bool affine ()
const {
return impl().affine(); }
95 int corners ()
const {
return impl().corners(); }
96 GlobalCoordinate corner (
int i )
const {
return impl().corner( i ); }
97 GlobalCoordinate center ()
const {
return impl().center(); }
99 GlobalCoordinate global (
const LocalCoordinate &local )
const {
return impl().global( local ); }
100 LocalCoordinate local (
const GlobalCoordinate &global )
const {
return impl().local( global ); }
102 ctype integrationElement (
const LocalCoordinate &local )
const {
return impl().integrationElement( local ); }
103 ctype volume ()
const {
return impl().volume(); }
105 JacobianTransposed jacobianTransposed (
const LocalCoordinate &local )
const {
return impl().jacobianTransposed( local ); }
106 JacobianInverseTransposed jacobianInverseTransposed (
const LocalCoordinate &local )
const {
return impl().jacobianInverseTransposed( local ); }
108 Jacobian jacobian (
const LocalCoordinate &local )
const {
return impl().jacobian( local ); }
109 JacobianInverse jacobianInverse (
const LocalCoordinate &local )
const {
return impl().jacobianInverse( local ); }
111 Allocator allocator ()
const {
return allocator_; }
113 const Impl &impl ()
const { assert( data_ );
return data_->first; }
114 Impl &impl () { assert( data_ );
return data_->first; }
117 template<
class... Args >
118 Data *construct ( std::tuple< Args... > args )
120 Data *data = allocator_.allocate( 1 );
121 return new (data) Data( std::piecewise_construct, args, std::make_tuple( 1u ) );
127 allocator_.deallocate( data_, 1 );
130 Data *data_ =
nullptr;
131 typename std::allocator_traits< Allocator >::template rebind_alloc< Data > allocator_;
Wrapper and interface classes for element geometries.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Dune namespace.
Definition: alignedallocator.hh:13