Block-Structured AMR Software Framework
AMReX_IntVect.H
Go to the documentation of this file.
1 #ifndef AMREX_INTVECT_H_
2 #define AMREX_INTVECT_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_INT.H>
6 #include <AMReX_SPACE.H>
7 #include <AMReX_Array.H>
8 #include <AMReX_Vector.H>
9 #include <AMReX_Dim3.H>
10 #include <AMReX_BLassert.H>
11 #include <AMReX_Extension.H>
12 #include <AMReX_GpuQualifiers.H>
13 #include <AMReX_Math.H>
14 #include <AMReX_Tuple.H>
15 #include <AMReX_TypeTraits.H>
16 
17 #include <iosfwd>
18 #include <cstdlib>
19 #include <cmath>
20 #include <limits>
21 #include <climits>
22 #include <algorithm>
23 
24 namespace amrex {
25 
27 int coarsen (int i, int ratio) noexcept
28 {
29  switch (ratio) {
30  case 1: return i;
31  case 2: return (i<0) ? -std::abs(i+1)/2 -1 : i/2;
32  case 4: return (i<0) ? -std::abs(i+1)/4 -1 : i/4;
33  default: return (i<0) ? -std::abs(i+1)/ratio-1 : i/ratio;
34  }
35 }
36 
46 template<int dim>
47 class IntVectND
48 {
49 public:
50  static_assert(dim >= 1, "The number of dimensions of IntVectND must be positive");
51 
52  struct shift_hasher {
53  std::size_t operator()(const IntVectND<dim>& vec) const noexcept
54  {
55  static constexpr unsigned shift1 = sizeof(size_t)>=8 ? 20 : 10;
56  static constexpr unsigned shift2 = sizeof(size_t)>=8 ? 40 : 20;
57  if constexpr (dim == 1) {
58  amrex::ignore_unused(shift1);
59  amrex::ignore_unused(shift2);
60  return static_cast<std::size_t>(vec[0]);
61  } else if constexpr (dim == 2) {
62  amrex::ignore_unused(shift2);
63  return static_cast<std::size_t>(vec[0]) ^
64  (static_cast<std::size_t>(vec[1]) << shift1);
65  } else if constexpr (dim == 3) {
66  return static_cast<std::size_t>(vec[0]) ^
67  (static_cast<std::size_t>(vec[1]) << shift1) ^
68  (static_cast<std::size_t>(vec[2]) << shift2);
69  } else {
70  std::size_t seed = dim;
71  // hash function from
72  // https://stackoverflow.com/questions/20511347/a-good-hash-function-for-a-vector
73  for (int i=0; i<dim; ++i) {
74  auto x = static_cast<unsigned int>(vec[i]);
75  x = ((x >> 16) ^ x) * 0x45d9f3b;
76  x = ((x >> 16) ^ x) * 0x45d9f3b;
77  x = (x >> 16) ^ x;
78  seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2);
79  }
80  return seed;
81  }
82  }
83  };
84 
86 
88 
91  constexpr IntVectND () noexcept {} // cannot use = default due to Clang bug // NOLINT
92 
98  template <class...Args,
99  std::enable_if_t<
100  (sizeof...(Args)+2 == dim) &&
101  IsConvertible_v<int, Args...>,
102  int> = 0>
104  constexpr IntVectND (int i, int j, Args...ks) noexcept : vect{i, j, static_cast<int>(ks)...} {}
105 
110  explicit constexpr IntVectND (int s) noexcept {
111  for (int i=0; i<dim; ++i) {
112  vect[i] = s;
113  }
114  }
115 
121  explicit IntVectND (const int* a) noexcept {
122  for (int i=0; i<dim; ++i) {
123  vect[i] = a[i];
124  }
125  }
126 
132  explicit IntVectND (const Vector<int>& a) noexcept {
133  BL_ASSERT(a.size() == dim);
134  for (int i=0; i<dim; ++i) {
135  vect[i] = a[i];
136  }
137  }
138 
142  explicit IntVectND (const Array<int,dim>& a) noexcept {
143  for (int i=0; i<dim; ++i) {
144  vect[i] = a[i];
145  }
146  }
147 
148  template <int N=dim, std::enable_if_t<( 1<=N && N<=3 ), int> = 0>
149  explicit constexpr IntVectND (Dim3 const& a) noexcept {
150  vect[0] = a.x;
151  if constexpr (dim >= 2) {
152  vect[1] = a.y;
153  }
154  if constexpr (dim == 3) {
155  vect[2] = a.z;
156  }
157  }
158 
159  // dtor, copy-ctor, copy-op=, move-ctor, and move-op= are compiler generated.
160 
161  template <int N=dim, std::enable_if_t<( 1<=N && N<=3 ), int> = 0>
162  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
163  Dim3 dim3 () const noexcept {
164  if constexpr (dim == 1) {
165  return Dim3{vect[0],0,0};
166  } else if constexpr (dim == 2) {
167  return Dim3{vect[0],vect[1],0};
168  } else {
169  return Dim3{vect[0],vect[1],vect[2]};
170  }
171  }
172 
173  template <int N=dim, std::enable_if_t<( 1<=N && N<=3 ), int> = 0>
174  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
175  Dim3 dim3 ([[maybe_unused]] int fill_extra) const noexcept {
176  if constexpr (dim == 1) {
177  return Dim3{vect[0],fill_extra,fill_extra};
178  } else if constexpr (dim == 2) {
179  return Dim3{vect[0],vect[1],fill_extra};
180  } else {
181  return Dim3{vect[0],vect[1],vect[2]};
182  }
183  }
184 
185 #if __cplusplus >= 201402L
186  template< typename T = int >
189  toArray () const noexcept {
190  Array<T, dim> ret {};
191  for (int i=0; i<dim; ++i) {
192  ret[i] = T(vect[i]);
193  }
194  return ret;
195  }
196 #endif
197 
199 
203  int sum () const noexcept
204  {
205  int retval = vect[0];
206  for (int i=1; i<dim; ++i) {
207  retval += vect[i];
208  }
209  return retval;
210  }
211 
214  int max () const noexcept
215  {
216  int retval = vect[0];
217  for (int i=1; i<dim; ++i) {
218  retval = retval > vect[i] ? retval : vect[i];
219  }
220  return retval;
221  }
222 
225  int min () const noexcept
226  {
227  int retval = vect[0];
228  for (int i=1; i<dim; ++i) {
229  retval = retval < vect[i] ? retval : vect[i];
230  }
231  return retval;
232  }
233 
234  //return coordinate with largest value
236  int maxDir(bool a_doAbsValue) const noexcept;
237 
239  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
240  int& operator[] (int i) noexcept { BL_ASSERT(i>=0 && i < dim); return vect[i]; }
241 
243  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
244  const int& operator[] (int i) const noexcept { BL_ASSERT(i>=0 && i < dim); return vect[i]; }
245 
247  template<std::size_t i>
248  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
249  int& get () noexcept {static_assert(0<=i && i<dim); return vect[i];}
250 
252  template<std::size_t i>
253  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
254  const int& get () const noexcept {static_assert(0<=i && i<dim); return vect[i];}
255 
257  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
258  int* begin () noexcept { return &vect[0]; }
259 
261  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
262  const int* begin () const noexcept { return &vect[0]; }
263 
265  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
266  int* end () noexcept { return &vect[dim]; }
267 
269  [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
270  const int* end () const noexcept { return &vect[dim]; }
271 
274  IntVectND& setVal (int i, int val) noexcept
275  {
276  BL_ASSERT(i>=0 && i<dim); vect[i] = val; return *this;
277  }
278 
284  const int* getVect () const& noexcept { return vect; }
286  int* getVect () & noexcept { return vect; }
288  int* getVect () && = delete;
289 
292  bool operator== (int val) const noexcept
293  {
294  bool retval = vect[0] == val;
295  for (int i=1; i<dim; ++i) {
296  retval = retval && vect[i] == val;
297  }
298  return retval;
299  }
300 
303  bool operator!= (int val) const noexcept
304  {
305  bool retval = vect[0] != val;
306  for (int i=1; i<dim; ++i) {
307  retval = retval || vect[i] != val;
308  }
309  return retval;
310  }
311 
314  bool operator== (const IntVectND<dim>& rhs) const noexcept
315  {
316  bool retval = vect[0] == rhs[0];
317  for (int i=1; i<dim; ++i) {
318  retval = retval && vect[i] == rhs[i];
319  }
320  return retval;
321  }
324  bool operator!= (const IntVectND<dim>& rhs) const noexcept
325  {
326  bool retval = vect[0] != rhs[0];
327  for (int i=1; i<dim; ++i) {
328  retval = retval || vect[i] != rhs[i];
329  }
330  return retval;
331  }
334  bool operator< (const IntVectND<dim>& rhs) const noexcept
335  {
336  for (int i=dim-1; i>=0; --i) {
337  if (vect[i] < rhs[i]) {
338  return true;
339  } else if (vect[i] > rhs[i]) {
340  return false;
341  }
342  }
343  return false;
344  }
347  bool operator<= (const IntVectND<dim>& rhs) const noexcept
348  {
349  return !(rhs < *this);
350  }
353  bool operator> (const IntVectND<dim>& rhs) const noexcept
354  {
355  return rhs < *this;
356  }
359  bool operator>= (const IntVectND<dim>& rhs) const noexcept
360  {
361  return !(*this < rhs);
362  }
368  bool allLT (const IntVectND<dim>& rhs) const noexcept
369  {
370  bool retval = vect[0] < rhs[0];
371  for (int i=1; i<dim; ++i) {
372  retval = retval && vect[i] < rhs[i];
373  }
374  return retval;
375  }
380  bool allLT (int rhs) const noexcept
381  {
382  bool retval = vect[0] < rhs;
383  for (int i=1; i<dim; ++i) {
384  retval = retval && vect[i] < rhs;
385  }
386  return retval;
387  }
393  bool allLE (const IntVectND<dim>& rhs) const noexcept
394  {
395  bool retval = vect[0] <= rhs[0];
396  for (int i=1; i<dim; ++i) {
397  retval = retval && vect[i] <= rhs[i];
398  }
399  return retval;
400  }
405  bool allLE (int rhs) const noexcept
406  {
407  bool retval = vect[0] <= rhs;
408  for (int i=1; i<dim; ++i) {
409  retval = retval && vect[i] <= rhs;
410  }
411  return retval;
412  }
418  bool allGT (const IntVectND<dim>& rhs) const noexcept
419  {
420  bool retval = vect[0] > rhs[0];
421  for (int i=1; i<dim; ++i) {
422  retval = retval && vect[i] > rhs[i];
423  }
424  return retval;
425  }
430  bool allGT (int rhs) const noexcept
431  {
432  bool retval = vect[0] > rhs;
433  for (int i=1; i<dim; ++i) {
434  retval = retval && vect[i] > rhs;
435  }
436  return retval;
437  }
443  bool allGE (const IntVectND<dim>& rhs) const noexcept
444  {
445  bool retval = vect[0] >= rhs[0];
446  for (int i=1; i<dim; ++i) {
447  retval = retval && vect[i] >= rhs[i];
448  }
449  return retval;
450  }
455  bool allGE (int rhs) const noexcept
456  {
457  bool retval = vect[0] >= rhs;
458  for (int i=1; i<dim; ++i) {
459  retval = retval && vect[i] >= rhs;
460  }
461  return retval;
462  }
465  IntVectND<dim> operator+ () const noexcept { return *this; }
468  IntVectND<dim> operator- () const noexcept {
469  IntVectND<dim> retval(0);
470  for (int i=0; i<dim; ++i) {
471  retval[i] = -vect[i];
472  }
473  return retval;
474  }
477  IntVectND<dim>& operator+= (int s) noexcept
478  {
479  for (int i=0; i<dim; ++i) {
480  vect[i] += s;
481  }
482  return *this;
483  }
487  {
488  for (int i=0; i<dim; ++i) {
489  vect[i] += p[i];
490  }
491  return *this;
492  }
495  IntVectND<dim>& operator*= (int s) noexcept
496  {
497  for (int i=0; i<dim; ++i) {
498  vect[i] *= s;
499  }
500  return *this;
501  }
505  {
506  for (int i=0; i<dim; ++i) {
507  vect[i] *= p[i];
508  }
509  return *this;
510  }
513  IntVectND<dim>& operator/= (int s) noexcept
514  {
515  for (int i=0; i<dim; ++i) {
516  vect[i] /= s;
517  }
518  return *this;
519  }
523  {
524  for (int i=0; i<dim; ++i) {
525  vect[i] /= p[i];
526  }
527  return *this;
528  }
531  IntVectND<dim>& operator-= (int s) noexcept
532  {
533  for (int i=0; i<dim; ++i) {
534  vect[i] -= s;
535  }
536  return *this;
537  }
541  {
542  for (int i=0; i<dim; ++i) {
543  vect[i] -= p[i];
544  }
545  return *this;
546  }
549  IntVectND<dim> operator+ (const IntVectND<dim>& p) const noexcept
550  {
551  IntVectND<dim> retval = *this;
552  return retval += p;
553  }
556  IntVectND<dim> operator+ (int s) const noexcept
557  {
558  IntVectND<dim> retval = *this;
559  return retval += s;
560  }
563  IntVectND<dim> operator- (const IntVectND<dim>& p) const noexcept
564  {
565  IntVectND<dim> retval = *this;
566  return retval -= p;
567  }
570  IntVectND<dim> operator- (int s) const noexcept
571  {
572  IntVectND<dim> retval = *this;
573  return retval -= s;
574  }
577  IntVectND<dim> operator* (const IntVectND<dim>& p) const noexcept
578  {
579  IntVectND<dim> retval = *this;
580  return retval *= p;
581  }
584  IntVectND<dim> operator* (int s) const noexcept
585  {
586  IntVectND<dim> retval = *this;
587  return retval *= s;
588  }
591  IntVectND<dim> operator/ (const IntVectND<dim>& p) const noexcept
592  {
593  IntVectND<dim> retval = *this;
594  return retval /= p;
595  }
598  IntVectND<dim> operator/ (int s) const noexcept
599  {
600  IntVectND<dim> retval = *this;
601  return retval /= s;
602  }
605  IntVectND<dim>& min (const IntVectND<dim>& p) noexcept
606  {
607  for (int i=0; i<dim; ++i) {
608  vect[i] = (vect[i] < p.vect[i] ? vect[i] : p.vect[i]);
609  }
610  return *this;
611  }
614  IntVectND<dim>& max (const IntVectND<dim>& p) noexcept
615  {
616  for (int i=0; i<dim; ++i) {
617  vect[i] = (vect[i] > p.vect[i] ? vect[i] : p.vect[i]);
618  }
619  return *this;
620  }
623  IntVectND<dim>& scale (int s) noexcept {
624  for (int i=0; i<dim; ++i) {
625  vect[i] *= s;
626  }
627  return *this;
628  }
634  IntVectND<dim>& reflect (int ref_ix, int idir) noexcept
635  {
636  BL_ASSERT(idir >= 0 && idir < dim);
637  vect[idir] = -vect[idir] + 2*ref_ix;
638  return *this;
639  }
642  IntVectND<dim>& shift (int coord, int s) noexcept
643  {
644  BL_ASSERT(coord >= 0 && coord < dim); vect[coord] += s; return *this;
645  }
648  IntVectND<dim>& shift (const IntVectND<dim>& iv) noexcept { *this += iv; return *this; }
651  IntVectND<dim>& diagShift (int s) noexcept
652  {
653  for (int i=0; i<dim; ++i) {
654  vect[i] += s;
655  }
656  return *this;
657  }
660  IntVectND<dim>& coarsen (const IntVectND<dim>& p) noexcept;
663  IntVectND<dim>& coarsen (int p) noexcept;
664 
672  static constexpr IntVectND<dim> TheZeroVector () noexcept {
673  return IntVectND<dim>(0);
674  }
682  static constexpr IntVectND<dim> TheUnitVector () noexcept {
683  return IntVectND<dim>(1);
684  }
691  static constexpr IntVectND<dim> TheDimensionVector (int d) noexcept {
692  IntVectND<dim> retval(0);
693  retval[d] = 1;
694  return retval;
695  }
702  static constexpr IntVectND<dim> TheNodeVector () noexcept {
703  return IntVectND<dim>(1);
704  }
711  static constexpr IntVectND<dim> TheCellVector () noexcept {
712  return IntVectND<dim>(0);
713  }
714 
716  static constexpr IntVectND<dim> TheMaxVector () noexcept {
718  }
720  static constexpr IntVectND<dim> TheMinVector () noexcept {
721  return IntVectND<dim>(std::numeric_limits<int>::lowest());
722  }
723 
725  static constexpr std::size_t size () noexcept {
726  return static_cast<std::size_t>(dim);
727  }
728 
730  static constexpr int isize () noexcept {
731  return dim;
732  }
733 
734  using value_type = int;
735 
740  template<int new_dim>
742  IntVectND<new_dim> shrink () const noexcept {
743  static_assert(new_dim <= dim);
744  return IntVectND<new_dim>(this->begin());
745  }
746 
751  template<int new_dim>
753  IntVectND<new_dim> expand (int fill_extra=0) const noexcept {
754  static_assert(new_dim >= dim);
755  IntVectND<new_dim> retval(fill_extra);
756  for (int i=0; i<dim; ++i) {
757  retval[i] = vect[i];
758  }
759  return retval;
760  }
761 
766  template<int new_dim>
768  IntVectND<new_dim> resize (int fill_extra=0) const noexcept {
769  if constexpr (new_dim > dim) {
770  return expand<new_dim>(fill_extra);
771  } else {
772  return shrink<new_dim>();
773  }
774  }
775 
779  static const IntVectND<dim> Zero;
780 
784  static const IntVectND<dim> Unit;
785 
786 private:
787 
788  int vect[dim] = {};
789 };
790 
791 template <int dim>
792 inline constexpr const IntVectND<dim> IntVectND<dim>::Zero{0};
793 
794 template <int dim>
795 inline constexpr const IntVectND<dim> IntVectND<dim>::Unit{1};
796 
797 // Template deduction guide for IntVectND
798 template<std::size_t dim>
799 AMREX_GPU_HOST_DEVICE // __device__ for HIP
801 
802 // Template deduction guide for IntVectND
803 template <class...Args,
804  std::enable_if_t<
805  IsConvertible_v<int, Args...>,
806  int> = 0>
807 AMREX_GPU_HOST_DEVICE // __device__ for HIP
808 IntVectND(int, int, Args...) -> IntVectND<sizeof...(Args)+2>;
809 
811 
812 template<int dim>
816 IntVectND<dim>::coarsen (int s) noexcept
817 {
818  BL_ASSERT(s > 0);
819  switch (s) {
820  case 1:
821  break;
822  case 2:
823  for (int i=0; i<dim; ++i) {
824  vect[i] = (vect[i]<0) ? -std::abs(vect[i]+1)/2-1 : vect[i]/2;
825  }
826  break;
827  case 4:
828  for (int i=0; i<dim; ++i) {
829  vect[i] = (vect[i]<0) ? -std::abs(vect[i]+1)/4-1 : vect[i]/4;
830  }
831  break;
832  default:
833  for (int i=0; i<dim; ++i) {
834  vect[i] = (vect[i]<0) ? -std::abs(vect[i]+1)/s-1 : vect[i]/s;
835  }
836  }
837  return *this;
838 }
839 
840 template<int dim>
845 {
846  BL_ASSERT(p.allGT(0));
847  for (int i=0; i<dim; ++i) {
848  vect[i] = amrex::coarsen(vect[i], p.vect[i]);
849  }
850  return *this;
851 }
852 
853 template<int dim>
856 int
857 IntVectND<dim>::maxDir(bool a_doAbsValue) const noexcept
858 {
859  int retval = 0;
860  if(a_doAbsValue)
861  {
862  int maxval = std::abs((*this)[0]);
863  for(int idir = 1; idir < dim; idir++)
864  {
865  int curval = std::abs((*this)[idir]);
866  if(curval > maxval)
867  {
868  maxval = curval;
869  retval = idir;
870  }
871  }
872  }
873  else
874  {
875  int maxval = (*this)[0];
876  for(int idir = 1; idir < dim; idir++)
877  {
878  int curval = (*this)[idir];
879  if(curval > maxval)
880  {
881  maxval = curval;
882  retval = idir;
883  }
884  }
885  }
886  return retval;
887 }
888 
890 template<int dim>
893 IntVectND<dim> operator+ (int s, const IntVectND<dim>& p) noexcept
894 {
895  IntVectND<dim> retval = p;
896  for (int i=0; i<dim; ++i) {
897  retval[i] = s + retval[i];
898  }
899  return retval;
900 }
901 
903 template<int dim>
907 IntVectND<dim> operator- (int s, const IntVectND<dim>& p) noexcept
908 {
909  IntVectND<dim> retval = p;
910  for (int i=0; i<dim; ++i) {
911  retval[i] = s - retval[i];
912  }
913  return retval;
914 }
915 
917 template<int dim>
920 IntVectND<dim> operator* (int s, const IntVectND<dim>& p) noexcept
921 {
922  IntVectND<dim> retval = p;
923  for (int i=0; i<dim; ++i) {
924  retval[i] = s * retval[i];
925  }
926  return retval;
927 }
928 
933 template<int dim>
936 IntVectND<dim>
937 min (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
938 {
939  IntVectND<dim> p(p1);
940  p.min(p2);
941  return p;
942 }
943 
944 template<int dim>
947 IntVectND<dim>
948 elemwiseMin (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
949 {
950  IntVectND<dim> p(p1);
951  p.min(p2);
952  return p;
953 }
954 
959 template<int dim>
962 IntVectND<dim>
963 max (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
964 {
965  IntVectND<dim> p(p1);
966  p.max(p2);
967  return p;
968 }
969 
970 template<int dim>
973 IntVectND<dim>
974 elemwiseMax (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
975 {
976  IntVectND<dim> p(p1);
977  p.max(p2);
978  return p;
979 }
980 
986 template<int dim = AMREX_SPACEDIM>
989 IntVectND<dim>
990 BASISV (int dir) noexcept
991 {
992  BL_ASSERT(dir >= 0 && dir < dim);
993  IntVectND<dim> tmp(0);
994  tmp[dir] = 1;
995  return tmp;
996 }
997 
1002 template<int dim>
1005 IntVectND<dim>
1006 scale (const IntVectND<dim>& p, int s) noexcept
1007 {
1008  return IntVectND<dim>(p).scale(s);
1009 }
1010 
1016 template<int dim>
1019 IntVectND<dim>
1020 reflect (const IntVectND<dim>& a, int ref_ix, int idir) noexcept
1021 {
1022  return IntVectND<dim>(a).reflect(ref_ix, idir);
1023 }
1024 
1029 template<int dim>
1032 IntVectND<dim>
1033 diagShift (const IntVectND<dim>& p, int s) noexcept
1034 {
1035  return p + s;
1036 }
1037 
1042 template<int dim>
1045 IntVectND<dim>
1046 coarsen (const IntVectND<dim>& p, int s) noexcept
1047 {
1048  BL_ASSERT(s > 0);
1049  IntVectND<dim> v = p;
1050  v.coarsen(s);
1051  return v;
1052 }
1053 
1058 template<int dim>
1061 IntVectND<dim>
1062 coarsen (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1063 {
1064  IntVectND<dim> v = p1;
1065  v.coarsen(p2);
1066  return v;
1067 }
1068 
1069 template<int dim, std::enable_if_t<( 1<=dim && dim<=3 ), int> = 0>
1070 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
1071 Dim3 refine (Dim3 const& coarse, IntVectND<dim> const& ratio) noexcept
1072 {
1073  if constexpr (dim == 1) {
1074  return Dim3{coarse.x*ratio[0], coarse.y, coarse.z};
1075  } else if constexpr (dim == 2) {
1076  return Dim3{coarse.x*ratio[0], coarse.y*ratio[1], coarse.z};
1077  } else {
1078  return Dim3{coarse.x*ratio[0], coarse.y*ratio[1], coarse.z*ratio[2]};
1079  }
1080 }
1081 
1082 template<int dim, std::enable_if_t<( 1<=dim && dim<=3 ), int> = 0>
1083 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
1084 Dim3 coarsen (Dim3 const& fine, IntVectND<dim> const& ratio) noexcept
1085 {
1086  if constexpr (dim == 1) {
1087  return Dim3{amrex::coarsen(fine.x, ratio[0]),
1088  fine.y,
1089  fine.z};
1090  } else if constexpr (dim == 2) {
1091  return Dim3{amrex::coarsen(fine.x, ratio[0]),
1092  amrex::coarsen(fine.y, ratio[1]),
1093  fine.z};
1094  } else {
1095  return Dim3{amrex::coarsen(fine.x, ratio[0]),
1096  amrex::coarsen(fine.y, ratio[1]),
1097  amrex::coarsen(fine.z, ratio[2])};
1098  }
1099 }
1100 
1101 namespace detail {
1102  std::ostream& int_vector_write (std::ostream& os, const int* iv, int dim);
1103  std::istream& int_vector_read (std::istream& is, int* iv, int dim);
1104 
1105  template<int dim>
1107  void IntVectCat_imp (int*& dst, const IntVectND<dim>& src) noexcept {
1108  for (int i=0; i<dim; ++i) {
1109  dst[i] = src[i];
1110  }
1111  dst += dim;
1112  }
1113 
1114  template<int dim>
1116  void IntVectSplit_imp2 (IntVectND<dim>& dst, const int*& src) noexcept {
1117  for (int i=0; i<dim; ++i) {
1118  dst[i] = src[i];
1119  }
1120  src += dim;
1121  }
1122 
1123  template<class T, std::size_t...Ns>
1125  T IntVectSplit_imp (T& retval, std::index_sequence<Ns...>, const int * src) noexcept {
1126  (IntVectSplit_imp2(amrex::get<Ns>(retval), src), ...);
1127  return retval;
1128  }
1129 
1130  template<int...dims>
1132  int get_sum () {
1133  return (0 + ... + dims);
1134  }
1135 }
1136 
1137 template<int dim>
1138 std::ostream&
1139 operator<< (std::ostream& os, const IntVectND<dim>& iv)
1140 {
1141  return detail::int_vector_write(os, iv.begin(), dim);
1142 }
1143 
1144 template<int dim>
1145 std::istream&
1146 operator>> (std::istream& is, IntVectND<dim>& iv)
1147 {
1148  return detail::int_vector_read(is, iv.begin(), dim);
1149 }
1150 
1155 template<int d, int...dims>
1158 constexpr IntVectND<detail::get_sum<d, dims...>()>
1159 IntVectCat (const IntVectND<d>& v, const IntVectND<dims>&...vects) noexcept {
1160  IntVectND<detail::get_sum<d, dims...>()> retval (0);
1161  int* dst = retval.begin();
1162  detail::IntVectCat_imp(dst, v);
1163  (detail::IntVectCat_imp(dst, vects), ...);
1164  return retval;
1165 }
1166 
1171 template<int d, int...dims>
1174 constexpr GpuTuple<IntVectND<d>, IntVectND<dims>...>
1175 IntVectSplit (const IntVectND<detail::get_sum<d, dims...>()>& v) noexcept {
1177  return detail::IntVectSplit_imp(retval,
1178  std::make_index_sequence<1 + sizeof...(dims)>(),
1179  v.begin());
1180 }
1181 
1186 template<int new_dim, int old_dim>
1189 constexpr IntVectND<new_dim>
1190 IntVectShrink (const IntVectND<old_dim>& iv) noexcept {
1191  return iv.template shrink<new_dim>();
1192 }
1193 
1198 template<int new_dim, int old_dim>
1201 constexpr IntVectND<new_dim>
1202 IntVectExpand (const IntVectND<old_dim>& iv, int fill_extra=0) noexcept {
1203  return iv.template expand<new_dim>(fill_extra);
1204 }
1205 
1210 template<int new_dim, int old_dim>
1213 constexpr IntVectND<new_dim>
1214 IntVectResize (const IntVectND<old_dim>& iv, int fill_extra=0) noexcept {
1215  return iv.template resize<new_dim>(fill_extra);
1216 }
1217 
1218 } // namespace amrex
1219 
1220 // Spcialize std::tuple_size for IntVectND. Used by structured bindings.
1221 template<int dim>
1222 struct std::tuple_size<amrex::IntVectND<dim>> {
1223  static constexpr std::size_t value = dim;
1224 };
1225 
1226 // Spcialize std::tuple_element for IntVectND. Used by structured bindings.
1227 template<std::size_t s, int dim>
1228 struct std::tuple_element<s, amrex::IntVectND<dim>> {
1229  using type = int;
1230 };
1231 
1232 #endif /*AMREX_INTVECT_H*/
#define BL_ASSERT(EX)
Definition: AMReX_BLassert.H:39
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
int idir
Definition: AMReX_HypreMLABecLap.cpp:1093
Definition: AMReX_Tuple.H:93
Definition: AMReX_IntVect.H:48
IntVectND(const Array< int, dim > &a) noexcept
Construct an IntVectND from an Array<int,dim>.
Definition: AMReX_IntVect.H:142
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE std::size_t size() noexcept
Definition: AMReX_IntVect.H:725
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const int * begin() const noexcept
Returns a pointer to the first element of the IntVectND.
Definition: AMReX_IntVect.H:262
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE int * end() noexcept
Returns a pointer to the (last+1) element of the IntVectND.
Definition: AMReX_IntVect.H:266
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< new_dim > shrink() const noexcept
Returns a new IntVectND of size new_dim and assigns the first new_dim values of this IntVectND to it.
Definition: AMReX_IntVect.H:742
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allGE(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than or equal to argument for all components. NOTE: This is NOT a str...
Definition: AMReX_IntVect.H:443
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator<(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically less than rhs.
Definition: AMReX_IntVect.H:334
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLE(const IntVectND< dim > &rhs) const noexcept
Returns true if this is less than or equal to argument for all components. NOTE: This is NOT a strict...
Definition: AMReX_IntVect.H:393
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLE(int rhs) const noexcept
Returns true if this is less than or equal to argument for all components.
Definition: AMReX_IntVect.H:405
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLT(int rhs) const noexcept
Returns true if this is less than argument for all components.
Definition: AMReX_IntVect.H:380
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE int & get() noexcept
Returns a reference to the i'th coordinate of the IntVectND. Used by structured bindings.
Definition: AMReX_IntVect.H:249
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheMaxVector() noexcept
Definition: AMReX_IntVect.H:716
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int sum() const noexcept
Definition: AMReX_IntVect.H:203
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & coarsen(int p) noexcept
Modify IntVectND<dim> by component-wise integer projection.
Definition: AMReX_IntVect.H:816
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & coarsen(const IntVectND< dim > &p) noexcept
Modify IntVectND<dim> by component-wise integer projection.
Definition: AMReX_IntVect.H:844
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE int & operator[](int i) noexcept
Returns a reference to the i'th coordinate of the IntVectND.
Definition: AMReX_IntVect.H:240
int value_type
Definition: AMReX_IntVect.H:734
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< new_dim > resize(int fill_extra=0) const noexcept
Returns a new IntVectND of size new_dim by either shrinking or expanding this IntVectND.
Definition: AMReX_IntVect.H:768
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int maxDir(bool a_doAbsValue) const noexcept
Definition: AMReX_IntVect.H:857
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allGT(const IntVectND< dim > &rhs) const noexcept
Returns true if this is greater than argument for all components. NOTE: This is NOT a strict weak ord...
Definition: AMReX_IntVect.H:418
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator!=(int val) const noexcept
Returns true if any component is not equal to the argument val.
Definition: AMReX_IntVect.H:303
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > operator-() const noexcept
Unary Minus – negates all components.
Definition: AMReX_IntVect.H:468
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allGE(int rhs) const noexcept
Returns true if this is greater than or equal to argument for all components.
Definition: AMReX_IntVect.H:455
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheUnitVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:682
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > operator*(const IntVectND< dim > &p) const noexcept
Returns component-wise product of IntVectND and argument.
Definition: AMReX_IntVect.H:577
constexpr AMREX_GPU_HOST_DEVICE IntVectND(int s) noexcept
Construct an IntVectND whose components are all the same.
Definition: AMReX_IntVect.H:110
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & shift(int coord, int s) noexcept
Modify IntVectND by adding s to given coordinate.
Definition: AMReX_IntVect.H:642
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator==(int val) const noexcept
Returns true if all components are equal to the argument val.
Definition: AMReX_IntVect.H:292
IntVectND(const Vector< int > &a) noexcept
Construct an IntVectND from an Vector<int>. It is an error if the Vector<int> doesn't have the same d...
Definition: AMReX_IntVect.H:132
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & reflect(int ref_ix, int idir) noexcept
Modify IntVectND by reflecting it in the plane defined by the index ref_ix and with normal in the dir...
Definition: AMReX_IntVect.H:634
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE const int * getVect() const &noexcept
Returns a const pointer to an array of coordinates of the IntVectND. Useful for arguments to FORTRAN ...
Definition: AMReX_IntVect.H:284
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & diagShift(int s) noexcept
Modify IntVectND by adding s to each coordinate.
Definition: AMReX_IntVect.H:651
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheNodeVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:702
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & operator-=(int s) noexcept
Modifies IntVectND by subtraction of a scalar to each component.
Definition: AMReX_IntVect.H:531
static const IntVectND< dim > Unit
Definition: AMReX_IntVect.H:784
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allGT(int rhs) const noexcept
Returns true if this is greater than argument for all components.
Definition: AMReX_IntVect.H:430
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const int * end() const noexcept
Returns a pointer to the (last+1) element of the IntVectND.
Definition: AMReX_IntVect.H:270
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & operator*=(int s) noexcept
Modifies IntVectND by multiplication of a scalar to each component.
Definition: AMReX_IntVect.H:495
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & shift(const IntVectND< dim > &iv) noexcept
Equivalent to shift(0,iv[0]).shift(1,iv[1]) ...
Definition: AMReX_IntVect.H:648
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND & setVal(int i, int val) noexcept
Set i'th coordinate of IntVectND to val.
Definition: AMReX_IntVect.H:274
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const int & get() const noexcept
Returns a reference to the i'th coordinate of the IntVectND. Used by structured bindings.
Definition: AMReX_IntVect.H:254
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator<=(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically less than or equal to rhs.
Definition: AMReX_IntVect.H:347
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & operator/=(int s) noexcept
Modifies IntVectND by division by a scalar to each component.
Definition: AMReX_IntVect.H:513
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int min() const noexcept
minimum (no absolute values) value
Definition: AMReX_IntVect.H:225
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator>(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically greater than rhs.
Definition: AMReX_IntVect.H:353
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE int * begin() noexcept
Returns a pointer to the first element of the IntVectND.
Definition: AMReX_IntVect.H:258
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > operator+() const noexcept
Unary plus – for completeness.
Definition: AMReX_IntVect.H:465
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int max() const noexcept
maximum (no absolute values) value
Definition: AMReX_IntVect.H:214
AMREX_GPU_HOST_DEVICE IntVectND(const int *a) noexcept
Construct an IntVectND setting the coordinates to the corresponding values in the integer array a.
Definition: AMReX_IntVect.H:121
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & min(const IntVectND< dim > &p) noexcept
Modifies IntVectND by taking component-wise min with argument.
Definition: AMReX_IntVect.H:605
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & max(const IntVectND< dim > &p) noexcept
Modifies IntVectND by taking component-wise max with argument.
Definition: AMReX_IntVect.H:614
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & operator+=(int s) noexcept
Modifies IntVectND by addition of a scalar to each component.
Definition: AMReX_IntVect.H:477
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheMinVector() noexcept
Definition: AMReX_IntVect.H:720
static const IntVectND< dim > Zero
Definition: AMReX_IntVect.H:779
constexpr AMREX_GPU_HOST_DEVICE IntVectND(int i, int j, Args...ks) noexcept
Construct an IntVectND given the specific values for its coordinates. The inputs for this constructor...
Definition: AMReX_IntVect.H:104
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheZeroVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:672
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< new_dim > expand(int fill_extra=0) const noexcept
Returns a new IntVectND of size new_dim and assigns all values of this IntVectND to it and&#160;fill_extra...
Definition: AMReX_IntVect.H:753
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE int isize() noexcept
Definition: AMReX_IntVect.H:730
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > & scale(int s) noexcept
Modify IntVectND by multiplying each coordinate by s.
Definition: AMReX_IntVect.H:623
constexpr IntVectND() noexcept
Construct an IntVectND whose components are all zero.
Definition: AMReX_IntVect.H:91
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool operator>=(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically greater than or equal to rhs.
Definition: AMReX_IntVect.H:359
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheCellVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:711
AMREX_GPU_HOST_DEVICE int * getVect() &&=delete
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > operator/(const IntVectND< dim > &p) const noexcept
Returns component-wise division of IntVectND by argument.
Definition: AMReX_IntVect.H:591
int vect[dim]
Definition: AMReX_IntVect.H:788
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool allLT(const IntVectND< dim > &rhs) const noexcept
Returns true if this is less than argument for all components. NOTE: This is NOT a strict weak orderi...
Definition: AMReX_IntVect.H:368
AMREX_GPU_HOST_DEVICE static constexpr AMREX_FORCE_INLINE IntVectND< dim > TheDimensionVector(int d) noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition: AMReX_IntVect.H:691
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int * getVect() &noexcept
Definition: AMReX_IntVect.H:286
std::istream & int_vector_read(std::istream &is, int *iv, int dim)
Definition: AMReX_IntVect.cpp:29
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE void IntVectSplit_imp2(IntVectND< dim > &dst, const int *&src) noexcept
Definition: AMReX_IntVect.H:1116
std::ostream & int_vector_write(std::ostream &os, const int *iv, int dim)
Definition: AMReX_IntVect.cpp:13
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE int get_sum()
Definition: AMReX_IntVect.H:1132
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T IntVectSplit_imp(T &retval, std::index_sequence< Ns... >, const int *src) noexcept
Definition: AMReX_IntVect.H:1125
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE void IntVectCat_imp(int *&dst, const IntVectND< dim > &src) noexcept
Definition: AMReX_IntVect.H:1107
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > BASISV(int dir) noexcept
Returns a basis vector in the given coordinate direction; eg. IntVectND<3> BASISV<3>(1) == (0,...
Definition: AMReX_IntVect.H:990
AMREX_GPU_HOST_DEVICE IntVectND(int, int, Args...) -> IntVectND< sizeof...(Args)+2 >
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:35
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & min(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE T abs(const GpuComplex< T > &a_z) noexcept
Return the absolute value of a complex number.
Definition: AMReX_GpuComplex.H:356
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > max(const IntVectND< dim > &p1, const IntVectND< dim > &p2) noexcept
Returns the IntVectND that is the component-wise maximum of two argument IntVectNDs.
Definition: AMReX_IntVect.H:963
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE GpuTuple< IntVectND< d >, IntVectND< dims >... > IntVectSplit(const IntVectND< detail::get_sum< d, dims... >()> &v) noexcept
Returns a tuple of IntVectND obtained by splitting the input IntVectND according to the dimensions sp...
Definition: AMReX_IntVect.H:1175
constexpr bool IsConvertible_v
Definition: AMReX_TypeTraits.H:262
std::ostream & operator<<(std::ostream &os, const IntVectND< dim > &iv)
Definition: AMReX_IntVect.H:1139
std::istream & operator>>(std::istream &is, IntVectND< dim > &iv)
Definition: AMReX_IntVect.H:1146
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T elemwiseMax(T const &a, T const &b) noexcept
Definition: AMReX_Algorithm.H:62
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > diagShift(const IntVectND< dim > &p, int s) noexcept
Returns IntVectND obtained by adding s to each of the components of this IntVectND.
Definition: AMReX_IntVect.H:1033
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
This shuts up the compiler about unused variables.
Definition: AMReX.H:111
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > reflect(const IntVectND< dim > &a, int ref_ix, int idir) noexcept
Returns an IntVectND that is the reflection of input in the plane which passes through ref_ix and nor...
Definition: AMReX_IntVect.H:1020
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE IntVectND< new_dim > IntVectShrink(const IntVectND< old_dim > &iv) noexcept
Returns a new IntVectND of size new_dim and assigns the first new_dim values of iv to it.
Definition: AMReX_IntVect.H:1190
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE IntVectND< dim > scale(const IntVectND< dim > &p, int s) noexcept
Returns a IntVectND obtained by multiplying each of the components of this IntVectND by s.
Definition: AMReX_IntVect.H:1006
AMREX_GPU_HOST_DEVICE IntVectND(const Array< int, dim > &) -> IntVectND< dim >
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > operator-(const GpuComplex< T > &a_x)
Negate a complex number.
Definition: AMReX_GpuComplex.H:173
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE IntVectND< new_dim > IntVectExpand(const IntVectND< old_dim > &iv, int fill_extra=0) noexcept
Returns a new IntVectND of size new_dim and assigns all values of iv to it and&#160;fill_extra to the rema...
Definition: AMReX_IntVect.H:1202
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition: AMReX_Box.H:1304
const int[]
Definition: AMReX_BLProfiler.cpp:1664
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > operator+(const GpuComplex< T > &a_x)
Identity operation on a complex number.
Definition: AMReX_GpuComplex.H:166
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE IntVectND< detail::get_sum< d, dims... >)> IntVectCat(const IntVectND< d > &v, const IntVectND< dims > &...vects) noexcept
Returns a IntVectND obtained by concatenating the input IntVectNDs. The dimension of the return value...
Definition: AMReX_IntVect.H:1159
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE IntVectND< new_dim > IntVectResize(const IntVectND< old_dim > &iv, int fill_extra=0) noexcept
Returns a new IntVectND of size new_dim by either shrinking or expanding iv.
Definition: AMReX_IntVect.H:1214
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE T elemwiseMin(T const &a, T const &b) noexcept
Definition: AMReX_Algorithm.H:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE GpuComplex< T > operator*(const GpuComplex< T > &a_x, const GpuComplex< T > &a_y) noexcept
Multiply two complex numbers.
Definition: AMReX_GpuComplex.H:252
std::array< T, N > Array
Definition: AMReX_Array.H:24
Definition: AMReX_IntVect.H:52
std::size_t operator()(const IntVectND< dim > &vec) const noexcept
Definition: AMReX_IntVect.H:53
int type
Definition: AMReX_IntVect.H:1229