/usr/include/dune/grid/albertagrid/projection.hh is in libdune-grid-dev 2.4.1-1.
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 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ALBERTA_NODEPROJECTION_HH
#define DUNE_ALBERTA_NODEPROJECTION_HH
#include <dune/common/shared_ptr.hh>
#include <dune/grid/common/boundaryprojection.hh>
#include <dune/grid/albertagrid/misc.hh>
#include <dune/grid/albertagrid/elementinfo.hh>
#if HAVE_ALBERTA
namespace Dune
{
namespace Alberta
{
// Internal Forward Declarations
// -----------------------------
template< class Proj, class Impl >
class ProjectionFactory;
// DuneBoundaryProjection
// ----------------------
template< int dim >
class DuneBoundaryProjection
{
typedef DuneBoundaryProjection< dim > This;
public:
static const int dimension = dim;
typedef Alberta::ElementInfo< dimension > ElementInfo;
typedef FieldVector< Real, dimWorld > GlobalCoordinate;
typedef Dune::DuneBoundaryProjection< dimWorld > Projection;
typedef Dune::shared_ptr< const Projection > ProjectionPtr;
explicit DuneBoundaryProjection ( const ProjectionPtr &projection )
: projection_( projection )
{}
// note: GlobalVector is an array type; global is the return value
void operator() ( const ElementInfo &elementInfo, const LocalVector local,
GlobalVector global ) const
{
GlobalCoordinate x;
for( int i = 0; i < dimWorld; ++i )
x[ i ] = global[ i ];
GlobalCoordinate y = projection() ( x );
for( int i = 0; i < dimWorld; ++i )
global[ i ] = y[ i ];
}
const Projection &projection () const
{
return *projection_;
}
private:
ProjectionPtr projection_;
};
// ProjectionFactoryInterface
// --------------------------
template< class Proj, class Impl >
class ProjectionFactoryInterface
{
typedef ProjectionFactoryInterface< Proj, Impl > This;
friend class ProjectionFactory< Proj, Impl >;
public:
typedef Proj Projection;
static const int dimension = Projection::dimension;
typedef Alberta::ElementInfo< dimension > ElementInfo;
private:
ProjectionFactoryInterface ()
{}
ProjectionFactoryInterface ( const This &other );
This &operator= ( const This &other );
public:
bool hasProjection ( const ElementInfo &elementInfo, const int face ) const
{
return asImpl().hasProjection( elementInfo, face );
}
bool hasProjection ( const ElementInfo &elementInfo ) const
{
return asImpl().hasProjection( elementInfo );
}
Projection projection ( const ElementInfo &elementInfo, const int face ) const
{
return asImpl().projection( elementInfo, face );
};
Projection projection ( const ElementInfo &elementInfo ) const
{
return asImpl().projection( elementInfo );
};
protected:
const Impl &asImpl () const
{
return static_cast< const Impl & >( *this );
}
};
// ProjectionFactory
// -----------------
template< class Proj, class Impl >
class ProjectionFactory
: public ProjectionFactoryInterface< Proj, Impl >
{
typedef ProjectionFactory< Proj, Impl > This;
typedef ProjectionFactoryInterface< Proj, Impl > Base;
public:
typedef typename Base::Projection Projection;
typedef typename Base::ElementInfo ElementInfo;
protected:
ProjectionFactory ()
{}
private:
bool hasProjection ( const ElementInfo &elementInfo, const int face ) const;
bool hasProjection ( const ElementInfo &elementInfo ) const;
Projection projection ( const ElementInfo &elementInfo, const int face ) const;
Projection projection ( const ElementInfo &elementInfo ) const;
};
// DuneGlobalBoundaryProjectionFactory
// -----------------------------------
template< int dim >
class DuneGlobalBoundaryProjectionFactory
: public ProjectionFactory< DuneBoundaryProjection< dim >, DuneGlobalBoundaryProjectionFactory< dim > >
{
typedef DuneGlobalBoundaryProjectionFactory< dim > This;
typedef ProjectionFactory< DuneBoundaryProjection< dim >, This > Base;
public:
typedef typename Base::Projection Projection;
typedef typename Base::ElementInfo ElementInfo;
typedef typename Projection::ProjectionPtr DuneProjectionPtr;
DuneGlobalBoundaryProjectionFactory ( const DuneProjectionPtr &projection )
: projection_( projection )
{}
bool hasProjection ( const ElementInfo &elementInfo, const int face ) const
{
return true;
}
bool hasProjection ( const ElementInfo &elementInfo ) const
{
return true;
}
Projection projection ( const ElementInfo &elementInfo, const int face ) const
{
return projection_;
};
Projection projection ( const ElementInfo &elementInfo ) const
{
return projection_;
};
private:
const Projection projection_;
};
// BasicNodeProjection
// -------------------
struct BasicNodeProjection
: public ALBERTA NODE_PROJECTION
{
explicit BasicNodeProjection ( unsigned int boundaryIndex )
: boundaryIndex_( boundaryIndex )
{
func = 0;
}
virtual ~BasicNodeProjection ()
{}
unsigned int boundaryIndex () const
{
return boundaryIndex_;
}
private:
unsigned int boundaryIndex_;
};
// NodeProjection
// --------------
template< int dim, class Projection >
class NodeProjection
: public BasicNodeProjection
{
typedef NodeProjection< dim, Projection > This;
typedef BasicNodeProjection Base;
public:
static const int dimension = dim;
typedef Alberta::ElementInfo< dimension > ElementInfo;
private:
Projection projection_;
public:
NodeProjection ( unsigned int boundaryIndex, const Projection &projection )
: Base( boundaryIndex ),
projection_( projection )
{
func = apply;
}
private:
// note: global is the return type (it is an array type and hence no
// reference is needed)
static void apply ( GlobalVector global, const EL_INFO *info, const LocalVector local )
{
const ElementInfo elementInfo = ElementInfo::createFake( *info );
assert( (info->fill_flag & FillFlags< dimension >::projection) != 0 );
const This *nodeProjection = static_cast< const This * >( info->active_projection );
assert( nodeProjection != NULL );
nodeProjection->projection_( elementInfo, local, global );
}
};
}
}
#endif // #if HAVE_ALBERTA
#endif // #ifndef DUNE_ALBERTA_NODEPROJECTION_HH
|