/usr/include/dune/grid/alugrid/3d/mappings.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 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | #ifndef DUNE_ALU3DGRIDMAPPINGS_HH
#define DUNE_ALU3DGRIDMAPPINGS_HH
// System includes
#include <limits>
#include <cmath>
// Dune includes
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/exceptions.hh>
// Local includes
#include "alu3dinclude.hh"
namespace Dune {
static const alu3d_ctype ALUnumericEpsilon = 10.0 * std::numeric_limits< alu3d_ctype >::epsilon();
template<int mydim, int coorddim, class GridImp>
class ALU3dGridGeometry;
template< ALU3dGridElementType, class >
class ALU3dGrid;
//! A trilinear mapping from the Dune reference hexahedron into the physical
//! space (same as in mapp_cube_3d.h, but for a different reference hexahedron)
class TrilinearMapping
{
public:
typedef alu3d_ctype double_t[3];
typedef FieldVector<alu3d_ctype, 3> coord_t;
typedef FieldMatrix<alu3d_ctype, 3, 3> mat_t;
private:
static const double _epsilon ;
// the internal mapping
alu3d_ctype a [8][3] ;
mat_t Df;
mat_t Dfi;
mat_t invTransposed_;
alu3d_ctype DetDf ;
bool calcedDet_;
bool calcedLinear_;
bool calcedInv_;
bool affine_;
void linear (const alu3d_ctype, const alu3d_ctype, const alu3d_ctype) ;
void linear (const coord_t&) ;
void inverse (const coord_t&) ;
public :
TrilinearMapping (const coord_t&, const coord_t&,
const coord_t&, const coord_t&,
const coord_t&, const coord_t&,
const coord_t&, const coord_t&);
// only to call from geometry class
TrilinearMapping () {}
TrilinearMapping (const TrilinearMapping &) ;
~TrilinearMapping () {}
alu3d_ctype det (const coord_t&) ;
const mat_t& jacobianInverseTransposed(const coord_t&);
const mat_t& jacobianTransposed(const coord_t&);
void map2world (const coord_t&, coord_t&) const ;
void map2world (const alu3d_ctype , const alu3d_ctype , const alu3d_ctype ,
coord_t&) const ;
void world2map (const coord_t&, coord_t&) ;
template <class vector_t>
void buildMapping(const vector_t&, const vector_t&,
const vector_t&, const vector_t&,
const vector_t&, const vector_t&,
const vector_t&, const vector_t&);
// returns true if mapping is affine
inline bool affine () const { return affine_; }
};
//! A bilinear surface mapping
// NOTE: this class is different to the BilinearSurfaceMapping in
// ALUGrid, for example the reference elements differ
// here we have [0,1]^2 and in ALUGrid its [-1,1]^2
// also the point numbering is different
class SurfaceNormalCalculator
{
public:
// our coordinate types
typedef FieldVector<alu3d_ctype, 3> coord3_t;
typedef FieldVector<alu3d_ctype, 2> coord2_t;
// type of coordinate vectors from elements
typedef alu3d_ctype double3_t[3];
protected:
alu3d_ctype _n [3][3] ;
static const double _epsilon ;
bool _affine;
public :
//! Constructor creating empty mapping with double , i.e. zero
SurfaceNormalCalculator();
SurfaceNormalCalculator (const SurfaceNormalCalculator &) ;
~SurfaceNormalCalculator () {}
// returns true if mapping is affine
inline bool affine () const { return _affine ; }
// calcuates normal
void normal(const coord2_t&, coord3_t&) const ;
void normal(const alu3d_ctype, const alu3d_ctype, coord3_t&)const;
void negativeNormal(const coord2_t&, coord3_t&) const ;
void negativeNormal(const alu3d_ctype, const alu3d_ctype, coord3_t&)const;
public:
// builds _b and _n, called from the constructors
// public because also used in faceutility
template <class vector_t>
void buildMapping (const vector_t & , const vector_t & ,
const vector_t & , const vector_t & );
protected:
// builds _b and _n, called from the constructors
// public because also used in faceutility
template <class vector_t>
void buildMapping (const vector_t & , const vector_t & ,
const vector_t & , const vector_t & ,
alu3d_ctype (&_b)[4][3] );
} ;
//! A bilinear surface mapping
// NOTE: this class is different to the BilinearSurfaceMapping in
// ALUGrid, for example the reference elements differ
// here we have [0,1]^2 and in ALUGrid its [-1,1]^2
// also the point numbering is different
class BilinearSurfaceMapping : public SurfaceNormalCalculator
{
protected:
typedef SurfaceNormalCalculator BaseType;
using BaseType :: _n;
static const double _epsilon;
// our coordinate types
typedef FieldVector<alu3d_ctype, 3> coord3_t;
typedef FieldVector<alu3d_ctype, 2> coord2_t;
// type of coordinate vectors from elements
typedef alu3d_ctype double3_t[3];
// type for helper matrices
typedef FieldMatrix<alu3d_ctype,3,3> mat3_t;
// type for inverse matrices
typedef FieldMatrix<alu3d_ctype,2,3> matrix_t;
// type for inverse matrices
typedef FieldMatrix<alu3d_ctype,3,2> inv_t;
alu3d_ctype _b [4][3] ;
mutable mat3_t Df,Dfi;
mutable inv_t invTransposed_;
mutable matrix_t matrix_;
mutable alu3d_ctype DetDf;
mutable coord3_t normal_;
mutable coord3_t tmp_;
mutable bool _calcedInv;
mutable bool _calcedTransposed;
mutable bool _calcedMatrix;
public :
//! Constructor creating empty mapping with double , i.e. zero
BilinearSurfaceMapping ();
//! Constructor getting FieldVectors
BilinearSurfaceMapping (const coord3_t&, const coord3_t&,
const coord3_t&, const coord3_t&) ;
//! Constructor for double[3]
BilinearSurfaceMapping (const double3_t &, const double3_t &,
const double3_t &, const double3_t &) ;
BilinearSurfaceMapping (const BilinearSurfaceMapping &) ;
~BilinearSurfaceMapping () {}
void inverse (const coord3_t&) const;
const inv_t& jacobianInverseTransposed(const coord2_t&) const ;
const matrix_t& jacobianTransposed(const coord2_t&) const ;
// calculates determinant of face mapping using the normal
alu3d_ctype det(const coord2_t&) const;
// maps from local coordinates to global coordinates
void world2map(const coord3_t &, coord2_t & ) const;
// maps form global coordinates to local (within reference element)
// coordinates
void map2world(const coord2_t&, coord3_t&) const ;
void map2world(const alu3d_ctype ,const alu3d_ctype , coord3_t&) const ;
private:
void map2worldnormal(const alu3d_ctype, const alu3d_ctype, const alu3d_ctype , coord3_t&)const;
void map2worldlinear(const alu3d_ctype, const alu3d_ctype, const alu3d_ctype ) const;
public:
// builds _b and _n, called from the constructors
// public because also used in faceutility
template <class vector_t>
void buildMapping (const vector_t & , const vector_t & ,
const vector_t & , const vector_t & );
} ;
//! A bilinear mapping
template< int cdim >
class BilinearMapping
{
public:
typedef alu3d_ctype ctype;
typedef FieldVector< ctype, cdim > world_t;
typedef FieldVector< ctype, 2 > map_t;
typedef FieldMatrix< ctype, 2, cdim > matrix_t;
typedef FieldMatrix< ctype, cdim, 2 > inv_t;
protected:
ctype _b [4][cdim];
mutable ctype det_;
mutable matrix_t matrix_;
mutable inv_t invTransposed_;
mutable bool affine_;
mutable bool calcedMatrix_;
mutable bool calcedDet_;
mutable bool calcedInv_;
public:
BilinearMapping ();
BilinearMapping ( const world_t &p0, const world_t &p1,
const world_t &p2, const world_t &p3 );
BilinearMapping ( const ctype (&p0)[ cdim ], const ctype (&p1)[ cdim ],
const ctype (&p2)[ cdim ], const ctype (&p3)[ cdim ] );
bool affine () const;
void world2map ( const world_t &, map_t & ) const;
void map2world ( const ctype x, const ctype y, world_t &w ) const;
void map2world ( const map_t &, world_t & ) const;
ctype det ( const map_t & ) const;
const matrix_t &jacobianTransposed ( const map_t & ) const;
const inv_t &jacobianInverseTransposed ( const map_t & ) const;
template< class vector_t >
void buildMapping ( const vector_t &, const vector_t &,
const vector_t &, const vector_t & );
protected:
static void multTransposedMatrix ( const matrix_t &, FieldMatrix< ctype, 2, 2 > & );
static void multMatrix ( const matrix_t &, const FieldMatrix< ctype, 2, 2 > &, inv_t & );
void map2worldlinear ( const ctype, const ctype ) const;
void inverse ( const map_t & ) const;
};
//! A linear mapping
template< int cdim, int mydim >
class LinearMapping
{
public:
typedef alu3d_ctype ctype;
typedef ctype double_t[ cdim ];
typedef FieldVector< ctype, cdim > world_t;
typedef FieldVector< ctype, mydim > map_t;
typedef FieldMatrix< ctype, mydim, cdim > matrix_t;
typedef FieldMatrix< ctype, cdim, mydim > inv_t;
protected:
matrix_t _matrix; //!< transformation matrix (transposed)
mutable inv_t _invTransposed; //!< storage for inverse of jacobian (transposed)
world_t _p0; //! P[0]
//! stores the determinant of the inverse
mutable ctype _det;
//! true if inverse has been calculated
mutable bool _calcedInv;
//! true if determinant has been calculated
mutable bool _calcedDet;
public:
//! Constructor creating empty mapping with double , i.e. zero
LinearMapping ();
//! copy constructor
LinearMapping (const LinearMapping &) ;
// returns true if mapping is affine (which is always true)
inline bool affine () const { return true ; }
// return reference to transposed jacobian
const matrix_t& jacobianTransposed(const map_t &) const ;
// return reference to transposed jacobian inverse
const inv_t& jacobianInverseTransposed(const map_t &) const ;
// calculates determinant of mapping
ctype det(const map_t&) const;
// maps from local coordinates to global coordinates
void world2map(const world_t &, map_t &) const;
// maps form global coordinates to local (within reference element)
// coordinates
void map2world(const map_t &, world_t &) const ;
protected:
// calculate inverse
void inverse (const map_t&) const;
// calculate inverse one codim one entity
void inverseCodimOne (const map_t&) const;
// calculate determinant
void calculateDeterminant (const map_t&) const;
void multTransposedMatrix(const matrix_t& matrix,
FieldMatrix<ctype, mydim, mydim>& result) const;
void multMatrix ( const matrix_t& A,
const FieldMatrix< ctype, mydim, mydim> &B,
inv_t& ret ) const ;
public:
// builds _b and _n, called from the constructors
// public because also used in faceutility
template <class vector_t>
void buildMapping (const vector_t & , const vector_t & ,
const vector_t & , const vector_t & );
// builds _b and _n, called from the constructors
// public because also used in faceutility
template <class vector_t>
void buildMapping (const vector_t & , const vector_t & ,
const vector_t & );
// builds _b and _n, called from the constructors
// public because also used in faceutility
template <class vector_t>
void buildMapping (const vector_t & , const vector_t & );
template <class vector_t>
void buildMapping (const vector_t & );
} ;
///////////////////////////////////////////////////////////////////
//
// NonConforming Mappings
//
///////////////////////////////////////////////////////////////////
//! General form of non-conforming face mapping
//! This class is empty and needs to be specialised
template< ALU3dGridElementType type, class Comm >
class NonConformingFaceMapping;
//! Non-conforming face mappings for tetrahedra
template< class Comm >
class NonConformingFaceMapping< tetra, Comm >
{
public:
typedef FieldVector< alu3d_ctype, 3 > CoordinateType;
typedef typename ALU3dImplTraits< tetra, Comm >::HfaceRuleType RefinementRuleType;
NonConformingFaceMapping ( RefinementRuleType rule, int nChild )
: rule_( rule ), nChild_( nChild )
{}
void child2parent ( const CoordinateType &childCoordinates,
CoordinateType &parentCoordinates) const;
CoordinateType child2parent ( const FieldVector< alu3d_ctype, 2 > &childCoordinates ) const;
private:
void child2parentNosplit(const CoordinateType& childCoordinates,
CoordinateType& parentCoordinates) const;
void child2parentE01(const CoordinateType& childCoordinates,
CoordinateType& parentCoordinates) const;
void child2parentE12(const CoordinateType& childCoordinates,
CoordinateType& parentCoordinates) const;
void child2parentE20(const CoordinateType& childCoordinates,
CoordinateType& parentCoordinates) const;
void child2parentIso4(const CoordinateType& childCoordinates,
CoordinateType& parentCoordinates) const;
RefinementRuleType rule_;
int nChild_;
};
//! Non-conforming face mappings for hexahedra
template< class Comm >
class NonConformingFaceMapping< hexa, Comm >
{
public:
typedef FieldVector< alu3d_ctype, 2 > CoordinateType;
typedef typename ALU3dImplTraits< hexa, Comm >::HfaceRuleType RefinementRuleType;
NonConformingFaceMapping ( RefinementRuleType rule, int nChild )
: rule_( rule ), nChild_( nChild )
{}
void child2parent ( const CoordinateType &childCoordinates,
CoordinateType &parentCoordinates) const;
CoordinateType child2parent ( const FieldVector< alu3d_ctype, 2 > &childCoordinates ) const;
private:
void child2parentNosplit(const CoordinateType& childCoordinates,
CoordinateType& parentCoordinates) const;
void child2parentIso4(const CoordinateType& childCoordinates,
CoordinateType& parentCoordinates) const;
RefinementRuleType rule_;
int nChild_;
};
} // end namespace Dune
#if COMPILE_ALUGRID_INLINE
#include "mappings_imp.cc"
#endif
#endif
|