Loading...
Searching...
No Matches
entity.hh
// -*- mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=2 sw=2 sts=2:
#ifndef DUNE_POLYHEDRALGRID_ENTITY_HH
#define DUNE_POLYHEDRALGRID_ENTITY_HH
//- dune-common includes
#include <dune/common/typetraits.hh>
//- dune-grid includes
#include <dune/grid/common/entity.hh>
namespace Dune
{
// PolyhedralGridEntityBasic
// -----------------
template< int codim, int dim, class Grid >
class PolyhedralGridEntityBasic
{
protected:
typedef typename std::remove_const< Grid >::type::Traits Traits;
public:
static const int codimension = codim;
static const int dimension = Traits::dimension;
static const int mydimension = dimension - codimension;
static const int dimensionworld = Traits::dimensionworld;
typedef typename Traits::ctype ctype;
typedef typename Traits::Index Index;
typedef typename Grid::template Codim< codimension >::Entity Entity;
typedef typename Grid::template Codim< codimension >::EntitySeed EntitySeed;
typedef typename Traits::template Codim< codimension >::Geometry Geometry;
typedef typename Traits::template Codim< codimension >::GeometryImpl GeometryImpl;
protected:
// type of extra data, e.g. a pointer to grid (here empty)
typedef typename Traits::ExtraData ExtraData;
public:
PolyhedralGridEntityBasic ()
: data_( nullptr ),
seed_()
{}
explicit PolyhedralGridEntityBasic ( ExtraData data )
: data_( data ),
seed_()
{}
PolyhedralGridEntityBasic ( ExtraData data, const EntitySeed& seed )
: data_( data )
, seed_( seed )
{}
GeometryType type () const
{
return data()->geometryType(seed_);
}
int level () const
{
return 0;
}
PartitionType partitionType () const
{
return InteriorEntity; // data()->partitionType( *this );
}
Geometry geometry () const
{
return Geometry( GeometryImpl( data(), seed_ ) );
}
EntitySeed seed () const { return seed_; }
ExtraData data() const { return data_; }
Index index () const { return seed_.index(); }
bool equals(const PolyhedralGridEntityBasic& other) const
{
return seed_.equals(other.seed_);
}
protected:
ExtraData data_;
EntitySeed seed_;
};
// PolyhedralGridEntity
// ------------
template< int codim, int dim, class Grid >
class PolyhedralGridEntity : public PolyhedralGridEntityBasic< codim, dim, Grid >
{
typedef PolyhedralGridEntityBasic< codim, dim, Grid > Base ;
protected:
typedef typename std::remove_const< Grid >::type::Traits Traits;
protected:
// type of extra data, e.g. a pointer to grid (here empty)
typedef typename Traits::ExtraData ExtraData;
using Base::seed_;
public:
typedef typename Base :: EntitySeed EntitySeed;
using Base :: codimension ;
using Base :: data ;
PolyhedralGridEntity ()
: Base()
{}
explicit PolyhedralGridEntity ( ExtraData data_param )
: Base( data_param )
{}
PolyhedralGridEntity ( ExtraData data_param, const EntitySeed& seed )
: Base( data_param, seed )
{}
unsigned int subEntities( const unsigned int cd ) const
{
if( cd == Base :: codimension )
return 1;
else
return data()->subEntities( seed_, cd );
}
template< int cd >
typename Grid::template Codim< cd >::EntityPointer
subEntity ( int i ) const
{
typedef typename Traits::template Codim< cd >::EntityPointerImpl EntityPointerImpl;
typedef typename Traits::template Codim< cd >::EntityImpl EntityImpl;
return EntityPointerImpl( EntityImpl( data(), data()->template subEntitySeed< cd >( seed_, i ) ) );
}
};
// PolyhedralGridEntity for codimension 0
// ----------------------------------
template< int dim, class Grid >
class PolyhedralGridEntity< 0, dim, Grid > : public PolyhedralGridEntityBasic< 0, dim, Grid >
{
typedef PolyhedralGridEntityBasic< 0, dim, Grid > Base ;
typedef PolyhedralGridEntity< 0, dim, Grid > This;
protected:
typedef typename Base::Traits Traits;
// type of extra data, e.g. a pointer to grid (here empty)
typedef typename Base::ExtraData ExtraData;
using Base::seed_;
public:
using Base::codimension ;
using Base::data ;
protected:
typedef typename Traits :: LeafIntersectionIteratorImpl LeafIntersectionIteratorImpl;
typedef typename Traits::template Codim< codimension >::LocalGeometryImpl LocalGeometryImpl;
public:
typedef typename Base :: EntitySeed EntitySeed;
typedef typename Traits::template Codim< codimension >::LocalGeometry LocalGeometry;
typedef typename Traits::template Codim< codimension >::Entity Entity;
typedef typename Traits::template Codim< codimension >::EntityPointer EntityPointer;
typedef typename Traits::HierarchicIterator HierarchicIterator;
typedef typename Traits::LeafIntersectionIterator LeafIntersectionIterator;
typedef typename Traits::LevelIntersectionIterator LevelIntersectionIterator;
PolyhedralGridEntity ()
: Base()
{}
explicit PolyhedralGridEntity ( ExtraData data_param )
: Base( data_param )
{}
PolyhedralGridEntity ( ExtraData data_param, const EntitySeed& seed )
: Base( data_param, seed )
{}
const This& dereference() const
{ return *this; }
This& dereference()
{ return *this; }
unsigned int subEntities( const unsigned int codim ) const
{
if( codim == 0 )
return 1;
else
return data()->subEntities( seed_, codim );
}
template< int codim >
int count () const
{
return subEntities( codim );
}
template< int codim >
typename Grid::template Codim< codim >::EntityPointer
subEntity ( int i ) const
{
typedef typename Traits::template Codim< codim >::EntityPointerImpl EntityPointerImpl;
typedef typename Traits::template Codim< codim >::EntityImpl EntityImpl;
return EntityPointerImpl( EntityImpl( data(), data()->template subEntitySeed< codim >( seed_, i ) ) );
}
bool hasBoundaryIntersections () const
{
return data()->hasBoundaryIntersections( this->seed() );
}
LeafIntersectionIterator ibegin () const
{
return LeafIntersectionIterator( LeafIntersectionIteratorImpl( data(), seed_, true ) );
}
LeafIntersectionIterator iend () const
{
return LeafIntersectionIterator( LeafIntersectionIteratorImpl( data(), seed_, false ) );
}
LeafIntersectionIterator ileafbegin () const { return ibegin(); }
LevelIntersectionIterator ilevelbegin () const { return ibegin(); }
LeafIntersectionIterator ileafend () const { return iend(); }
LevelIntersectionIterator ilevelend () const { return iend(); }
bool isLeaf () const
{
return true;
}
EntityPointer father () const
{
DUNE_THROW(InvalidStateException,"no father available");
typedef typename Traits::template Codim< 0 >::EntityImpl EntityImpl;
typedef typename Traits::template Codim< 0 >::EntityPointerImpl EntityPointerImpl;
return EntityPointer( EntityPointerImpl( EntityImpl( data() ) ) );
}
bool hasFather () const
{
return false;
}
LocalGeometry geometryInFather () const
{
DUNE_THROW(InvalidStateException,"no father available");
return LocalGeometry( LocalGeometryImpl( data() ) );
}
HierarchicIterator hbegin ( int maxLevel ) const
{
return hend( maxLevel );
}
HierarchicIterator hend ( int ) const
{
typedef typename Traits :: HierarchicIteratorImpl HierarchicIteratorImpl ;
return HierarchicIterator( HierarchicIteratorImpl( data(), false ) );
}
bool isRegular () const
{
return true;
}
bool isNew () const
{
return false;
}
bool mightVanish () const
{
return false;
}
};
} // namespace Dune
#endif // #ifndef DUNE_POLYHEDRALGRID_ENTITY_HH
Dune::PolyhedralGridEntityBasic< 0, dim, Grid >
Dune::PolyhedralGridEntityBasic< 0, dim, Grid >::codimension
static const int codimension
Definition entity.hh:33
Dune::PolyhedralGridEntityBasic::Geometry
Traits::template Codim< codimension >::Geometry Geometry
type of corresponding geometry
Definition entity.hh:57
Dune::PolyhedralGridEntityBasic::Entity
Grid::template Codim< codimension >::Entity Entity
type of entity
Definition entity.hh:52
Dune::PolyhedralGridEntityBasic::level
int level() const
obtain the level of this entity
Definition entity.hh:104
Dune::PolyhedralGridEntityBasic::PolyhedralGridEntityBasic
PolyhedralGridEntityBasic()
construct a null entity
Definition entity.hh:71
Dune::PolyhedralGridEntityBasic< 0, dim, Grid >::mydimension
static const int mydimension
Definition entity.hh:37
Dune::PolyhedralGridEntityBasic::ctype
Traits::ctype ctype
coordinate type of the grid
Definition entity.hh:47
Dune::PolyhedralGridEntityBasic< 0, dim, Grid >::dimension
static const int dimension
Definition entity.hh:35
Dune::PolyhedralGridEntityBasic< 0, dim, Grid >::dimensionworld
static const int dimensionworld
Definition entity.hh:39
Dune::PolyhedralGridEntityBasic::PolyhedralGridEntityBasic
PolyhedralGridEntityBasic(ExtraData data, const EntitySeed &seed)
construct an initialized entity
Definition entity.hh:84
Dune::PolyhedralGridEntityBasic::partitionType
PartitionType partitionType() const
obtain the partition type of this entity
Definition entity.hh:110
Dune::PolyhedralGridEntityBasic::EntitySeed
Grid::template Codim< codimension >::EntitySeed EntitySeed
type of corresponding entity seed
Definition entity.hh:55
Dune::PolyhedralGridEntityBasic::geometry
Geometry geometry() const
obtain the geometry of this entity
Definition entity.hh:116
Dune::PolyhedralGridEntityBasic::PolyhedralGridEntityBasic
PolyhedralGridEntityBasic(ExtraData data)
construct a null entity with data pointer
Definition entity.hh:77
Dune::PolyhedralGridEntityBasic< 0, dim, Grid >::seed
EntitySeed seed() const
Definition entity.hh:122
Dune::PolyhedralGridEntityBasic::type
GeometryType type() const
obtain the name of the corresponding reference element
Definition entity.hh:98
Dune::PolyhedralGridEntity< 0, dim, Grid >
construct a null entity
Definition entity.hh:207
Dune::PolyhedralGridEntity< 0, dim, Grid >::LocalGeometry
Traits::template Codim< codimension >::LocalGeometry LocalGeometry
type of corresponding local geometry
Definition entity.hh:233
Dune::PolyhedralGridEntity< 0, dim, Grid >::PolyhedralGridEntity
PolyhedralGridEntity(ExtraData data_param, const EntitySeed &seed)
construct an initialized entity
Definition entity.hh:262
Dune::PolyhedralGridEntity< 0, dim, Grid >::Entity
Traits::template Codim< codimension >::Entity Entity
type of corresponding entity
Definition entity.hh:235
Dune::PolyhedralGridEntity< 0, dim, Grid >::PolyhedralGridEntity
PolyhedralGridEntity(ExtraData data_param)
construct a null entity with data pointer
Definition entity.hh:257
Dune::PolyhedralGridEntity< 0, dim, Grid >::EntityPointer
Traits::template Codim< codimension >::EntityPointer EntityPointer
type of corresponding entity
Definition entity.hh:237
Dune::PolyhedralGridEntity< 0, dim, Grid >::HierarchicIterator
Traits::HierarchicIterator HierarchicIterator
type of hierarchic iterator
Definition entity.hh:240
Dune::PolyhedralGridEntity< 0, dim, Grid >::PolyhedralGridEntity
PolyhedralGridEntity()
construct a null entity
Definition entity.hh:252
Dune::PolyhedralGridEntity< 0, dim, Grid >::LeafIntersectionIterator
Traits::LeafIntersectionIterator LeafIntersectionIterator
type of leaf intersection iterator
Definition entity.hh:242
Dune::PolyhedralGridEntity< 0, dim, Grid >::LevelIntersectionIterator
Traits::LevelIntersectionIterator LevelIntersectionIterator
type of level intersection iterator
Definition entity.hh:244
Dune
The namespace Dune is the main namespace for all Dune code.
Definition CartesianIndexMapper.hpp:10