/usr/include/dune/grid/albertagrid/coordcache.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 | #ifndef DUNE_ALBERTA_COORDCACHE_HH
#define DUNE_ALBERTA_COORDCACHE_HH
#include <dune/grid/albertagrid/meshpointer.hh>
#include <dune/grid/albertagrid/dofadmin.hh>
#include <dune/grid/albertagrid/dofvector.hh>
#if HAVE_ALBERTA
namespace Dune
{
namespace Alberta
{
// CoordCache
// ----------
template< int dim >
class CoordCache
{
typedef DofVectorPointer< GlobalVector > CoordVectorPointer;
typedef Alberta::DofAccess< dim, dim > DofAccess;
class LocalCaching;
struct Interpolation;
public:
static const int dimension = dim;
typedef Alberta::ElementInfo< dimension > ElementInfo;
typedef Alberta::MeshPointer< dimension > MeshPointer;
typedef HierarchyDofNumbering< dimension > DofNumbering;
GlobalVector &operator() ( const Element *element, int vertex ) const
{
assert( !(!coords_) );
GlobalVector *array = (GlobalVector *)coords_;
return array[ dofAccess_( element, vertex ) ];
}
GlobalVector &operator() ( const ElementInfo &elementInfo, int vertex ) const
{
return (*this)( elementInfo.el(), vertex );
}
void create ( const DofNumbering &dofNumbering )
{
MeshPointer mesh = dofNumbering.mesh();
const DofSpace *dofSpace = dofNumbering.dofSpace( dimension );
coords_.create( dofSpace, "Coordinate Cache" );
LocalCaching localCaching( coords_ );
mesh.hierarchicTraverse( localCaching, FillFlags< dimension >::coords );
coords_.template setupInterpolation< Interpolation >();
dofAccess_ = DofAccess( dofSpace );
}
void release ()
{
coords_.release();
}
private:
CoordVectorPointer coords_;
DofAccess dofAccess_;
};
// CoordCache::LocalCaching
// ------------------------
template< int dim >
class CoordCache< dim >::LocalCaching
{
CoordVectorPointer coords_;
DofAccess dofAccess_;
public:
explicit LocalCaching ( const CoordVectorPointer &coords )
: coords_( coords ),
dofAccess_( coords.dofSpace() )
{}
void operator() ( const ElementInfo &elementInfo ) const
{
GlobalVector *array = (GlobalVector *)coords_;
for( int i = 0; i < DofAccess::numSubEntities; ++i )
{
const GlobalVector &x = elementInfo.coordinate( i );
GlobalVector &y = array[ dofAccess_( elementInfo.el(), i ) ];
for( int i = 0; i < dimWorld; ++i )
y[ i ] = x[ i ];
}
}
};
// CoordCache::Interpolation
// -------------------------
template< int dim >
struct CoordCache< dim >::Interpolation
{
static const int dimension = dim;
typedef Alberta::Patch< dimension > Patch;
static void
interpolateVector ( const CoordVectorPointer &dofVector, const Patch &patch )
{
DofAccess dofAccess( dofVector.dofSpace() );
GlobalVector *array = (GlobalVector *)dofVector;
const Element *element = patch[ 0 ];
// new vertex is always the last one
assert( element->child[ 0 ] != NULL );
GlobalVector &newCoord = array[ dofAccess( element->child[ 0 ], dimension ) ];
if( element->new_coord != NULL )
{
for( int j = 0; j < dimWorld; ++j )
newCoord[ j ] = element->new_coord[ j ];
}
else
{
// new coordinate is the average of of old ones on the same edge
// refinement edge is always between vertices 0 and 1
const GlobalVector &coord0 = array[ dofAccess( element, 0 ) ];
const GlobalVector &coord1 = array[ dofAccess( element, 1 ) ];
for( int j = 0; j < dimWorld; ++j )
newCoord[ j ] = 0.5 * (coord0[ j ] + coord1[ j ]);
}
}
};
}
}
#endif // #if HAVE_ALBERTA
#endif // #ifndef DUNE_ALBERTA_COORDCACHE_HH
|