3 #ifndef DUNE_DGF_GRIDPTR_HH
4 #define DUNE_DGF_GRIDPTR_HH
14 #include <dune/common/shared_ptr.hh>
15 #include <dune/common/parallel/mpihelper.hh>
32 struct DGFGridFactory;
34 template<
class Gr
idImp,
class IntersectionImp >
54 template<
class Gr
idType >
59 typedef shared_ptr< GridType > base_t ;
61 typedef null_deleter< GridType > emptydeleter_t ;
66 if( use_count() == 1 )
70 if( grd )
delete grd ;
77 base_t :: operator = ( other );
81 using base_t :: swap ;
82 using base_t :: use_count ;
85 mygrid_ptr() : base_t( ( GridType * ) 0, emptydeleter_t() ) {}
89 explicit mygrid_ptr( GridType* grd ) : base_t( grd, emptydeleter_t() ) {}
104 GridType* grd = this->
get();
105 base_t ptr(( GridType * ) 0, emptydeleter_t() );
115 explicit GridPtr (
const std::string &filename,
116 MPICommunicatorType comm = MPIHelper::getCommunicator() )
133 MPICommunicatorType comm = MPIHelper::getCommunicator() )
252 template <
class Entity>
259 template<
class Gr
idImp,
class IntersectionImp >
266 template <
class Entity>
269 typedef typename GridType::LevelGridView
GridView;
270 GridView gridView =
gridPtr_->levelGridView( 0 );
276 assert( (
unsigned int)gridView.
indexSet().index( entity ) <
elParam_.size() );
280 case GridType::dimension :
292 template<
class Gr
idImp,
class IntersectionImp >
309 if (
gridPtr_->comm().max( params ) > 0 )
325 typedef typename GridType::LevelGridView
GridView;
326 GridView gridView =
gridPtr_->levelGridView( 0 );
329 nofElParam_ = dgfFactory.template numParameters< 0 >();
330 nofVtxParam_ = dgfFactory.template numParameters< dimension >();
334 elParam_.resize( indexSet.size(0) );
335 if ( nofVtxParam_ > 0 )
336 vtxParam_.resize( indexSet.size(dimension) );
337 bndId_.resize( indexSet.size(1) );
342 typedef typename GridView::template Codim< 0 >::template Partition< partType >::Iterator Iterator;
343 const Iterator enditer = gridView.template end< 0, partType >();
344 for( Iterator iter = gridView.template begin< 0, partType >(); iter != enditer; ++iter )
346 const typename Iterator::Entity &el = *iter;
351 if ( nofVtxParam_ > 0 )
353 const int subEntities = el.subEntities(dimension);
354 for (
int v = 0; v < subEntities; ++v)
356 typename GridView::IndexSet::IndexType index = indexSet.subIndex(el,v,dimension);
358 std::swap(
vtxParam_[ index ], dgfFactory.
parameter(el.template subEntity<dimension>(v) ) );
359 assert(
vtxParam_[ index ].size() == (
size_t)nofVtxParam_ );
362 if ( el.hasBoundaryIntersections() )
365 const IntersectionIterator iend = gridView.
iend(el);
366 for( IntersectionIterator iiter = gridView.
ibegin(el); iiter != iend; ++iiter )
382 template <
class Entity>
385 typedef typename GridType::LevelGridView
GridView;
386 GridView gridView =
gridPtr_->levelGridView( 0 );
396 case GridType::dimension :
419 idSet_(gridPtr->localIdSet())
421 typedef typename GridType::LevelGridView
GridView;
422 GridView gridView = gridPtr_->levelGridView( 0 );
426 typedef typename GridView::template Codim< 0 >::template Partition< partType >::Iterator Iterator;
427 const Iterator enditer = gridView.template end< 0, partType >();
428 for( Iterator iter = gridView.template begin< 0, partType >(); iter != enditer; ++iter )
430 const typename Iterator::Entity &el = *iter;
432 std::swap( gridPtr_.
elParam_[ indexSet.index(el) ], elData_[ idSet_.id(el) ] );
435 for (
int v = 0; v < el.subEntities(dimension); ++v)
437 typename GridView::IndexSet::IndexType index = indexSet.subIndex(el,v,dimension);
438 if ( ! gridPtr_.
vtxParam_[ index ].empty() )
439 std::swap( gridPtr_.
vtxParam_[ index ], vtxData_[ idSet_.subId(el,v,dimension) ] );
447 typedef typename GridType::LevelGridView
GridView;
448 GridView gridView = gridPtr_->levelGridView( 0 );
452 gridPtr_.
elParam_.resize( indexSet.size(0) );
454 gridPtr_.
vtxParam_.resize( indexSet.size(dimension) );
457 typedef typename GridView::template Codim< 0 >::template Partition< partType >::Iterator Iterator;
458 const Iterator enditer = gridView.template end< 0, partType >();
459 for( Iterator iter = gridView.template begin< 0, partType >(); iter != enditer; ++iter )
461 const typename Iterator::Entity &el = *iter;
464 std::swap( gridPtr_.
elParam_[ indexSet.index(el) ], elData_[ idSet_.id(el) ] );
465 assert( gridPtr_.
elParam_[ indexSet.index(el) ].size() == (
unsigned int)gridPtr_.
nofElParam_ );
469 for (
int v = 0; v < el.subEntities(dimension); ++v)
471 typename GridView::IndexSet::IndexType index = indexSet.subIndex(el,v,dimension);
472 if ( gridPtr_.
vtxParam_[ index ].empty() )
473 std::swap( gridPtr_.
vtxParam_[ index ], vtxData_[ idSet_.subId(el,v,dimension) ] );
487 return (codim==dim || codim==0);
495 template<
class EntityType>
496 size_t size (
const EntityType& e)
const
501 template<
class MessageBufferImp,
class EntityType>
502 void gather (MessageBufferImp& buff,
const EntityType& e)
const
504 const std::vector<double> &v = (e.codimension==0) ? elData_[idSet_.id(e)] : vtxData_[idSet_.id(e)];
505 const size_t s = v.size();
506 for (
size_t i=0; i<s; ++i)
508 assert( s == (
size_t)gridPtr_.
nofParameters(e.codimension) );
511 template<
class MessageBufferImp,
class EntityType>
512 void scatter (MessageBufferImp& buff,
const EntityType& e,
size_t n)
514 std::vector<double> &v = (e.codimension==0) ? elData_[idSet_.id(e)] : vtxData_[idSet_.id(e)];
517 for (
size_t i=0; i<n; ++i)
522 typedef typename GridType::LocalIdSet
IdSet;
525 mutable std::map< typename IdSet::IdType, std::vector<double> > elData_, vtxData_;
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
const std::vector< double > & parameters(const Entity &entity) const
get parameters defined for each codim 0 und dim entity on the grid through the grid file ...
Definition: gridptr.hh:267
bool haveBoundaryParameters() const
Definition: dgfgridfactory.hh:156
void loadBalance()
Definition: gridptr.hh:302
Traits::IndexSet IndexSet
type of the index set
Definition: common/gridview.hh:80
std::vector< std::vector< double > > elParam_
Definition: gridptr.hh:531
mygrid_ptr()
Definition: gridptr.hh:85
std::vector< int > bndId_
Definition: gridptr.hh:534
std::vector< DGFBoundaryParameter::type > bndParam_
Definition: gridptr.hh:533
const GridType & operator*() const
return const reference to GridType instance
Definition: gridptr.hh:230
bool fixedsize(int dim, int codim) const
Definition: gridptr.hh:490
GridPtr(GridType *grd)
Constructor storing given pointer to internal auto pointer.
Definition: gridptr.hh:162
GridPtr(const GridPtr &org)
Copy constructor, copies internal auto pointer.
Definition: gridptr.hh:175
GridPtr & operator=(const GridPtr &org)
assignment of grid pointer
Definition: gridptr.hh:188
int nofParameters(const Intersection< GridImp, IntersectionImp > &intersection) const
get number of parameters defined for a given intersection
Definition: gridptr.hh:260
only interior entities
Definition: gridenums.hh:135
const DGFBoundaryParameter::type & parameters(const Intersection< GridImp, IntersectionImp > &intersection) const
get parameters for intersection
Definition: gridptr.hh:293
Wrapper class for entities.
Definition: common/entity.hh:61
int nofParameters(int cdim) const
get number of parameters defined for a given codimension
Definition: gridptr.hh:243
Definition: gridptr.hh:57
GeometryType type() const
obtain the type of reference element for this intersection
Definition: common/intersection.hh:379
Know your own codimension.
Definition: common/entity.hh:104
GridPtr(std::istream &input, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor given a std::istream
Definition: gridptr.hh:132
~DataHandle()
Definition: gridptr.hh:445
size_t size(const EntityType &e) const
Definition: gridptr.hh:496
IntersectionIterator ibegin(const typename Codim< 0 >::Entity &entity) const
obtain begin intersection iterator with respect to this view
Definition: common/gridview.hh:236
Grid view abstract base class.
Definition: common/gridview.hh:58
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: common/intersection.hh:260
std::vector< std::vector< double > > vtxParam_
Definition: gridptr.hh:532
GridType & operator*()
return reference to GridType instance
Definition: gridptr.hh:220
GridType * operator->()
return pointer to GridType instance
Definition: gridptr.hh:225
Id Set Interface.
Definition: common/grid.hh:362
communicate as given in InterfaceType
Definition: gridenums.hh:169
bool boundary() const
Return true if intersection is with interior or exterior boundary (see the cases above) ...
Definition: common/intersection.hh:218
std::vector< double > & params(const Entity &entity)
Definition: gridptr.hh:383
mygrid_ptr gridPtr_
Definition: gridptr.hh:529
~mygrid_ptr()
Definition: gridptr.hh:92
send interior and border, receive all entities
Definition: gridenums.hh:86
MPIHelper::MPICommunicator MPICommunicatorType
Definition: gridptr.hh:111
bool haveBndParam_
Definition: gridptr.hh:539
all entities
Definition: gridenums.hh:139
mygrid_ptr(GridType *grd)
Definition: gridptr.hh:89
static const int dimension
Definition: gridptr.hh:112
void initialize(DGFGridFactory< GridType > &dgfFactory)
Definition: gridptr.hh:321
GridType * release()
Definition: gridptr.hh:102
int nofParameters(const Entity &) const
get parameters defined for given entity
Definition: gridptr.hh:253
std::vector< double > & parameter(const Element &element)
Definition: dgfgridfactory.hh:129
void setNofParams(int cdim, int nofP)
Definition: gridptr.hh:407
PartitionIteratorType
Parameter to be used for the parallel level- and leaf iterators.
Definition: gridenums.hh:134
const DGFBoundaryParameter::type & boundaryParameter(const Intersection< GG, II > &intersection) const
Definition: dgfgridfactory.hh:163
IntersectionIterator iend(const typename Codim< 0 >::Entity &entity) const
obtain end intersection iterator with respect to this view
Definition: common/gridview.hh:243
GridPtr()
Default constructor, creating empty GridPtr.
Definition: gridptr.hh:149
int nofElParam_
Definition: gridptr.hh:537
void gather(MessageBufferImp &buff, const EntityType &e) const
Definition: gridptr.hh:502
Describes the parallel communication interface class for MessageBuffers and DataHandles.
CommDataHandleIF< DataHandle, double > & interface()
Definition: gridptr.hh:480
std::vector< double > emptyParam_
Definition: gridptr.hh:535
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in...
Definition: common/intersection.hh:393
bool contains(int dim, int codim) const
Definition: gridptr.hh:485
Grid * grid()
Definition: dgfgridfactory.hh:95
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:360
const IndexSet & indexSet() const
obtain the index set
Definition: common/gridview.hh:175
std::string type
type of additional boundary parameters
Definition: parser.hh:23
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:72
static const type & defaultValue()
default constructor
Definition: parser.hh:26
void scatter(MessageBufferImp &buff, const EntityType &e, size_t n)
Definition: gridptr.hh:512
GridType * release()
release pointer from internal ownership
Definition: gridptr.hh:240
int nofVtxParam_
Definition: gridptr.hh:538
const GridType * operator->() const
return const pointer to GridType instance
Definition: gridptr.hh:235
Include standard header files.
Definition: agrid.hh:59
GridPtr(const std::string &filename, MPICommunicatorType comm=MPIHelper::getCommunicator())
constructor given the name of a DGF file
Definition: gridptr.hh:115
DataHandle(GridPtr &gridPtr)
Definition: gridptr.hh:417
Traits::IntersectionIterator IntersectionIterator
type of the intersection iterator
Definition: common/gridview.hh:86
Definition: gridptr.hh:415
mygrid_ptr & operator=(const mygrid_ptr &other)
Definition: gridptr.hh:95
int boundaryId(const Intersection &intersection) const
Definition: dgfgridfactory.hh:107
mygrid_ptr(const mygrid_ptr &other)
Definition: gridptr.hh:87
Class for constructing grids from DGF files.
Definition: gridptr.hh:55