/usr/include/dune/grid/geometrygrid/geometry.hh is in libdune-grid-dev 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | #ifndef DUNE_GEOGRID_GEOMETRY_HH
#define DUNE_GEOGRID_GEOMETRY_HH
#include <dune/common/nullptr.hh>
#include <dune/common/typetraits.hh>
#include <dune/geometry/referenceelements.hh>
#include <dune/geometry/genericgeometry/mappingprovider.hh>
#include <dune/grid/common/capabilities.hh>
#include <dune/grid/geometrygrid/cornerstorage.hh>
namespace Dune
{
namespace GeoGrid
{
// GeometryTraits
// --------------
template< int cdim, class Grid >
struct GeometryTraits
{
typedef typename remove_const< Grid >::type::Traits Traits;
typedef GenericGeometry::DuneCoordTraits< typename Traits::ctype > CoordTraits;
static const int dimWorld = cdim;
template< class Topology >
struct Mapping
{
typedef GeoGrid::CornerStorage< Topology, const Grid > CornerStorage;
typedef GenericGeometry::CornerMapping< CoordTraits, Topology, dimWorld, CornerStorage > type;
};
struct Caching
{
static const GenericGeometry::EvaluationType evaluateJacobianTransposed = GenericGeometry::ComputeOnDemand;
static const GenericGeometry::EvaluationType evaluateJacobianInverseTransposed = GenericGeometry::ComputeOnDemand;
static const GenericGeometry::EvaluationType evaluateIntegrationElement = GenericGeometry::ComputeOnDemand;
static const GenericGeometry::EvaluationType evaluateNormal = GenericGeometry::ComputeOnDemand;
};
struct UserData
{
UserData () : refCount_( 0 ) {}
void addReference () { ++refCount_; }
bool removeReference () { return (--refCount_ == 0); }
private:
unsigned int refCount_;
};
};
// MappingFamily
// -------------
template< int cdim, class Grid >
class MappingFamily
{
typedef typename remove_const< Grid >::type::Traits Traits;
public:
typedef GeoGrid::GeometryTraits< cdim, Grid > GeometryTraits;
static const int dimension = Traits::dimension;
private:
template< bool >
struct Hybrid
{
typedef GenericGeometry::HybridMapping< dimension, GeometryTraits > ElementMapping;
};
template< bool >
struct NonHybrid
{
static const unsigned int topologyId = Capabilities::hasSingleGeometryType< Grid >::topologyId;
typedef typename GenericGeometry::Topology< topologyId, dimension >::type Topology;
typedef GenericGeometry::NonHybridMapping< Topology, GeometryTraits > ElementMapping;
};
public:
typedef typename SelectType< Capabilities::hasSingleGeometryType< Grid >::v, NonHybrid< true >, Hybrid< false > >::Type::ElementMapping ElementMapping;
template< int codim >
struct Codim
{
typedef GenericGeometry::MappingProvider< ElementMapping, codim > MappingProvider;
typedef typename MappingProvider::Mapping Mapping;
static const unsigned int maxMappingSize = MappingProvider::maxMappingSize;
};
};
// Geometry
// --------
template< int mydim, int cdim, class Grid >
class Geometry
{
typedef Geometry< mydim, cdim, Grid > This;
typedef GeoGrid::MappingFamily< cdim, Grid > MappingFamily;
typedef typename remove_const< Grid >::type::Traits Traits;
template< int, int, class > friend class Geometry;
public:
static const int mydimension = mydim;
static const int coorddimension = cdim;
static const int dimension = MappingFamily::dimension;
static const int codimension = dimension - mydimension;
protected:
typedef typename MappingFamily::template Codim< codimension >::MappingProvider MappingProvider;
typedef typename MappingFamily::template Codim< codimension >::Mapping Mapping;
public:
typedef typename Mapping::FieldType ctype;
typedef FieldVector< ctype, mydimension > LocalCoordinate;
typedef FieldVector< ctype, coorddimension > GlobalCoordinate;
typedef typename Mapping::JacobianTransposed JacobianTransposed;
typedef typename Mapping::JacobianInverseTransposed JacobianInverseTransposed;
// for cenvencience: Jacobian is the name of the type in the geometry interface
typedef JacobianInverseTransposed Jacobian;
Geometry ( const Grid &grid )
: grid_( &grid ),
mapping_( nullptr )
{}
template< class CoordVector >
Geometry ( const Grid &grid, const GeometryType &type, const CoordVector &coords )
: grid_( &grid )
{
char *mappingStorage = grid.template allocateMappingStorage< codimension >( type );
mapping_ = MappingProvider::construct( type.id(), coords, mappingStorage );
mapping_->userData().addReference();
}
template< int fatherdim >
Geometry ( const Geometry< fatherdim, cdim, Grid > &father, int i )
: grid_( father.grid_ )
{
const unsigned int codim = fatherdim - mydim;
char *mappingStorage = grid().template allocateMappingStorage< codimension >( type );
mapping_ = father.mapping_->template trace< codim >( i, mappingStorage );
mapping_->userData().addReference();
}
Geometry ( const This &other )
: grid_( other.grid_ ),
mapping_( other.mapping_ )
{
if( mapping_ )
mapping_->userData().addReference();
}
~Geometry ()
{
if( mapping_ && mapping_->userData().removeReference() )
destroyMapping();
}
const This &operator= ( const This &other )
{
if( other.mapping_ )
other.mapping_->userData().addReference();
if( mapping_ && mapping_->userData().removeReference() )
destroyMapping();
grid_ = other.grid_;
mapping_ = other.mapping_;
return *this;
}
operator bool () const { return bool( mapping_ ); }
bool affine () const { return mapping_->affine(); }
GeometryType type () const { return mapping_->type(); }
int corners () const { return mapping_->numCorners(); }
GlobalCoordinate corner ( const int i ) const { return mapping_->corner( i ); }
GlobalCoordinate center () const { return mapping_->center(); }
GlobalCoordinate global ( const LocalCoordinate &local ) const { return mapping_->global( local ); }
LocalCoordinate local ( const GlobalCoordinate &global ) const { return mapping_->local( global ); }
ctype integrationElement ( const LocalCoordinate &local ) const { return mapping_->integrationElement( local ); }
ctype volume () const { return mapping_->volume(); }
const JacobianTransposed &jacobianTransposed ( const LocalCoordinate &local ) const { return mapping_->jacobianTransposed( local ); }
const JacobianInverseTransposed &jacobianInverseTransposed ( const LocalCoordinate &local ) const { return mapping_->jacobianInverseTransposed( local ); }
const Grid &grid () const { return *grid_; }
private:
void destroyMapping ()
{
const GeometryType gt = type();
mapping_->~Mapping();
grid().template deallocateMappingStorage< codimension >( gt, (char *)mapping_ );
}
const Grid *grid_;
Mapping* mapping_;
};
} // namespace GeoGrid
// FacadeOptions
// -------------
namespace FacadeOptions
{
template< int mydim, int cdim, class Grid >
struct StoreGeometryReference< mydim, cdim, Grid, GeoGrid::Geometry >
{
static const bool v = false;
};
} // namespace FacadeOptions
} // namespace Dune
#endif // #ifndef DUNE_GEOGRID_GEOMETRY_HH
|