Dune Core Modules (2.3.1)

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
15#include <dune/geometry/genericgeometry/topologytypes.hh>
19#include <dune/grid/sgrid/numbering.hh>
21
27namespace 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>
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,
120 {
121 if (mydim==0) {
122 // set up base class
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>
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
194 Geometry geometry () const
195 {
197
198 // return result
199 return Geometry( geo );
200 }
201
202 PartitionType partitionType () const { return InteriorEntity; }
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
237 PersistentIndexType persistentIndex () const
238 {
239 return grid->persistentIndex(l, codim, z);
240 }
241
243 int compressedIndex () const
244 {
245 return index;
246 }
247
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;
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 };
527 using SEntityPointer::realEntity;
529 using SEntityPointer::l;
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>
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;
604 typedef Dune::SIntersection<GridImp> IntersectionImp;
607 enum { dimension=dim };
609 enum { dimensionworld=dimworld };
611 typedef typename GridImp::ctype ctype;
612
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
652 LocalGeometry geometryInInside () const;
656 LocalGeometry geometryInOutside () const;
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;
744 typedef typename Geometry::LocalCoordinate LocalCoordinate;
745 typedef typename Geometry::GlobalCoordinate GlobalCoordinate;
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
779 EntityPointer inside() const
780 {
781 return is.inside();
782 }
783
785 EntityPointer outside() const
786 {
787 return is.outside();
788 }
789
791 bool conforming () const
792 {
793 return true;
794 }
795
797 LocalGeometry geometryInInside () const
798 {
799 return is.geometryInInside();
800 }
801
803 LocalGeometry geometryInOutside () const
804 {
805 return is.geometryInOutside();
806 }
807
809 Geometry geometry () const
810 {
811 return is.geometry();
812 }
813
815 GeometryType type () const
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
833 GlobalCoordinate outerNormal (const LocalCoordinate& local) const
834 {
835 return centerUnitOuterNormal();
836 }
837
839 GlobalCoordinate integrationOuterNormal (const LocalCoordinate& local) const
840 {
841 FieldVector<ctype, dimworld> n = centerUnitOuterNormal();
842 n *= is.geometry().integrationElement(local);
843 return n;
844 }
845
847 GlobalCoordinate unitOuterNormal (const LocalCoordinate& local) const
848 {
849 return centerUnitOuterNormal();
850 }
851
853 GlobalCoordinate centerUnitOuterNormal () const
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
861 SIntersection (const SIntersectionIterator<GridImp> & is_) : is(is_) {}
862
863 private:
864#ifndef DOXYGEN // doxygen can't handle this recursive usage
865 const SIntersectionIterator<GridImp> & is;
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>
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
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:
953 inline SEntity<codim,dim,GridImp>& realEntity() const
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
967 typedef AutoPtrStack< Entity > EntityStackType;
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>
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>
1038 public Dune::SEntityPointer <codim,GridImp>
1039 {
1040 friend class SLevelIterator<codim, pitype,const GridImp>;
1041 enum { dim = GridImp::dimension };
1043 using SEntityPointer::realEntity;
1044 using SEntityPointer::l;
1046 public:
1047 typedef typename GridImp::template Codim<codim>::Entity Entity;
1048
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 */
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>
1187 struct SGridFamily
1188 {
1189 typedef GridTraits<dim,dimworld,Dune::SGrid<dim,dimworld,ctype>,
1190 SGeometry,SEntity,
1191 SEntityPointer,SLevelIterator,
1192 SIntersection, // leaf intersection
1193 SIntersection, // level intersection
1194 SIntersectionIterator, // leaf intersection iter
1195 SIntersectionIterator, // level intersection iter
1196 SHierarchicIterator,
1197 SLevelIterator,
1198 SGridLevelIndexSet<const SGrid<dim,dimworld,ctype> >,
1199 SGridLevelIndexSet<const SGrid<dim,dimworld,ctype> >,
1200 SGridGlobalIdSet<const SGrid<dim,dimworld,ctype> >,
1201 bigunsignedint<dim*sgrid_dim_bits+sgrid_level_bits+sgrid_codim_bits>,
1202 SGridGlobalIdSet<const SGrid<dim,dimworld,ctype> >,
1203 bigunsignedint<dim*sgrid_dim_bits+sgrid_level_bits+sgrid_codim_bits>,
1204 CollectiveCommunication<Dune::SGrid<dim,dimworld,ctype> >,
1205 DefaultLevelGridViewTraits, DefaultLeafGridViewTraits,
1206 SEntitySeed>
1207 Traits;
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:
1270 typedef SGridFamily<dim,dimworld,_ctype> GridFamily;
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
1316
1319
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>
1359 typename Traits::template Codim<cd>::template Partition<All_Partition>::LeafIterator leafbegin () const
1360 {
1361 return leafbegin<cd,All_Partition>();
1362 }
1363
1365 template<int cd>
1366 typename Traits::template Codim<cd>::template Partition<All_Partition>::LeafIterator leafend () const
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 };
1377 return SEntityPointer<codim,const SGrid<dim,dimworld> >(this,
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
1456 return low;
1457 }
1458
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
A geometry implementation for axis-aligned hypercubes.
Portable very large unsigned integers.
a stack of pointers with auto destruction if the stack is destructed
Definition: sgrid.hh:876
A geometry implementation for axis-aligned hypercubes.
Definition: axisalignedcubegeometry.hh:50
Default Implementations for EntityImp.
Definition: entity.hh:553
GridImp::template Codim< cd >::EntityPointer EntityPointer
The corresponding entity seed (for storage of entities)
Definition: entity.hh:574
Wrapper class for pointers to entities.
Definition: entitypointer.hh:92
Wrapper class for entities.
Definition: entity.hh:57
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
@ cube
Cube element in any nonnegative dimension.
Definition: type.hh:31
FieldVector< ctype, cdim > GlobalCoordinate
type of the global coordinates
Definition: geometry.hh:136
FieldVector< ctype, mydim > LocalCoordinate
type of local coordinates
Definition: geometry.hh:133
Definition: grid.hh:1017
static ReturnImplementationType< InterfaceType >::ImplementationType & getRealImplementation(InterfaceType &i)
return real implementation of interface class
Definition: grid.hh:1223
Id Set Interface.
Definition: indexidset.hh:403
Index Set Interface base class.
Definition: indexidset.hh:78
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: intersection.hh:161
Default exception for dummy implementations.
Definition: exceptions.hh:289
Definition: sgrid.hh:158
int level() const
level of this element
Definition: sgrid.hh:171
void make(int _l, int _id)
Reinitialization.
Geometry geometry() const
geometry of this entity
Definition: sgrid.hh:194
GridImp * grid
grid containes mapper, geometry, etc.
Definition: sgrid.hh:282
int compressedIndex() const
consecutive, codim-wise, level-wise index
Definition: sgrid.hh:243
void make(GridImp *_grid, int _l, int _id)
Reinitialization.
void makegeometry() const
geometry of this entity
int index
my consecutive index
Definition: sgrid.hh:284
int subCompressedLeafIndex(int cd, int i) const
subentity compressed leaf index (not available here)
Definition: sgrid.hh:274
array< int, dim > z
my coordinate, number of even components = codim
Definition: sgrid.hh:285
GeometryImpl geo
geometry, is only built on demand
Definition: sgrid.hh:286
int l
level where element is on
Definition: sgrid.hh:283
PersistentIndexType persistentIndex() const
globally unique, persistent index
Definition: sgrid.hh:237
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
int globalIndex() const
global index is calculated from the index and grid size
int compressedLeafIndex() const
consecutive, codim-wise, level-wise index
Definition: sgrid.hh:249
GeometryType type() const
return the element type identifier
Definition: sgrid.hh:187
SEntityBase(const SEntityBase &other)
copy constructor
Definition: sgrid.hh:218
SEntityBase(GridImp *_grid, int _l, int _index)
constructor
Definition: sgrid.hh:205
bool builtgeometry
true if geometry has been constructed
Definition: sgrid.hh:287
SEntityBase()
empty constructor
Definition: sgrid.hh:213
int subCompressedIndex(int cd, int i) const
subentity compressed index (not available here)
Definition: sgrid.hh:267
Definition: sgrid.hh:893
int index
my consecutive index
Definition: sgrid.hh:994
SEntityPointer(const SEntityPointer< codim, GridImp > &other)
constructor
Definition: sgrid.hh:922
bool equals(const SEntityPointer< codim, GridImp > &i) const
equality
SEntityPointer(GridImp *_grid, int _l, int _index)
constructor
Definition: sgrid.hh:910
int l
level where element is on
Definition: sgrid.hh:993
SEntityPointer & operator=(const SEntityPointer &other)
assignment operator
Definition: sgrid.hh:938
Entity & dereference() const
dereferencing
SEntityPointer(const SEntity< codim, dim, GridImp > &_e)
constructor
Definition: sgrid.hh:916
Entity * e
virtual entity
Definition: sgrid.hh:995
GridImp * grid
my grid
Definition: sgrid.hh:992
~SEntityPointer()
destructor pointer
Definition: sgrid.hh:928
int level() const
ask for level of entity
Definition: sgrid.hh:1002
bool isValid() const
check whether the EntitySeed refers to a valid Entity
Definition: sgrid.hh:1018
SEntitySeed()
default constructor (invalid)
Definition: sgrid.hh:1008
SEntitySeed(int l, int index)
constructor
Definition: sgrid.hh:1013
Definition: sgrid.hh:336
bool hasFather() const
returns true if father entity exists
Definition: sgrid.hh:430
bool isLeaf() const
return true if the entity is leaf
Definition: sgrid.hh:436
IntersectionIterator ibegin() const
int subCompressedLeafIndex(int codim, int i) const
Definition: sgrid.hh:390
PersistentIndexType subPersistentIndex(int codim, int i) const
subentity persistent index
Definition: sgrid.hh:400
Codim< cc >::EntityPointer subEntity(int i) const
int subCompressedIndex(int codim, int i) const
subentity compressed index
Definition: sgrid.hh:380
HierarchicIterator hbegin(int maxLevel) const
Inter-level access to son elements on higher levels<=maxLevel.
IntersectionIterator iend() const
Reference to one past the last intersection.
LocalGeometry geometryInFather() const
Location of this element relative to the reference element element of the father.
EntityPointer father() const
Inter-level access to father element on coarser grid.
SEntity(GridImp *_grid, int _l, int _index)
constructor
Definition: sgrid.hh:467
void make(int _l, int _id)
Reinitialization.
Definition: sgrid.hh:485
void make(GridImp *_grid, int _l, int _id)
Reinitialization.
Definition: sgrid.hh:478
HierarchicIterator hend(int maxLevel) const
Returns iterator to one past the last son.
Definition: sgrid.hh:298
SEntity(GridImp *_grid, int _l, int _id)
constructor
Definition: sgrid.hh:304
Definition: sgrid.hh:106
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: sgrid.hh:109
SGeometry()
constructor
Definition: sgrid.hh:144
void make(const FieldVector< ctype, cdim > &lower, const FieldMatrix< ctype, mydim, cdim > &A)
Set up the geometry.
Definition: sgrid.hh:118
persistent, globally unique Ids
Definition: sgrid.hh:1150
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
IdType id(const typename remove_const< GridImp >::type::Traits::template Codim< cd >::Entity &e) const
get id of an entity
Definition: sgrid.hh:1168
remove_const< GridImp >::type::PersistentIndexType IdType
define the type used for persistent indices
Definition: sgrid.hh:1160
implementation of index set
Definition: sgrid.hh:1067
const std::vector< GeometryType > & geomTypes(int codim) const
deliver all geometry types used in this grid
Definition: sgrid.hh:1123
int index(const typename GridImp::Traits::template Codim< cd >::Entity &e) const
get index of an entity
Definition: sgrid.hh:1088
int size(int codim) const
return size of set for a given codim
Definition: sgrid.hh:1117
SGridLevelIndexSet(const GridImp &g, int l)
constructor stores reference to a grid and level
Definition: sgrid.hh:1076
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
[ provides Dune::Grid ]
Definition: sgrid.hh:1268
int ghostSize(int level, int codim) const
return size (= distance in graph) of ghost region
Definition: sgrid.hh:1523
int size(int level, int codim) const
number of grid entities per level and codim
int overlapSize(int level, int codim)
return size (= distance in graph) of overlap region
Definition: sgrid.hh:1433
FieldVector< ctype, dimworld > upperRight() const
Get upper right corner.
Definition: sgrid.hh:1460
SGrid()
empty constructor making grid of unit square discretized with one cell
bool adapt()
map adapt to global refine
Definition: sgrid.hh:1465
Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator leafbegin() const
return LeafIterator which points to the first entity
Definition: sgrid.hh:1359
const array< int, dim > & dims(int level) const
Get number of elements in each coordinate direction.
Definition: sgrid.hh:1450
int ghostSize(int level, int codim)
return size (= distance in graph) of ghost region
Definition: sgrid.hh:1439
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
int size(GeometryType type) const
number of leaf entities per codim and geometry type in this process
Definition: sgrid.hh:1418
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
Definition: sgrid.hh:1412
Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator lend(int level) const
one past the end on this level
Definition: sgrid.hh:1344
int overlapSize(int level, int codim) const
return size (= distance in graph) of overlap region
Definition: sgrid.hh:1511
Traits::template Codim< cd >::template Partition< pitype >::LeafIterator leafend() const
one past the end on the leaf level
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
int global_size(int codim) const
number of grid entities of all level for given codim
int overlapSize(int codim) const
return size (= distance in graph) of overlap region
Definition: sgrid.hh:1517
_ctype ctype
define type used for coordinates in grid module
Definition: sgrid.hh:1284
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
SGrid(const int *const N_, const ctype *const L_, const ctype *const H_)
Make an SGrid from position, extend and number of cells per direction.
SGrid(const int *const N_, const ctype *const H_)
Make an SGrid from extend and number of cells per direction.
int size(int codim) const
number of leaf entities per codim in this process
Definition: sgrid.hh:1406
Traits::template Codim< cd >::template Partition< All_Partition >::LeafIterator leafend() const
return LeafIterator which points behind the last entity
Definition: sgrid.hh:1366
~SGrid()
SGrid destructor.
const FieldVector< ctype, dimworld > & lowerLeft() const
Get lower left corner.
Definition: sgrid.hh:1455
void globalRefine(int refCount)
Refine mesh globally by one refCount levels.
int ghostSize(int codim) const
return size (= distance in graph) of ghost region
Definition: sgrid.hh:1529
SGrid(FieldVector< int, dim > N_, FieldVector< ctype, dim > L_, FieldVector< ctype, dim > H_)
Make an SGrid from position, extend and number of cells per direction.
Traits::template Codim< cd >::template Partition< pitype >::LeafIterator leafbegin() const
return LeafIterator which points to the first entity
int maxLevel() const
void communicate(T &t, InterfaceType iftype, CommunicationDirection dir, int level)
Definition: sgrid.hh:1396
size_t numBoundarySegments() const
returns the number of boundary segments within the macro grid
Definition: sgrid.hh:1424
Definition: sgrid.hh:590
Geometry geometry() const
EntityPointer outside() const
bool equals(const SIntersectionIterator< GridImp > &i) const
equality
bool neighbor() const
return true if neighbor on this level exists
SIntersectionIterator(GridImp *_grid, const SEntity< 0, dim, GridImp > *_self, int _count)
constructor
Definition: sgrid.hh:675
int indexInOutside() const
local index of codim 1 entity in neighbor where intersection is contained in
LocalGeometry geometryInInside() const
int indexInInside() const
local index of codim 1 entity in self where intersection is contained in
EntityPointer inside() const
GeometryType type() const
obtain the type of reference element for this intersection
Definition: sgrid.hh:663
LocalGeometry geometryInOutside() const
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: sgrid.hh:611
SIntersectionIterator & operator=(const SIntersectionIterator &other)
assignment operator
Definition: sgrid.hh:695
bool boundary() const
return true if intersection is with boundary.
const Intersection & dereference() const
dereferencing
Definition: sgrid.hh:619
Definition: sgrid.hh:1039
SLevelIterator(GridImp *_grid, int _l, int _id)
constructor
Definition: sgrid.hh:1053
void increment()
increment
Portable very large unsigned integers.
Definition: bigunsignedint.hh:42
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
bool ne(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test for inequality using epsilon
Definition: float_cmp.cc:125
Provides base classes for index and id sets.
Dune namespace.
Definition: alignment.hh:14
double sgrid_ctype
Definition: sgrid.hh:33
PartitionType
Attributes used in the generic overlap model.
Definition: gridenums.hh:24
@ InteriorEntity
all interior entities
Definition: gridenums.hh:25
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:164
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:80
Implements an utility class that provides collective communication methods for sequential programs.
An stl-compliant random-access container which stores everything on the stack.
Specialize with 'true' for all codims that a grid implements entities for. (default=false)
Definition: capabilities.hh:56
Specialize with 'true' for if the codimension 0 entity of the grid has only one possible geometry typ...
Definition: capabilities.hh:25
Specialize with 'true' if the grid is a Cartesian grid. Cartesian grids satisfy the following propert...
Definition: capabilities.hh:46
Specialize with 'true' if implementation guarantees a conforming leaf grid. (default=false)
Definition: capabilities.hh:96
Specialize with 'true' if implementation guarantees conforming level grids. (default=false)
Definition: capabilities.hh:87
static const bool v
Whether to store by reference.
Definition: geometry.hh:49
A traits struct that collects all associated types of one grid model.
Definition: grid.hh:1261
IdSet< const GridImp, GlobalIdSetImp, GIDType > GlobalIdSet
The type of the global id set.
Definition: grid.hh:1347
IndexSet< const GridImp, LevelIndexSetImp > LevelIndexSet
The type of the level index set.
Definition: grid.hh:1343
IndexSet< const GridImp, LeafIndexSetImp > LeafIndexSet
The type of the leaf index set.
Definition: grid.hh:1345
IdSet< const GridImp, LocalIdSetImp, LIDType > LocalIdSet
The type of the local id set.
Definition: grid.hh:1349
Definition: sgrid.hh:510
Removes a const qualifier while preserving others.
Definition: typetraits.hh:176
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)