Dune Core Modules (2.8.0)

ygrid.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_GRID_YASPGRID_YGRID_HH
4#define DUNE_GRID_YASPGRID_YGRID_HH
5
6#include <array>
7#include <vector>
8#include <bitset>
9#include <deque>
10
12#include <dune/common/power.hh>
14
19namespace Dune {
20
21 namespace Yasp {
26 template<int d, typename ct>
27 std::array<int,d> sizeArray(const std::array<std::vector<ct>,d>& v)
28 {
29 std::array<int,d> tmp;
30 for (int i=0; i<d; ++i)
31 tmp[i] = v[i].size() - 1;
32 return tmp;
33 }
34 } //namespace Yasp
35
71 template<class Coordinates>
73 {
74 public:
75 //extract coordinate type and dimension from the coordinate container
76 typedef typename Coordinates::ctype ct;
77 static const int d = Coordinates::dimension;
78
79 typedef std::array<int, d> iTupel;
81
83 YGridComponent () : _shift(0ULL)
84 {
85 std::fill(_origin.begin(), _origin.end(), 0);
86 std::fill(_offset.begin(), _offset.end(), 0);
87 std::fill(_size.begin(), _size.end(), 0);
88 }
89
97 YGridComponent(iTupel origin, iTupel size)
98 : _origin(origin), _size(size)
99 {}
100
106 YGridComponent (iTupel origin, iTupel size, const YGridComponent<Coordinates>& enclosing)
107 : _origin(origin), _shift(enclosing.shift()), _coords(enclosing.getCoords()), _size(size), _supersize(enclosing.supersize())
108 {
109 for (int i=0; i<d; i++)
110 _offset[i] = origin[i] - enclosing.origin(i) + enclosing.offset(i);
111
112 // compute superincrements
113 int inc = 1;
114 for (int i=0; i<d; ++i)
115 {
116 _superincrement[i] = inc;
117 inc *= _supersize[i];
118 }
119 }
120
129 YGridComponent (iTupel origin, std::bitset<d> shift, Coordinates* coords, iTupel size, iTupel offset, iTupel supersize)
130 : _origin(origin), _shift(shift), _coords(coords), _size(size), _offset(offset), _supersize(supersize)
131 {
132 // compute superincrements
133 int inc = 1;
134 for (int i=0; i<d; ++i)
135 {
136 _superincrement[i] = inc;
137 inc *= _supersize[i];
138 }
139 }
140
142 int origin (int i) const
143 {
144 return _origin[i];
145 }
146
148 const iTupel& origin () const
149 {
150 return _origin;
151 }
152
154 bool shift (int i) const
155 {
156 return _shift[i];
157 }
158
160 const std::bitset<d>& shift () const
161 {
162 return _shift;
163 }
164
165 Coordinates* getCoords() const
166 {
167 return _coords;
168 }
169
171 int offset (int i) const
172 {
173 return _offset[i];
174 }
175
177 const iTupel & offset () const
178 {
179 return _offset;
180 }
181
183 int supersize (int i) const
184 {
185 return _supersize[i];
186 }
187
189 const iTupel & supersize () const
190 {
191 return _supersize;
192 }
193
195 int size (int i) const
196 {
197 return _size[i];
198 }
199
201 iTupel size () const
202 {
203 return _size;
204 }
205
207 int totalsize () const
208 {
209 int s=1;
210 for (int i=0; i<d; ++i)
211 s *= size(i);
212 return s;
213 }
214
216 int min (int i) const
217 {
218 return _origin[i];
219 }
220
222 int max (int i) const
223 {
224 return _origin[i] + size(i) - 1;
225 }
226
228 bool empty () const
229 {
230 for (int i=0; i<d; ++i)
231 {
232 if (size(i) == 0)
233 return true;
234 }
235 return false;
236 }
237
239 bool inside (const iTupel& coord) const
240 {
241 for (int i=0; i<d; i++)
242 {
243 if ((coord[i]<_origin[i]) || (coord[i]>=_origin[i]+_size[i]))
244 return false;
245 }
246 return true;
247 }
248
250 int index (const iTupel& coord) const
251 {
252 int index = (coord[d-1]-_origin[d-1]);
253
254 for (int i=d-2; i>=0; i--)
255 index = index*_size[i] + (coord[i]-_origin[i]);
256
257 return index;
258 }
259
262 {
263 for (int i=0; i<d; i++)
264 v[i] += _origin[i];
265 return YGridComponent<Coordinates>(v,_size,*this);
266 }
267
270 {
271 for (int i=0; i<d; i++)
272 {
273 //empty coordinate vectors result in empty intersections
274 if (empty() || r.empty())
276 }
277
278 iTupel neworigin;
279 iTupel newsize;
280 for (int i=0; i<d; ++i)
281 {
282 neworigin[i] = std::max(origin(i),r.origin(i));
283 newsize[i] = std::min(max(i),r.max(i)) - neworigin[i] + 1;
284 }
285
286 return YGridComponent<Coordinates>(neworigin,newsize,*this);
287 }
288
289
296 class Iterator {
297 public:
298 // default constructor
299 Iterator () = default;
300
303 {
304 iTupel coord(r.origin());
305 reinit(r,coord);
306 }
307
310 {
311 reinit(r,coord);
312 }
313
315 void reinit (const YGridComponent<Coordinates>& r, const iTupel& coord)
316 {
317 // initialize to given position in index set
318 for (int i=0; i<d; ++i)
319 _coord[i] = coord[i];
320
321 // move superindex to first cell in subgrid
322 _superindex = 0;
323 for (int i=0; i<d; ++i)
324 _superindex += (r.offset(i)+coord[i]-r.origin(i))*r.superincrement(i);
325
326 _grid = &r;
327 }
328
330 bool operator== (const Iterator& i) const
331 {
332 return _superindex == i._superindex;
333 }
334
336 bool operator!= (const Iterator& i) const
337 {
338 return _superindex != i._superindex;
339 }
340
342 int superindex () const
343 {
344 return _superindex;
345 }
346
348 int coord (int i) const
349 {
350 return _coord[i];
351 }
352
354 const iTupel& coord () const
355 {
356 return _coord;
357 }
358
360 void move (int i, int dist)
361 {
362 _coord[i] += dist;
363 _superindex += dist*_grid->superincrement(i);
364 }
365
367 void move (const iTupel& dist)
368 {
369 for (int i = 0; i < d; ++i)
370 {
371 _coord[i] += dist[i];
372 _superindex += dist[i]*_grid->superincrement(i);
373 }
374 }
375
378 {
379 for (int i=0; i<d; i++) // check for wrap around
380 {
381 _superindex += _grid->superincrement(i); // move on cell in direction i
382 if (++_coord[i] <= _grid->max(i))
383 return *this;
384 else
385 {
386 _coord[i] = _grid->origin(i); // move back to origin in direction i
387 _superindex -= _grid->size(i) * _grid->superincrement(i);
388 }
389 }
390 // if we wrapped around, back to to begin(), we must put the iterator to end()
391 if (_coord == _grid->origin())
392 {
393 for (int i=0; i<d; i++)
394 _superindex += (_grid->size(i)-1) * _grid->superincrement(i);
395 _superindex += _grid->superincrement(0);
396 }
397 return *this;
398 }
399
401 ct lowerleft(int i) const
402 {
403 return _grid->getCoords()->coordinate(i,_coord[i]);
404 }
405
408 {
409 fTupel ll;
410 for (int i=0; i<d; i++)
411 ll[i] = lowerleft(i);
412 return ll;
413 }
414
416 ct upperright(int i) const
417 {
418 int coord = _coord[i];
419 if (shift(i))
420 coord++;
421 return _grid->getCoords()->coordinate(i,coord);
422 }
423
426 {
427 fTupel ur;
428 for (int i=0; i<d; i++)
429 ur[i] = upperright(i);
430 return ur;
431 }
432
434 ct meshsize (int i) const
435 {
436 return _grid->getCoords()->meshsize(i,_coord[i]);
437 }
438
441 {
442 fTupel h;
443 for (int i=0; i<d; i++)
444 h[i] = meshsize(i);
445 return h;
446 }
447
448 bool shift (int i) const
449 {
450 return _grid->shift(i);
451 }
452
453 std::bitset<d> shift() const
454 {
455 return _grid->shift();
456 }
457
458 Coordinates* coordCont() const
459 {
460 return _grid->getCoords();
461 }
462
463 protected:
464 iTupel _coord;
465 int _superindex = 0;
466 const YGridComponent<Coordinates>* _grid = nullptr;
467 };
468
469
470 int superindex(iTupel coord) const
471 {
472 // move superindex to first cell in subgrid
473 int si = 0;
474 for (int i=0; i<d; ++i)
475 si += (offset(i)+coord[i]-origin(i))*_superincrement[i];
476 return si;
477 }
478
479 int superincrement(int i) const
480 {
481 return _superincrement[i];
482 }
483
486 {
487 return Iterator(*this);
488 }
489
491 Iterator begin (const iTupel& co) const
492 {
493 return Iterator(*this,co);
494 }
495
497 Iterator end () const
498 {
499 iTupel last;
500 for (int i=0; i<d; i++)
501 last[i] = max(i);
502 last[0] += 1;
503 return Iterator(*this,last);
504 }
505
506 private:
507 iTupel _origin;
508 std::bitset<d> _shift;
509 Coordinates* _coords;
510 iTupel _size;
511 iTupel _offset;
512 iTupel _supersize;
513 iTupel _superincrement;
514
515 };
516
517
519 template <class Coordinates>
520 inline std::ostream& operator<< (std::ostream& s, YGridComponent<Coordinates> e)
521 {
522 s << "Printing YGridComponent structure:" << std::endl;
523 s << "Origin: " << e.origin() << std::endl;
524 s << "Shift: " << e.shift() << std::endl;
525 s << "Size: " << e.size() << std::endl;
526 s << "Offset: " << e.offset() << std::endl;
527 s << "Supersize: " << e.supersize() << std::endl;
528 return s;
529 }
530
532 template <class Coordinates>
533 inline std::ostream& operator<< (std::ostream& s, typename YGridComponent<Coordinates>::Iterator& e)
534 {
535 s << "Printing YGridComponent Iterator:" << std::endl << "Iterator at " << e.coord() << " (index ";
536 s << e.index() << "), position " << e.position();
537 return s;
538 }
539
547 template<class Coordinates>
548 class YGrid
549 {
550 public:
551 static const int dim = Coordinates::dimension;
552
553 // define data array iterator
555
556 typedef typename std::array<int, dim> iTupel;
557
560 {
561 _begin = begin;
562 }
563
565 int shiftmapping(const std::bitset<dim>& shift) const
566 {
567 return _shiftmapping[shift.to_ulong()];
568 }
569
572 {
573 return _begin;
574 }
575
577 DAI dataEnd() const
578 {
579 return _end;
580 }
581
583 bool inside(const iTupel& coord, const std::bitset<dim>& shift = std::bitset<dim>()) const
584 {
585 return (_begin+_shiftmapping[shift.to_ulong()])->inside(coord);
586 }
587
592 {
593 public:
594
596 Iterator () = default;
597
599 Iterator (const YGrid<Coordinates>& yg, const std::array<int,dim>& coords, int which = 0)
600 : _which(which), _yg(&yg)
601 {
602 _it = typename YGridComponent<Coordinates>::Iterator(*(_yg->dataBegin()+which),coords);
603 }
604
606 Iterator (const YGrid<Coordinates>& yg, bool end=false) : _yg(&yg)
607 {
608 if (end)
609 {
610 _it = _yg->_itends.back();
611 _which = _yg->_itends.size() - 1;
612 }
613 else
614 {
615 _it = _yg->_itbegins[0];
616 _which = 0;
617 }
618 }
619
621 void reinit(const YGrid<Coordinates>& yg, const std::array<int,dim>& coords, int which = 0)
622 {
623 _yg = &yg;
624 _which = which;
625 _it = typename YGridComponent<Coordinates>::Iterator(*(_yg->dataBegin()+which),coords);
626 }
627
629 int coord (int i) const
630 {
631 return _it.coord(i);
632 }
633
635 const std::array<int, dim>& coord () const
636 {
637 return _it.coord();
638 }
639
640 typename Coordinates::ctype lowerleft(int i) const
641 {
642 return _it.lowerleft(i);
643 }
644
646 {
647 return _it.lowerleft();
648 }
649
650 typename Coordinates::ctype upperright(int i) const
651 {
652 return _it.upperright(i);
653 }
654
656 {
657 return _it.upperright();
658 }
659
661 typename Coordinates::ctype meshsize (int i) const
662 {
663 return _it.meshsize(i);
664 }
665
668 {
669 return _it.meshsize();
670 }
671
673 bool shift (int i) const
674 {
675 return _it.shift(i);
676 }
677
679 std::bitset<dim> shift () const
680 {
681 return _it.shift();
682 }
683
685 int superindex() const
686 {
687 // the offset of the current component has to be taken into account
688 return _yg->_indexOffset[_which] + _it.superindex();
689 }
690
693 {
694 if ((++_it == _yg->_itends[_which]) && (_which < _yg->_itends.size()-1))
695 _it = _yg->_itbegins[++_which];
696 return *this;
697 }
698
700 bool operator==(const Iterator& i) const
701 {
702 if (_which != i._which)
703 return false;
704 return _it == i._it;
705 }
706
708 bool operator!=(const Iterator& i) const
709 {
710 if (_it != i._it)
711 return true;
712 return _which != i._which;
713 }
714
716 int which() const
717 {
718 return _which;
719 }
720
722 void move(int i, int dist)
723 {
724 _it.move(i,dist);
725 }
726
727 void move(const iTupel& dist)
728 {
729 _it.move(dist);
730 }
731
732 Coordinates* coordCont() const
733 {
734 return _it.coordCont();
735 }
736
737
738 private:
739 unsigned int _which = 0;
740 const YGrid<Coordinates>* _yg = nullptr;
741 typename YGridComponent<Coordinates>::Iterator _it;
742 };
743
746 {
747 return Iterator(*this);
748 }
749
751 Iterator begin(const std::array<int, dim>& coord, int which = 0) const
752 {
753 return Iterator(*this, coord, which);
754 }
755
757 Iterator end() const
758 {
759 return Iterator(*this,true);
760 }
761
762 int superindex(const iTupel& coord, int which) const
763 {
764 return _indexOffset[which] + (dataBegin()+which)->superindex(coord);
765 }
766
767
768 // finalize the ygrid construction by storing component iterators
769 void finalize(const DAI& end, int artificialOffset = 0)
770 {
771 // set the end iterator in the ygrid component array
772 _end = end;
773
774 _indexOffset.push_back(artificialOffset);
775 int k = 0;
776 for (DAI i=_begin; i != _end; ++i, ++k)
777 {
778 //store begin and end iterators
779 _itbegins.push_back(i->begin());
780 _itends.push_back(i->end());
781
782 // store index offset
783 _indexOffset.push_back(_indexOffset.back() + i->totalsize());
784
785 // store shift to component mapping
786 _shiftmapping[i->shift().to_ulong()] = k;
787 }
788 _indexOffset.resize(_itends.size());
789 }
790
791 private:
792
793 friend class YGrid<Coordinates>::Iterator;
794 DAI _begin;
795 DAI _end;
796 std::array<int,StaticPower<2,dim>::power> _shiftmapping;
797 std::vector<typename YGridComponent<Coordinates>::Iterator> _itbegins;
798 std::vector<typename YGridComponent<Coordinates>::Iterator> _itends;
799 std::vector<int> _indexOffset;
800 };
801
803 template <class Coordinates>
804 inline std::ostream& operator<< (std::ostream& s, const YGrid<Coordinates>& e)
805 {
806 s << "Printing YGrid structure:" << std::endl;
807 for (auto it = e.dataBegin(); it != e.dataEnd(); ++it)
808 s << *it << std::endl;
809 return s;
810 }
811
819 template<class Coordinates>
820 class YGridList
821 {
822 public:
823 static const int dim = Coordinates::dimension;
824
826 struct Intersection
827 {
829 YGridComponent<Coordinates> grid;
831 int rank;
833 int distance;
835 YGrid<Coordinates> yg;
836 };
837
838 // define data array iterator type
839 typedef typename std::array<std::deque<Intersection>, StaticPower<2,dim>::power>::iterator DAI;
840
841 // iterator that allows to iterate over a concatenation of deques. namely those
842 // that belong to the same codimension.
843 class Iterator
844 {
845 public:
846
848 Iterator(const YGridList<Coordinates>& ygl, bool end=false) : _end(ygl.dataEnd()), _which(ygl.dataBegin())
849 {
850 _it = _which->begin();
851
852 // advance the iterator to the first element that exists.
853 // some deques might be empty and should be skipped
854 while ((_which != _end) && (_it == _which->end()))
855 {
856 ++_which;
857 if (_which != _end)
858 _it = _which->begin();
859 }
860 // the iterator is at the end if and only if _which==_end
861 if (end)
862 {
863 _which = _end;
864 }
865 }
866
868 Iterator& operator++ ()
869 {
870 ++_it;
871 // advance the iterator to the next element that exists.
872 // some deques might be empty and should be skipped
873 while ((_which != _end) && (_it == _which->end()))
874 {
875 ++_which;
876 if (_which != _end)
877 _it = _which->begin();
878 }
879 return *this;
880 }
881
883 typename std::deque<Intersection>::iterator operator->() const
884 {
885 return _it;
886 }
887
889 typename std::deque<Intersection>::iterator operator*() const
890 {
891 return _it;
892 }
893
895 bool operator== (const Iterator& i) const
896 {
897 if (_which != i._which)
898 return false;
899 if (_which == _end)
900 return true;
901 return _it == i._it;
902 }
903
905 bool operator!= (const Iterator& i) const
906 {
907 if (_which != i._which)
908 return true;
909 if (_which == _end)
910 return false;
911 return _it != i._it;
912 }
913
914 private:
915 typename std::deque<Intersection>::iterator _it;
916 DAI _end;
917 DAI _which;
918 };
919
921 Iterator begin() const
922 {
923 return Iterator(*this);
924 }
925
927 Iterator end() const
928 {
929 return Iterator(*this,true);
930 }
931
933 void setBegin(typename std::array<std::deque<Intersection>, StaticPower<2,dim>::power>::iterator begin)
934 {
935 _begin = begin;
936 }
937
939 DAI dataBegin() const
940 {
941 return _begin;
942 }
943
945 DAI dataEnd() const
946 {
947 return _end;
948 }
949
951 int size() const
952 {
953 int count = 0;
954 for (DAI it = _begin; it != _end; ++it)
955 count += it->size();
956 return count;
957 }
958
960 void finalize(DAI end, const YGrid<Coordinates>& ygrid)
961 {
962 // Instead of directly iterating over the intersection deques, this code
963 // iterates over the components of an associated ygrid and works its way
964 // through the list of intersection deques in parallel.
965 // The reason for this convoluted iteration technique is that there are not
966 // necessarily intersections for all possible shifts, but we have to make
967 // sure that we stop at each shift to update the per-component index shift.
968 // This is ensured by iterating over the ygrid, which is guaranteed to have
969 // a component for each shift vector.
970
971 // set end iterator in the data array
972 _end = end;
973
975 int offset = 0;
976
977 DAI i = _begin;
978
979 // make sure that we have a valid deque (i.e. a non-empty one)
980 while (i != _end && i->begin() == i->end())
981 ++i;
982
983 for (auto yit = ygrid.dataBegin(); yit != ygrid.dataEnd(); ++yit)
984 {
985 if (i == _end)
986 break;
987 auto it = i->begin();
988 if (it->grid.shift() == yit->shift())
989 {
990 // iterate over the intersections in the deque and set the offset
991 for (; it != i->end(); ++it)
992 {
993 it->yg.setBegin(&(it->grid));
994 it->yg.finalize(&(it->grid)+1, offset);
995 }
996
997 // advance to next non-empty deque
998 ++i;
999 while (i != _end && i->begin() == i->end())
1000 ++i;
1001 }
1002
1003 // update the offset from the ygrid component
1004 int add = 1;
1005 for (int j=0; j<dim; j++)
1006 add *= yit->supersize(j);
1007 offset += add;
1008 }
1009 assert (i == end);
1010 }
1011
1012 private:
1013 DAI _begin;
1014 DAI _end;
1015 };
1016
1017} // namespace Dune
1018
1019#endif
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Definition: ygrid.hh:296
Iterator & operator++()
Increment iterator to next cell with position.
Definition: ygrid.hh:377
int superindex() const
Return consecutive index in enclosing grid.
Definition: ygrid.hh:342
bool operator!=(const Iterator &i) const
Return true when two iterators over the same grid are not equal (!).
Definition: ygrid.hh:336
ct lowerleft(int i) const
Return ith component of lower left corner of the entity associated with the current coordinates and s...
Definition: ygrid.hh:401
ct meshsize(int i) const
Return meshsize in direction i.
Definition: ygrid.hh:434
void reinit(const YGridComponent< Coordinates > &r, const iTupel &coord)
reinitialize iterator to given position
Definition: ygrid.hh:315
void move(const iTupel &dist)
move this iterator dist cells in direction i
Definition: ygrid.hh:367
fTupel meshsize() const
Return meshsize of current cell as reference.
Definition: ygrid.hh:440
fTupel lowerleft() const
Return lower left corner of the entity associated with the current coordinates and shift.
Definition: ygrid.hh:407
iTupel _coord
current position in index set
Definition: ygrid.hh:464
const iTupel & coord() const
Return coordinate of the cell as reference (do not modify).
Definition: ygrid.hh:354
void move(int i, int dist)
move this iterator dist cells in direction i
Definition: ygrid.hh:360
Iterator(const YGridComponent< Coordinates > &r)
Make iterator pointing to first cell in a grid.
Definition: ygrid.hh:302
ct upperright(int i) const
Return ith component of upper right corder of the entity associated with the current coordinates and ...
Definition: ygrid.hh:416
int coord(int i) const
Return coordinate of the cell in direction i.
Definition: ygrid.hh:348
fTupel upperright() const
Return upper right corder of the entity associated with the current coordinates and shift.
Definition: ygrid.hh:425
bool operator==(const Iterator &i) const
Return true when two iterators over the same grid are equal (!).
Definition: ygrid.hh:330
Iterator(const YGridComponent< Coordinates > &r, const iTupel &coord)
Make iterator pointing to given cell in a grid.
Definition: ygrid.hh:309
int _superindex
consecutive index in enclosing grid
Definition: ygrid.hh:465
Definition: ygrid.hh:73
int index(const iTupel &coord) const
given a tupel compute its index in the lexicographic numbering
Definition: ygrid.hh:250
int offset(int i) const
Return offset to origin of enclosing grid.
Definition: ygrid.hh:171
YGridComponent< Coordinates > move(iTupel v) const
return grid moved by the vector v
Definition: ygrid.hh:261
iTupel size() const
retrun size
Definition: ygrid.hh:201
YGridComponent< Coordinates > intersection(const YGridComponent< Coordinates > &r) const
Return YGridComponent of supergrid of self which is the intersection of self and another YGridCompone...
Definition: ygrid.hh:269
int min(int i) const
Return minimum index in direction i.
Definition: ygrid.hh:216
YGridComponent(iTupel origin, iTupel size)
make ygrid without coordinate information
Definition: ygrid.hh:97
int totalsize() const
Return total size of index set which is the product of all size per direction.
Definition: ygrid.hh:207
YGridComponent(iTupel origin, iTupel size, const YGridComponent< Coordinates > &enclosing)
make a subgrid by taking coordinates from a larger grid
Definition: ygrid.hh:106
const iTupel & supersize() const
return size of enclosing grid
Definition: ygrid.hh:189
YGridComponent(iTupel origin, std::bitset< d > shift, Coordinates *coords, iTupel size, iTupel offset, iTupel supersize)
Make YGridComponent by giving all parameters.
Definition: ygrid.hh:129
Iterator begin() const
return iterator to first element of index set
Definition: ygrid.hh:485
Iterator begin(const iTupel &co) const
return iterator to given element of index set
Definition: ygrid.hh:491
YGridComponent()
make uninitialized ygrid
Definition: ygrid.hh:83
int origin(int i) const
Return origin in direction i.
Definition: ygrid.hh:142
int supersize(int i) const
return size of enclosing grid
Definition: ygrid.hh:183
int size(int i) const
return size in direction i
Definition: ygrid.hh:195
int max(int i) const
Return maximum index in direction i.
Definition: ygrid.hh:222
const std::bitset< d > & shift() const
Return shift tupel.
Definition: ygrid.hh:160
bool shift(int i) const
Return shift in direction i.
Definition: ygrid.hh:154
Iterator end() const
return subiterator to last element of index set
Definition: ygrid.hh:497
bool inside(const iTupel &coord) const
given a coordinate, return true if it is in the grid
Definition: ygrid.hh:239
bool empty() const
Return true if YGrid is empty, i.e. has size 0 in all directions.
Definition: ygrid.hh:228
const iTupel & offset() const
Return offset to origin of enclosing grid.
Definition: ygrid.hh:177
const iTupel & origin() const
return reference to origin
Definition: ygrid.hh:148
Iterator over a collection o YGrids A YGrid::Iterator is the heart of an entity in YaspGrid.
Definition: ygrid.hh:592
Iterator()=default
default constructor
int which() const
return the current component number
Definition: ygrid.hh:716
void move(int i, int dist)
move the grid, this is only done and needed for codim 0
Definition: ygrid.hh:722
bool operator==(const Iterator &i) const
compare two iterators: component has to match
Definition: ygrid.hh:700
Dune::FieldVector< typename Coordinates::ctype, dim > meshsize() const
return the current meshsize vector
Definition: ygrid.hh:667
Iterator(const YGrid< Coordinates > &yg, const std::array< int, dim > &coords, int which=0)
construct an iterator from coordinates and component
Definition: ygrid.hh:599
std::bitset< dim > shift() const
return the shift vector
Definition: ygrid.hh:679
bool shift(int i) const
return the shift in direction i
Definition: ygrid.hh:673
bool operator!=(const Iterator &i) const
compare two iterators: component has to match
Definition: ygrid.hh:708
const std::array< int, dim > & coord() const
return coordinate array at the current position
Definition: ygrid.hh:635
Iterator & operator++()
increment to the next entity jumping to next component if necessary
Definition: ygrid.hh:692
Coordinates::ctype meshsize(int i) const
return the current meshsize in direction i
Definition: ygrid.hh:661
int coord(int i) const
return coordinate at the current position (direction i)
Definition: ygrid.hh:629
Iterator(const YGrid< Coordinates > &yg, bool end=false)
create an iterator to start or end of the codimension
Definition: ygrid.hh:606
int superindex() const
return the superindex
Definition: ygrid.hh:685
void reinit(const YGrid< Coordinates > &yg, const std::array< int, dim > &coords, int which=0)
reinitializes an iterator, as if it was just constructed.
Definition: ygrid.hh:621
implements a collection of YGridComponents which form a codimension Entities of given codimension c n...
Definition: ygrid.hh:549
int shiftmapping(const std::bitset< dim > &shift) const
get which component belongs to a given shift vector
Definition: ygrid.hh:565
DAI dataBegin() const
get start iterator in the data array
Definition: ygrid.hh:571
Iterator begin() const
return begin iterator for the codimension and partition the ygrid represents
Definition: ygrid.hh:745
DAI dataEnd() const
get end iterator in the data array
Definition: ygrid.hh:577
void setBegin(DAI begin)
set start iterator in the data array
Definition: ygrid.hh:559
bool inside(const iTupel &coord, const std::bitset< dim > &shift=std::bitset< dim >()) const
decide whether a coordinate is in the grid (depending on the component)
Definition: ygrid.hh:583
Iterator begin(const std::array< int, dim > &coord, int which=0) const
return iterator pointint to a specified position
Definition: ygrid.hh:751
Iterator end() const
return end iterator for the codimension and partition the ygrid represents
Definition: ygrid.hh:757
Various implementations of the power function for run-time and static arguments.
Implements a vector constructed from a given type representing a field and a compile-time given size.
auto min(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::min()
Definition: defaults.hh:87
auto max(ADLTag< 0 >, const V &v1, const V &v2)
implements binary Simd::max()
Definition: defaults.hh:79
Dune namespace.
Definition: alignedallocator.hh:11
Implementation of stream operators for std::array and std::tuple.
std::array< int, d > sizeArray(const std::array< std::vector< ct >, d > &v)
Definition: ygrid.hh:27
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)