Chombo + EB  3.0
IntVect.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _INTVECT_H_
12 #define _INTVECT_H_
13 
14 #include <cstddef>
15 #include <cstdlib>
16 #include <cstring>
17 #include <iostream>
18 #include "SPACE.H"
19 #include "Vector.H"
20 #include "IndexTM.H"
21 #include "Misc.H"
22 
23 namespace BLfacade
24 {
25  class IntVect;
26 }
27 
28 #include "NamespaceHeader.H"
29 
30 
31 //template<typename T, int n>
32 //class IndexTM;
33 
34 class HDF5Handle;
35 
36 /// An integer Vector in SpaceDim-dimensional space
37 /**
38  The class IntVect is an implementation of an integer vector in a
39  SpaceDim-dimensional space. It represents a point in a discrete space.
40  IntVect values are accessed using the operator[] function, as for a normal
41  C++ array. In addition, the basic arithmetic operators have been overloaded
42  to implement scaling and translation operations.
43 */
44 
45 class IntVect
46 {
47 public:
48 
49  /**
50  \name Constructors and Accessors
51  */
52  /*@{*/
53 
54  ///
55  /**
56  Construct an IntVect whose components are uninitialized.
57  */
59  {}
60 
61  explicit IntVect( const Vector<int>& vi)
62  {
63  D_EXPR6(vect[0]=vi[0], vect[1]=vi[1], vect[2] = vi[2],
64  vect[3]=vi[3], vect[4]=vi[4], vect[5] = vi[5]);
65  }
66 
67  ///
68  /**
69  Destructor.
70  */
72  {}
73 
74  ///
75  /**
76  Construct an IntVect given the specific values for its
77  coordinates. D_DECL6 is a macro that sets the constructor to
78  take CH_SPACEDIM arguments.
79  */
80  explicit IntVect (D_DECL6(int i, int j, int k,
81  int l, int m, int n));
82 
83  ///
84  /**
85  Construct an IntVect setting the coordinates to the corresponding
86  values in the integer array <i>a</i>.
87  */
88  explicit IntVect (const int* a);
89 
90  ///
91  /**
92  The copy constructor.
93  */
94  IntVect (const IntVect& rhs);
95 
96  IntVect (const IndexTM<int, CH_SPACEDIM>& a_tm);
97 
98  IntVect copy() const
99  {
100  return *this;
101  }
102  ///
103  /**
104  The assignment operator.
105  */
106  IntVect& operator= (const IntVect& rhs);
107 
108  ///
109  /**
110  Returns a modifiable lvalue reference to the <i>i</i>'th coordinate of the
111  IntVect.
112  */
113  inline
114  int& operator[] (int i);
115 
116  ///
117  /**
118  Returns the <i>i</i>'th coordinate of the IntVect.
119  */
120  inline
121  int operator[] (int i) const;
122 
123  ///
124  /**
125  Set <i>i</i>'th coordinate of IntVect to <i>val</i>.
126  */
127  void setVal (int i,
128  int val);
129 
130  /*@}*/
131 
132  /**
133  \name Data pointer functions
134  */
135  /*@{*/
136 
137  ///
138  /**
139  Returns a const pointer to an array of coordinates of the IntVect.
140  Useful for arguments to FORTRAN calls.
141  */
142  const int* getVect () const;
143 
144  ///
145  /**
146  Only for sending to Fortran
147  */
148  const int* dataPtr() const;
149 
150  ///
151  /**
152  Only for sending to Fortran
153  */
154  int* dataPtr();
155 
156  /*@}*/
157 
158  /**
159  \name Comparison Operators
160  */
161  /*@{*/
162 
163  ///
164  /**
165  Returns true if this IntVect is equivalent to argument IntVect. All
166  comparisons between analogous components must be satisfied.
167  */
168  bool operator== (const IntVect& p) const;
169 
170  ///
171  /**
172  Returns true if this IntVect is different from argument IntVect.
173  All comparisons between analogous components must be satisfied.
174  */
175  bool operator!= (const IntVect& p) const;
176 
177  ///
178  /**
179  Returns true if this IntVect is less than argument IntVect. All
180  comparisons between analogous components must be satisfied. Note
181  that, since the comparison is component-wise, it is possible for
182  an IntVect to be neither greater than, less than, nor equal to
183  another.
184  */
185  bool operator< (const IntVect& p) const;
186 
187  ///
188  /**
189  Returns true if this IntVect is less than or equal to argument
190  IntVect. All comparisons between analogous components must be
191  satisfied. Note that, since the comparison is component-wise, it
192  is possible for an IntVect to be neither greater than or equal
193  to, less than or equal to, nor equal to another.
194  */
195  bool operator<= (const IntVect& p) const;
196 
197  ///
198  /**
199  Returns true if this IntVect is greater than argument IntVect.
200  All comparisons between analogous components must be satisfied.
201  Note that, since the comparison is component-wise, it is possible
202  for an IntVect to be neither greater than, less than, nor equal
203  to another.
204  */
205  bool operator> (const IntVect& p) const;
206 
207  ///
208  /**
209  Returns true if this IntVect is greater than or equal to argument
210  IntVect. All comparisons between analogous components must be
211  satisfied. Note that, since the comparison is component-wise, it
212  is possible for an IntVect to be neither greater than or equal
213  to, less than or equal to, nor equal to another.
214  */
215 
216  bool operator>= (const IntVect& p) const;
217 
218  ///
219  /**
220  Returns true if this IntVect is lexically less than the argument.
221  An IntVect MUST BE either lexically less than, lexically greater
222  than, or equal to another IntVect.
223 
224  iv1 is lexically less than iv2 if:
225 
226  in 2-D:<br>
227  (iv1[0] < iv2[0]) || ((iv1[0] == iv2[0]) && (iv1[1] < iv2[1]));
228 
229  in 3-D:<br>
230  (iv1[0] < iv2[0]) || (iv1[0]==iv2[0] && ((iv1[1] < iv2[1] || ((iv1[1] == iv2[1]) && (iv1[2] < iv2[2])))));
231  */
232  bool lexLT (const IntVect& s) const;
233 
234  ///
235  /**
236  Returns true if this IntVect is lexically greater than the
237  argument. An IntVect MUST BE either lexically less than,
238  lexically greater than, or equal to another IntVect.
239 
240  iv1 is lexically less than iv2 if:
241 
242  in 2-D:<br>
243  (iv1[0] > iv2[0]) || ((iv1[0] == iv2[0]) && (iv1[1] > iv2[1]));
244 
245  in 3-D:<br>
246  (iv1[0] > iv2[0]) || (iv1[0]==iv2[0] && ((iv1[1] > iv2[1] || ((iv1[1] == iv2[1]) && (iv1[2] > iv2[2])))));
247  */
248  bool lexGT (const IntVect& s) const;
249 
250  /*@}*/
251 
252  /**
253  \name Unary operators
254  */
255  /*@{*/
256 
257  ///
258  /**
259  Unary plus -- for completeness.
260  */
261  IntVect operator+ () const;
262 
263  ///
264  /**
265  Unary minus -- negates all components of this IntVect.
266  */
267  IntVect operator- () const;
268 
269  ///
270  /**
271  Sum of all components of this IntVect.
272  */
273  int sum () const;
274 
275  ///
276  /**
277  Product of all components of this IntVect.
278  */
279  int product () const;
280 
281  /*@}*/
282 
283  /**
284  \name Addition operators
285  */
286  /*@{*/
287 
288  ///
289  /**
290  Modifies this IntVect by addition of a scalar to each component.
291  */
292  IntVect& operator+= (int s);
293 
294  ///
295  /**
296  Modifies this IntVect by component-wise addition with argument.
297  */
298  IntVect& operator+= (const IntVect& p);
299 
300  ///
301  /**
302  Returns component-wise sum of this IntVect and argument.
303  */
304  IntVect operator+ (const IntVect& p) const;
305 
306  ///
307  /**
308  Return an IntVect that is this IntVect with a scalar added to
309  each component.
310  */
311  IntVect operator+ (int s) const;
312 
313  ///
314  /**
315  Returns an IntVect that is an IntVect <i>p</i>
316  with a scalar <i>s</i> added to each component.
317  */
318  friend inline IntVect operator+ (int s,
319  const IntVect& p);
320 
321  /*@}*/
322 
323  /**
324  \name Subtraction operators
325  */
326  /*@{*/
327 
328  ///
329  /**
330  Modifies this IntVect by subtraction of a scalar from each
331  component.
332  */
333  IntVect& operator-= (int s);
334 
335  ///
336  /**
337  Modifies this IntVect by component-wise subtraction by argument.
338  */
339  IntVect& operator-= (const IntVect& p);
340 
341  ///
342  /**
343  Returns an IntVect that is this IntVect with <i>p</i> subtracted
344  from it component-wise.
345  */
346  IntVect operator- (const IntVect& p) const;
347 
348  ///
349  /**
350  Returns an IntVect that is this IntVect with a scalar <i>s</i> subtracted
351  from each component.
352  */
353  IntVect operator- (int s) const;
354 
355  ///
356  /**
357  Returns <i>s - p</i>.
358  */
359  friend inline IntVect operator- (int s,
360  const IntVect& p);
361 
362  /*@}*/
363 
364  /**
365  \name Multiplication operators
366  */
367  /*@{*/
368 
369  ///
370  /**
371  Modifies this IntVect by multiplication of each component by
372  a scalar.
373  */
374  IntVect& operator*= (int s);
375 
376  ///
377  /**
378  Modifies this IntVect by component-wise multiplication by argument.
379  */
380  IntVect& operator*= (const IntVect& p);
381 
382  ///
383  /**
384  Returns component-wise product of this IntVect with argument.
385  */
386  IntVect operator* (const IntVect& p) const;
387 
388  ///
389  /**
390  Returns an IntVect that is this IntVect with each component
391  multiplied by a scalar.
392  */
393  IntVect operator* (int s) const;
394 
395  ///
396  /**
397  Returns an IntVect that is an IntVect <i>p</i> with each component
398  multiplied by a scalar <i>s</i>.
399  */
400  friend inline IntVect operator* (int s,
401  const IntVect& p);
402 
403  /*@}*/
404 
405  /**
406  \name Division operators
407  */
408  /*@{*/
409 
410  ///
411  /**
412  Modifies this IntVect by division of each component by a scalar.
413  */
414  IntVect& operator/= (int s);
415 
416  ///
417  /**
418  Modifies this IntVect by component-wise division by IntVect
419  argument.
420  */
421  IntVect& operator/= (const IntVect& p);
422 
423  ///
424  /**
425  Returns component-wise quotient of this IntVect by argument.
426  */
427  IntVect operator/ (const IntVect& p) const;
428 
429  ///
430  /**
431  Returns an IntVect that is this IntVect with each component
432  divided by a scalar.
433  */
434  IntVect operator/ (int s) const;
435 
436  /*@}*/
437 
438  /**
439  \name Other arithmetic operators
440  */
441  /*@{*/
442 
443  ///
444  /**
445  Modifies this IntVect by taking component-wise min with IntVect
446  argument.
447  */
448  IntVect& min (const IntVect& p);
449 
450  ///
451  /**
452  Returns the IntVect that is the component-wise minimum of two
453  argument IntVects.
454  */
455  friend inline IntVect min (const IntVect& p1,
456  const IntVect& p2);
457 
458  ///
459  /**
460  Modifies this IntVect by taking component-wise max with IntVect
461  argument.
462  */
463  IntVect& max (const IntVect& p);
464 
465  ///
466  /**
467  Returns the IntVect that is the component-wise maximum of two
468  argument IntVects.
469  */
470  friend inline IntVect max (const IntVect& p1,
471  const IntVect& p2);
472 
473  ///
474  /**
475  Modifies this IntVect by multiplying each component by a scalar.
476  */
477  IntVect& scale (int s);
478 
479  ///
480  /**
481  Returns an IntVect obtained by multiplying each of the components
482  of the given IntVect by a scalar.
483  */
484  friend inline IntVect scale (const IntVect& p,
485  int s);
486 
487  /// Returns the componentwise absolute value of the given IntVect.
488  friend const IntVect absolute(const IntVect& p);
489 
490  ///
491  /**
492  Modifies IntVect by reflecting it in the plane defined by the
493  index <i>ref_ix</i> and with normal in the direction of <i>idir</i>.
494  Directions are based at zero.
495  */
496  IntVect& reflect (int ref_ix,
497  int idir);
498 
499  ///
500  /**
501  Returns an IntVect that is the reflection of the given IntVect in
502  the plane which passes through <i>ref_ix</i> and normal to the
503  coordinate direction idir.
504  */
505  friend inline IntVect reflect(const IntVect& a,
506  int ref_ix,
507  int idir);
508 
509  ///
510  /**
511  Modifies this IntVect by adding <i>s</i> to component in given coordinate
512  direction.
513  */
514  IntVect& shift (int coord,
515  int s);
516 
517  ///
518  /**
519  Modifies this IntVect by component-wise addition with IntVect
520  argument.
521  */
522  IntVect& shift (const IntVect& iv);
523 
524  ///
525  /**
526  Modifies this IntVect by adding a scalar <i>s</i> to each component.
527 
528  */
529  IntVect& diagShift (int s);
530 
531  ///
532  /**
533  Returns IntVect obtained by adding a scalar to each of the
534  components of the given IntVect.
535  */
536  friend inline IntVect diagShift (const IntVect& p,
537  int s);
538 
539  ///
540  /**
541  Modify IntVect by component-wise integer projection.
542  */
543  IntVect& coarsen (const IntVect& p);
544 
545  ///
546  /**
547  Modify IntVect by component-wise integer projection.
548  */
549  IntVect& coarsen (int p);
550 
551  ///
552  /**
553  Returns an IntVect that is the component-wise integer projection of
554  <i>p</i> by <i>s</i>.
555  */
556  friend inline IntVect coarsen (const IntVect& p,
557  int s);
558 
559  ///
560  /**
561  Returns an IntVect which is the component-wise integer projection
562  of IntVect <i>p1</i> by IntVect <i>p2</i>.
563  */
564  friend inline IntVect coarsen (const IntVect& p1,
565  const IntVect& p2);
566 
567  /*@}*/
568 
569  /**
570  \name I/O Functions
571  */
572  /*@{*/
573 
574  ///
575  /**
576  Print an IntVect to the ostream.
577  */
578  void printOn (std::ostream& os) const;
579 
580  ///
581  /**
582  Print an IntVect to the pout().
583  */
584  void p() const;
585 
586  ///
587  /**
588  Print an IntVect to the ostream a bit more verbosely.
589  */
590  void dumpOn (std::ostream& os) const;
591 
592  ///
593  /**
594  Print the IntVect to given output stream in ASCII.
595  */
596  friend std::ostream& operator<< (std::ostream& os,
597  const IntVect& iv);
598 
599  ///
600  /**
601  Read next IntVect from given input stream.
602  */
603  friend std::istream& operator>> (std::istream& os,
604  IntVect& iv);
605 
606  /*@}*/
607 
608  /**
609  \name Constants
610  */
611  /*@{*/
612 
613  ///
614  /**
615  Returns a basis vector in the given coordinate direction.<br>
616  In 3-D:
617  BASISV(0) == (1,0,0); BASISV(1) == (0,1,0); BASISV(2) == (0,0,1).<br>
618  In 2-D:
619  BASISV(0) == (1,0); BASISV(1) == (0,1).<br>
620  Note that the coordinate directions are based at zero.
621  */
622  friend inline IntVect BASISV (int dir);
623 
624  /**
625  This is an IntVect all of whose components are equal to zero.
626  */
627  static const IntVect Zero;
628 
629  /**
630  This is an IntVect all of whose components are equal to one.
631  */
632  static const IntVect Unit;
633 
634  /**
635  Initializes Zero and Unit.
636  */
637  static int InitStatics();
638 
639  /*@}*/
640 
641 protected:
642  //
643  // Box is a friend of ours.
644  //
645  friend class Box;
646 
647  friend class HDF5Handle;
648  friend class VolIndex;
649  friend class FaceIndex;
650  friend class BLfacade::IntVect;
651 
652  /**
653  The individual components of this IntVect.
654  */
655  int vect[SpaceDim];
656 
657  /**
658  Number of bytes of storage used by this IntVect.
659  */
660  static const size_t IntVectSize;
661 };
662 
663 //
664 // Static initialization. Gotta make sure there are no static object
665 // definitions above here (except possibly stuff in headers). Otherwise,
666 // the danger is that some static object's constructor calls IntVect::Zero or
667 // IntVect::Unit -- the very things the following definition is supposed to
668 // initialize.
669 //
671 
672 
673 #ifndef WRAPPER
674 //
675 // Inlines.
676 //
677 
678 // try uninitialized IntVect null construction for now.....
679 
680 // inline
681 // IntVect::IntVect ()
682 // {
683 // D_EXPR6(vect[0] = 0, vect[1] = 0, vect[2] = 0);
684 // }
685 
686 inline
687 IntVect::IntVect (D_DECL6(int i, int j, int k,
688  int l, int m, int n))
689 {
690  D_EXPR6(vect[0] = i, vect[1] = j, vect[2] = k, vect[3] = l, vect[4] = m, vect[5] = n);
691 }
692 
693 inline
694 IntVect::IntVect (const int *a)
695 {
696  D_EXPR6(vect[0] = a[0], vect[1] = a[1], vect[2] = a[2],
697  vect[3] = a[3], vect[4] = a[4], vect[5] = a[5]);
698 }
699 
700 inline
701 IntVect::IntVect (const IntVect &iv)
702 {
703  //D_EXPR6(vect[0]=iv.vect[0], vect[1]=iv.vect[1], vect[2]=iv.vect[2]);
704  memcpy(vect, iv.vect, IntVectSize);
705 }
706 
707 inline
708 IntVect&
710 {
711  D_EXPR6(vect[0]=iv.vect[0], vect[1]=iv.vect[1], vect[2]=iv.vect[2],
712  vect[3]=iv.vect[3], vect[4]=iv.vect[4], vect[5]=iv.vect[5]);
713  return *this;
714 }
715 
716 inline
717 int&
719 {
720  CH_assert(i>=0 && i < SpaceDim);
721  return vect[i];
722 }
723 
724 inline
725 int
726 IntVect::operator[] (int i) const
727 {
728  CH_assert(i>=0 && i < SpaceDim);
729  return vect[i];
730 }
731 
732 inline
733 void
735  int val)
736 {
737  CH_assert(i >=0 && i < SpaceDim);
738  vect[i] = val;
739  // return *this;
740 }
741 
742 inline
743 const int*
745 {
746  return vect;
747 }
748 
749 inline
750 int*
752 {
753  return vect;
754 }
755 
756 inline
757 const int*
759 {
760  return vect;
761 }
762 
763 inline
764 bool
766 {
767  return D_TERM6(vect[0] == p[0], && vect[1] == p[1], && vect[2] == p[2],
768  && vect[3] == p[3], && vect[4] == p[4], && vect[5] == p[5]);
769 }
770 
771 inline
772 bool
774 {
775  return D_TERM6(vect[0] != p[0], || vect[1] != p[1], || vect[2] != p[2],
776  || vect[3] != p[3], || vect[4] != p[4], || vect[5] != p[5]);
777 }
778 
779 inline
780 bool
782 {
783  return D_TERM6(vect[0] < p[0], && vect[1] < p[1], && vect[2] < p[2],
784  && vect[3] < p[3], && vect[4] < p[4], && vect[5] < p[5]);
785 }
786 
787 inline
788 bool
790 {
791  return D_TERM6(vect[0] <= p[0], && vect[1] <= p[1], && vect[2] <= p[2],
792  && vect[3] <= p[3], && vect[4] <= p[4], && vect[5] <= p[5]);
793 }
794 
795 
796 inline
797 bool
799 {
800  return D_TERM6(vect[0] > p[0], && vect[1] > p[1], && vect[2] > p[2],
801  && vect[3] > p[3], && vect[4] > p[4], && vect[5] > p[5]);
802 }
803 
804 inline
805 bool
807 {
808  return D_TERM6(vect[0] >= p[0], && vect[1] >= p[1], && vect[2] >= p[2],
809  && vect[3] >= p[3], && vect[4] >= p[4], && vect[5] >= p[5]);
810 }
811 
812 inline
813 bool
814 IntVect::lexLT (const IntVect &s) const
815 
816 {
817  if (vect[0] < s[0]) return true;
818 #if CH_SPACEDIM > 1
819  if (vect[0] > s[0]) return false;
820  if (vect[1] < s[1]) return true;
821 #endif
822 #if CH_SPACEDIM > 2
823  if (vect[1] > s[1]) return false;
824  if (vect[2] < s[2]) return true;
825 #endif
826 #if CH_SPACEDIM > 3
827  if (vect[2] > s[2]) return false;
828  if (vect[3] < s[3]) return true;
829 #endif
830 #if CH_SPACEDIM > 4
831  if (vect[3] > s[3]) return false;
832  if (vect[4] < s[4]) return true;
833 #endif
834 #if CH_SPACEDIM > 5
835  if (vect[4] > s[4]) return false;
836  if (vect[5] < s[5]) return true;
837 #endif
838 
839  return false;
840 }
841 
842 
843 inline
844 bool
845 IntVect::lexGT (const IntVect& s) const
846 {
847  if (vect[0] > s[0]) return true;
848 #if CH_SPACEDIM > 1
849  if (vect[0] < s[0]) return false;
850  if (vect[1] > s[1]) return true;
851 #endif
852 #if CH_SPACEDIM > 2
853  if (vect[1] < s[1]) return false;
854  if (vect[2] > s[2]) return true;
855 #endif
856 #if CH_SPACEDIM > 3
857  if (vect[2] < s[2]) return false;
858  if (vect[3] > s[3]) return true;
859 #endif
860 #if CH_SPACEDIM > 4
861  if (vect[3] < s[3]) return false;
862  if (vect[4] > s[4]) return true;
863 #endif
864 #if CH_SPACEDIM > 5
865  if (vect[4] < s[4]) return false;
866  if (vect[5] > s[5]) return true;
867 #endif
868 
869  return false;
870 }
871 
872 inline
873 IntVect
875 {
876  return IntVect(*this);
877 }
878 
879 inline
880 IntVect
882 {
883  return IntVect(D_DECL6(-vect[0], -vect[1], -vect[2],
884  -vect[3], -vect[4], -vect[5] ));
885 }
886 
887 inline
888 int
889 IntVect::sum () const
890 {
891  return D_TERM6(vect[0], + vect[1], + vect[2],
892  + vect[3], + vect[4], + vect[5]);
893 }
894 
895 inline
896 int
897 IntVect::product () const
898 {
899  return D_TERM6(vect[0], * vect[1], * vect[2],
900  * vect[3], * vect[4], * vect[5]);
901 }
902 
903 inline
904 IntVect&
906 {
907  D_EXPR6(vect[0] += s, vect[1] += s, vect[2] += s,
908  vect[3] += s, vect[4] += s, vect[5] += s);
909  return *this;
910 }
911 
912 inline
913 IntVect&
915 {
916  D_EXPR6(vect[0] += p[0], vect[1] += p[1], vect[2] += p[2],
917  vect[3] += p[3], vect[4] += p[4], vect[5] += p[5]);
918  return *this;
919 }
920 
921 inline
922 IntVect&
924 {
925  D_EXPR6(vect[0] *= s, vect[1] *= s, vect[2] *= s,
926  vect[3] *= s, vect[4] *= s, vect[5] *= s);
927  return *this;
928 }
929 
930 inline
931 IntVect&
933 {
934  D_EXPR6(vect[0] *= p[0], vect[1] *= p[1], vect[2] *= p[2],
935  vect[3] *= p[3], vect[4] *= p[4], vect[5] *= p[5]);
936  return *this;
937 }
938 
939 inline
940 IntVect&
942 {
943  D_EXPR6(vect[0] /= s, vect[1] /= s, vect[2] /= s,
944  vect[3] /= s, vect[4] /= s, vect[5] /= s);
945  return *this;
946 }
947 
948 inline
949 IntVect&
951 {
952  D_EXPR6(vect[0] /= p[0], vect[1] /= p[1], vect[2] /= p[2],
953  vect[3] /= p[3], vect[4] /= p[4], vect[5] /= p[5]);
954  return *this;
955 }
956 
957 inline
958 IntVect&
960 {
961  D_EXPR6(vect[0] -= s, vect[1] -= s, vect[2] -= s,
962  vect[3] -= s, vect[4] -= s, vect[5] -= s);
963  return *this;
964 }
965 
966 inline
967 IntVect&
969 {
970  D_EXPR6(vect[0] -= p[0], vect[1] -= p[1], vect[2] -= p[2],
971  vect[3] -= p[3], vect[4] -= p[4], vect[5] -= p[5]);
972  return *this;
973 }
974 
975 inline
976 IntVect
978 {
979  return IntVect(D_DECL6(vect[0] + p[0], vect[1] + p[1], vect[2] + p[2],
980  vect[3] + p[3], vect[4] + p[4], vect[5] + p[5]));
981 }
982 
983 inline
984 IntVect
986 {
987  return IntVect(D_DECL6(vect[0] + s, vect[1] + s, vect[2] + s,
988  vect[3] + s, vect[4] + s, vect[5] + s));
989 }
990 
991 inline
992 IntVect
994 {
995  return IntVect(D_DECL6(vect[0] - p[0], vect[1] - p[1], vect[2] - p[2],
996  vect[3] - p[3], vect[4] - p[4], vect[5] - p[5]));
997 }
998 
999 inline
1000 IntVect
1002 {
1003  return IntVect(D_DECL6(vect[0] - s, vect[1] - s, vect[2] - s,
1004  vect[3] - s, vect[4] - s, vect[5] - s));
1005 }
1006 
1007 inline
1008 IntVect
1010 {
1011  return IntVect(D_DECL6(vect[0] * p[0], vect[1] * p[1], vect[2] * p[2],
1012  vect[3] * p[3], vect[4] * p[4], vect[5] * p[5]));
1013 }
1014 
1015 inline
1016 IntVect
1018 {
1019  return IntVect(D_DECL6(vect[0] * s, vect[1] * s, vect[2] * s,
1020  vect[3] * s, vect[4] * s, vect[5] * s));
1021 }
1022 
1023 inline
1024 IntVect
1026 {
1027  return IntVect(D_DECL6(vect[0] / p[0], vect[1] / p[1], vect[2] / p[2],
1028  vect[3] / p[3], vect[4] / p[4], vect[5] / p[5]));
1029 }
1030 
1031 inline
1032 IntVect
1034 {
1035  return IntVect(D_DECL6(vect[0] / s, vect[1] / s, vect[2] / s,
1036  vect[3] / s, vect[4] / s, vect[5] / s));
1037 }
1038 
1039 inline
1040 IntVect&
1042 {
1043  D_EXPR6(vect[0] = Min(vect[0], p.vect[0]),
1044  vect[1] = Min(vect[1], p.vect[1]),
1045  vect[2] = Min(vect[2], p.vect[2]),
1046  vect[3] = Min(vect[3], p.vect[3]),
1047  vect[4] = Min(vect[4], p.vect[4]),
1048  vect[5] = Min(vect[5], p.vect[5]));
1049  return *this;
1050 }
1051 
1052 inline
1053 IntVect&
1055 {
1056  D_EXPR6(vect[0] = Max(vect[0], p.vect[0]),
1057  vect[1] = Max(vect[1], p.vect[1]),
1058  vect[2] = Max(vect[2], p.vect[2]),
1059  vect[3] = Max(vect[3], p.vect[3]),
1060  vect[4] = Max(vect[4], p.vect[4]),
1061  vect[5] = Max(vect[5], p.vect[5]));
1062  return *this;
1063 }
1064 
1065 inline
1066 IntVect&
1068 {
1069  D_EXPR6(vect[0] *= s, vect[1] *= s, vect[2] *= s,
1070  vect[3] *= s, vect[4] *= s, vect[5] *= s);
1071  return *this;
1072 }
1073 
1074 inline
1075 IntVect&
1076 IntVect::reflect (int ref_ix,
1077  int idir)
1078 {
1079  CH_assert(idir >= 0 && idir < SpaceDim);
1080  vect[idir] = -vect[idir] + 2*ref_ix;
1081  return *this;
1082 }
1083 
1084 inline
1085 IntVect&
1086 IntVect::shift (int coord,
1087  int s)
1088 {
1089  CH_assert(coord >= 0 && coord < SpaceDim);
1090  vect[coord] += s;
1091  return *this;
1092 }
1093 
1094 inline
1095 IntVect&
1097 {
1098  *this += iv;
1099  return *this;
1100 }
1101 
1102 inline
1103 IntVect&
1105 {
1106  D_EXPR6(vect[0] += s, vect[1] += s, vect[2] += s,
1107  vect[3] += s, vect[4] += s, vect[5] += s);
1108  return *this;
1109 }
1110 
1111 inline
1112 IntVect
1114  const IntVect& p)
1115 {
1116  return IntVect(D_DECL6(p[0] + s, p[1] + s, p[2] + s,
1117  p[3] + s, p[4] + s, p[5] + s));
1118 }
1119 
1120 inline
1121 IntVect
1123  const IntVect& p)
1124 {
1125  return IntVect(D_DECL6(s - p[0], s - p[1], s - p[2],
1126  s - p[3], s - p[4], s - p[5]));
1127 }
1128 
1129 inline
1130 IntVect
1132  const IntVect& p)
1133 {
1134  return IntVect(D_DECL6(s * p[0], s * p[1], s * p[2],
1135  s * p[3], s * p[4], s * p[5]));
1136 }
1137 
1138 inline
1139 IntVect
1140 scale (const IntVect& p,
1141  int s)
1142 {
1143  return IntVect(D_DECL6(s * p[0], s * p[1], s * p[2],
1144  s * p[3], s * p[4], s * p[5]));
1145 }
1146 
1147 inline
1148 const IntVect
1149 absolute (const IntVect& p)
1150 {
1151  return IntVect(D_DECL6(abs(p[0]), abs(p[1]), abs(p[2]),
1152  abs(p[3]), abs(p[4]), abs(p[5])));
1153 }
1154 
1155 inline
1156 IntVect
1157 diagShift (const IntVect &p, int s)
1158 {
1159  return IntVect(D_DECL6(p[0] + s, p[1] + s, p[2] + s,
1160  p[3] + s, p[4] + s, p[5] + s));
1161 }
1162 
1163 inline
1164 IntVect
1165 min (const IntVect& p1,
1166  const IntVect& p2)
1167 {
1168  IntVect p(p1);
1169  return p.min(p2);
1170 }
1171 
1172 inline
1173 IntVect
1174 max (const IntVect& p1,
1175  const IntVect& p2)
1176 {
1177  IntVect p(p1);
1178  return p.max(p2);
1179 }
1180 
1181 inline
1182 IntVect
1183 BASISV (int dir)
1184 {
1185  CH_assert(dir >= 0 && dir < SpaceDim);
1186  IntVect tmp = IntVect::Zero ;
1187  tmp.vect[dir] = 1;
1188  return tmp;
1189 }
1190 
1191 inline
1192 IntVect
1193 reflect (const IntVect& a,
1194  int ref_ix,
1195  int idir)
1196 {
1197  CH_assert(idir >= 0 && idir < SpaceDim);
1198  IntVect b(a);
1199  b.vect[idir] = -b.vect[idir] + 2*ref_ix;
1200  return b;
1201 }
1202 
1203 inline
1204 IntVect
1205 coarsen (const IntVect& p,
1206  int s)
1207 {
1208  CH_assert(s > 0);
1209  return IntVect(
1210  D_DECL6((p.vect[0]<0) ? -abs(p.vect[0]+1)/s-1 : p.vect[0]/s ,
1211  (p.vect[1]<0) ? -abs(p.vect[1]+1)/s-1 : p.vect[1]/s ,
1212  (p.vect[2]<0) ? -abs(p.vect[2]+1)/s-1 : p.vect[2]/s ,
1213  (p.vect[3]<0) ? -abs(p.vect[3]+1)/s-1 : p.vect[3]/s ,
1214  (p.vect[4]<0) ? -abs(p.vect[4]+1)/s-1 : p.vect[4]/s ,
1215  (p.vect[5]<0) ? -abs(p.vect[5]+1)/s-1 : p.vect[5]/s ));
1216 }
1217 
1218 inline
1219 IntVect
1220 coarsen (const IntVect& p1,
1221  const IntVect& p2)
1222 {
1223  CH_assert(p2 > IntVect::Zero);
1224  return IntVect(
1225  D_DECL6(
1226  (p1.vect[0]<0)?-abs(p1.vect[0]+1)/p2.vect[0]-1:p1.vect[0]/p2.vect[0],
1227  (p1.vect[1]<0)?-abs(p1.vect[1]+1)/p2.vect[1]-1:p1.vect[1]/p2.vect[1],
1228  (p1.vect[2]<0)?-abs(p1.vect[2]+1)/p2.vect[2]-1:p1.vect[2]/p2.vect[2],
1229  (p1.vect[3]<0)?-abs(p1.vect[3]+1)/p2.vect[3]-1:p1.vect[3]/p2.vect[3],
1230  (p1.vect[4]<0)?-abs(p1.vect[4]+1)/p2.vect[4]-1:p1.vect[4]/p2.vect[4],
1231  (p1.vect[5]<0)?-abs(p1.vect[5]+1)/p2.vect[5]-1:p1.vect[5]/p2.vect[5])
1232  );
1233 }
1234 
1235 inline
1236 IntVect&
1238 {
1239  CH_assert(s > 0);
1240  for (int i = 0; i < SpaceDim; ++i)
1241  vect[i] = ((vect[i]<0) ? -abs(vect[i]+1)/s-1 : vect[i]/s);
1242  return *this;
1243 }
1244 
1245 inline
1246 IntVect&
1248 {
1249  CH_assert(p > IntVect::Zero);
1250  for (int i = 0; i <SpaceDim; ++i)
1251  {
1252  const int s = p.vect[i];
1253  vect[i] = ((vect[i]<0) ? -abs(vect[i]+1)/s-1 : vect[i]/s);
1254  }
1255  return *this;
1256 }
1257 
1258 #endif /* WRAPPER */
1259 
1260 #include "NamespaceFooter.H"
1261 #endif
IntVect min(const IntVect &p1, const IntVect &p2)
Definition: IntVect.H:1165
IntVect & operator*=(int s)
Definition: IntVect.H:923
#define D_DECL6(a, b, c, d, e, f)
Definition: CHArray.H:39
IntVect & min(const IntVect &p)
Definition: IntVect.H:1041
const int * getVect() const
Definition: IntVect.H:758
#define D_TERM6(a, b, c, d, e, f)
Definition: CHArray.H:40
static const size_t IntVectSize
Definition: IntVect.H:660
#define CH_assert(cond)
Definition: CHArray.H:37
IntVect & scale(int s)
Definition: IntVect.H:1067
IntVect scale(const IntVect &p, int s)
Definition: IntVect.H:1140
IntVect operator*(const IntVect &p) const
Definition: IntVect.H:1009
Definition: FaceIndex.H:28
IntVect operator*(int s, const IntVect &p)
Definition: IntVect.H:1131
static int InitStatics()
static int s_dummyForIntVectH
Definition: IntVect.H:670
IntVect & operator/=(int s)
Definition: IntVect.H:941
IntVect max(const IntVect &p1, const IntVect &p2)
Definition: IntVect.H:1174
IntVect BASISV(int dir)
Definition: IntVect.H:1183
IntVect & operator-=(int s)
Definition: IntVect.H:959
bool operator<(const IntVect &p) const
Definition: IntVect.H:781
IntVect diagShift(const IntVect &p, int s)
Definition: IntVect.H:1157
const int SpaceDim
Definition: SPACE.H:39
Definition: IndexTM.H:36
void setVal(int i, int val)
Definition: IntVect.H:734
IntVect coarsen(const IntVect &p, int s)
Definition: IntVect.H:1205
std::ostream & operator<<(std::ostream &a_os, const IndexTM< T, N > &a_iv)
IntVect & shift(int coord, int s)
Definition: IntVect.H:1086
static const IntVect Unit
Definition: IntVect.H:632
bool operator==(const IntVect &p) const
Definition: IntVect.H:765
std::istream & operator>>(std::istream &a_os, IndexTM< T, N > &a_iv)
IntVect & operator=(const IntVect &rhs)
Definition: IntVect.H:709
bool operator<(const FaceIndex &f1, const FaceIndex &f2)
Definition: FaceIndex.H:204
IntVect & reflect(int ref_ix, int idir)
Definition: IntVect.H:1076
IntVect & max(const IntVect &p)
Definition: IntVect.H:1054
IntVect operator/(const IntVect &p) const
Definition: IntVect.H:1025
bool operator!=(const IntVect &p) const
Definition: IntVect.H:773
IntVect & operator+=(int s)
Definition: IntVect.H:905
int & operator[](const int i)
Definition: CHArray.H:56
IntVect(const Vector< int > &vi)
Definition: IntVect.H:61
IntVect operator+() const
Definition: IntVect.H:874
static const IntVect Zero
Definition: IntVect.H:627
C::self_type operator/(const C &, const C &)
Definition: GenericArithmeticI.H:136
A Rectangular Domain on an Integer Lattice.
Definition: Box.H:465
IntVect & diagShift(int s)
Definition: IntVect.H:1104
IntVect reflect(const IntVect &a, int ref_ix, int idir)
Definition: IntVect.H:1193
int product() const
Definition: CHArray.H:64
const IntVect absolute(const IntVect &p)
Definition: IntVect.H:1149
bool operator<=(const IntVect &p) const
Definition: IntVect.H:789
bool operator>(const IntVect &p) const
Definition: IntVect.H:798
Handle to a particular group in an HDF file.
Definition: CH_HDF5.H:267
int vect[SpaceDim]
Definition: IntVect.H:655
T Min(const T &a_a, const T &a_b)
Definition: Misc.H:26
An integer Vector in SpaceDim-dimensional space.
Definition: CHArray.H:42
IntVect operator-(int s, const IntVect &p)
Definition: IntVect.H:1122
int sum() const
Definition: IntVect.H:889
Volume of Fluid Index.
Definition: VolIndex.H:31
const int * dataPtr() const
Definition: IntVect.H:744
T Max(const T &a_a, const T &a_b)
Definition: Misc.H:39
~IntVect()
Definition: IntVect.H:71
IntVect & coarsen(const IntVect &p)
Definition: IntVect.H:1247
IntVect operator-() const
Definition: IntVect.H:881
bool lexGT(const IntVect &s) const
Definition: IntVect.H:845
Definition: IntVect.H:23
IntVect operator+(int s, const IntVect &p)
Definition: IntVect.H:1113
IntVect copy() const
Definition: IntVect.H:98
bool lexLT(const IntVect &s) const
Definition: IntVect.H:814
IntVect()
Definition: IntVect.H:58
bool operator>=(const IntVect &p) const
Definition: IntVect.H:806