5#ifndef DUNE_ALBERTA_MESHPOINTER_HH
6#define DUNE_ALBERTA_MESHPOINTER_HH
33 class HierarchyDofNumbering;
45 class BoundaryProvider;
47 template<
int dimWorld >
66 explicit operator bool ()
const
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 >
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 >
376 const ElementInfo info = it.elementInfo( fillFlags );
383 template<
class Functor >
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 );
provides a wrapper for ALBERTA's macro_data structure
provides a wrapper for ALBERTA's el_info structure
#define ALBERTA
Definition: albertaheader.hh:29
Include standard header files.
Definition: agrid.hh:60
ALBERTA MESH Mesh
Definition: misc.hh:53
ALBERTA REAL Real
Definition: misc.hh:48
static const int meshRefined
Definition: misc.hh:56
static const int dimWorld
Definition: misc.hh:46
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:337
static const int meshCoarsened
Definition: misc.hh:57
Definition: meshpointer.hh:40
int numMacroElements() const
Definition: meshpointer.hh:257
unsigned int create(const MacroData< dim > ¯oData, const ProjectionFactoryInterface< Proj, Impl > &projectionFactory)
Definition: meshpointer.hh:312
void release()
Definition: meshpointer.hh:361
unsigned int read(const std::string &filename, Real &time)
Definition: meshpointer.hh:342
MacroIterator end() const
Definition: meshpointer.hh:76
bool coarsen(typename FillFlags::Flags fillFlags=FillFlags::nothing)
Definition: meshpointer.hh:398
int size(int codim) const
unsigned int create(const std::string &filename, bool binary=false)
Definition: meshpointer.hh:331
void leafTraverse(Functor &functor, typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:385
unsigned int create(const MacroData< dim > ¯oData)
Definition: meshpointer.hh:299
MacroIterator begin() const
Definition: meshpointer.hh:71
MeshPointer(Mesh *mesh)
Definition: meshpointer.hh:57
bool write(const std::string &filename, Real time) const
Definition: meshpointer.hh:353
bool refine(typename FillFlags::Flags fillFlags=FillFlags::nothing)
Definition: meshpointer.hh:407
MeshPointer()
Definition: meshpointer.hh:53
void hierarchicTraverse(Functor &functor, typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:370
Definition: elementinfo.hh:43
void hierarchicTraverse(Functor &functor) const
Definition: elementinfo.hh:695
void leafTraverse(Functor &functor) const
Definition: elementinfo.hh:708
Definition: macrodata.hh:30
void release()
release the macro data structure
Definition: macrodata.hh:127
void read(const std::string &filename, bool binary=false)
Definition: macrodata.hh:413
Definition: macroelement.hh:24
bool isBoundary(const int face) const
Definition: macroelement.hh:42
Definition: meshpointer.hh:167
const MeshPointer & mesh() const
Definition: meshpointer.hh:211
const MacroElement & macroElement() const
Definition: meshpointer.hh:205
Alberta::ElementInfo< dim > ElementInfo
Definition: meshpointer.hh:174
Alberta::MeshPointer< dim > MeshPointer
Definition: meshpointer.hh:173
ElementInfo elementInfo(typename FillFlags::Flags fillFlags=FillFlags::standard) const
Definition: meshpointer.hh:238
bool done() const
Definition: meshpointer.hh:189
void increment()
Definition: meshpointer.hh:199
bool equals(const MacroIterator &other) const
Definition: meshpointer.hh:194
MacroIterator()
Definition: meshpointer.hh:176
static const Flags nothing
Definition: misc.hh:234
ALBERTA FLAGS Flags
Definition: misc.hh:232
static const Flags standard
Definition: misc.hh:256
Definition: albertagrid/projection.hh:135
Base::Projection Projection
Definition: albertagrid/projection.hh:140
Definition: albertagrid/projection.hh:80
Definition: albertagrid/projection.hh:208