5 #ifndef DUNE_ALBERTA_MESHPOINTER_HH 6 #define DUNE_ALBERTA_MESHPOINTER_HH 33 class HierarchyDofNumbering;
41 typedef Alberta::ElementInfo< dim > ElementInfo;
45 class BoundaryProvider;
47 template<
int dimWorld >
66 explicit 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 ( [[maybe_unused]]
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 inline unsigned int boundaryCount = 0;
152 static inline const void *projectionFactory =
nullptr;
196 return (index_ == other.index_);
208 return static_cast< const MacroElement &
>( mesh().mesh_->macro_els[ index_ ] );
224 return elementInfo();
229 return equals( other );
234 return !equals( other );
243 return ElementInfo( mesh(), macroElement(), fillFlags );
259 return (mesh_ ? mesh_->n_macro_el : 0);
266 assert( (codim >= 0) && (codim <= 1) );
267 return (codim == 0 ? mesh_->n_elements : mesh_->n_vertices);
273 assert( (codim >= 0) && (codim <= 2) );
275 return mesh_->n_elements;
276 else if( codim == 2 )
277 return mesh_->n_vertices;
279 return mesh_->n_edges;
285 assert( (codim >= 0) && (codim <= 3) );
287 return mesh_->n_elements;
288 else if( codim == 3 )
289 return mesh_->n_vertices;
290 else if( codim == 1 )
291 return mesh_->n_faces;
293 return mesh_->n_edges;
303 Library< dimWorld >::boundaryCount = 0;
304 Library< dimWorld >::create( *
this, macroData, &initNodeProjection );
305 return Library< dimWorld >::boundaryCount;
310 template<
class Proj,
class Impl >
319 Library< dimWorld >::boundaryCount = 0;
320 Library< dimWorld >::projectionFactory = &projectionFactory;
321 Library< dimWorld >::create( *
this, macroData, &initNodeProjection< ProjectionFactory > );
322 Library< dimWorld >::projectionFactory =
nullptr;
323 return Library< dimWorld >::boundaryCount;
331 ::create (
const std::string &filename,
bool binary )
334 macroData.
read( filename, binary );
335 const unsigned int boundaryCount = create( macroData );
337 return boundaryCount;
346 Library< dimWorld >::boundaryCount = 0;
347 mesh_ =
ALBERTA read_mesh_xdr( filename.c_str(), &time, NULL, NULL );
348 return Library< dimWorld >::boundaryCount;
355 int success =
ALBERTA write_mesh_xdr( mesh_, filename.c_str(), time );
356 return (success == 0);
363 Library< dimWorld >::release( *
this );
368 template<
class Functor >
373 const MacroIterator eit = end();
374 for( MacroIterator it = begin(); it != eit; ++it )
376 const ElementInfo info = it.elementInfo( fillFlags );
383 template<
class Functor >
388 const MacroIterator eit = end();
389 for( MacroIterator it = begin(); it != eit; ++it )
391 const ElementInfo info = it.elementInfo( fillFlags );
414 inline ALBERTA NODE_PROJECTION *
418 if( (n > 0) && macroElement.
isBoundary( n-1 ) )
426 template<
class ProjectionFactory >
427 inline ALBERTA NODE_PROJECTION *
428 MeshPointer< dim >::initNodeProjection (
Mesh *mesh,
ALBERTA MACRO_EL *macroEl,
int n )
432 const MacroElement ¯oElement =
static_cast< const MacroElement &
>( *macroEl );
434 MeshPointer< dim > meshPointer( mesh );
436 const ProjectionFactory &projectionFactory = *
static_cast< const ProjectionFactory *
>( Library< dimWorld >::projectionFactory );
437 if( (n > 0) && macroElement.isBoundary( n-1 ) )
439 const unsigned int boundaryIndex = Library< dimWorld >::boundaryCount++;
440 if( projectionFactory.hasProjection( elementInfo, n-1 ) )
442 Projection projection = projectionFactory.projection( elementInfo, n-1 );
443 return new NodeProjection< dim, Projection >( boundaryIndex, projection );
446 return new BasicNodeProjection( boundaryIndex );
448 else if( (dim <
dimWorld) && (n == 0) )
451 if( projectionFactory.hasProjection( elementInfo ) )
453 Projection projection = projectionFactory.projection( elementInfo );
454 return new NodeProjection< dim, Projection >( boundaryIndex, projection );
467 #endif // #if HAVE_ALBERTA 469 #endif // #ifndef DUNE_ALBERTA_MESHPOINTER_HH Definition: albertagrid/projection.hh:27
void release()
Definition: meshpointer.hh:361
ALBERTA MESH Mesh
Definition: misc.hh:53
Definition: elementinfo.hh:42
Alberta::FillFlags< dimension > FillFlags
Definition: elementinfo.hh:60
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:337
Definition: macroelement.hh:22
static const int meshRefined
Definition: misc.hh:56
void hierarchicTraverse(Functor &functor) const
Definition: elementinfo.hh:695
int numMacroElements() const
Definition: meshpointer.hh:257
provides a wrapper for ALBERTA's el_info structure
Definition: meshpointer.hh:166
MacroIterator()
Definition: meshpointer.hh:176
void hierarchicTraverse(Functor &functor, typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:370
unsigned int create(const MacroData< dim > ¯oData)
Definition: meshpointer.hh:299
Alberta::MeshPointer< dim > MeshPointer
Definition: meshpointer.hh:173
ALBERTA FLAGS Flags
Definition: misc.hh:232
MeshPointer(Mesh *mesh)
Definition: meshpointer.hh:57
void leafTraverse(Functor &functor) const
Definition: elementinfo.hh:708
void read(const std::string &filename, bool binary=false)
Definition: macrodata.hh:413
static const Flags nothing
Definition: misc.hh:234
int size(int codim) const
void increment()
Definition: meshpointer.hh:199
Alberta::MacroElement< dimension > MacroElement
Definition: elementinfo.hh:58
ALBERTA REAL Real
Definition: misc.hh:48
Alberta::ElementInfo< dim > ElementInfo
Definition: meshpointer.hh:174
ElementInfo elementInfo(typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:238
#define ALBERTA
Definition: albertaheader.hh:29
MacroIterator end() const
Definition: meshpointer.hh:76
MeshPointer()
Definition: meshpointer.hh:53
Definition: albertagrid/projection.hh:79
void release()
release the macro data structure
Definition: macrodata.hh:127
bool done() const
Definition: meshpointer.hh:189
Include standard header files.
Definition: agrid.hh:59
bool refine(typename FillFlags::Flags fillFlags=FillFlags::nothing)
Definition: meshpointer.hh:407
MacroIterator begin() const
Definition: meshpointer.hh:71
provides a wrapper for ALBERTA's macro_data structure
const MacroElement & macroElement() const
Definition: meshpointer.hh:205
Definition: dofadmin.hh:27
bool isBoundary(const int face) const
Definition: macroelement.hh:42
bool equals(const MacroIterator &other) const
Definition: meshpointer.hh:194
void leafTraverse(Functor &functor, typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:385
Base::Projection Projection
Definition: albertagrid/projection.hh:140
const MeshPointer & mesh() const
Definition: meshpointer.hh:211
Definition: albertagrid/projection.hh:206
static const int meshCoarsened
Definition: misc.hh:57
bool coarsen(typename FillFlags::Flags fillFlags=FillFlags::nothing)
Definition: meshpointer.hh:398
static const Flags standard
Definition: misc.hh:256
unsigned int read(const std::string &filename, Real &time)
Definition: meshpointer.hh:342
Definition: macrodata.hh:29
bool write(const std::string &filename, Real time) const
Definition: meshpointer.hh:353
static const int dimWorld
Definition: misc.hh:46