1 #ifndef DUNE_ALBERTA_MESHPOINTER_HH
2 #define DUNE_ALBERTA_MESHPOINTER_HH
29 class HierarchyDofNumbering;
39 typedef Alberta::ElementInfo< dim > ElementInfo;
43 class BoundaryProvider;
45 template<
int dimWorld >
64 operator bool ()
const
71 return MacroIterator( *
this,
false );
74 MacroIterator
end ()
const
76 return MacroIterator( *
this,
true );
80 int size (
int codim )
const;
91 template<
class Proj,
class Impl >
99 unsigned int create (
const std::string &filename,
bool binary =
false );
110 unsigned int read (
const std::string &filename,
Real &time );
112 bool write (
const std::string &filename,
Real time )
const;
116 template<
class Functor >
120 template<
class Functor >
129 static ALBERTA NODE_PROJECTION *
130 initNodeProjection (
Mesh *mesh,
ALBERTA MACRO_EL *macroElement,
int n );
131 template<
class ProjectionProv
ider >
132 static ALBERTA NODE_PROJECTION *
133 initNodeProjection (
Mesh *mesh,
ALBERTA MACRO_EL *macroElement,
int n );
144 template<
int dimWorld >
145 struct MeshPointer< dim >::Library
149 static unsigned int boundaryCount;
150 static const void *projectionFactory;
188 return (index_ == other.index_);
200 return static_cast< const MacroElement &
>( mesh().mesh_->macro_els[ index_ ] );
216 return elementInfo();
221 return equals( other );
226 return !equals( other );
235 return ElementInfo( mesh(), macroElement(), fillFlags );
251 return (mesh_ ? mesh_->n_macro_el : 0);
258 assert( (codim >= 0) && (codim <= 1) );
259 return (codim == 0 ? mesh_->n_elements : mesh_->n_vertices);
265 assert( (codim >= 0) && (codim <= 2) );
267 return mesh_->n_elements;
268 else if( codim == 2 )
269 return mesh_->n_vertices;
271 return mesh_->n_edges;
277 assert( (codim >= 0) && (codim <= 3) );
279 return mesh_->n_elements;
280 else if( codim == 3 )
281 return mesh_->n_vertices;
282 else if( codim == 1 )
283 return mesh_->n_faces;
285 return mesh_->n_edges;
295 Library< dimWorld >::boundaryCount = 0;
296 Library< dimWorld >::create( *
this, macroData, &initNodeProjection );
297 return Library< dimWorld >::boundaryCount;
302 template<
class Proj,
class Impl >
311 Library< dimWorld >::boundaryCount = 0;
312 Library< dimWorld >::projectionFactory = &projectionFactory;
313 Library< dimWorld >::create( *
this, macroData, &initNodeProjection< ProjectionFactory > );
314 Library< dimWorld >::projectionFactory = 0;
315 return Library< dimWorld >::boundaryCount;
323 ::create (
const std::string &filename,
bool binary )
326 macroData.
read( filename, binary );
327 const unsigned int boundaryCount = create( macroData );
329 return boundaryCount;
338 Library< dimWorld >::boundaryCount = 0;
339 #if DUNE_ALBERTA_VERSION >= 0x300
340 mesh_ =
ALBERTA read_mesh_xdr( filename.c_str(), &time, NULL, NULL );
342 mesh_ =
ALBERTA read_mesh_xdr( filename.c_str(), &time, NULL );
344 return Library< dimWorld >::boundaryCount;
351 int success =
ALBERTA write_mesh_xdr( mesh_, filename.c_str(), time );
352 return (success == 0);
359 Library< dimWorld >::release( *
this );
364 template<
class Functor >
372 const ElementInfo info = it.elementInfo( fillFlags );
379 template<
class Functor >
387 const ElementInfo info = it.elementInfo( fillFlags );
393 #if DUNE_ALBERTA_VERSION >= 0x300
402 #endif // #if DUNE_ALBERTA_VERSION >= 0x300
404 #if DUNE_ALBERTA_VERSION <= 0x200
414 #endif // #if DUNE_ALBERTA_VERSION <= 0x200
417 #if DUNE_ALBERTA_VERSION >= 0x300
423 #endif // #if DUNE_ALBERTA_VERSION >= 0x300
425 #if DUNE_ALBERTA_VERSION <= 0x200
432 #endif // #if DUNE_ALBERTA_VERSION <= 0x200
436 inline ALBERTA NODE_PROJECTION *
440 if( (n > 0) && macroElement.
isBoundary( n-1 ) )
448 template<
class ProjectionFactory >
449 inline ALBERTA NODE_PROJECTION *
450 MeshPointer< dim >::initNodeProjection (
Mesh *mesh,
ALBERTA MACRO_EL *macroEl,
int n )
454 const MacroElement ¯oElement =
static_cast< const MacroElement &
>( *macroEl );
456 MeshPointer< dim > meshPointer( mesh );
458 const ProjectionFactory &projectionFactory = *
static_cast< const ProjectionFactory *
>( Library< dimWorld >::projectionFactory );
459 if( (n > 0) && macroElement.isBoundary( n-1 ) )
461 const unsigned int boundaryIndex = Library< dimWorld >::boundaryCount++;
462 if( projectionFactory.hasProjection( elementInfo, n-1 ) )
464 Projection projection = projectionFactory.projection( elementInfo, n-1 );
465 return new NodeProjection< dim, Projection >( boundaryIndex, projection );
468 return new BasicNodeProjection( boundaryIndex );
470 else if( (dim <
dimWorld) && (n == 0) )
473 if( projectionFactory.hasProjection( elementInfo ) )
475 Projection projection = projectionFactory.projection( elementInfo );
476 return new NodeProjection< dim, Projection >( boundaryIndex, projection );
489 #endif // #if HAVE_ALBERTA
491 #endif // #ifndef DUNE_ALBERTA_MESHPOINTER_HH