3#ifndef DUNE_ALBERTA_NODEPROJECTION_HH
4#define DUNE_ALBERTA_NODEPROJECTION_HH
8#include <dune/grid/common/boundaryprojection.hh>
10#include <dune/grid/albertagrid/misc.hh>
24 template<
class Proj,
class Impl >
25 class ProjectionFactory;
33 class DuneBoundaryProjection
35 typedef DuneBoundaryProjection< dim > This;
38 static const int dimension = dim;
40 typedef Alberta::ElementInfo< dimension > ElementInfo;
41 typedef FieldVector< Real, dimWorld > GlobalCoordinate;
44 typedef std::shared_ptr< const Projection > ProjectionPtr;
46 explicit DuneBoundaryProjection (
const ProjectionPtr &projection )
47 : projection_( projection )
51 void operator() (
const ElementInfo & ,
const LocalVector ,
52 GlobalVector global )
const
55 for(
int i = 0; i < dimWorld; ++i )
57 GlobalCoordinate y = projection() ( x );
58 for(
int i = 0; i < dimWorld; ++i )
62 const Projection &projection ()
const
68 ProjectionPtr projection_;
76 template<
class Proj,
class Impl >
77 class ProjectionFactoryInterface
79 typedef ProjectionFactoryInterface< Proj, Impl > This;
81 friend class ProjectionFactory< Proj, Impl >;
84 typedef Proj Projection;
86 static const int dimension = Projection::dimension;
88 typedef Alberta::ElementInfo< dimension > ElementInfo;
91 ProjectionFactoryInterface ()
94 ProjectionFactoryInterface (
const This &other );
95 This &operator= (
const This &other );
98 bool hasProjection (
const ElementInfo &elementInfo,
const int face )
const
100 return asImpl().hasProjection( elementInfo, face );
103 bool hasProjection (
const ElementInfo &elementInfo )
const
105 return asImpl().hasProjection( elementInfo );
108 Projection projection (
const ElementInfo &elementInfo,
const int face )
const
110 return asImpl().projection( elementInfo, face );
113 Projection projection (
const ElementInfo &elementInfo )
const
115 return asImpl().projection( elementInfo );
119 const Impl &asImpl ()
const
121 return static_cast< const Impl &
>( *this );
130 template<
class Proj,
class Impl >
131 class ProjectionFactory
132 :
public ProjectionFactoryInterface< Proj, Impl >
134 typedef ProjectionFactory< Proj, Impl > This;
135 typedef ProjectionFactoryInterface< Proj, Impl > Base;
138 typedef typename Base::Projection Projection;
139 typedef typename Base::ElementInfo ElementInfo;
146 bool hasProjection (
const ElementInfo &elementInfo,
const int face )
const;
147 bool hasProjection (
const ElementInfo &elementInfo )
const;
149 Projection projection (
const ElementInfo &elementInfo,
const int face )
const;
150 Projection projection (
const ElementInfo &elementInfo )
const;
159 class DuneGlobalBoundaryProjectionFactory
160 :
public ProjectionFactory< DuneBoundaryProjection< dim >, DuneGlobalBoundaryProjectionFactory< dim > >
162 typedef DuneGlobalBoundaryProjectionFactory< dim > This;
163 typedef ProjectionFactory< DuneBoundaryProjection< dim >, This > Base;
166 typedef typename Base::Projection Projection;
167 typedef typename Base::ElementInfo ElementInfo;
169 typedef typename Projection::ProjectionPtr DuneProjectionPtr;
171 DuneGlobalBoundaryProjectionFactory (
const DuneProjectionPtr &projection )
172 : projection_( projection )
175 bool hasProjection (
const ElementInfo &elementInfo,
const int face )
const
180 bool hasProjection (
const ElementInfo &elementInfo )
const
185 Projection projection (
const ElementInfo &elementInfo,
const int face )
const
190 Projection projection (
const ElementInfo &elementInfo )
const
196 const Projection projection_;
204 struct BasicNodeProjection
205 :
public ALBERTA NODE_PROJECTION
207 explicit BasicNodeProjection (
unsigned int boundaryIndex )
208 : boundaryIndex_( boundaryIndex )
213 virtual ~BasicNodeProjection ()
216 unsigned int boundaryIndex ()
const
218 return boundaryIndex_;
222 unsigned int boundaryIndex_;
230 template<
int dim,
class Projection >
232 :
public BasicNodeProjection
234 typedef NodeProjection< dim, Projection > This;
235 typedef BasicNodeProjection Base;
238 static const int dimension = dim;
240 typedef Alberta::ElementInfo< dimension > ElementInfo;
243 Projection projection_;
246 NodeProjection (
unsigned int boundaryIndex,
const Projection &projection )
247 : Base( boundaryIndex ),
248 projection_( projection )
256 static void apply ( GlobalVector global,
const EL_INFO *info,
const LocalVector local )
258 const ElementInfo elementInfo = ElementInfo::createFake( *info );
260 assert( (info->fill_flag & FillFlags< dimension >::projection) != 0 );
261 const This *nodeProjection =
static_cast< const This *
>( info->active_projection );
263 assert( nodeProjection != NULL );
264 nodeProjection->projection_( elementInfo, local, global );
provides a wrapper for ALBERTA's el_info structure
Dune namespace.
Definition: alignedallocator.hh:11
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:31