dune-grid  2.3.1-rc1
sgrid.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_SGRID_HH
4 #define DUNE_SGRID_HH
5 
6 #include <limits>
7 #include <vector>
8 #include <stack>
9 
10 #include <dune/common/fvector.hh>
11 #include <dune/common/fmatrix.hh>
12 #include <dune/common/bigunsignedint.hh>
13 #include <dune/common/parallel/collectivecommunication.hh>
14 #include <dune/common/reservedvector.hh>
15 #include <dune/geometry/genericgeometry/topologytypes.hh>
16 #include <dune/geometry/axisalignedcubegeometry.hh>
18 #include <dune/grid/common/grid.hh>
19 #include <dune/grid/sgrid/numbering.hh>
21 
27 namespace Dune {
28 
29  //************************************************************************
33  typedef double sgrid_ctype;
34 
35  // globally define the persistent index type
36  const int sgrid_dim_bits = 24; // bits for encoding each dimension
37  const int sgrid_level_bits = 6; // bits for encoding level number
38  const int sgrid_codim_bits = 4; // bits for encoding codimension
39 
40  //************************************************************************
41  // forward declaration of templates
42 
43  template<int dim, int dimworld, class GridImp> class SGeometry;
44  template<int codim, int dim, class GridImp> class SEntity;
45  template<int codim, class GridImp> class SEntityPointer;
46  template<int codim, class GridImp> class SEntitySeed;
47  template<int codim, PartitionIteratorType, class GridImp> class SLevelIterator;
48  template<int dim, int dimworld, class ctype> class SGrid;
49  template<class GridImp> class SIntersection;
50  template<class GridImp> class SIntersectionIterator;
51  template<class GridImp> class SHierarchicIterator;
52 
53  namespace FacadeOptions
54  {
55 
56  template<int dim, int dimworld, class ctype, int mydim, int cdim>
57  struct StoreGeometryReference<mydim, cdim,
58  SGrid<dim,dimworld,ctype>, SGeometry>
59  {
60  static const bool v = false;
61  };
62 
63  template<int dim, int dimworld, class ctype, int mydim, int cdim>
64  struct StoreGeometryReference<mydim, cdim,
65  const SGrid<dim,dimworld,ctype>, SGeometry>
66  {
67  static const bool v = false;
68  };
69 
70  }
71 
72  //************************************************************************
103  template<int mydim, int cdim, class GridImp>
104  class SGeometry
105  : public AxisAlignedCubeGeometry<typename GridImp::ctype,mydim,cdim>
106  {
107  public:
109  typedef typename GridImp::ctype ctype;
110 
118  void make (const FieldVector<ctype,cdim>& lower,
119  const FieldMatrix<ctype,mydim,cdim>& A)
120  {
121  if (mydim==0) {
122  // set up base class
123  static_cast< AxisAlignedCubeGeometry<ctype,mydim,cdim> & >( *this ) = AxisAlignedCubeGeometry<ctype,mydim,cdim>(lower);
124  return;
125  }
126 
127  // construct the upper right corner of the cube geometry
128  FieldVector<ctype, cdim> upper = lower;
129  for (int i=0; i<mydim; i++)
130  upper += A[i];
131 
132  // look for the directions where the cube is actually extended
133  std::bitset<cdim> axes;
134 
135  for (size_t i=0; i<cdim; i++)
136  if ((upper[i] - lower[i]) > 1e-10)
137  axes[i] = true;
138 
139  // set up base class
140  static_cast< AxisAlignedCubeGeometry<ctype,mydim,cdim> & >( *this ) = AxisAlignedCubeGeometry<ctype,mydim,cdim>(lower, upper, axes);
141  }
142 
145  : AxisAlignedCubeGeometry<ctype,mydim,cdim>(FieldVector<ctype,cdim>(0),FieldVector<ctype,cdim>(0)) // anything
146  {}
147  };
148 
149 
150  //************************************************************************
155  template<int codim, int dim, class GridImp, template<int,int,class> class EntityImp>
156  class SEntityBase :
157  public EntityDefaultImplementation<codim,dim,GridImp,EntityImp>
158  {
159  friend class SEntityPointer<codim,GridImp>;
160  friend class SIntersectionIterator<GridImp>;
161  enum { dimworld = GridImp::dimensionworld };
162 
163  typedef typename GridImp::Traits::template Codim< codim >::GeometryImpl GeometryImpl;
164 
165  public:
166  typedef typename GridImp::ctype ctype;
167  typedef typename GridImp::template Codim<codim>::Geometry Geometry;
168  typedef typename GridImp::PersistentIndexType PersistentIndexType;
169 
171  int level () const
172  {
173  return l;
174  }
175 
177  int globalIndex() const;
178 
184  }
185 
188  {
189  static const GeometryType cubeType(GeometryType::cube,dim-codim);
190  return cubeType;
191  }
192 
195  {
196  if (!builtgeometry) makegeometry();
197 
198  // return result
199  return Geometry( geo );
200  }
201 
203 
205  SEntityBase (GridImp* _grid, int _l, int _index) :
206  grid(_grid),
207  l(_l),
208  index(_index),
209  z(grid->z(l,index,codim)),
210  builtgeometry(false) {}
211 
214  builtgeometry(false) // mark geometry as not built
215  {}
216 
218  SEntityBase ( const SEntityBase& other ) :
219  grid(other.grid),
220  l(other.l),
221  index(other.index),
222  z(other.z),
223  geo(), // do not copy geometry
224  builtgeometry(false) // mark geometry as not built
225  {}
226 
228  void make (GridImp* _grid, int _l, int _id);
229 
231  void make (int _l, int _id);
232 
234  void makegeometry () const;
235 
238  {
239  return grid->persistentIndex(l, codim, z);
240  }
241 
243  int compressedIndex () const
244  {
245  return index;
246  }
247 
249  int compressedLeafIndex () const
250  {
251  // codim != dim -> there are no copies of entities
252  // maxlevel -> ids are fine
253  if (codim<dim || l==grid->maxLevel())
254  return compressedIndex();
255 
256  // this is a vertex which is not on the finest level
257  // move coordinates up to maxlevel (multiply by 2 for each level
258  array<int,dim> coord;
259  for (int k=0; k<dim; k++)
260  coord[k] = z[k]*(1<<(grid->maxLevel()-l));
261 
262  // compute number with respect to maxLevel
263  return grid->n(grid->maxLevel(),coord);
264  }
265 
267  int subCompressedIndex (int cd, int i) const
268  {
269  DUNE_THROW(NotImplemented,"subIndex for entities with codimension > 0 is not implemented");
270  return -1;
271  }
272 
274  int subCompressedLeafIndex (int cd, int i) const
275  {
276  DUNE_THROW(NotImplemented,"subIndex for entities with codimension > 0 is not implemented");
277  return -1;
278  }
279 
280  protected:
281  // this is how we implement our elements
282  GridImp* grid;
283  int l;
284  int index;
285  array<int,dim> z;
286  mutable GeometryImpl geo;
287  mutable bool builtgeometry;
288  };
289 
290 
296  template<int codim, int dim, class GridImp>
297  class SEntity : public SEntityBase<codim,dim,GridImp,SEntity>
298  {
300  friend class SEntityPointer<codim,GridImp>;
301  friend class SIntersectionIterator<GridImp>;
302  public:
304  SEntity (GridImp* _grid, int _l, int _id) :
305  SEntityBase(_grid,_l,_id) {}
306  };
307 
334  template<int dim, class GridImp>
335  class SEntity<0,dim,GridImp> : public SEntityBase<0,dim,GridImp,SEntity>
336  {
337  enum { dimworld = GridImp::dimensionworld };
339  using SEntityBase::grid;
340  using SEntityBase::l;
341  using SEntityBase::index;
342  using SEntityBase::z;
343 
344  typedef typename GridImp::Traits::template Codim< 0 >::GeometryImpl GeometryImpl;
345  typedef typename GridImp::Traits::template Codim< 0 >::LocalGeometryImpl LocalGeometryImpl;
346 
347  friend class SEntityPointer<0,GridImp>;
348  friend class SIntersectionIterator<GridImp>;
349 
350  public:
351  typedef typename GridImp::ctype ctype;
352  typedef typename GridImp::template Codim<0>::Geometry Geometry;
353  typedef typename GridImp::template Codim<0>::LocalGeometry LocalGeometry;
354  template <int cd>
355  struct Codim
356  {
357  typedef typename GridImp::template Codim<cd>::EntityPointer EntityPointer;
358  };
359  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
360  typedef typename GridImp::LeafIntersectionIterator IntersectionIterator;
361  typedef typename GridImp::HierarchicIterator HierarchicIterator;
362  typedef typename GridImp::PersistentIndexType PersistentIndexType;
363 
365  friend class SHierarchicIterator<GridImp>;
366 
371  template<int cc> int count () const;
372 
377  template<int cc> typename Codim<cc>::EntityPointer subEntity (int i) const;
378 
380  int subCompressedIndex (int codim, int i) const
381  {
382  if (codim==0) return this->compressedIndex();
383  // compute subIndex
384  return (this->grid)->n(this->l, this->grid->subz(this->z,i,codim));
385  }
386 
390  int subCompressedLeafIndex (int codim, int i) const
391  {
392  if (codim==0) return this->compressedLeafIndex();
393 
394  assert(this->l == this->grid->maxLevel());
395  // compute subIndex
396  return (this->grid)->n(this->l, this->grid->subz(this->z,i,codim));
397  }
398 
400  PersistentIndexType subPersistentIndex (int codim, int i) const
401  {
402  if (codim==0) return this->persistentIndex();
403  // compute subId
404  return this->grid->persistentIndex(this->l, codim, this->grid->subz(this->z,i,codim));
405  }
406 
414  IntersectionIterator ibegin () const;
415  IntersectionIterator ileafbegin () const;
416  IntersectionIterator ilevelbegin () const;
418  IntersectionIterator iend () const;
419  IntersectionIterator ileafend () const;
420  IntersectionIterator ilevelend () const;
421 
427  EntityPointer father () const;
428 
430  bool hasFather () const
431  {
432  return (this->level()>0);
433  }
434 
436  bool isLeaf () const
437  {
438  return ( this->grid->maxLevel() == this->level() );
439  }
440 
452  LocalGeometry geometryInFather () const;
453 
460  HierarchicIterator hbegin (int maxLevel) const;
461 
463  HierarchicIterator hend (int maxLevel) const;
464 
465  // members specific to SEntity
467  SEntity (GridImp* _grid, int _l, int _index) :
468  SEntityBase(_grid,_l,_index),
469  built_father(false)
470  {}
471 
472  SEntity (const SEntity& other ) :
473  SEntityBase(other.grid, other.l, other.index ),
474  built_father(false)
475  {}
476 
478  void make (GridImp* _grid, int _l, int _id)
479  {
480  SEntityBase::make(_grid,_l,_id);
481  built_father = false;
482  }
483 
485  void make (int _l, int _id)
486  {
487  SEntityBase::make(_l,_id);
488  built_father = false;
489  }
490 
491  private:
492 
493  SEntity();
494 
495  mutable bool built_father;
496  mutable int father_index;
497  mutable LocalGeometryImpl in_father_local;
498  void make_father() const;
499  };
500 
501 
502  //************************************************************************
511  int l;
512  int index;
513  SHierarchicStackElem () : l(-1), index(-1) {}
514  SHierarchicStackElem (int _l, int _index) {l=_l; index=_index;}
515  bool operator== (const SHierarchicStackElem& s) const {return !operator!=(s);}
516  bool operator!= (const SHierarchicStackElem& s) const {return l!=s.l || index!=s.index;}
517  };
518 
519  template<class GridImp>
520  class SHierarchicIterator :
521  public Dune::SEntityPointer <0,GridImp>
522  {
523  friend class SHierarchicIterator<const GridImp>;
524  enum { dim = GridImp::dimension };
525  enum { dimworld = GridImp::dimensionworld };
526  typedef Dune::SEntityPointer<0,GridImp> SEntityPointer;
528  using SEntityPointer::grid;
529  using SEntityPointer::l;
530  using SEntityPointer::index;
531  public:
532  typedef typename GridImp::template Codim<0>::Entity Entity;
533  typedef typename GridImp::ctype ctype;
534 
536  void increment();
537 
544  SHierarchicIterator (GridImp* _grid,
546  int _maxLevel, bool makeend) :
547  SEntityPointer(_grid,_e.level(),_e.compressedIndex())
548  {
549  // without sons, we are done
550  // (the end iterator is equal to the calling iterator)
551  if (makeend) return;
552 
553  // remember element where begin has been called
554  orig_l = this->entity().level();
555  orig_index = _grid->getRealImplementation(this->entity()).compressedIndex();
556 
557  // push original element on stack
558  SHierarchicStackElem originalElement(orig_l, orig_index);
559  stack.push(originalElement);
560 
561  // compute maxLevel
562  maxLevel = std::min(_maxLevel,this->grid->maxLevel());
563 
564  // ok, push all the sons as well
565  push_sons(orig_l,orig_index);
566 
567  // and pop the first son
568  increment();
569  }
570 
571  private:
572  int maxLevel;
573  int orig_l, orig_index;
574 
576  std::stack<SHierarchicStackElem, Dune::ReservedVector<SHierarchicStackElem,GridImp::MAXL> > stack;
577 
578  void push_sons (int level, int fatherid);
579  };
580 
581  //************************************************************************
588  template<class GridImp>
589  class SIntersectionIterator
590  {
591  enum { dim=GridImp::dimension };
592  enum { dimworld=GridImp::dimensionworld };
593 
594  typedef typename GridImp::Traits::template Codim< 1 >::GeometryImpl GeometryImpl;
595  typedef typename GridImp::Traits::template Codim< 1 >::LocalGeometryImpl LocalGeometryImpl;
596 
597  friend class SIntersection<GridImp>;
598 
599  public:
600  typedef typename GridImp::template Codim<0>::Entity Entity;
601  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
602  typedef typename GridImp::template Codim<1>::Geometry Geometry;
603  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
607  enum { dimension=dim };
609  enum { dimensionworld=dimworld };
611  typedef typename GridImp::ctype ctype;
612 
614  bool equals(const SIntersectionIterator<GridImp>& i) const;
616  void increment();
617 
619  const Intersection & dereference() const
620  {
621  return intersection;
622  }
623 
626  EntityPointer inside() const;
627 
630  EntityPointer outside() const;
631 
633  bool boundary () const;
634 
635  int boundaryId () const {
636  if (boundary()) return count + 1;
637  return 0;
638  }
639 
640  int boundarySegmentIndex () const {
641  if (boundary())
642  return grid->boundarySegmentIndex(self.level(), count, zred);
643  return -1;
644  }
645 
647  bool neighbor () const;
648 
660  Geometry geometry () const;
661 
664  {
665  static const GeometryType cubeType(GeometryType::cube,dim-1);
666  return cubeType;
667  }
668 
670  int indexInInside () const;
672  int indexInOutside () const;
673 
675  SIntersectionIterator (GridImp* _grid, const SEntity<0,dim,GridImp >* _self, int _count) :
676  self(*_self), ne(self), grid(_grid),
677  partition(_grid->partition(grid->getRealImplementation(ne).l,_self->z)),
678  zred(_grid->compress(grid->getRealImplementation(ne).l,_self->z)),
679  intersection(IntersectionImp(*this))
680  {
681  // make neighbor
682  make(_count);
683  }
684 
686  self(other.self), ne(other.ne), grid(other.grid),
687  partition(other.partition), zred(other.zred),
688  count(other.count), valid_count(other.valid_count),
689  valid_nb(other.valid_nb), is_on_boundary(other.is_on_boundary),
690  built_intersections(false),
691  intersection(IntersectionImp(*this))
692  {}
693 
696  {
697  /* We can't assign the grid */
698  assert(grid == other.grid);
699 
700  /* Assign data from other */
701  self = other.self;
702  ne = other.ne;
703  partition = other.partition;
704  zred = other.zred;
705  count = other.count;
706  valid_count = other.valid_count;
707  valid_nb = other.valid_nb;
708  is_on_boundary = other.is_on_boundary;
709 
710  /* mark cached data as invalid */
711  built_intersections = false;
712 
713  return *this;
714  }
715 
716  private:
717  void make (int _count) const;
718  void makeintersections () const;
719  EntityPointer self;
720  mutable EntityPointer ne;
721  const GridImp * grid;
722  int partition;
723  array<int,dim> zred;
724  mutable int count;
725  mutable bool valid_count;
726  mutable bool valid_nb;
727  mutable bool is_on_boundary;
728  mutable bool built_intersections;
729  mutable LocalGeometryImpl is_self_local;
730  mutable GeometryImpl is_global;
731  mutable LocalGeometryImpl is_nb_local;
732  Intersection intersection;
733  };
734 
735  template<class GridImp>
736  class SIntersection
737  {
738  enum { dim=GridImp::dimension };
739  enum { dimworld=GridImp::dimensionworld };
740  public:
741  typedef typename GridImp::template Codim<0>::Entity Entity;
742  typedef typename GridImp::template Codim<0>::EntityPointer EntityPointer;
743  typedef typename GridImp::template Codim<1>::Geometry Geometry;
746  typedef typename GridImp::template Codim<1>::LocalGeometry LocalGeometry;
749  enum { dimension=dim };
751  enum { dimensionworld=dimworld };
753  typedef typename GridImp::ctype ctype;
754 
755  bool boundary () const
756  {
757  return is.boundary();
758  }
759 
761  int boundaryId () const
762  {
763  return is.boundaryId();
764  }
765 
767  size_t boundarySegmentIndex () const
768  {
769  return is.boundarySegmentIndex();
770  }
771 
773  bool neighbor () const
774  {
775  return is.neighbor();
776  }
777 
780  {
781  return is.inside();
782  }
783 
786  {
787  return is.outside();
788  }
789 
791  bool conforming () const
792  {
793  return true;
794  }
795 
798  {
799  return is.geometryInInside();
800  }
801 
804  {
805  return is.geometryInOutside();
806  }
807 
810  {
811  return is.geometry();
812  }
813 
816  {
817  return is.type();
818  }
819 
821  int indexInInside () const
822  {
823  return is.indexInInside();
824  }
825 
827  int indexInOutside () const
828  {
829  return is.indexInOutside();
830  }
831 
834  {
835  return centerUnitOuterNormal();
836  }
837 
840  {
841  FieldVector<ctype, dimworld> n = centerUnitOuterNormal();
842  n *= is.geometry().integrationElement(local);
843  return n;
844  }
845 
848  {
849  return centerUnitOuterNormal();
850  }
851 
854  {
855  FieldVector<ctype, dimworld> normal(0.0);
856  normal[is.count/2] = (is.count%2) ? 1.0 : -1.0;
857  return normal;
858  }
859 
862 
863  private:
864 #ifndef DOXYGEN // doxygen can't handle this recursive usage
866 #endif
867  };
868 
869  //************************************************************************
870 
874  template <class T>
875  class AutoPtrStack : public std::stack<T*>
876  {
877  public:
879  {
880  while(! this->empty())
881  {
882  T* e = this->top();
883  delete e;
884  this->pop();
885  }
886  }
887  };
888 
891  template<int codim, class GridImp>
892  class SEntityPointer
893  {
894  enum { dim = GridImp::dimension };
895  friend class SIntersectionIterator<GridImp>;
896  public:
898  typedef typename GridImp::template Codim<codim>::Entity Entity;
900  enum { codimension = codim };
901 
903  bool equals(const SEntityPointer<codim,GridImp>& i) const;
905  Entity& dereference() const;
907  int level () const;
908 
910  SEntityPointer (GridImp * _grid, int _l, int _index) :
911  grid(_grid), l(_l), index(_index),
912  e(0)
913  {}
914 
917  grid(_e.grid), l(_e.l), index(_e.index),
918  e(0)
919  {}
920 
923  grid(other.grid), l(other.l), index(other.index),
924  e( 0 )
925  {}
926 
929  {
930  if( e )
931  enStack().push( e );
932 #ifndef NDEBUG
933  index = -1;
934 #endif
935  }
936 
939  {
940  grid = other.grid;
941  l = other.l;
942  index = other.index;
943 
944  // free current entity
945  if( e )
946  enStack().push( e );
947  e = 0;
948 
949  return *this;
950  }
951 
952  protected:
954  {
955  return grid->getRealImplementation(entity());
956  }
957 
958  inline Entity& entity() const
959  {
960  if( ! e )
961  {
962  e = getEntity( grid, l, index );
963  }
964  return *e;
965  }
966 
968  static inline EntityStackType& enStack()
969  {
970  static EntityStackType eStack;
971  return eStack;
972  }
973 
974  inline Entity* getEntity(GridImp* _grid, int _l, int _id ) const
975  {
976  // get stack reference
977  EntityStackType& enSt = enStack();
978 
979  if( enSt.empty() )
980  {
981  return (new Entity(SEntity<codim,dim,GridImp>(_grid, _l, _id)));
982  }
983  else
984  {
985  Entity* e = enSt.top();
986  enSt.pop();
987  grid->getRealImplementation(*e).make(_grid, _l,_id);
988  return e;
989  }
990  }
991 
992  GridImp* grid;
993  int l;
994  mutable int index;
995  mutable Entity* e;
996  };
997 
1000  template<int codim, class GridImp>
1001  class SEntitySeed
1002  {
1003  enum { dim = GridImp::dimension };
1004  public:
1005  enum { codimension = codim };
1006 
1009  _l(-1), _index(0)
1010  {}
1011 
1013  SEntitySeed (int l, int index) :
1014  _l(l), _index(index)
1015  {}
1016 
1018  bool isValid() const
1019  {
1020  return _l != -1;
1021  }
1022 
1023  int level () const { return this->_l; }
1024  int index () const { return this->_index; }
1025 
1026  private:
1027  int _l;
1028  int _index;
1029  };
1030 
1031  //************************************************************************
1032 
1033 
1036  template<int codim, PartitionIteratorType pitype, class GridImp>
1037  class SLevelIterator :
1038  public Dune::SEntityPointer <codim,GridImp>
1039  {
1040  friend class SLevelIterator<codim, pitype,const GridImp>;
1041  enum { dim = GridImp::dimension };
1044  using SEntityPointer::l;
1045  using SEntityPointer::index;
1046  public:
1047  typedef typename GridImp::template Codim<codim>::Entity Entity;
1048 
1050  void increment();
1051 
1053  SLevelIterator (GridImp * _grid, int _l, int _id) :
1054  SEntityPointer(_grid,_l,_id) {}
1055  };
1056 
1057 
1058  //========================================================================
1063  //========================================================================
1064 
1065  template<class GridImp>
1066  class SGridLevelIndexSet : public IndexSet<GridImp,SGridLevelIndexSet<GridImp> >
1067  {
1070 
1071  enum { dim = GridImp::dimension };
1072 
1073  public:
1074 
1076  SGridLevelIndexSet ( const GridImp &g, int l )
1077  : grid( g ),
1078  level( l )
1079  {
1080  // TODO move list of geometrytypes to grid, can be computed static (singleton)
1081  // contains a single element type;
1082  for (int codim=0; codim<=GridImp::dimension; codim++)
1083  mytypes[codim].push_back(GeometryType(GeometryType::cube,GridImp::dimension-codim));
1084  }
1085 
1087  template<int cd>
1088  int index (const typename GridImp::Traits::template Codim<cd>::Entity& e) const
1089  {
1090  return grid.getRealImplementation(e).compressedIndex();
1091  }
1092 
1093  template< int cc >
1094  int subIndex ( const typename GridImp::Traits::template Codim< cc >::Entity &e,
1095  int i, unsigned int codim ) const
1096  {
1097  if( cc == 0 )
1098  return grid.getRealImplementation(e).subCompressedIndex(codim, i);
1099  else
1100  DUNE_THROW( NotImplemented, "subIndex for higher codimension entity not implemented for SGrid." );
1101  }
1102 
1103  // return true if the given entity is contained in \f$E\f$.
1104  template< class EntityType >
1105  bool contains ( const EntityType &e ) const
1106  {
1107  return (e.level() == level);
1108  }
1109 
1111  int size (GeometryType type) const
1112  {
1113  return grid.size( level, type );
1114  }
1115 
1117  int size (int codim) const
1118  {
1119  return grid.size( level, codim );
1120  }
1121 
1123  const std::vector<GeometryType>& geomTypes (int codim) const
1124  {
1125  return mytypes[codim];
1126  }
1127 
1128  private:
1129  const GridImp& grid;
1130  int level;
1131  std::vector<GeometryType> mytypes[GridImp::dimension+1];
1132  };
1133 
1134 
1135 
1136  //========================================================================
1141  //========================================================================
1142 
1143  template<class GridImp>
1145  public IdSet<GridImp,SGridGlobalIdSet<GridImp>, typename remove_const<GridImp>::type::PersistentIndexType>
1146  /*
1147  We used the remove_const to extract the Type from the mutable class,
1148  because the const class is not instantiated yet.
1149  */
1150  {
1152 
1153  public:
1154 
1156  /*
1157  We use the remove_const to extract the Type from the mutable class,
1158  because the const class is not instantiated yet.
1159  */
1160  typedef typename remove_const<GridImp>::type::PersistentIndexType IdType;
1161 
1163  /*
1164  We use the remove_const to extract the Type from the mutable class,
1165  because the const class is not instantiated yet.
1166  */
1167  template<int cd>
1168  IdType id (const typename remove_const<GridImp>::type::Traits::template Codim<cd>::Entity& e) const
1169  {
1170  return GridImp::getRealImplementation(e).persistentIndex();
1171  }
1172 
1174  /*
1175  We use the remove_const to extract the Type from the mutable class,
1176  because the const class is not instantiated yet.
1177  */
1178  IdType subId ( const typename remove_const< GridImp >::type::Traits::template Codim< 0 >::Entity &e,
1179  int i, unsigned int codim ) const
1180  {
1181  return GridImp::getRealImplementation(e).subPersistentIndex(codim, i);
1182  }
1183  };
1184 
1185 
1186  template<int dim, int dimworld, class ctype>
1188  {
1192  SIntersection, // leaf intersection
1193  SIntersection, // level intersection
1194  SIntersectionIterator, // leaf intersection iter
1195  SIntersectionIterator, // level intersection iter
1201  bigunsignedint<dim*sgrid_dim_bits+sgrid_level_bits+sgrid_codim_bits>,
1203  bigunsignedint<dim*sgrid_dim_bits+sgrid_level_bits+sgrid_codim_bits>,
1204  CollectiveCommunication<Dune::SGrid<dim,dimworld,ctype> >,
1206  SEntitySeed>
1208  };
1209 
1210 
1211  //************************************************************************
1266  template<int dim, int dimworld, typename _ctype = sgrid_ctype>
1267  class SGrid : public GridDefaultImplementation <dim,dimworld,_ctype,SGridFamily<dim,dimworld,_ctype> >
1268  {
1269  public:
1271  typedef bigunsignedint<dim*sgrid_dim_bits+sgrid_level_bits+sgrid_codim_bits> PersistentIndexType;
1272 
1273  // need for friend declarations in entity
1277 
1279 
1281  enum { MAXL=32 };
1282 
1284  typedef _ctype ctype;
1285 
1286  // constructors
1287 
1295  SGrid (const int * const N_, const ctype * const H_);
1296 
1304  SGrid (const int * const N_, const ctype * const L_, const ctype * const H_);
1305 
1315  SGrid (FieldVector<int,dim> N_, FieldVector<ctype,dim> L_, FieldVector<ctype,dim> H_);
1316 
1318  SGrid ();
1319 
1321  ~SGrid ();
1322 
1325  int maxLevel() const;
1326 
1328  template<int cd, PartitionIteratorType pitype>
1329  typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator lbegin (int level) const;
1330 
1332  template<int cd, PartitionIteratorType pitype>
1333  typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator lend (int level) const;
1334 
1336  template<int cd>
1337  typename Traits::template Codim<cd>::template Partition<All_Partition>::LevelIterator lbegin (int level) const
1338  {
1339  return lbegin<cd,All_Partition>(level);
1340  }
1341 
1343  template<int cd>
1344  typename Traits::template Codim<cd>::template Partition<All_Partition>::LevelIterator lend (int level) const
1345  {
1346  return lend<cd,All_Partition>(level);
1347  }
1348 
1350  template<int cd, PartitionIteratorType pitype>
1351  typename Traits::template Codim<cd>::template Partition<pitype>::LeafIterator leafbegin () const;
1352 
1354  template<int cd, PartitionIteratorType pitype>
1355  typename Traits::template Codim<cd>::template Partition<pitype>::LeafIterator leafend () const;
1356 
1358  template<int cd>
1360  {
1361  return leafbegin<cd,All_Partition>();
1362  }
1363 
1365  template<int cd>
1367  {
1368  return leafend<cd,All_Partition>();
1369  }
1370 
1371  // \brief obtain EntityPointer from EntitySeed. */
1372  template <typename Seed>
1373  typename Traits::template Codim<Seed::codimension>::EntityPointer
1374  entityPointer(const Seed& seed) const
1375  {
1376  enum { codim = Seed::codimension };
1378  this->getRealImplementation(seed).level(),
1379  this->getRealImplementation(seed).index());
1380  }
1381 
1395  template<class T, template<class> class P, int codim>
1396  void communicate (T& t, InterfaceType iftype, CommunicationDirection dir, int level)
1397  {
1398  // SGrid is sequential and has no periodic boundaries, so do nothing ...
1399  return;
1400  }
1401 
1403  int size (int level, int codim) const;
1404 
1406  int size (int codim) const
1407  {
1408  return size(maxLevel(),codim);
1409  }
1410 
1412  int size (int level, GeometryType type) const
1413  {
1414  return (type.isCube()) ? size(level,dim-type.dim()) : 0;
1415  }
1416 
1418  int size (GeometryType type) const
1419  {
1420  return size(maxLevel(),type);
1421  }
1422 
1424  size_t numBoundarySegments () const
1425  {
1426  return boundarysize;
1427  }
1428 
1430  int global_size (int codim) const;
1431 
1433  int overlapSize (int level, int codim)
1434  {
1435  return 0;
1436  }
1437 
1439  int ghostSize (int level, int codim)
1440  {
1441  return 0;
1442  }
1443 
1444  // these are all members specific to sgrid
1445 
1447  void globalRefine (int refCount);
1448 
1450  const array<int, dim>& dims(int level) const {
1451  return N[level];
1452  }
1453 
1455  const FieldVector<ctype, dimworld>& lowerLeft() const {
1456  return low;
1457  }
1458 
1460  FieldVector<ctype, dimworld> upperRight() const {
1461  return H;
1462  }
1463 
1465  bool adapt ()
1466  {
1467  globalRefine(1);
1468  return true;
1469  }
1470 
1471  // The new index sets from DDM 11.07.2005
1472  const typename Traits::GlobalIdSet& globalIdSet() const
1473  {
1474  return theglobalidset;
1475  }
1476 
1477  const typename Traits::LocalIdSet& localIdSet() const
1478  {
1479  return theglobalidset;
1480  }
1481 
1482  const typename Traits::LevelIndexSet& levelIndexSet(int level) const
1483  {
1484  assert(level>=0 && level<=maxLevel());
1485  return *(indexsets[level]);
1486  }
1487 
1488  const typename Traits::LeafIndexSet& leafIndexSet() const
1489  {
1490  return *indexsets.back();
1491  }
1492 
1497  template<class DataHandle>
1498  void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir, int level) const
1499  {}
1500 
1501  template<class DataHandle>
1502  void communicate (DataHandle& data, InterfaceType iftype, CommunicationDirection dir) const
1503  {}
1504 
1505  const CollectiveCommunication<SGrid>& comm () const
1506  {
1507  return ccobj;
1508  }
1509 
1511  int overlapSize (int level, int codim) const
1512  {
1513  return 0;
1514  }
1515 
1517  int overlapSize (int codim) const
1518  {
1519  return 0;
1520  }
1521 
1523  int ghostSize (int level, int codim) const
1524  {
1525  return 0;
1526  }
1527 
1529  int ghostSize (int codim) const
1530  {
1531  return 0;
1532  }
1533 
1534  /*
1535  @}
1536  */
1537 
1538  private:
1539  /*
1540  Make associated classes friends to grant access to the real entity
1541  */
1542  friend class Dune::SGridLevelIndexSet<Dune::SGrid<dim,dimworld> >;
1543  friend class Dune::SGridGlobalIdSet<Dune::SGrid<dim,dimworld> >;
1544  friend class Dune::SIntersectionIterator<Dune::SGrid<dim,dimworld> >;
1545  friend class Dune::SHierarchicIterator<Dune::SGrid<dim,dimworld> >;
1546  friend class Dune::SEntity<0,dim,Dune::SGrid<dim,dimworld> >;
1547 
1548  friend class Dune::SGridLevelIndexSet<const Dune::SGrid<dim,dimworld> >;
1549  friend class Dune::SGridGlobalIdSet<const Dune::SGrid<dim,dimworld> >;
1550  friend class Dune::SIntersectionIterator<const Dune::SGrid<dim,dimworld> >;
1551  friend class Dune::SHierarchicIterator<const Dune::SGrid<dim,dimworld> >;
1552  friend class Dune::SEntity<0,dim,const Dune::SGrid<dim,dimworld> >;
1553 
1554  template<int codim_, int dim_, class GridImp_, template<int,int,class> class EntityImp_>
1555  friend class Dune::SEntityBase;
1556 
1557  template<int codim_, class GridImp_>
1558  friend class Dune::SEntityPointer;
1559 
1560  template<int codim_, int dim_, class GridImp_, template<int,int,class> class EntityImp_>
1561  friend class Entity;
1562 
1564  FieldVector<ctype, dimworld> pos (int level, array<int,dim>& z) const;
1565 
1567  int calc_codim (int level, const array<int,dim>& z) const;
1568 
1570  int n (int level, const array<int,dim>& z) const;
1571 
1573  array<int,dim> z (int level, int i, int codim) const;
1574 
1576  array<int,dim> subz (const array<int,dim> & z, int i, int codim) const;
1577 
1579  array<int,dim> compress (int level, const array<int,dim>& z) const;
1580 
1582  array<int,dim> expand (int level, const array<int,dim>& r, int b) const;
1583 
1587  int partition (int level, const array<int,dim>& z) const;
1588 
1590  bool exists (int level, const array<int,dim>& zred) const;
1591 
1592  // compute boundary segment index for a given zentity and a face
1593  int boundarySegmentIndex (int l, int face, const array<int,dim> & zentity) const
1594  {
1595  array<int,dim-1> zface;
1596  int dir = face/2;
1597  int side = face%2;
1598  // compute z inside the global face
1599  for (int i=0; i<dir; i++) zface[i] = zentity[i]/(1<<l);
1600  for (int i=dir+1; i<dim; i++) zface[i-1] = zentity[i]/(1<<l);
1601  zface = boundarymapper[dir].expand(zface, 0);
1602  // compute index in the face
1603  int index = boundarymapper[dir].n(zface);
1604  // compute offset
1605  for (int i=0; i<dir; i++)
1606  index += 2*boundarymapper[i].elements(0);
1607  index += side*boundarymapper[dir].elements(0);
1608  return index;
1609  }
1610 
1611  // compute persistent index for a given zentity
1612  PersistentIndexType persistentIndex (int l, int codim, const array<int,dim> & zentity) const
1613  {
1614  if (codim!=dim)
1615  {
1616  // encode codim, this would actually not be necessary
1617  // because z is unique in codim
1618  PersistentIndexType id(codim);
1619 
1620  // encode level
1621  id = id << sgrid_level_bits;
1622  id = id+PersistentIndexType(l);
1623 
1624  // encode coordinates
1625  for (int i=dim-1; i>=0; i--)
1626  {
1627  id = id << sgrid_dim_bits;
1628  id = id+PersistentIndexType(zentity[i]);
1629  }
1630 
1631  return id;
1632  }
1633  else
1634  {
1635  // determine min number of trailing zeroes
1636  // consider that z is on the doubled grid !
1637  int trailing = 1000;
1638  for (int i=0; i<dim; i++)
1639  {
1640  // count trailing zeros
1641  int zeros = 0;
1642  for (int j=0; j<l; j++)
1643  if (zentity[i]&(1<<(j+1)))
1644  break;
1645  else
1646  zeros++;
1647  trailing = std::min(trailing,zeros);
1648  }
1649 
1650  // determine the level of this vertex
1651  int level = l-trailing;
1652 
1653  // encode codim
1654  PersistentIndexType id(dim);
1655 
1656  // encode level
1657  id = id << sgrid_level_bits;
1658  id = id+PersistentIndexType(level);
1659 
1660  // encode coordinates
1661  for (int i=dim-1; i>=0; i--)
1662  {
1663  id = id << sgrid_dim_bits;
1664  id = id+PersistentIndexType(zentity[i]>>trailing);
1665  }
1666 
1667  return id;
1668  }
1669  }
1670 
1671  // disable copy and assign
1672  SGrid(const SGrid &) {}
1673  SGrid & operator = (const SGrid &) { return *this; }
1674  // generate SGrid
1675  void makeSGrid (const array<int,dim>& N_, const FieldVector<ctype, dim>& L_, const FieldVector<ctype, dim>& H_);
1676 
1677  /*
1678  internal data
1679  */
1680  CollectiveCommunication<SGrid> ccobj;
1681 
1682  ReservedVector<SGridLevelIndexSet<const SGrid<dim,dimworld> >*, MAXL> indexsets;
1683  SGridGlobalIdSet<const SGrid<dim,dimworld> > theglobalidset;
1684 
1685  int L; // number of levels in hierarchic mesh 0<=level<L
1686  FieldVector<ctype, dim> low; // lower left corner of the grid
1687  FieldVector<ctype, dim> H; // length of cube per direction
1688  std::vector<array<int,dim> > N; // number of elements per direction for each level
1689  std::vector<FieldVector<ctype, dim> > h; // mesh size per direction for each level
1690  mutable CubeMapper<dim> *mapper; // a mapper for each level
1691 
1692  // boundary segement index set
1693  array<CubeMapper<dim-1>, dim> boundarymapper; // a mapper for each coarse grid face
1694  int boundarysize;
1695  };
1696 
1697  namespace Capabilities
1698  {
1699 
1711  template<int dim, int dimw>
1712  struct hasSingleGeometryType< SGrid<dim,dimw> >
1713  {
1714  static const bool v = true;
1715  static const unsigned int topologyId = GenericGeometry :: CubeTopology< dim > :: type :: id ;
1716  };
1717 
1721  template<int dim, int dimw>
1722  struct isCartesian< SGrid<dim,dimw> >
1723  {
1724  static const bool v = true;
1725  };
1726 
1730  template<int dim, int dimw, int cdim>
1731  struct hasEntity< SGrid<dim,dimw>, cdim>
1732  {
1733  static const bool v = true;
1734  };
1735 
1739  template<int dim, int dimw>
1740  struct isLevelwiseConforming< SGrid<dim,dimw> >
1741  {
1742  static const bool v = true;
1743  };
1744 
1748  template<int dim, int dimw>
1749  struct isLeafwiseConforming< SGrid<dim,dimw> >
1750  {
1751  static const bool v = true;
1752  };
1753 
1754  } // end namespace Capabilities
1755 
1756 } // end namespace Dune
1757 
1758 #include "sgrid/sgrid.cc"
1759 
1760 #endif
Entity & dereference() const
dereferencing
void make(GridImp *_grid, int _l, int _id)
Reinitialization.
Entity * getEntity(GridImp *_grid, int _l, int _id) const
Definition: sgrid.hh:974
int subCompressedIndex(int codim, int i) const
subentity compressed index
Definition: sgrid.hh:380
implementation of index set
Definition: sgrid.hh:1066
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: common/capabilities.hh:45
GridImp::ctype ctype
Definition: sgrid.hh:351
GeometryType type() const
return the element type identifier
Definition: sgrid.hh:187
A Traits struct that collects all associated types of one implementation.
Definition: common/grid.hh:435
int l
level where element is on
Definition: sgrid.hh:993
Definition: sgrid.hh:1187
const Traits::LocalIdSet & localIdSet() const
Definition: sgrid.hh:1477
int indexInInside() const
local index of codim 1 entity in self where intersection is contained in
GridImp * grid
grid containes mapper, geometry, etc.
Definition: sgrid.hh:282
bool contains(const EntityType &e) const
Definition: sgrid.hh:1105
int indexInOutside() const
local index of codim 1 entity in neighbor where intersection is contained in
int level() const
ask for level of entity
SHierarchicStackElem()
Definition: sgrid.hh:513
static ReturnImplementationType< InterfaceType >::ImplementationType & getRealImplementation(InterfaceType &i)
return real implementation of interface class
Definition: common/grid.hh:1223
Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator leafend() const
return LeafIterator which points behind the last entity
Definition: sgrid.hh:1366
static const bool v
Definition: common/capabilities.hh:57
SEntityBase(GridImp *_grid, int _l, int _index)
constructor
Definition: sgrid.hh:205
Definition: defaultgridview.hh:223
SGridGlobalIdSet< SGrid< dim, dimworld > > GlobalIdSetType
Definition: sgrid.hh:1276
EntityPointer outside() const
int l
Definition: sgrid.hh:511
const Traits::LeafIndexSet & leafIndexSet() const
Definition: sgrid.hh:1488
SGridLevelIndexSet(const GridImp &g, int l)
constructor stores reference to a grid and level
Definition: sgrid.hh:1076
int size(int codim) const
number of leaf entities per codim in this process
Definition: sgrid.hh:1406
Definition: sgrid.hh:335
Wrapper class for entities.
Definition: common/entity.hh:56
GridImp::HierarchicIterator HierarchicIterator
Definition: sgrid.hh:361
bool isValid() const
check whether the EntitySeed refers to a valid Entity
Definition: sgrid.hh:1018
Dune::SIntersection< GridImp > IntersectionImp
Definition: sgrid.hh:604
size_t boundarySegmentIndex() const
index of the boundary segment within the macro grid
Definition: sgrid.hh:767
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
SEntityPointer< codim, GridImp > EntityPointerImp
Definition: sgrid.hh:897
GridImp::template Codim< 0 >::Entity Entity
Definition: sgrid.hh:741
const CollectiveCommunication< SGrid > & comm() const
Definition: sgrid.hh:1505
GlobalCoordinate outerNormal(const LocalCoordinate &local) const
Return an outer normal (length not necessarily 1)
Definition: sgrid.hh:833
int subCompressedIndex(int cd, int i) const
subentity compressed index (not available here)
Definition: sgrid.hh:267
int size(int level, int codim) const
number of grid entities per level and codim
Enables iteration over all codim zero entities in a subtree See also the documentation of Dune::Entit...
Definition: common/hierarchiciterator.hh:31
int overlapSize(int codim) const
return size (= distance in graph) of overlap region
Definition: sgrid.hh:1517
Index Set Interface base class.
Definition: common/grid.hh:359
GridImp::PersistentIndexType PersistentIndexType
Definition: sgrid.hh:168
AutoPtrStack< Entity > EntityStackType
Definition: sgrid.hh:967
IdType id(const typename remove_const< GridImp >::type::Traits::template Codim< cd >::Entity &e) const
get id of an entity
Definition: sgrid.hh:1168
GridImp::template Codim< 0 >::LocalGeometry LocalGeometry
Definition: sgrid.hh:353
a stack of pointers with auto destruction if the stack is destructed
Definition: sgrid.hh:875
const Traits::LevelIndexSet & levelIndexSet(int level) const
Definition: sgrid.hh:1482
SGridLevelIndexSet< SGrid< dim, dimworld > > LeafIndexSetType
Definition: sgrid.hh:1275
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Definition: sgrid.hh:746
SIntersectionIterator(GridImp *_grid, const SEntity< 0, dim, GridImp > *_self, int _count)
constructor
Definition: sgrid.hh:675
LocalGeometry geometryInOutside() const
geometrical information about this intersection in local coordinates of the outside() entity...
Definition: sgrid.hh:803
bool adapt()
map adapt to global refine
Definition: sgrid.hh:1465
GlobalCoordinate centerUnitOuterNormal() const
Return unit outer normal (length == 1)
Definition: sgrid.hh:853
SLevelIterator(GridImp *_grid, int _l, int _id)
constructor
Definition: sgrid.hh:1053
Definition: sgrid.hh:751
SEntity(GridImp *_grid, int _l, int _index)
constructor
Definition: sgrid.hh:467
int boundaryId() const
Definition: sgrid.hh:635
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
Definition: sgrid.hh:1412
Definition: alugrid/common/declaration.hh:18
Wrapper class for pointers to entities.
Definition: common/entitypointer.hh:91
Traits::template Codim< cd >::template Partition< pitype >::LeafIterator leafend() const
one past the end on the leaf level
SEntity(GridImp *_grid, int _l, int _id)
constructor
Definition: sgrid.hh:304
persistent, globally unique Ids
Definition: sgrid.hh:1144
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: sgrid.hh:109
[ provides Dune::Grid ]
Definition: sgrid.hh:48
static const bool v
Definition: common/capabilities.hh:48
bool operator==(const SHierarchicStackElem &s) const
Definition: sgrid.hh:515
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:164
int size(GeometryType type) const
get number of entities of given type and level (the level is known to the object) ...
Definition: sgrid.hh:1111
remove_const< const Dune::SGrid< dim, dimworld > >::type::PersistentIndexType IdType
Type used to represent an id.
Definition: indexidset.hh:406
int subCompressedLeafIndex(int cd, int i) const
subentity compressed leaf index (not available here)
Definition: sgrid.hh:274
const FieldVector< ctype, dimworld > & lowerLeft() const
Get lower left corner.
Definition: sgrid.hh:1455
void increment()
increment
GridImp::template Codim< 0 >::EntityPointer EntityPointer
Definition: sgrid.hh:742
Wrapper class for geometries.
Definition: common/geometry.hh:101
void globalRefine(int refCount)
Refine mesh globally by one refCount levels.
int subCompressedLeafIndex(int codim, int i) const
Definition: sgrid.hh:390
SEntitySeed(int l, int index)
constructor
Definition: sgrid.hh:1013
bool boundary() const
Definition: sgrid.hh:755
const Traits::GlobalIdSet & globalIdSet() const
Definition: sgrid.hh:1472
void increment()
increment
PartitionType partitionType() const
Definition: sgrid.hh:202
Types for GridView.
Definition: common/grid.hh:418
GridImp::template Codim< 0 >::EntityPointer EntityPointer
Definition: sgrid.hh:601
SEntityPointer(const SEntityPointer< codim, GridImp > &other)
constructor
Definition: sgrid.hh:922
int ghostSize(int level, int codim) const
return size (= distance in graph) of ghost region
Definition: sgrid.hh:1523
Entity * e
virtual entity
Definition: sgrid.hh:995
bool equals(const SIntersectionIterator< GridImp > &i) const
equality
int ghostSize(int codim) const
return size (= distance in graph) of ghost region
Definition: sgrid.hh:1529
Traits class determining whether the Dune::Geometry facade class stores the implementation object by ...
Definition: common/geometry.hh:46
LocalGeometry geometryInInside() const
geometrical information about this intersection in local coordinates of the inside() entity...
Definition: sgrid.hh:797
bool hasFather() const
returns true if father entity exists
Definition: sgrid.hh:430
Specialize with 'true' if implementation guarantees conforming level grids. (default=false) ...
Definition: common/capabilities.hh:86
Definition: sgrid.hh:46
Provides base classes for index and id sets.
int compressedIndex() const
consecutive, codim-wise, level-wise index
Definition: sgrid.hh:243
bool isLeaf() const
return true if the entity is leaf
Definition: sgrid.hh:436
GridImp::template Codim< 1 >::Geometry Geometry
Definition: sgrid.hh:602
const std::vector< GeometryType > & geomTypes(int codim) const
deliver all geometry types used in this grid
Definition: sgrid.hh:1123
bool equals(const SEntityPointer< codim, GridImp > &i) const
equality
GridImp::ctype ctype
Definition: sgrid.hh:533
Geometry geometry() const
SIntersectionIterator & operator=(const SIntersectionIterator &other)
assignment operator
Definition: sgrid.hh:695
int boundaryId() const
Identifier for boundary segment from macro grid.
Definition: sgrid.hh:761
int global_size(int codim) const
number of grid entities of all level for given codim
int size(int codim) const
return size of set for a given codim
Definition: sgrid.hh:1117
SEntityBase()
empty constructor
Definition: sgrid.hh:213
Geometry::LocalCoordinate LocalCoordinate
Definition: sgrid.hh:744
Entity & entity() const
Definition: sgrid.hh:958
void communicate(T &t, InterfaceType iftype, CommunicationDirection dir, int level)
Definition: sgrid.hh:1396
GridImp::template Codim< codim >::Entity Entity
Definition: sgrid.hh:1047
Definition: sgrid.hh:47
int overlapSize(int level, int codim) const
return size (= distance in graph) of overlap region
Definition: sgrid.hh:1511
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: common/geometry.hh:133
Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator lend(int level) const
one past the end on this level
Definition: sgrid.hh:1344
Traits::template Codim< cd >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to the first entity
GridImp::template Codim< codim >::Entity Entity
Definition: sgrid.hh:898
Definition: sgrid.hh:510
GridImp::template Codim< 0 >::EntityPointer EntityPointer
Definition: sgrid.hh:359
int subIndex(const typename GridImp::Traits::template Codim< cc >::Entity &e, int i, unsigned int codim) const
Definition: sgrid.hh:1094
const array< int, dim > & dims(int level) const
Get number of elements in each coordinate direction.
Definition: sgrid.hh:1450
int index(const typename GridImp::Traits::template Codim< cd >::Entity &e) const
get index of an entity
Definition: sgrid.hh:1088
~SEntityPointer()
destructor pointer
Definition: sgrid.hh:928
int size(GeometryType type) const
number of leaf entities per codim and geometry type in this process
Definition: sgrid.hh:1418
Definition: sgrid.hh:44
int l
level where element is on
Definition: sgrid.hh:283
int maxLevel() const
IdType subId(const typename remove_const< GridImp >::type::Traits::template Codim< 0 >::Entity &e, int i, unsigned int codim) const
get id of subentity
Definition: sgrid.hh:1178
SEntitySeed< codim, GridImp > seed() const
Return the entity seed which contains sufficient information to generate the entity again and uses as...
Definition: sgrid.hh:182
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: common/geometry.hh:136
int indexInInside() const
Local index of codim 1 entity in the inside() entity where intersection is contained in...
Definition: sgrid.hh:821
SEntity< codim, dim, GridImp > & realEntity() const
Definition: sgrid.hh:953
SEntityBase(const SEntityBase &other)
copy constructor
Definition: sgrid.hh:218
int ghostSize(int level, int codim)
return size (= distance in graph) of ghost region
Definition: sgrid.hh:1439
bool operator!=(const SHierarchicStackElem &s) const
Definition: sgrid.hh:516
Default Implementations for EntityImp.
Definition: common/entity.hh:552
int index
my consecutive index
Definition: sgrid.hh:994
PersistentIndexType persistentIndex() const
globally unique, persistent index
Definition: sgrid.hh:237
Geometry geometry() const
geometrical information about the intersection in global coordinates.
Definition: sgrid.hh:809
SEntitySeed()
default constructor (invalid)
Definition: sgrid.hh:1008
~SGrid()
SGrid destructor.
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: sgrid.hh:753
SEntityPointer(GridImp *_grid, int _l, int _index)
constructor
Definition: sgrid.hh:910
static const bool v
Whether to store by reference.
Definition: common/geometry.hh:49
Definition: sgrid.hh:45
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false) ...
Definition: common/capabilities.hh:95
bool neighbor() const
return true if intersection is shared with another element.
Definition: sgrid.hh:773
GridImp::template Codim< 0 >::Entity Entity
Definition: sgrid.hh:532
int index() const
Definition: sgrid.hh:1024
GridImp::PersistentIndexType PersistentIndexType
Definition: sgrid.hh:362
SIntersection(const SIntersectionIterator< GridImp > &is_)
constructor
Definition: sgrid.hh:861
int level() const
Definition: sgrid.hh:1023
Definition: sgrid.hh:49
SGrid()
empty constructor making grid of unit square discretized with one cell
void makegeometry() const
geometry of this entity
Definition: sgrid.hh:43
const int sgrid_dim_bits
Definition: sgrid.hh:36
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: common/grid.hh:358
GridImp::template Codim< codim >::Geometry Geometry
Definition: sgrid.hh:167
GridImp::ctype ctype
Definition: sgrid.hh:166
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
PersistentIndexType subPersistentIndex(int codim, int i) const
subentity persistent index
Definition: sgrid.hh:400
void make(GridImp *_grid, int _l, int _id)
Reinitialization.
Definition: sgrid.hh:478
SIntersectionIterator(const SIntersectionIterator &other)
Definition: sgrid.hh:685
A set of traits classes to store static information about grid implementation.
Definition: sgrid.hh:51
EntityPointer inside() const
return EntityPointer to the Entity on the inside of this intersection.
Definition: sgrid.hh:779
GeometryImpl geo
geometry, is only built on demand
Definition: sgrid.hh:286
GridImp * grid
my grid
Definition: sgrid.hh:992
Definition: sgrid.hh:1005
static const bool v
Definition: common/capabilities.hh:26
LocalGeometry geometryInInside() const
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: albertagrid/dgfparser.hh:26
static const bool v
Definition: common/capabilities.hh:88
static const unsigned int topologyId
Definition: common/capabilities.hh:29
SGridFamily< dim, dimworld, _ctype > GridFamily
Definition: sgrid.hh:1270
int index
my consecutive index
Definition: sgrid.hh:284
EntityPointer inside() const
Definition: sgrid.hh:749
GlobalCoordinate unitOuterNormal(const LocalCoordinate &local) const
Return unit outer normal (length == 1)
Definition: sgrid.hh:847
int indexInOutside() const
Local index of codim 1 entity in outside() entity where intersection is contained in...
Definition: sgrid.hh:827
bool boundary() const
return true if intersection is with boundary.
Geometry geometry() const
geometry of this entity
Definition: sgrid.hh:194
bigunsignedint< dim *sgrid_dim_bits+sgrid_level_bits+sgrid_codim_bits > PersistentIndexType
Definition: sgrid.hh:1271
_ctype ctype
define type used for coordinates in grid module
Definition: sgrid.hh:1284
void communicate(DataHandle &data, InterfaceType iftype, CommunicationDirection dir) const
Definition: sgrid.hh:1502
int globalIndex() const
global index is calculated from the index and grid size
~AutoPtrStack()
Definition: sgrid.hh:878
Specialize with 'true' for all codims that a grid implements entities for. (default=false) ...
Definition: common/capabilities.hh:55
int boundarySegmentIndex() const
Definition: sgrid.hh:640
Different resources needed by all grid implementations.
A traits struct that collects all associated types of one grid model.
Definition: common/grid.hh:1260
static const bool v
Definition: common/capabilities.hh:97
void make(int _l, int _id)
Reinitialization.
Definition: sgrid.hh:485
Definition: common/geometry.hh:24
SHierarchicStackElem(int _l, int _index)
Definition: sgrid.hh:514
GlobalCoordinate integrationOuterNormal(const LocalCoordinate &local) const
return outer normal scaled with the integration element
Definition: sgrid.hh:839
Definition: sgrid.hh:50
bool conforming() const
return true if intersection is conform.
Definition: sgrid.hh:791
const int sgrid_codim_bits
Definition: sgrid.hh:38
int index
Definition: sgrid.hh:512
Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator leafbegin() const
return LeafIterator which points to the first entity
Definition: sgrid.hh:1359
SHierarchicIterator(GridImp *_grid, const Dune::SEntity< 0, GridImp::dimension, GridImp > &_e, int _maxLevel, bool makeend)
Definition: sgrid.hh:544
const int sgrid_level_bits
Definition: sgrid.hh:37
void communicate(DataHandle &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Definition: sgrid.hh:1498
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:80
GridImp::template Codim< cd >::EntityPointer EntityPointer
Definition: sgrid.hh:357
LocalGeometry geometryInOutside() const
GridImp::template Codim< 0 >::Geometry Geometry
Definition: sgrid.hh:352
GeometryType type() const
obtain the type of reference element for this intersection
Definition: sgrid.hh:815
Definition: sgrid.hh:900
SGridFamily< dim, dimworld, _ctype >::Traits Traits
Definition: sgrid.hh:1278
Definition: defaultgridview.hh:23
bool neighbor() const
return true if neighbor on this level exists
remove_const< GridImp >::type::PersistentIndexType IdType
define the type used for persistent indices
Definition: sgrid.hh:1160
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: sgrid.hh:1424
int overlapSize(int level, int codim)
return size (= distance in graph) of overlap region
Definition: sgrid.hh:1433
const Intersection & dereference() const
dereferencing
Definition: sgrid.hh:619
SEntityPointer(const SEntity< codim, dim, GridImp > &_e)
constructor
Definition: sgrid.hh:916
SEntityPointer & operator=(const SEntityPointer &other)
assignment operator
Definition: sgrid.hh:938
GridImp::template Codim< 1 >::LocalGeometry LocalGeometry
Definition: sgrid.hh:603
bool builtgeometry
true if geometry has been constructed
Definition: sgrid.hh:287
Dune::Intersection< const GridImp, Dune::SIntersection< const GridImp > > Intersection
Definition: sgrid.hh:605
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: common/capabilities.hh:24
void increment()
increment
GridImp::template Codim< 1 >::Geometry Geometry
Definition: sgrid.hh:743
Definition: sgrid.hh:156
SGridLevelIndexSet< SGrid< dim, dimworld > > LevelIndexSetType
Definition: sgrid.hh:1274
GridImp::template Codim< 0 >::Entity Entity
Definition: sgrid.hh:600
Dune::Intersection< const GridImp, Dune::SIntersectionIterator< const GridImp > > Intersection
Definition: sgrid.hh:747
GridImp::LeafIntersectionIterator IntersectionIterator
Definition: sgrid.hh:360
Id Set Interface.
Definition: common/grid.hh:360
void make(const FieldVector< ctype, cdim > &lower, const FieldMatrix< ctype, mydim, cdim > &A)
Set up the geometry.
Definition: sgrid.hh:118
static EntityStackType & enStack()
Definition: sgrid.hh:968
Definition: sgrid.hh:1281
int level() const
level of this element
Definition: sgrid.hh:171
GeometryType type() const
obtain the type of reference element for this intersection
Definition: sgrid.hh:663
all interior entities
Definition: gridenums.hh:25
int min(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:352
SGeometry()
constructor
Definition: sgrid.hh:144
SEntity(const SEntity &other)
Definition: sgrid.hh:472
array< int, dim > z
my coordinate, number of even components = codim
Definition: sgrid.hh:285
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: sgrid.hh:611
EntityPointer outside() const
return EntityPointer to the Entity on the outside of this intersection.
Definition: sgrid.hh:785
GridTraits< dim, dimworld, Dune::SGrid< dim, dimworld, ctype >, SGeometry, SEntity, SEntityPointer, SLevelIterator, SIntersection, SIntersection, SIntersectionIterator, SIntersectionIterator, SHierarchicIterator, SLevelIterator, SGridLevelIndexSet< const SGrid< dim, dimworld, ctype > >, SGridLevelIndexSet< const SGrid< dim, dimworld, ctype > >, SGridGlobalIdSet< const SGrid< dim, dimworld, ctype > >, bigunsignedint< dim *sgrid_dim_bits+sgrid_level_bits+sgrid_codim_bits >, SGridGlobalIdSet< const SGrid< dim, dimworld, ctype > >, bigunsignedint< dim *sgrid_dim_bits+sgrid_level_bits+sgrid_codim_bits >, CollectiveCommunication< Dune::SGrid< dim, dimworld, ctype > >, DefaultLevelGridViewTraits, DefaultLeafGridViewTraits, SEntitySeed > Traits
Definition: sgrid.hh:1207
double sgrid_ctype
Definition: sgrid.hh:33
Geometry::GlobalCoordinate GlobalCoordinate
Definition: sgrid.hh:745
FieldVector< ctype, dimworld > upperRight() const
Get upper right corner.
Definition: sgrid.hh:1460
Traits::template Codim< Seed::codimension >::EntityPointer entityPointer(const Seed &seed) const
Definition: sgrid.hh:1374
Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: sgrid.hh:1337
int compressedLeafIndex() const
consecutive, codim-wise, level-wise index
Definition: sgrid.hh:249