3 #ifndef DUNE_ALBERTA_MESHPOINTER_HH
4 #define DUNE_ALBERTA_MESHPOINTER_HH
31 class HierarchyDofNumbering;
41 typedef Alberta::ElementInfo< dim > ElementInfo;
45 class BoundaryProvider;
47 template<
int dimWorld >
66 operator bool ()
const
73 return MacroIterator( *
this,
false );
76 MacroIterator
end ()
const
78 return MacroIterator( *
this,
true );
82 int size (
int codim )
const;
93 template<
class Proj,
class Impl >
101 unsigned int create (
const std::string &filename,
bool binary =
false );
112 unsigned int read (
const std::string &filename,
Real &time );
114 bool write (
const std::string &filename,
Real time )
const;
118 template<
class Functor >
122 template<
class Functor >
131 static ALBERTA NODE_PROJECTION *
132 initNodeProjection (
Mesh *mesh,
ALBERTA MACRO_EL *macroElement,
int n );
133 template<
class ProjectionProv
ider >
134 static ALBERTA NODE_PROJECTION *
135 initNodeProjection (
Mesh *mesh,
ALBERTA MACRO_EL *macroElement,
int n );
146 template<
int dimWorld >
147 struct MeshPointer< dim >::Library
151 static unsigned int boundaryCount;
152 static const void *projectionFactory;
190 return (index_ == other.index_);
202 return static_cast< const MacroElement &
>( mesh().mesh_->macro_els[ index_ ] );
218 return elementInfo();
223 return equals( other );
228 return !equals( other );
237 return ElementInfo( mesh(), macroElement(), fillFlags );
253 return (mesh_ ? mesh_->n_macro_el : 0);
260 assert( (codim >= 0) && (codim <= 1) );
261 return (codim == 0 ? mesh_->n_elements : mesh_->n_vertices);
267 assert( (codim >= 0) && (codim <= 2) );
269 return mesh_->n_elements;
270 else if( codim == 2 )
271 return mesh_->n_vertices;
273 return mesh_->n_edges;
279 assert( (codim >= 0) && (codim <= 3) );
281 return mesh_->n_elements;
282 else if( codim == 3 )
283 return mesh_->n_vertices;
284 else if( codim == 1 )
285 return mesh_->n_faces;
287 return mesh_->n_edges;
297 Library< dimWorld >::boundaryCount = 0;
298 Library< dimWorld >::create( *
this, macroData, &initNodeProjection );
299 return Library< dimWorld >::boundaryCount;
304 template<
class Proj,
class Impl >
313 Library< dimWorld >::boundaryCount = 0;
314 Library< dimWorld >::projectionFactory = &projectionFactory;
315 Library< dimWorld >::create( *
this, macroData, &initNodeProjection< ProjectionFactory > );
316 Library< dimWorld >::projectionFactory = 0;
317 return Library< dimWorld >::boundaryCount;
325 ::create (
const std::string &filename,
bool binary )
328 macroData.
read( filename, binary );
329 const unsigned int boundaryCount = create( macroData );
331 return boundaryCount;
340 Library< dimWorld >::boundaryCount = 0;
341 #if DUNE_ALBERTA_VERSION >= 0x300
342 mesh_ =
ALBERTA read_mesh_xdr( filename.c_str(), &time, NULL, NULL );
344 mesh_ =
ALBERTA read_mesh_xdr( filename.c_str(), &time, NULL );
346 return Library< dimWorld >::boundaryCount;
353 int success =
ALBERTA write_mesh_xdr( mesh_, filename.c_str(), time );
354 return (success == 0);
361 Library< dimWorld >::release( *
this );
366 template<
class Functor >
381 template<
class Functor >
395 #if DUNE_ALBERTA_VERSION >= 0x300
404 #endif // #if DUNE_ALBERTA_VERSION >= 0x300
406 #if DUNE_ALBERTA_VERSION <= 0x200
416 #endif // #if DUNE_ALBERTA_VERSION <= 0x200
419 #if DUNE_ALBERTA_VERSION >= 0x300
425 #endif // #if DUNE_ALBERTA_VERSION >= 0x300
427 #if DUNE_ALBERTA_VERSION <= 0x200
434 #endif // #if DUNE_ALBERTA_VERSION <= 0x200
438 inline ALBERTA NODE_PROJECTION *
442 if( (n > 0) && macroElement.
isBoundary( n-1 ) )
450 template<
class ProjectionFactory >
451 inline ALBERTA NODE_PROJECTION *
452 MeshPointer< dim >::initNodeProjection (
Mesh *mesh,
ALBERTA MACRO_EL *macroEl,
int n )
456 const MacroElement ¯oElement =
static_cast< const MacroElement &
>( *macroEl );
458 MeshPointer< dim > meshPointer( mesh );
460 const ProjectionFactory &projectionFactory = *
static_cast< const ProjectionFactory *
>( Library< dimWorld >::projectionFactory );
461 if( (n > 0) && macroElement.isBoundary( n-1 ) )
463 const unsigned int boundaryIndex = Library< dimWorld >::boundaryCount++;
464 if( projectionFactory.hasProjection( elementInfo, n-1 ) )
466 Projection projection = projectionFactory.projection( elementInfo, n-1 );
467 return new NodeProjection< dim, Projection >( boundaryIndex, projection );
470 return new BasicNodeProjection( boundaryIndex );
472 else if( (dim <
dimWorld) && (n == 0) )
475 if( projectionFactory.hasProjection( elementInfo ) )
477 Projection projection = projectionFactory.projection( elementInfo );
478 return new NodeProjection< dim, Projection >( boundaryIndex, projection );
491 #endif // #if HAVE_ALBERTA
493 #endif // #ifndef DUNE_ALBERTA_MESHPOINTER_HH
static const int dimWorld
Definition: misc.hh:43
bool done() const
Definition: meshpointer.hh:183
MeshPointer(Mesh *mesh)
Definition: meshpointer.hh:57
Alberta::MeshPointer< dim > MeshPointer
Definition: meshpointer.hh:173
Definition: elementinfo.hh:39
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:341
Definition: albertagrid/projection.hh:25
MacroIterator begin() const
Definition: meshpointer.hh:71
void leafTraverse(Functor &functor) const
Definition: elementinfo.hh:768
bool coarsen(typename FillFlags::Flags fillFlags=FillFlags::nothing)
Definition: meshpointer.hh:408
bool refine(typename FillFlags::Flags fillFlags=FillFlags::nothing)
Definition: meshpointer.hh:429
void increment()
Definition: meshpointer.hh:193
Definition: macroelement.hh:20
bool equals(const MacroIterator &other) const
Definition: meshpointer.hh:188
MacroIterator end() const
Definition: meshpointer.hh:76
Base::Projection Projection
Definition: albertagrid/projection.hh:138
static const int meshCoarsened
Definition: misc.hh:64
bool isBoundary(const int face) const
Definition: macroelement.hh:52
int numMacroElements() const
Definition: meshpointer.hh:251
Definition: macrodata.hh:27
static const Flags nothing
Definition: misc.hh:245
ElementInfo elementInfo(typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:232
provides a wrapper for ALBERTA's el_info structure
Alberta::ElementInfo< dim > ElementInfo
Definition: meshpointer.hh:174
void hierarchicTraverse(Functor &functor, typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:368
provides a wrapper for ALBERTA's macro_data structure
int size(int codim) const
Alberta::MacroElement< dimension > MacroElement
Definition: elementinfo.hh:55
ALBERTA MESH Mesh
Definition: misc.hh:60
void read(const std::string &filename, bool binary=false)
Definition: macrodata.hh:447
unsigned int create(const MacroData< dim > ¯oData)
Definition: meshpointer.hh:293
void hierarchicTraverse(Functor &functor) const
Definition: elementinfo.hh:755
#define ALBERTA
Definition: albertaheader.hh:27
Alberta::FillFlags< dimension > FillFlags
Definition: elementinfo.hh:57
Definition: dofadmin.hh:21
Definition: meshpointer.hh:166
unsigned int read(const std::string &filename, Real &time)
Definition: meshpointer.hh:336
void release()
Definition: meshpointer.hh:359
MeshPointer()
Definition: meshpointer.hh:53
Definition: grapecommon.hh:49
ALBERTA FLAGS Flags
Definition: misc.hh:243
Definition: albertagrid/projection.hh:204
const MeshPointer & mesh() const
Definition: meshpointer.hh:205
ALBERTA REAL Real
Definition: misc.hh:45
void leafTraverse(Functor &functor, typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:383
const MacroElement & macroElement() const
Definition: meshpointer.hh:199
static const int meshRefined
Definition: misc.hh:63
Definition: albertagrid/projection.hh:77
static const Flags standard
Definition: misc.hh:283
void release()
release the macro data structure
Definition: macrodata.hh:125
bool write(const std::string &filename, Real time) const
Definition: meshpointer.hh:351