Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
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.H>
6#include <AMReX_INT.H>
7#include <AMReX_SPACE.H>
8#include <AMReX_Array.H>
9#include <AMReX_Vector.H>
10#include <AMReX_Dim3.H>
11#include <AMReX_BLassert.H>
12#include <AMReX_Extension.H>
13#include <AMReX_GpuQualifiers.H>
14#include <AMReX_Math.H>
15#include <AMReX_Tuple.H>
16#include <AMReX_TypeTraits.H>
17
18#include <iosfwd>
19#include <cstdlib>
20#include <cmath>
21#include <limits>
22#include <climits>
23#include <algorithm>
24
25namespace amrex {
26
28int coarsen (int i, int ratio) noexcept
29{
30 switch (ratio) {
31 case 1: return i;
32 case 2: return (i<0) ? -std::abs(i+1)/2 -1 : i/2;
33 case 4: return (i<0) ? -std::abs(i+1)/4 -1 : i/4;
34 default: return (i<0) ? -std::abs(i+1)/ratio-1 : i/ratio;
35 }
36}
37
38template <int ratio>
40int coarsen (int i) noexcept
41{
42 return (i<0) ? -std::abs(i+1)/ratio-1 : i/ratio;
43}
44
46namespace detail
47{
48 template <typename T>
49 std::ostream& T_vector_write (std::ostream& os, const T* data, int dim)
50 {
51 os << '(' << data[0];
52 for (int i = 1; i < dim; ++i) {
53 os << ',' << data[i];
54 }
55 os << ')';
56 if (os.fail()) {
57 amrex::Error("operator<<(ostream&,[Int|Real]Vect&) failed");
58 }
59 return os;
60 }
61
62 template <typename T>
63 std::istream& T_vector_read (std::istream& is, T* data, int dim)
64 {
65 is >> std::ws;
66 char c;
67 is >> c;
68
69 for (int i = 0; i < dim; ++i) {
70 data[i] = T(0);
71 }
72
73 if (c == '(')
74 {
75 int component = 0;
76 bool need_comma = false;
77
78 while (true) {
79 is >> std::ws;
80 int ic = is.peek();
81
82 if (ic == std::char_traits<char>::eof()) {
83 if (component == 0) {
84 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): missing first component");
85 } else {
86 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): premature EOF");
87 }
88 }
89
90 if (ic == static_cast<int>(')')) {
91 is.get();
92 if (component == 0) {
93 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): missing first component");
94 }
95 break;
96 }
97
98 if (need_comma) {
99 if (ic != static_cast<int>(',')) {
100 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): expected ',' or ')'");
101 }
102 is.get();
103 is >> std::ws;
104 }
105
106 T value{};
107 if (!(is >> value)) {
108 if (component == 0) {
109 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): missing first component");
110 } else {
111 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): premature EOF");
112 }
113 }
114
115 if (component < dim) {
116 data[component] = value;
117 }
118 ++component;
119 need_comma = true;
120 }
121 }
122 else
123 {
124 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): expected '('");
125 }
126
127 if (is.fail()) {
128 amrex::Error("operator>>(ostream&,[Int|Real]Vect&) failed");
129 }
130
131 return is;
132 }
133}
135
147template<int dim>
149{
150public:
151 static_assert(dim >= 1, "The number of dimensions of IntVectND must be positive");
152
155 std::size_t operator()(const IntVectND<dim>& vec) const noexcept
156 {
157 static constexpr unsigned shift1 = sizeof(size_t)>=8 ? 20 : 10;
158 static constexpr unsigned shift2 = sizeof(size_t)>=8 ? 40 : 20;
159 if constexpr (dim == 1) {
160 amrex::ignore_unused(shift1);
161 amrex::ignore_unused(shift2);
162 return static_cast<std::size_t>(vec[0]);
163 } else if constexpr (dim == 2) {
164 amrex::ignore_unused(shift2);
165 return static_cast<std::size_t>(vec[0]) ^
166 (static_cast<std::size_t>(vec[1]) << shift1);
167 } else if constexpr (dim == 3) {
168 return static_cast<std::size_t>(vec[0]) ^
169 (static_cast<std::size_t>(vec[1]) << shift1) ^
170 (static_cast<std::size_t>(vec[2]) << shift2);
171 } else {
172 std::size_t seed = dim;
173 // hash function from
174 // https://stackoverflow.com/questions/20511347/a-good-hash-function-for-a-vector
175 for (int i=0; i<dim; ++i) {
176 auto x = static_cast<unsigned int>(vec[i]);
177 x = ((x >> 16) ^ x) * 0x45d9f3b;
178 x = ((x >> 16) ^ x) * 0x45d9f3b;
179 x = (x >> 16) ^ x;
180 seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2);
181 }
182 return seed;
183 }
184 }
185 };
186
188
190
193 constexpr IntVectND () noexcept {} // cannot use = default due to Clang bug // NOLINT
194
200 template <class...Args>
201 requires ((sizeof...(Args)+2 == dim) && IsConvertible_v<int, Args...>)
203 constexpr IntVectND (int i, int j, Args...ks) noexcept : vect{i, j, static_cast<int>(ks)...} {}
204
209 explicit constexpr IntVectND (int s) noexcept {
210 for (int i=0; i<dim; ++i) {
211 vect[i] = s;
212 }
213 }
214
220 explicit IntVectND (const int* a) noexcept {
221 for (int i=0; i<dim; ++i) {
222 vect[i] = a[i];
223 }
224 }
225
231 explicit IntVectND (const Vector<int>& a) noexcept {
232 BL_ASSERT(a.size() == dim);
233 for (int i=0; i<dim; ++i) {
234 vect[i] = a[i];
235 }
236 }
237
241 explicit constexpr IntVectND (const Array<int,dim>& a) noexcept {
242 for (int i=0; i<dim; ++i) {
243 vect[i] = a[i];
244 }
245 }
246
247 explicit constexpr IntVectND (Dim3 const& a) noexcept
248 requires ( 1<=dim && dim<=3 )
249 {
250 vect[0] = a.x;
251 if constexpr (dim >= 2) {
252 vect[1] = a.y;
253 }
254 if constexpr (dim == 3) {
255 vect[2] = a.z;
256 }
257 }
258
259 // dtor, copy-ctor, copy-op=, move-ctor, and move-op= are compiler generated.
260
262 constexpr Dim3 dim3 () const noexcept
263 requires ( 1<=dim && dim<=3 )
264 {
265 if constexpr (dim == 1) {
266 return Dim3{.x = vect[0], .y = 0, .z = 0};
267 } else if constexpr (dim == 2) {
268 return Dim3{.x = vect[0], .y = vect[1], .z = 0};
269 } else {
270 return Dim3{.x = vect[0], .y = vect[1], .z = vect[2]};
271 }
272 }
273
275 constexpr Dim3 dim3 ([[maybe_unused]] int fill_extra) const noexcept
276 requires ( 1<=dim && dim<=3 )
277 {
278 if constexpr (dim == 1) {
279 return Dim3{.x = vect[0], .y = fill_extra, .z = fill_extra};
280 } else if constexpr (dim == 2) {
281 return Dim3{.x = vect[0], .y = vect[1], .z = fill_extra};
282 } else {
283 return Dim3{.x = vect[0], .y = vect[1], .z = vect[2]};
284 }
285 }
286
287 template< typename T = int >
289 constexpr Array<T, dim> toArray () const noexcept {
290 Array<T, dim> ret {};
291 for (int i=0; i<dim; ++i) {
292 ret[i] = T(vect[i]);
293 }
294 return ret;
295 }
296
298
302 constexpr int sum () const noexcept
303 {
304 int retval = vect[0];
305 for (int i=1; i<dim; ++i) {
306 retval += vect[i];
307 }
308 return retval;
309 }
310
313 constexpr int max () const noexcept
314 {
315 int retval = vect[0];
316 for (int i=1; i<dim; ++i) {
317 retval = retval > vect[i] ? retval : vect[i];
318 }
319 return retval;
320 }
321
324 constexpr int min () const noexcept
325 {
326 int retval = vect[0];
327 for (int i=1; i<dim; ++i) {
328 retval = retval < vect[i] ? retval : vect[i];
329 }
330 return retval;
331 }
332
333 //return coordinate with largest value
335 int maxDir(bool a_doAbsValue) const noexcept;
336
338 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
339 int& operator[] (int i) noexcept { BL_ASSERT(i>=0 && i < dim); return vect[i]; }
340
342 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
343 const int& operator[] (int i) const noexcept { BL_ASSERT(i>=0 && i < dim); return vect[i]; }
344
346 template<std::size_t i>
347 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
348 int& get () noexcept {static_assert(0<=i && i<dim); return vect[i];}
349
351 template<std::size_t i>
352 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
353 const int& get () const noexcept {static_assert(0<=i && i<dim); return vect[i];}
354
356 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
357 int* begin () noexcept { return &vect[0]; }
358
360 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
361 const int* begin () const noexcept { return &vect[0]; }
362
364 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
365 int* end () noexcept { return &vect[dim]; }
366
368 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
369 const int* end () const noexcept { return &vect[dim]; }
370
373 IntVectND& setVal (int i, int val) noexcept
374 {
375 BL_ASSERT(i>=0 && i<dim); vect[i] = val; return *this;
376 }
377
383 const int* getVect () const& noexcept { return vect; }
385 int* getVect () & noexcept { return vect; }
387 int* getVect () && = delete;
388
391 constexpr bool operator== (int val) const noexcept
392 {
393 bool retval = vect[0] == val;
394 for (int i=1; i<dim; ++i) {
395 retval = retval && vect[i] == val;
396 }
397 return retval;
398 }
399
402 constexpr bool operator!= (int val) const noexcept
403 {
404 bool retval = vect[0] != val;
405 for (int i=1; i<dim; ++i) {
406 retval = retval || vect[i] != val;
407 }
408 return retval;
409 }
410
413 constexpr bool operator== (const IntVectND<dim>& rhs) const noexcept
414 {
415 bool retval = vect[0] == rhs[0];
416 for (int i=1; i<dim; ++i) {
417 retval = retval && vect[i] == rhs[i];
418 }
419 return retval;
420 }
423 constexpr bool operator!= (const IntVectND<dim>& rhs) const noexcept
424 {
425 bool retval = vect[0] != rhs[0];
426 for (int i=1; i<dim; ++i) {
427 retval = retval || vect[i] != rhs[i];
428 }
429 return retval;
430 }
433 constexpr bool operator< (const IntVectND<dim>& rhs) const noexcept
434 {
435 for (int i=dim-1; i>=0; --i) {
436 if (vect[i] < rhs[i]) {
437 return true;
438 } else if (vect[i] > rhs[i]) {
439 return false;
440 }
441 }
442 return false;
443 }
446 constexpr bool operator<= (const IntVectND<dim>& rhs) const noexcept
447 {
448 return !(rhs < *this);
449 }
452 constexpr bool operator> (const IntVectND<dim>& rhs) const noexcept
453 {
454 return rhs < *this;
455 }
458 constexpr bool operator>= (const IntVectND<dim>& rhs) const noexcept
459 {
460 return !(*this < rhs);
461 }
467 constexpr bool allLT (const IntVectND<dim>& rhs) const noexcept
468 {
469 bool retval = vect[0] < rhs[0];
470 for (int i=1; i<dim; ++i) {
471 retval = retval && vect[i] < rhs[i];
472 }
473 return retval;
474 }
479 constexpr bool allLT (int rhs) const noexcept
480 {
481 bool retval = vect[0] < rhs;
482 for (int i=1; i<dim; ++i) {
483 retval = retval && vect[i] < rhs;
484 }
485 return retval;
486 }
492 constexpr bool allLE (const IntVectND<dim>& rhs) const noexcept
493 {
494 bool retval = vect[0] <= rhs[0];
495 for (int i=1; i<dim; ++i) {
496 retval = retval && vect[i] <= rhs[i];
497 }
498 return retval;
499 }
504 constexpr bool allLE (int rhs) const noexcept
505 {
506 bool retval = vect[0] <= rhs;
507 for (int i=1; i<dim; ++i) {
508 retval = retval && vect[i] <= rhs;
509 }
510 return retval;
511 }
517 constexpr bool allGT (const IntVectND<dim>& rhs) const noexcept
518 {
519 bool retval = vect[0] > rhs[0];
520 for (int i=1; i<dim; ++i) {
521 retval = retval && vect[i] > rhs[i];
522 }
523 return retval;
524 }
529 constexpr bool allGT (int rhs) const noexcept
530 {
531 bool retval = vect[0] > rhs;
532 for (int i=1; i<dim; ++i) {
533 retval = retval && vect[i] > rhs;
534 }
535 return retval;
536 }
542 constexpr bool allGE (const IntVectND<dim>& rhs) const noexcept
543 {
544 bool retval = vect[0] >= rhs[0];
545 for (int i=1; i<dim; ++i) {
546 retval = retval && vect[i] >= rhs[i];
547 }
548 return retval;
549 }
554 constexpr bool allGE (int rhs) const noexcept
555 {
556 bool retval = vect[0] >= rhs;
557 for (int i=1; i<dim; ++i) {
558 retval = retval && vect[i] >= rhs;
559 }
560 return retval;
561 }
564 constexpr IntVectND<dim> operator+ () const noexcept { return *this; }
567 constexpr IntVectND<dim> operator- () const noexcept {
568 IntVectND<dim> retval(0);
569 for (int i=0; i<dim; ++i) {
570 retval[i] = -vect[i];
571 }
572 return retval;
573 }
576 constexpr IntVectND<dim>& operator+= (int s) noexcept
577 {
578 for (int i=0; i<dim; ++i) {
579 vect[i] += s;
580 }
581 return *this;
582 }
585 constexpr IntVectND<dim>& operator+= (const IntVectND<dim>& p) noexcept
586 {
587 for (int i=0; i<dim; ++i) {
588 vect[i] += p[i];
589 }
590 return *this;
591 }
594 constexpr IntVectND<dim>& operator*= (int s) noexcept
595 {
596 for (int i=0; i<dim; ++i) {
597 vect[i] *= s;
598 }
599 return *this;
600 }
603 constexpr IntVectND<dim>& operator*= (const IntVectND<dim>& p) noexcept
604 {
605 for (int i=0; i<dim; ++i) {
606 vect[i] *= p[i];
607 }
608 return *this;
609 }
612 constexpr IntVectND<dim>& operator/= (int s) noexcept
613 {
614 for (int i=0; i<dim; ++i) {
615 vect[i] /= s;
616 }
617 return *this;
618 }
621 constexpr IntVectND<dim>& operator/= (const IntVectND<dim>& p) noexcept
622 {
623 for (int i=0; i<dim; ++i) {
624 vect[i] /= p[i];
625 }
626 return *this;
627 }
630 constexpr IntVectND<dim>& operator-= (int s) noexcept
631 {
632 for (int i=0; i<dim; ++i) {
633 vect[i] -= s;
634 }
635 return *this;
636 }
639 constexpr IntVectND<dim>& operator-= (const IntVectND<dim>& p) noexcept
640 {
641 for (int i=0; i<dim; ++i) {
642 vect[i] -= p[i];
643 }
644 return *this;
645 }
648 constexpr IntVectND<dim> operator+ (const IntVectND<dim>& p) const noexcept
649 {
650 IntVectND<dim> retval = *this;
651 return retval += p;
652 }
655 constexpr IntVectND<dim> operator+ (int s) const noexcept
656 {
657 IntVectND<dim> retval = *this;
658 return retval += s;
659 }
662 constexpr IntVectND<dim> operator- (const IntVectND<dim>& p) const noexcept
663 {
664 IntVectND<dim> retval = *this;
665 return retval -= p;
666 }
669 constexpr IntVectND<dim> operator- (int s) const noexcept
670 {
671 IntVectND<dim> retval = *this;
672 return retval -= s;
673 }
676 constexpr IntVectND<dim> operator* (const IntVectND<dim>& p) const noexcept
677 {
678 IntVectND<dim> retval = *this;
679 return retval *= p;
680 }
683 constexpr IntVectND<dim> operator* (int s) const noexcept
684 {
685 IntVectND<dim> retval = *this;
686 return retval *= s;
687 }
690 constexpr IntVectND<dim> operator/ (const IntVectND<dim>& p) const noexcept
691 {
692 IntVectND<dim> retval = *this;
693 return retval /= p;
694 }
697 constexpr IntVectND<dim> operator/ (int s) const noexcept
698 {
699 IntVectND<dim> retval = *this;
700 return retval /= s;
701 }
704 constexpr IntVectND<dim>& min (const IntVectND<dim>& p) noexcept
705 {
706 for (int i=0; i<dim; ++i) {
707 vect[i] = (vect[i] < p.vect[i] ? vect[i] : p.vect[i]);
708 }
709 return *this;
710 }
713 constexpr IntVectND<dim>& max (const IntVectND<dim>& p) noexcept
714 {
715 for (int i=0; i<dim; ++i) {
716 vect[i] = (vect[i] > p.vect[i] ? vect[i] : p.vect[i]);
717 }
718 return *this;
719 }
722 constexpr IntVectND<dim>& scale (int s) noexcept {
723 for (int i=0; i<dim; ++i) {
724 vect[i] *= s;
725 }
726 return *this;
727 }
733 constexpr IntVectND<dim>& reflect (int ref_ix, int idir) noexcept
734 {
735 BL_ASSERT(idir >= 0 && idir < dim);
736 vect[idir] = -vect[idir] + 2*ref_ix;
737 return *this;
738 }
741 constexpr IntVectND<dim>& shift (int coord, int s) noexcept
742 {
743 BL_ASSERT(coord >= 0 && coord < dim); vect[coord] += s; return *this;
744 }
747 constexpr IntVectND<dim>& shift (const IntVectND<dim>& iv) noexcept { *this += iv; return *this; }
750 constexpr IntVectND<dim>& diagShift (int s) noexcept
751 {
752 for (int i=0; i<dim; ++i) {
753 vect[i] += s;
754 }
755 return *this;
756 }
762 IntVectND<dim>& coarsen (int p) noexcept;
763
771 static constexpr IntVectND<dim> TheZeroVector () noexcept {
772 return IntVectND<dim>(0);
773 }
781 static constexpr IntVectND<dim> TheUnitVector () noexcept {
782 return IntVectND<dim>(1);
783 }
790 static constexpr IntVectND<dim> TheDimensionVector (int d) noexcept {
791 IntVectND<dim> retval(0);
792 retval[d] = 1;
793 return retval;
794 }
802 static constexpr IntVectND<dim> TheFaceVector (int d) noexcept {
803 return TheDimensionVector(d);
804 }
812 static constexpr IntVectND<dim> TheEdgeVector (int d) noexcept {
813 IntVectND<dim> retval(1);
814 retval[d] = 0;
815 return retval;
816 }
823 static constexpr IntVectND<dim> TheNodeVector () noexcept {
824 return IntVectND<dim>(1);
825 }
832 static constexpr IntVectND<dim> TheCellVector () noexcept {
833 return IntVectND<dim>(0);
834 }
835
837 static constexpr IntVectND<dim> TheMaxVector () noexcept {
838 return IntVectND<dim>(std::numeric_limits<int>::max());
839 }
841 static constexpr IntVectND<dim> TheMinVector () noexcept {
842 return IntVectND<dim>(std::numeric_limits<int>::lowest());
843 }
844
846 static constexpr std::size_t size () noexcept {
847 return static_cast<std::size_t>(dim);
848 }
849
851 static constexpr int isize () noexcept {
852 return dim;
853 }
854
856
861 template<int new_dim>
863 constexpr IntVectND<new_dim> shrink () const noexcept {
864 static_assert(new_dim <= dim);
865 return IntVectND<new_dim>(this->begin());
866 }
867
872 template<int new_dim>
874 constexpr IntVectND<new_dim> expand (int fill_extra=0) const noexcept {
875 static_assert(new_dim >= dim);
876 IntVectND<new_dim> retval(fill_extra);
877 for (int i=0; i<dim; ++i) {
878 retval[i] = vect[i];
879 }
880 return retval;
881 }
882
887 template<int new_dim>
889 constexpr IntVectND<new_dim> resize (int fill_extra=0) const noexcept {
890 if constexpr (new_dim > dim) {
891 return expand<new_dim>(fill_extra);
892 } else {
893 return shrink<new_dim>();
894 }
895 }
896
900 static const IntVectND<dim> Zero;
901
905 static const IntVectND<dim> Unit;
906
907 int vect[dim] = {};
908};
909
910template <int dim>
911inline constexpr const IntVectND<dim> IntVectND<dim>::Zero{0};
912
913template <int dim>
914inline constexpr const IntVectND<dim> IntVectND<dim>::Unit{1};
915
916// Template deduction guide for IntVectND
917template<std::size_t dim>
918#if defined(__clang__) && __clang_major__ < 22
919AMREX_GPU_HOST_DEVICE // __device__ for HIP
920#endif
922
923// Template deduction guide for IntVectND
924template <class...Args>
925requires (IsConvertible_v<int, Args...>)
926#if defined(__clang__) && __clang_major__ < 22
927AMREX_GPU_HOST_DEVICE // __device__ for HIP
928#endif
929IntVectND(int, int, Args...) -> IntVectND<sizeof...(Args)+2>;
930
934
935template<int dim>
940{
941 BL_ASSERT(s > 0);
942 switch (s) {
943 case 1:
944 break;
945 case 2:
946 for (int i=0; i<dim; ++i) {
947 vect[i] = (vect[i]<0) ? -std::abs(vect[i]+1)/2-1 : vect[i]/2;
948 }
949 break;
950 case 4:
951 for (int i=0; i<dim; ++i) {
952 vect[i] = (vect[i]<0) ? -std::abs(vect[i]+1)/4-1 : vect[i]/4;
953 }
954 break;
955 default:
956 for (int i=0; i<dim; ++i) {
957 vect[i] = (vect[i]<0) ? -std::abs(vect[i]+1)/s-1 : vect[i]/s;
958 }
959 }
960 return *this;
961}
962
963template<int dim>
968{
969 BL_ASSERT(p.allGT(0));
970 for (int i=0; i<dim; ++i) {
971 vect[i] = amrex::coarsen(vect[i], p.vect[i]);
972 }
973 return *this;
974}
975
976template<int dim>
979int
980IntVectND<dim>::maxDir(bool a_doAbsValue) const noexcept
981{
982 int retval = 0;
983 if(a_doAbsValue)
984 {
985 int maxval = std::abs((*this)[0]);
986 for(int idir = 1; idir < dim; idir++)
987 {
988 int curval = std::abs((*this)[idir]);
989 if(curval > maxval)
990 {
991 maxval = curval;
992 retval = idir;
993 }
994 }
995 }
996 else
997 {
998 int maxval = (*this)[0];
999 for(int idir = 1; idir < dim; idir++)
1000 {
1001 int curval = (*this)[idir];
1002 if(curval > maxval)
1003 {
1004 maxval = curval;
1005 retval = idir;
1006 }
1007 }
1008 }
1009 return retval;
1010}
1011
1013template<int dim>
1016constexpr IntVectND<dim> operator+ (int s, const IntVectND<dim>& p) noexcept
1017{
1018 IntVectND<dim> retval = p;
1019 for (int i=0; i<dim; ++i) {
1020 retval[i] = s + retval[i];
1021 }
1022 return retval;
1023}
1024
1026template<int dim>
1029constexpr IntVectND<dim> operator- (int s, const IntVectND<dim>& p) noexcept
1030{
1031 IntVectND<dim> retval = p;
1032 for (int i=0; i<dim; ++i) {
1033 retval[i] = s - retval[i];
1034 }
1035 return retval;
1036}
1037
1039template<int dim>
1042constexpr IntVectND<dim> operator* (int s, const IntVectND<dim>& p) noexcept
1043{
1044 IntVectND<dim> retval = p;
1045 for (int i=0; i<dim; ++i) {
1046 retval[i] = s * retval[i];
1047 }
1048 return retval;
1049}
1050
1055template<int dim>
1058constexpr IntVectND<dim>
1059min (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1060{
1061 IntVectND<dim> p(p1);
1062 p.min(p2);
1063 return p;
1064}
1065
1066template<int dim>
1069constexpr IntVectND<dim>
1070elemwiseMin (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1071{
1072 IntVectND<dim> p(p1);
1073 p.min(p2);
1074 return p;
1075}
1076
1081template<int dim>
1084constexpr IntVectND<dim>
1085max (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1086{
1087 IntVectND<dim> p(p1);
1088 p.max(p2);
1089 return p;
1090}
1091
1092template<int dim>
1095constexpr IntVectND<dim>
1096elemwiseMax (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1097{
1098 IntVectND<dim> p(p1);
1099 p.max(p2);
1100 return p;
1101}
1102
1108template<int dim = AMREX_SPACEDIM>
1111IntVectND<dim>
1112BASISV (int dir) noexcept
1113{
1114 BL_ASSERT(dir >= 0 && dir < dim);
1115 IntVectND<dim> tmp(0);
1116 tmp[dir] = 1;
1117 return tmp;
1118}
1119
1124template<int dim>
1127constexpr IntVectND<dim>
1128scale (const IntVectND<dim>& p, int s) noexcept
1129{
1130 return IntVectND<dim>(p).scale(s);
1131}
1132
1138template<int dim>
1141constexpr IntVectND<dim>
1142reflect (const IntVectND<dim>& a, int ref_ix, int idir) noexcept
1143{
1144 return IntVectND<dim>(a).reflect(ref_ix, idir);
1145}
1146
1151template<int dim>
1154constexpr IntVectND<dim>
1155diagShift (const IntVectND<dim>& p, int s) noexcept
1156{
1157 return p + s;
1158}
1159
1164template<int dim>
1167IntVectND<dim>
1168coarsen (const IntVectND<dim>& p, int s) noexcept
1169{
1170 BL_ASSERT(s > 0);
1171 IntVectND<dim> v = p;
1172 v.coarsen(s);
1173 return v;
1174}
1175
1180template<int dim>
1183IntVectND<dim>
1184coarsen (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1185{
1186 IntVectND<dim> v = p1;
1187 v.coarsen(p2);
1188 return v;
1189}
1190
1191template<int dim>
1192requires ( 1<=dim && dim<=3 )
1194constexpr Dim3 refine (Dim3 const& coarse, IntVectND<dim> const& ratio) noexcept
1195{
1196 if constexpr (dim == 1) {
1197 return Dim3{.x = coarse.x*ratio[0], .y = coarse.y, .z = coarse.z};
1198 } else if constexpr (dim == 2) {
1199 return Dim3{.x = coarse.x*ratio[0], .y = coarse.y*ratio[1], .z = coarse.z};
1200 } else {
1201 return Dim3{.x = coarse.x*ratio[0], .y = coarse.y*ratio[1], .z = coarse.z*ratio[2]};
1202 }
1203}
1204
1205template<int dim>
1206requires ( 1<=dim && dim<=3 )
1208Dim3 coarsen (Dim3 const& fine, IntVectND<dim> const& ratio) noexcept
1209{
1210 if constexpr (dim == 1) {
1211 return Dim3{.x = amrex::coarsen(fine.x, ratio[0]),
1212 .y = fine.y,
1213 .z = fine.z};
1214 } else if constexpr (dim == 2) {
1215 return Dim3{.x = amrex::coarsen(fine.x, ratio[0]),
1216 .y = amrex::coarsen(fine.y, ratio[1]),
1217 .z = fine.z};
1218 } else {
1219 return Dim3{.x = amrex::coarsen(fine.x, ratio[0]),
1220 .y = amrex::coarsen(fine.y, ratio[1]),
1221 .z = amrex::coarsen(fine.z, ratio[2])};
1222 }
1223}
1224
1226namespace detail {
1227
1228 template<int dim>
1230 void IntVectCat_imp (int*& dst, const IntVectND<dim>& src) noexcept {
1231 for (int i=0; i<dim; ++i) {
1232 dst[i] = src[i];
1233 }
1234 dst += dim;
1235 }
1236
1237 template<int dim>
1239 void IntVectSplit_imp2 (IntVectND<dim>& dst, const int*& src) noexcept {
1240 for (int i=0; i<dim; ++i) {
1241 dst[i] = src[i];
1242 }
1243 src += dim;
1244 }
1245
1246 template<class T, std::size_t...Ns>
1248 T IntVectSplit_imp (T& retval, std::index_sequence<Ns...>, const int * src) noexcept {
1249 (IntVectSplit_imp2(amrex::get<Ns>(retval), src), ...);
1250 return retval;
1251 }
1252
1253 template<int...dims>
1255 int get_sum () {
1256 return (0 + ... + dims);
1257 }
1258}
1260
1266template<int dim>
1267std::ostream&
1268operator<< (std::ostream& os, const IntVectND<dim>& iv)
1269{
1270 return detail::T_vector_write(os, iv.begin(), dim);
1271}
1272
1283template<int dim>
1284std::istream&
1285operator>> (std::istream& is, IntVectND<dim>& iv)
1286{
1287 return detail::T_vector_read(is, iv.begin(), dim);
1288}
1289
1294template<int d, int...dims>
1297constexpr IntVectND<detail::get_sum<d, dims...>()>
1298IntVectCat (const IntVectND<d>& v, const IntVectND<dims>&...vects) noexcept {
1299 IntVectND<detail::get_sum<d, dims...>()> retval (0);
1300 int* dst = retval.begin();
1301 detail::IntVectCat_imp(dst, v);
1302 (detail::IntVectCat_imp(dst, vects), ...);
1303 return retval;
1304}
1305
1310template<int d, int...dims>
1313constexpr GpuTuple<IntVectND<d>, IntVectND<dims>...>
1314IntVectSplit (const IntVectND<detail::get_sum<d, dims...>()>& v) noexcept {
1316 return detail::IntVectSplit_imp(retval,
1317 std::make_index_sequence<1 + sizeof...(dims)>(),
1318 v.begin());
1319}
1320
1325template<int new_dim, int old_dim>
1328constexpr IntVectND<new_dim>
1329IntVectShrink (const IntVectND<old_dim>& iv) noexcept {
1330 return iv.template shrink<new_dim>();
1331}
1332
1337template<int new_dim, int old_dim>
1340constexpr IntVectND<new_dim>
1341IntVectExpand (const IntVectND<old_dim>& iv, int fill_extra=0) noexcept {
1342 return iv.template expand<new_dim>(fill_extra);
1343}
1344
1349template<int new_dim, int old_dim>
1352constexpr IntVectND<new_dim>
1353IntVectResize (const IntVectND<old_dim>& iv, int fill_extra=0) noexcept {
1354 return iv.template resize<new_dim>(fill_extra);
1355}
1356
1358template <std::size_t I, int dim>
1360constexpr int get (IntVectND<dim> const& iv) noexcept { return iv.vect[I]; }
1361
1362namespace detail {
1363 template <typename F, int dim, std::size_t... N>
1365 constexpr auto apply_impl (F&& f, IntVectND<dim> const& iv,
1366 std::index_sequence<N...> /*is*/)
1367 {
1368 return std::forward<F>(f)(amrex::get<N>(iv)...);
1369 }
1370}
1371
1374template <typename F, int dim>
1376constexpr auto Apply (F&& f, IntVectND<dim> const& iv)
1377{
1378 return detail::apply_impl(std::forward<F>(f), iv, std::make_index_sequence<dim>());
1379}
1380
1381} // namespace amrex
1382
1383// Spcialize std::tuple_size for IntVectND. Used by structured bindings.
1384template<int dim>
1385struct std::tuple_size<amrex::IntVectND<dim>> {
1386 static constexpr std::size_t value = dim;
1387};
1388
1389// Spcialize std::tuple_element for IntVectND. Used by structured bindings.
1390template<std::size_t s, int dim>
1391struct std::tuple_element<s, amrex::IntVectND<dim>> {
1392 using type = int;
1393};
1394
1395#endif /*AMREX_INTVECT_H*/
Runtime initialization/finalization helpers and global diagnostics.
Fixed-size array types for use on GPU and CPU.
Assertion macros used across AMReX for runtime consistency checks.
#define BL_ASSERT(EX)
Definition AMReX_BLassert.H:39
Simple structs for 3-component integer and real-valued tuples.
Compiler- and backend-specific extension macros (e.g., restrict, SIMD, inline).
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:124
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
int idir
Definition AMReX_HypreMLABecLap.cpp:1143
Array4< Real > fine
Definition AMReX_InterpFaceRegister.cpp:90
GpuArray< MultiArray4< Real const >, 3 > s
Definition AMReX_MLEBNodeFDLaplacian.cpp:214
GPU-compatible tuple.
Definition AMReX_Tuple.H:104
An Integer Vector in dim-Dimensional Space.
Definition AMReX_IntVect.H:149
__host__ __device__ constexpr IntVectND< dim > & operator*=(int s) noexcept
Modifies IntVectND by multiplication of a scalar to each component.
Definition AMReX_IntVect.H:594
__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:220
__host__ __device__ int * getVect() &noexcept
Definition AMReX_IntVect.H:385
__host__ __device__ constexpr IntVectND< dim > operator*(const IntVectND< dim > &p) const noexcept
Returns component-wise product of IntVectND and argument.
Definition AMReX_IntVect.H:676
__host__ __device__ constexpr int & operator[](int i) noexcept
Returns a reference to the i'th coordinate of the IntVectND.
Definition AMReX_IntVect.H:339
__host__ __device__ constexpr 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:517
__host__ __device__ constexpr Dim3 dim3() const noexcept
Definition AMReX_IntVect.H:262
__host__ __device__ constexpr bool operator>(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically greater than rhs.
Definition AMReX_IntVect.H:452
__host__ __device__ constexpr IntVectND< dim > & shift(int coord, int s) noexcept
Modify IntVectND by adding s to given coordinate.
Definition AMReX_IntVect.H:741
__host__ __device__ constexpr int min() const noexcept
minimum (no absolute values) value
Definition AMReX_IntVect.H:324
__host__ __device__ constexpr 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 fill_extra...
Definition AMReX_IntVect.H:874
__host__ __device__ constexpr IntVectND< dim > & operator+=(int s) noexcept
Modifies IntVectND by addition of a scalar to each component.
Definition AMReX_IntVect.H:576
__host__ __device__ constexpr IntVectND< dim > & shift(const IntVectND< dim > &iv) noexcept
Equivalent to shift(0,iv[0]).shift(1,iv[1]) ...
Definition AMReX_IntVect.H:747
int value_type
Definition AMReX_IntVect.H:855
__host__ __device__ constexpr Array< T, dim > toArray() const noexcept
Definition AMReX_IntVect.H:289
__host__ __device__ constexpr int & get() noexcept
Returns a reference to the i'th coordinate of the IntVectND. Used by structured bindings.
Definition AMReX_IntVect.H:348
__host__ __device__ int * getVect() &&=delete
constexpr IntVectND(const Array< int, dim > &a) noexcept
Construct an IntVectND from an Array<int,dim>.
Definition AMReX_IntVect.H:241
__host__ static __device__ constexpr IntVectND< dim > TheMaxVector() noexcept
Definition AMReX_IntVect.H:837
__host__ static __device__ constexpr std::size_t size() noexcept
Definition AMReX_IntVect.H:846
__host__ __device__ IntVectND & setVal(int i, int val) noexcept
Set i'th coordinate of IntVectND to val.
Definition AMReX_IntVect.H:373
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:231
__host__ __device__ constexpr bool allGT(int rhs) const noexcept
Returns true if this is greater than argument for all components.
Definition AMReX_IntVect.H:529
__host__ __device__ constexpr int * begin() noexcept
Returns a pointer to the first element of the IntVectND.
Definition AMReX_IntVect.H:357
__host__ __device__ IntVectND< dim > & coarsen(const IntVectND< dim > &p) noexcept
Modify IntVectND<dim> by component-wise integer projection.
Definition AMReX_IntVect.H:967
__host__ static __device__ constexpr 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:781
__host__ __device__ int maxDir(bool a_doAbsValue) const noexcept
Definition AMReX_IntVect.H:980
__host__ __device__ 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:383
__host__ static __device__ constexpr IntVectND< dim > TheFaceVector(int d) noexcept
This static member function returns an IntVectND for the index type of faces normal to direction d: n...
Definition AMReX_IntVect.H:802
static const IntVectND< dim > Unit
Definition AMReX_IntVect.H:905
__host__ __device__ constexpr IntVectND< dim > & min(const IntVectND< dim > &p) noexcept
Modifies IntVectND by taking component-wise min with argument.
Definition AMReX_IntVect.H:704
__host__ __device__ constexpr Dim3 dim3(int fill_extra) const noexcept
Definition AMReX_IntVect.H:275
__host__ __device__ constexpr int sum() const noexcept
Definition AMReX_IntVect.H:302
__host__ __device__ constexpr IntVectND< dim > & scale(int s) noexcept
Modify IntVectND by multiplying each coordinate by s.
Definition AMReX_IntVect.H:722
__host__ __device__ constexpr const int * begin() const noexcept
Returns a pointer to the first element of the IntVectND.
Definition AMReX_IntVect.H:361
__host__ __device__ constexpr 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:542
__host__ static __device__ constexpr IntVectND< dim > TheEdgeVector(int d) noexcept
This static member function returns an IntVectND for the index type of edges parallel to direction d:...
Definition AMReX_IntVect.H:812
__host__ __device__ constexpr 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:733
__host__ static __device__ constexpr 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:832
__host__ __device__ constexpr bool operator==(int val) const noexcept
Returns true if all components are equal to the argument val.
Definition AMReX_IntVect.H:391
__host__ __device__ constexpr IntVectND< dim > & diagShift(int s) noexcept
Modify IntVectND by adding s to each coordinate.
Definition AMReX_IntVect.H:750
__host__ __device__ constexpr IntVectND< dim > operator-() const noexcept
Unary Minus – negates all components.
Definition AMReX_IntVect.H:567
__host__ __device__ constexpr 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:889
__host__ static __device__ constexpr 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:771
__host__ __device__ constexpr IntVectND< dim > operator+() const noexcept
Unary plus – for completeness.
Definition AMReX_IntVect.H:564
__host__ __device__ IntVectND< dim > & coarsen(int p) noexcept
Modify IntVectND<dim> by component-wise integer projection.
Definition AMReX_IntVect.H:939
__host__ __device__ constexpr int max() const noexcept
maximum (no absolute values) value
Definition AMReX_IntVect.H:313
constexpr IntVectND(Dim3 const &a) noexcept
Definition AMReX_IntVect.H:247
__host__ __device__ constexpr 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:467
__host__ static __device__ constexpr 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:823
static const IntVectND< dim > Zero
Definition AMReX_IntVect.H:900
__host__ __device__ constexpr bool allLE(int rhs) const noexcept
Returns true if this is less than or equal to argument for all components.
Definition AMReX_IntVect.H:504
__host__ __device__ constexpr IntVectND< dim > & operator-=(int s) noexcept
Modifies IntVectND by subtraction of a scalar to each component.
Definition AMReX_IntVect.H:630
__host__ __device__ constexpr IntVectND< dim > operator/(const IntVectND< dim > &p) const noexcept
Returns component-wise division of IntVectND by argument.
Definition AMReX_IntVect.H:690
__host__ __device__ constexpr IntVectND< dim > & operator/=(int s) noexcept
Modifies IntVectND by division by a scalar to each component.
Definition AMReX_IntVect.H:612
__host__ __device__ constexpr int * end() noexcept
Returns a pointer to the (last+1) element of the IntVectND.
Definition AMReX_IntVect.H:365
__host__ static __device__ constexpr int isize() noexcept
Definition AMReX_IntVect.H:851
__host__ __device__ constexpr bool operator<=(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically less than or equal to rhs.
Definition AMReX_IntVect.H:446
__host__ __device__ constexpr IntVectND(int s) noexcept
Construct an IntVectND whose components are all the same.
Definition AMReX_IntVect.H:209
__host__ __device__ constexpr const int * end() const noexcept
Returns a pointer to the (last+1) element of the IntVectND.
Definition AMReX_IntVect.H:369
__host__ __device__ constexpr bool operator<(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically less than rhs.
Definition AMReX_IntVect.H:433
__host__ __device__ constexpr const int & get() const noexcept
Returns a reference to the i'th coordinate of the IntVectND. Used by structured bindings.
Definition AMReX_IntVect.H:353
__host__ __device__ constexpr bool operator!=(int val) const noexcept
Returns true if any component is not equal to the argument val.
Definition AMReX_IntVect.H:402
__host__ __device__ constexpr 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:492
__host__ __device__ constexpr bool allGE(int rhs) const noexcept
Returns true if this is greater than or equal to argument for all components.
Definition AMReX_IntVect.H:554
__host__ __device__ constexpr IntVectND< dim > & max(const IntVectND< dim > &p) noexcept
Modifies IntVectND by taking component-wise max with argument.
Definition AMReX_IntVect.H:713
__host__ __device__ constexpr bool allLT(int rhs) const noexcept
Returns true if this is less than argument for all components.
Definition AMReX_IntVect.H:479
constexpr IntVectND() noexcept
Construct an IntVectND whose components are all zero.
Definition AMReX_IntVect.H:193
int vect[dim]
Definition AMReX_IntVect.H:907
__host__ static __device__ constexpr IntVectND< dim > TheMinVector() noexcept
Definition AMReX_IntVect.H:841
__host__ __device__ constexpr bool operator>=(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically greater than or equal to rhs.
Definition AMReX_IntVect.H:458
__host__ __device__ constexpr 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:863
__host__ static __device__ constexpr 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:790
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
__host__ __device__ BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b coarsened by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1469
__host__ __device__ BoxND< dim > refine(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b refined by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1510
std::array< T, N > Array
Definition AMReX_Array.H:31
__host__ __device__ constexpr T elemwiseMax(T const &a, T const &b) noexcept
Definition AMReX_Algorithm.H:90
__host__ __device__ constexpr const T & min(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:31
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:53
__host__ __device__ constexpr T elemwiseMin(T const &a, T const &b) noexcept
Definition AMReX_Algorithm.H:73
Definition AMReX_Amr.cpp:50
std::ostream & operator<<(std::ostream &os, AmrMesh const &amr_mesh)
Stream helper; forwards to the friend declared inside AmrMesh.
Definition AMReX_AmrMesh.cpp:1372
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:273
__host__ __device__ constexpr 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:1353
__host__ __device__ constexpr 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:1314
__host__ __device__ 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:1112
__host__ __device__ GpuComplex< T > operator*(const GpuComplex< T > &a_x, const GpuComplex< U > &a_y) noexcept
Multiply two complex numbers.
Definition AMReX_GpuComplex.H:257
__host__ __device__ constexpr 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:1155
constexpr bool IsConvertible_v
Definition AMReX_TypeTraits.H:256
__host__ __device__ constexpr 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:1142
__host__ __device__ constexpr 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:1329
__host__ __device__ constexpr auto Apply(F &&f, IntVectND< dim > const &iv)
Definition AMReX_IntVect.H:1376
__host__ __device__ constexpr 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:1128
void Error(const std::string &msg)
Print a message to stderr and abort the program.
Definition AMReX.cpp:238
__host__ __device__ constexpr 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 fill_extra to the rema...
Definition AMReX_IntVect.H:1341
const int[]
Definition AMReX_BLProfiler.cpp:1665
std::istream & operator>>(std::istream &is, BoxND< dim > &bx)
Read a BoxND from is.
Definition AMReX_Box.H:1965
__host__ __device__ constexpr 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:1298
__host__ __device__ XDim3 operator-(XDim3 const &a, XDim3 const &b)
Component-wise subtraction of two XDim3 structs.
Definition AMReX_Dim3.H:73
__host__ __device__ XDim3 operator+(XDim3 const &a, XDim3 const &b)
Component-wise addition of two XDim3 structs.
Definition AMReX_Dim3.H:62
__host__ __device__ constexpr int get(IntVectND< dim > const &iv) noexcept
Get I'th element of IntVectND<dim>
Definition AMReX_IntVect.H:1360
A simple struct holding 3 int values for a 3D index.
Definition AMReX_Dim3.H:24
int x
Definition AMReX_Dim3.H:24
int z
Definition AMReX_Dim3.H:24
int y
Definition AMReX_Dim3.H:24
Hash function for IntVectND.
Definition AMReX_IntVect.H:154
std::size_t operator()(const IntVectND< dim > &vec) const noexcept
Definition AMReX_IntVect.H:155
int type
Definition AMReX_IntVect.H:1392