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 <bit>
19#include <iosfwd>
20#include <cstdlib>
21#include <cmath>
22#include <limits>
23#include <climits>
24#include <algorithm>
25
26namespace amrex {
27
28// Coarsening rounds toward negative infinity. For ratios 2 and 4 that is a
29// right shift, which is arithmetic for a negative int (C++20).
31int coarsen (int i, int ratio) noexcept
32{
33 switch (ratio) {
34 case 1: return i;
35 case 2: return i >> 1;
36 case 4: return i >> 2;
37 default: return (i<0) ? -std::abs(i+1)/ratio-1 : i/ratio;
38 }
39}
40
41template <int ratio>
43int coarsen (int i) noexcept
44{
45 if constexpr (ratio > 0 && (ratio & (ratio-1)) == 0) {
46 return i >> std::countr_zero(unsigned(ratio));
47 } else {
48 return (i<0) ? -std::abs(i+1)/ratio-1 : i/ratio;
49 }
50}
51
53namespace detail
54{
55 template <typename T>
56 std::ostream& T_vector_write (std::ostream& os, const T* data, int dim)
57 {
58 os << '(' << data[0];
59 for (int i = 1; i < dim; ++i) {
60 os << ',' << data[i];
61 }
62 os << ')';
63 if (os.fail()) {
64 amrex::Error("operator<<(ostream&,[Int|Real]Vect&) failed");
65 }
66 return os;
67 }
68
69 template <typename T>
70 std::istream& T_vector_read (std::istream& is, T* data, int dim)
71 {
72 is >> std::ws;
73 char c;
74 is >> c;
75
76 for (int i = 0; i < dim; ++i) {
77 data[i] = T(0);
78 }
79
80 if (c == '(')
81 {
82 int component = 0;
83 bool need_comma = false;
84
85 while (true) {
86 is >> std::ws;
87 int ic = is.peek();
88
89 if (ic == std::char_traits<char>::eof()) {
90 if (component == 0) {
91 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): missing first component");
92 } else {
93 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): premature EOF");
94 }
95 }
96
97 if (ic == static_cast<int>(')')) {
98 is.get();
99 if (component == 0) {
100 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): missing first component");
101 }
102 break;
103 }
104
105 if (need_comma) {
106 if (ic != static_cast<int>(',')) {
107 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): expected ',' or ')'");
108 }
109 is.get();
110 is >> std::ws;
111 }
112
113 T value{};
114 if (!(is >> value)) {
115 if (component == 0) {
116 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): missing first component");
117 } else {
118 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): premature EOF");
119 }
120 }
121
122 if (component < dim) {
123 data[component] = value;
124 }
125 ++component;
126 need_comma = true;
127 }
128 }
129 else
130 {
131 amrex::Error("operator>>(ostream&,[Int|Real]Vect&): expected '('");
132 }
133
134 if (is.fail()) {
135 amrex::Error("operator>>(ostream&,[Int|Real]Vect&) failed");
136 }
137
138 return is;
139 }
140}
142
154template<int dim>
156{
157public:
158 static_assert(dim >= 1, "The number of dimensions of IntVectND must be positive");
159
162 std::size_t operator()(const IntVectND<dim>& vec) const noexcept
163 {
164 static constexpr unsigned shift1 = sizeof(size_t)>=8 ? 20 : 10;
165 static constexpr unsigned shift2 = sizeof(size_t)>=8 ? 40 : 20;
166 if constexpr (dim == 1) {
167 amrex::ignore_unused(shift1);
168 amrex::ignore_unused(shift2);
169 return static_cast<std::size_t>(vec[0]);
170 } else if constexpr (dim == 2) {
171 amrex::ignore_unused(shift2);
172 return static_cast<std::size_t>(vec[0]) ^
173 (static_cast<std::size_t>(vec[1]) << shift1);
174 } else if constexpr (dim == 3) {
175 return static_cast<std::size_t>(vec[0]) ^
176 (static_cast<std::size_t>(vec[1]) << shift1) ^
177 (static_cast<std::size_t>(vec[2]) << shift2);
178 } else {
179 std::size_t seed = dim;
180 // hash function from
181 // https://stackoverflow.com/questions/20511347/a-good-hash-function-for-a-vector
182 for (int i=0; i<dim; ++i) {
183 auto x = static_cast<unsigned int>(vec[i]);
184 x = ((x >> 16) ^ x) * 0x45d9f3b;
185 x = ((x >> 16) ^ x) * 0x45d9f3b;
186 x = (x >> 16) ^ x;
187 seed ^= x + 0x9e3779b9 + (seed << 6) + (seed >> 2);
188 }
189 return seed;
190 }
191 }
192 };
193
194 using hasher = shift_hasher;
195
197
200 constexpr IntVectND () noexcept {} // cannot use = default due to Clang bug // NOLINT
201
207 template <class...Args>
208 requires ((sizeof...(Args)+2 == dim) && IsConvertible_v<int, Args...>)
210 constexpr IntVectND (int i, int j, Args...ks) noexcept : vect{i, j, static_cast<int>(ks)...} {}
211
216 explicit constexpr IntVectND (int s) noexcept {
217 for (int i=0; i<dim; ++i) {
218 vect[i] = s;
219 }
220 }
221
227 explicit IntVectND (const int* a) noexcept {
228 for (int i=0; i<dim; ++i) {
229 vect[i] = a[i];
230 }
231 }
232
238 explicit IntVectND (const Vector<int>& a) noexcept {
239 BL_ASSERT(a.size() == dim);
240 for (int i=0; i<dim; ++i) {
241 vect[i] = a[i];
242 }
243 }
244
248 explicit constexpr IntVectND (const Array<int,dim>& a) noexcept {
249 for (int i=0; i<dim; ++i) {
250 vect[i] = a[i];
251 }
252 }
253
254 explicit constexpr IntVectND (Dim3 const& a) noexcept
255 requires ( 1<=dim && dim<=3 )
256 {
257 vect[0] = a.x;
258 if constexpr (dim >= 2) {
259 vect[1] = a.y;
260 }
261 if constexpr (dim == 3) {
262 vect[2] = a.z;
263 }
264 }
265
266 // dtor, copy-ctor, copy-op=, move-ctor, and move-op= are compiler generated.
267
269 constexpr Dim3 dim3 () const noexcept
270 requires ( 1<=dim && dim<=3 )
271 {
272 if constexpr (dim == 1) {
273 return Dim3{.x = vect[0], .y = 0, .z = 0};
274 } else if constexpr (dim == 2) {
275 return Dim3{.x = vect[0], .y = vect[1], .z = 0};
276 } else {
277 return Dim3{.x = vect[0], .y = vect[1], .z = vect[2]};
278 }
279 }
280
282 constexpr Dim3 dim3 ([[maybe_unused]] int fill_extra) const noexcept
283 requires ( 1<=dim && dim<=3 )
284 {
285 if constexpr (dim == 1) {
286 return Dim3{.x = vect[0], .y = fill_extra, .z = fill_extra};
287 } else if constexpr (dim == 2) {
288 return Dim3{.x = vect[0], .y = vect[1], .z = fill_extra};
289 } else {
290 return Dim3{.x = vect[0], .y = vect[1], .z = vect[2]};
291 }
292 }
293
294 template< typename T = int >
296 constexpr Array<T, dim> toArray () const noexcept {
297 Array<T, dim> ret {};
298 for (int i=0; i<dim; ++i) {
299 ret[i] = T(vect[i]);
300 }
301 return ret;
302 }
303
305
309 constexpr int sum () const noexcept
310 {
311 int retval = vect[0];
312 for (int i=1; i<dim; ++i) {
313 retval += vect[i];
314 }
315 return retval;
316 }
317
320 constexpr int max () const noexcept
321 {
322 int retval = vect[0];
323 for (int i=1; i<dim; ++i) {
324 retval = retval > vect[i] ? retval : vect[i];
325 }
326 return retval;
327 }
328
331 constexpr int min () const noexcept
332 {
333 int retval = vect[0];
334 for (int i=1; i<dim; ++i) {
335 retval = retval < vect[i] ? retval : vect[i];
336 }
337 return retval;
338 }
339
340 //return coordinate with largest value
342 int maxDir(bool a_doAbsValue) const noexcept;
343
345 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
346 int& operator[] (int i) noexcept { BL_ASSERT(i>=0 && i < dim); return vect[i]; }
347
349 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
350 const int& operator[] (int i) const noexcept { BL_ASSERT(i>=0 && i < dim); return vect[i]; }
351
353 template<std::size_t i>
354 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
355 int& get () noexcept {static_assert(0<=i && i<dim); return vect[i];}
356
358 template<std::size_t i>
359 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
360 const int& get () const noexcept {static_assert(0<=i && i<dim); return vect[i];}
361
363 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
364 int* begin () noexcept { return &vect[0]; }
365
367 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
368 const int* begin () const noexcept { return &vect[0]; }
369
371 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
372 int* end () noexcept { return &vect[dim]; }
373
375 [[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE constexpr
376 const int* end () const noexcept { return &vect[dim]; }
377
380 IntVectND& setVal (int i, int val) noexcept
381 {
382 BL_ASSERT(i>=0 && i<dim); vect[i] = val; return *this;
383 }
384
390 const int* getVect () const& noexcept { return vect; }
392 int* getVect () & noexcept { return vect; }
394 int* getVect () && = delete;
395
398 constexpr bool operator== (int val) const noexcept
399 {
400 bool retval = vect[0] == val;
401 for (int i=1; i<dim; ++i) {
402 retval = retval && vect[i] == val;
403 }
404 return retval;
405 }
406
409 constexpr bool operator!= (int val) const noexcept
410 {
411 bool retval = vect[0] != val;
412 for (int i=1; i<dim; ++i) {
413 retval = retval || vect[i] != val;
414 }
415 return retval;
416 }
417
420 constexpr bool operator== (const IntVectND<dim>& rhs) const noexcept
421 {
422 bool retval = vect[0] == rhs[0];
423 for (int i=1; i<dim; ++i) {
424 retval = retval && vect[i] == rhs[i];
425 }
426 return retval;
427 }
428
430 constexpr bool operator!= (const IntVectND<dim>& rhs) const noexcept
431 {
432 bool retval = vect[0] != rhs[0];
433 for (int i=1; i<dim; ++i) {
434 retval = retval || vect[i] != rhs[i];
435 }
436 return retval;
437 }
438
440 constexpr bool operator< (const IntVectND<dim>& rhs) const noexcept
441 {
442 for (int i=dim-1; i>=0; --i) {
443 if (vect[i] < rhs[i]) {
444 return true;
445 } else if (vect[i] > rhs[i]) {
446 return false;
447 }
448 }
449 return false;
450 }
451
453 constexpr bool operator<= (const IntVectND<dim>& rhs) const noexcept
454 {
455 return !(rhs < *this);
456 }
457
459 constexpr bool operator> (const IntVectND<dim>& rhs) const noexcept
460 {
461 return rhs < *this;
462 }
463
465 constexpr bool operator>= (const IntVectND<dim>& rhs) const noexcept
466 {
467 return !(*this < rhs);
468 }
469
474 constexpr bool allLT (const IntVectND<dim>& rhs) const noexcept
475 {
476 bool retval = vect[0] < rhs[0];
477 for (int i=1; i<dim; ++i) {
478 retval = retval && vect[i] < rhs[i];
479 }
480 return retval;
481 }
482
486 constexpr bool allLT (int rhs) const noexcept
487 {
488 bool retval = vect[0] < rhs;
489 for (int i=1; i<dim; ++i) {
490 retval = retval && vect[i] < rhs;
491 }
492 return retval;
493 }
494
499 constexpr bool allLE (const IntVectND<dim>& rhs) const noexcept
500 {
501 bool retval = vect[0] <= rhs[0];
502 for (int i=1; i<dim; ++i) {
503 retval = retval && vect[i] <= rhs[i];
504 }
505 return retval;
506 }
507
511 constexpr bool allLE (int rhs) const noexcept
512 {
513 bool retval = vect[0] <= rhs;
514 for (int i=1; i<dim; ++i) {
515 retval = retval && vect[i] <= rhs;
516 }
517 return retval;
518 }
519
524 constexpr bool allGT (const IntVectND<dim>& rhs) const noexcept
525 {
526 bool retval = vect[0] > rhs[0];
527 for (int i=1; i<dim; ++i) {
528 retval = retval && vect[i] > rhs[i];
529 }
530 return retval;
531 }
532
536 constexpr bool allGT (int rhs) const noexcept
537 {
538 bool retval = vect[0] > rhs;
539 for (int i=1; i<dim; ++i) {
540 retval = retval && vect[i] > rhs;
541 }
542 return retval;
543 }
544
549 constexpr bool allGE (const IntVectND<dim>& rhs) const noexcept
550 {
551 bool retval = vect[0] >= rhs[0];
552 for (int i=1; i<dim; ++i) {
553 retval = retval && vect[i] >= rhs[i];
554 }
555 return retval;
556 }
557
561 constexpr bool allGE (int rhs) const noexcept
562 {
563 bool retval = vect[0] >= rhs;
564 for (int i=1; i<dim; ++i) {
565 retval = retval && vect[i] >= rhs;
566 }
567 return retval;
568 }
569
571 constexpr IntVectND<dim> operator+ () const noexcept { return *this; }
574 constexpr IntVectND<dim> operator- () const noexcept {
575 IntVectND<dim> retval(0);
576 for (int i=0; i<dim; ++i) {
577 retval[i] = -vect[i];
578 }
579 return retval;
580 }
581
583 constexpr IntVectND<dim>& operator+= (int s) noexcept
584 {
585 for (int i=0; i<dim; ++i) {
586 vect[i] += s;
587 }
588 return *this;
589 }
590
592 constexpr IntVectND<dim>& operator+= (const IntVectND<dim>& p) noexcept
593 {
594 for (int i=0; i<dim; ++i) {
595 vect[i] += p[i];
596 }
597 return *this;
598 }
599
601 constexpr IntVectND<dim>& operator*= (int s) noexcept
602 {
603 for (int i=0; i<dim; ++i) {
604 vect[i] *= s;
605 }
606 return *this;
607 }
608
610 constexpr IntVectND<dim>& operator*= (const IntVectND<dim>& p) noexcept
611 {
612 for (int i=0; i<dim; ++i) {
613 vect[i] *= p[i];
614 }
615 return *this;
616 }
617
619 constexpr IntVectND<dim>& operator/= (int s) noexcept
620 {
621 for (int i=0; i<dim; ++i) {
622 vect[i] /= s;
623 }
624 return *this;
625 }
626
628 constexpr IntVectND<dim>& operator/= (const IntVectND<dim>& p) noexcept
629 {
630 for (int i=0; i<dim; ++i) {
631 vect[i] /= p[i];
632 }
633 return *this;
634 }
635
637 constexpr IntVectND<dim>& operator-= (int s) noexcept
638 {
639 for (int i=0; i<dim; ++i) {
640 vect[i] -= s;
641 }
642 return *this;
643 }
644
646 constexpr IntVectND<dim>& operator-= (const IntVectND<dim>& p) noexcept
647 {
648 for (int i=0; i<dim; ++i) {
649 vect[i] -= p[i];
650 }
651 return *this;
652 }
653
655 constexpr IntVectND<dim> operator+ (const IntVectND<dim>& p) const noexcept
656 {
657 IntVectND<dim> retval = *this;
658 return retval += p;
659 }
660
662 constexpr IntVectND<dim> operator+ (int s) const noexcept
663 {
664 IntVectND<dim> retval = *this;
665 return retval += s;
666 }
667
669 constexpr IntVectND<dim> operator- (const IntVectND<dim>& p) const noexcept
670 {
671 IntVectND<dim> retval = *this;
672 return retval -= p;
673 }
674
676 constexpr IntVectND<dim> operator- (int s) const noexcept
677 {
678 IntVectND<dim> retval = *this;
679 return retval -= s;
680 }
681
683 constexpr IntVectND<dim> operator* (const IntVectND<dim>& p) const noexcept
684 {
685 IntVectND<dim> retval = *this;
686 return retval *= p;
687 }
688
690 constexpr IntVectND<dim> operator* (int s) const noexcept
691 {
692 IntVectND<dim> retval = *this;
693 return retval *= s;
694 }
695
697 constexpr IntVectND<dim> operator/ (const IntVectND<dim>& p) const noexcept
698 {
699 IntVectND<dim> retval = *this;
700 return retval /= p;
701 }
702
704 constexpr IntVectND<dim> operator/ (int s) const noexcept
705 {
706 IntVectND<dim> retval = *this;
707 return retval /= s;
708 }
709
711 constexpr IntVectND<dim>& min (const IntVectND<dim>& p) noexcept
712 {
713 for (int i=0; i<dim; ++i) {
714 vect[i] = (vect[i] < p.vect[i] ? vect[i] : p.vect[i]);
715 }
716 return *this;
717 }
718
720 constexpr IntVectND<dim>& max (const IntVectND<dim>& p) noexcept
721 {
722 for (int i=0; i<dim; ++i) {
723 vect[i] = (vect[i] > p.vect[i] ? vect[i] : p.vect[i]);
724 }
725 return *this;
726 }
727
729 constexpr IntVectND<dim>& scale (int s) noexcept {
730 for (int i=0; i<dim; ++i) {
731 vect[i] *= s;
732 }
733 return *this;
734 }
735
740 constexpr IntVectND<dim>& reflect (int ref_ix, int idir) noexcept
741 {
742 BL_ASSERT(idir >= 0 && idir < dim);
743 vect[idir] = -vect[idir] + 2*ref_ix;
744 return *this;
745 }
746
748 constexpr IntVectND<dim>& shift (int coord, int s) noexcept
749 {
750 BL_ASSERT(coord >= 0 && coord < dim); vect[coord] += s; return *this;
751 }
752
754 constexpr IntVectND<dim>& shift (const IntVectND<dim>& iv) noexcept { *this += iv; return *this; }
757 constexpr IntVectND<dim>& diagShift (int s) noexcept
758 {
759 for (int i=0; i<dim; ++i) {
760 vect[i] += s;
761 }
762 return *this;
763 }
764
769 IntVectND<dim>& coarsen (int p) noexcept;
770
778 static constexpr IntVectND<dim> TheZeroVector () noexcept {
779 return IntVectND<dim>(0);
780 }
781
788 static constexpr IntVectND<dim> TheUnitVector () noexcept {
789 return IntVectND<dim>(1);
790 }
791
797 static constexpr IntVectND<dim> TheDimensionVector (int d) noexcept {
798 IntVectND<dim> retval(0);
799 retval[d] = 1;
800 return retval;
801 }
802
809 static constexpr IntVectND<dim> TheFaceVector (int d) noexcept {
810 return TheDimensionVector(d);
811 }
812
819 static constexpr IntVectND<dim> TheEdgeVector (int d) noexcept {
820 IntVectND<dim> retval(1);
821 retval[d] = 0;
822 return retval;
823 }
824
830 static constexpr IntVectND<dim> TheNodeVector () noexcept {
831 return IntVectND<dim>(1);
832 }
833
839 static constexpr IntVectND<dim> TheCellVector () noexcept {
840 return IntVectND<dim>(0);
841 }
842
844 static constexpr IntVectND<dim> TheMaxVector () noexcept {
845 return IntVectND<dim>(std::numeric_limits<int>::max());
846 }
848 static constexpr IntVectND<dim> TheMinVector () noexcept {
849 return IntVectND<dim>(std::numeric_limits<int>::lowest());
850 }
851
853 static constexpr std::size_t size () noexcept {
854 return static_cast<std::size_t>(dim);
855 }
856
858 static constexpr int isize () noexcept {
859 return dim;
860 }
861
863
868 template<int new_dim>
870 constexpr IntVectND<new_dim> shrink () const noexcept {
871 static_assert(new_dim <= dim);
872 return IntVectND<new_dim>(this->begin());
873 }
874
879 template<int new_dim>
881 constexpr IntVectND<new_dim> expand (int fill_extra=0) const noexcept {
882 static_assert(new_dim >= dim);
883 IntVectND<new_dim> retval(fill_extra);
884 for (int i=0; i<dim; ++i) {
885 retval[i] = vect[i];
886 }
887 return retval;
888 }
889
894 template<int new_dim>
896 constexpr IntVectND<new_dim> resize (int fill_extra=0) const noexcept {
897 if constexpr (new_dim > dim) {
898 return expand<new_dim>(fill_extra);
899 } else {
900 return shrink<new_dim>();
901 }
902 }
903
907 static const IntVectND<dim> Zero;
908
912 static const IntVectND<dim> Unit;
913
914 int vect[dim] = {};
915};
916
917template <int dim>
918inline constexpr const IntVectND<dim> IntVectND<dim>::Zero{0};
919
920template <int dim>
921inline constexpr const IntVectND<dim> IntVectND<dim>::Unit{1};
922
923// Template deduction guide for IntVectND
924template<std::size_t dim>
925#if defined(__clang__) && __clang_major__ < 22
926AMREX_GPU_HOST_DEVICE // __device__ for HIP
927#endif
929
930// Template deduction guide for IntVectND
931template <class...Args>
932requires (IsConvertible_v<int, Args...>)
933#if defined(__clang__) && __clang_major__ < 22
934AMREX_GPU_HOST_DEVICE // __device__ for HIP
935#endif
936IntVectND(int, int, Args...) -> IntVectND<sizeof...(Args)+2>;
937
941
942template<int dim>
947{
948 BL_ASSERT(s > 0);
949 switch (s) {
950 case 1:
951 break;
952 case 2:
953 for (int i=0; i<dim; ++i) {
954 vect[i] >>= 1;
955 }
956 break;
957 case 4:
958 for (int i=0; i<dim; ++i) {
959 vect[i] >>= 2;
960 }
961 break;
962 default:
963 for (int i=0; i<dim; ++i) {
964 vect[i] = (vect[i]<0) ? -std::abs(vect[i]+1)/s-1 : vect[i]/s;
965 }
966 }
967 return *this;
968}
969
970template<int dim>
975{
976 BL_ASSERT(p.allGT(0));
977 for (int i=0; i<dim; ++i) {
978 vect[i] = amrex::coarsen(vect[i], p.vect[i]);
979 }
980 return *this;
981}
982
983template<int dim>
986int
987IntVectND<dim>::maxDir(bool a_doAbsValue) const noexcept
988{
989 int retval = 0;
990 if(a_doAbsValue)
991 {
992 int maxval = std::abs((*this)[0]);
993 for(int idir = 1; idir < dim; idir++)
994 {
995 int curval = std::abs((*this)[idir]);
996 if(curval > maxval)
997 {
998 maxval = curval;
999 retval = idir;
1000 }
1001 }
1002 }
1003 else
1004 {
1005 int maxval = (*this)[0];
1006 for(int idir = 1; idir < dim; idir++)
1007 {
1008 int curval = (*this)[idir];
1009 if(curval > maxval)
1010 {
1011 maxval = curval;
1012 retval = idir;
1013 }
1014 }
1015 }
1016 return retval;
1017}
1018
1020template<int dim>
1023constexpr IntVectND<dim> operator+ (int s, const IntVectND<dim>& p) noexcept
1024{
1025 IntVectND<dim> retval = p;
1026 for (int i=0; i<dim; ++i) {
1027 retval[i] = s + retval[i];
1028 }
1029 return retval;
1030}
1031
1033template<int dim>
1036constexpr IntVectND<dim> operator- (int s, const IntVectND<dim>& p) noexcept
1037{
1038 IntVectND<dim> retval = p;
1039 for (int i=0; i<dim; ++i) {
1040 retval[i] = s - retval[i];
1041 }
1042 return retval;
1043}
1044
1046template<int dim>
1049constexpr IntVectND<dim> operator* (int s, const IntVectND<dim>& p) noexcept
1050{
1051 IntVectND<dim> retval = p;
1052 for (int i=0; i<dim; ++i) {
1053 retval[i] = s * retval[i];
1054 }
1055 return retval;
1056}
1057
1062template<int dim>
1065constexpr IntVectND<dim>
1066min (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1067{
1068 IntVectND<dim> p(p1);
1069 p.min(p2);
1070 return p;
1071}
1072
1073template<int dim>
1076constexpr IntVectND<dim>
1077elemwiseMin (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1078{
1079 IntVectND<dim> p(p1);
1080 p.min(p2);
1081 return p;
1082}
1083
1088template<int dim>
1091constexpr IntVectND<dim>
1092max (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1093{
1094 IntVectND<dim> p(p1);
1095 p.max(p2);
1096 return p;
1097}
1098
1099template<int dim>
1102constexpr IntVectND<dim>
1103elemwiseMax (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1104{
1105 IntVectND<dim> p(p1);
1106 p.max(p2);
1107 return p;
1108}
1109
1115template<int dim = AMREX_SPACEDIM>
1119BASISV (int dir) noexcept
1120{
1121 BL_ASSERT(dir >= 0 && dir < dim);
1122 IntVectND<dim> tmp(0);
1123 tmp[dir] = 1;
1124 return tmp;
1125}
1126
1131template<int dim>
1134constexpr IntVectND<dim>
1135scale (const IntVectND<dim>& p, int s) noexcept
1136{
1137 return IntVectND<dim>(p).scale(s);
1138}
1139
1145template<int dim>
1148constexpr IntVectND<dim>
1149reflect (const IntVectND<dim>& a, int ref_ix, int idir) noexcept
1150{
1151 return IntVectND<dim>(a).reflect(ref_ix, idir);
1152}
1153
1158template<int dim>
1161constexpr IntVectND<dim>
1162diagShift (const IntVectND<dim>& p, int s) noexcept
1163{
1164 return p + s;
1165}
1166
1171template<int dim>
1175coarsen (const IntVectND<dim>& p, int s) noexcept
1176{
1177 BL_ASSERT(s > 0);
1178 IntVectND<dim> v = p;
1179 v.coarsen(s);
1180 return v;
1181}
1182
1187template<int dim>
1191coarsen (const IntVectND<dim>& p1, const IntVectND<dim>& p2) noexcept
1192{
1193 IntVectND<dim> v = p1;
1194 v.coarsen(p2);
1195 return v;
1196}
1197
1198template<int dim>
1199requires ( 1<=dim && dim<=3 )
1201constexpr Dim3 refine (Dim3 const& coarse, IntVectND<dim> const& ratio) noexcept
1202{
1203 if constexpr (dim == 1) {
1204 return Dim3{.x = coarse.x*ratio[0], .y = coarse.y, .z = coarse.z};
1205 } else if constexpr (dim == 2) {
1206 return Dim3{.x = coarse.x*ratio[0], .y = coarse.y*ratio[1], .z = coarse.z};
1207 } else {
1208 return Dim3{.x = coarse.x*ratio[0], .y = coarse.y*ratio[1], .z = coarse.z*ratio[2]};
1209 }
1210}
1211
1212template<int dim>
1213requires ( 1<=dim && dim<=3 )
1215Dim3 coarsen (Dim3 const& fine, IntVectND<dim> const& ratio) noexcept
1216{
1217 if constexpr (dim == 1) {
1218 return Dim3{.x = amrex::coarsen(fine.x, ratio[0]),
1219 .y = fine.y,
1220 .z = fine.z};
1221 } else if constexpr (dim == 2) {
1222 return Dim3{.x = amrex::coarsen(fine.x, ratio[0]),
1223 .y = amrex::coarsen(fine.y, ratio[1]),
1224 .z = fine.z};
1225 } else {
1226 return Dim3{.x = amrex::coarsen(fine.x, ratio[0]),
1227 .y = amrex::coarsen(fine.y, ratio[1]),
1228 .z = amrex::coarsen(fine.z, ratio[2])};
1229 }
1230}
1231
1233namespace detail {
1234
1235 template<int dim>
1237 void IntVectCat_imp (int*& dst, const IntVectND<dim>& src) noexcept {
1238 for (int i=0; i<dim; ++i) {
1239 dst[i] = src[i];
1240 }
1241 dst += dim;
1242 }
1243
1244 template<int dim>
1246 void IntVectSplit_imp2 (IntVectND<dim>& dst, const int*& src) noexcept {
1247 for (int i=0; i<dim; ++i) {
1248 dst[i] = src[i];
1249 }
1250 src += dim;
1251 }
1252
1253 template<class T, std::size_t...Ns>
1255 T IntVectSplit_imp (T& retval, std::index_sequence<Ns...>, const int * src) noexcept {
1256 (IntVectSplit_imp2(amrex::get<Ns>(retval), src), ...);
1257 return retval;
1258 }
1259
1260 template<int...dims>
1262 int get_sum () {
1263 return (0 + ... + dims);
1264 }
1265}
1267
1273template<int dim>
1274std::ostream&
1275operator<< (std::ostream& os, const IntVectND<dim>& iv)
1276{
1277 return detail::T_vector_write(os, iv.begin(), dim);
1278}
1279
1290template<int dim>
1291std::istream&
1292operator>> (std::istream& is, IntVectND<dim>& iv)
1293{
1294 return detail::T_vector_read(is, iv.begin(), dim);
1295}
1296
1301template<int d, int...dims>
1304constexpr IntVectND<detail::get_sum<d, dims...>()>
1305IntVectCat (const IntVectND<d>& v, const IntVectND<dims>&...vects) noexcept {
1306 IntVectND<detail::get_sum<d, dims...>()> retval (0);
1307 int* dst = retval.begin();
1308 detail::IntVectCat_imp(dst, v);
1309 (detail::IntVectCat_imp(dst, vects), ...);
1310 return retval;
1311}
1312
1317template<int d, int...dims>
1320constexpr GpuTuple<IntVectND<d>, IntVectND<dims>...>
1321IntVectSplit (const IntVectND<detail::get_sum<d, dims...>()>& v) noexcept {
1323 return detail::IntVectSplit_imp(retval,
1324 std::make_index_sequence<1 + sizeof...(dims)>(),
1325 v.begin());
1326}
1327
1332template<int new_dim, int old_dim>
1335constexpr IntVectND<new_dim>
1336IntVectShrink (const IntVectND<old_dim>& iv) noexcept {
1337 return iv.template shrink<new_dim>();
1338}
1339
1344template<int new_dim, int old_dim>
1347constexpr IntVectND<new_dim>
1348IntVectExpand (const IntVectND<old_dim>& iv, int fill_extra=0) noexcept {
1349 return iv.template expand<new_dim>(fill_extra);
1350}
1351
1356template<int new_dim, int old_dim>
1359constexpr IntVectND<new_dim>
1360IntVectResize (const IntVectND<old_dim>& iv, int fill_extra=0) noexcept {
1361 return iv.template resize<new_dim>(fill_extra);
1362}
1363
1365template <std::size_t Idx, int dim>
1367constexpr int get (IntVectND<dim> const& iv) noexcept { return iv.vect[Idx]; }
1368
1369namespace detail {
1370 template <typename F, int dim, std::size_t... N>
1372 constexpr auto apply_impl (F&& f, IntVectND<dim> const& iv,
1373 std::index_sequence<N...> /*is*/)
1374 {
1375 return std::forward<F>(f)(amrex::get<N>(iv)...);
1376 }
1377}
1378
1381template <typename F, int dim>
1383constexpr auto Apply (F&& f, IntVectND<dim> const& iv)
1384{
1385 return detail::apply_impl(std::forward<F>(f), iv, std::make_index_sequence<dim>());
1386}
1387
1388} // namespace amrex
1389
1390// Spcialize std::tuple_size for IntVectND. Used by structured bindings.
1391template<int dim>
1392struct std::tuple_size<amrex::IntVectND<dim>> {
1393 static constexpr std::size_t value = dim;
1394};
1395
1396// Spcialize std::tuple_element for IntVectND. Used by structured bindings.
1397template<std::size_t s, int dim>
1398struct std::tuple_element<s, amrex::IntVectND<dim>> {
1399 using type = int;
1400};
1401
1402#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:123
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
while parser_exe_t p
Definition AMReX_Parser_Exe_Body.H:33
GPU-compatible tuple.
Definition AMReX_Tuple.H:104
An Integer Vector in dim-Dimensional Space.
Definition AMReX_IntVect.H:156
__host__ __device__ constexpr IntVectND< dim > & operator*=(int s) noexcept
Modifies IntVectND by multiplication of a scalar to each component.
Definition AMReX_IntVect.H:601
__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:227
__host__ __device__ int * getVect() &noexcept
Definition AMReX_IntVect.H:392
__host__ __device__ constexpr IntVectND< dim > operator*(const IntVectND< dim > &p) const noexcept
Returns component-wise product of IntVectND and argument.
Definition AMReX_IntVect.H:683
__host__ __device__ constexpr int & operator[](int i) noexcept
Returns a reference to the i'th coordinate of the IntVectND.
Definition AMReX_IntVect.H:346
__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:524
__host__ __device__ constexpr Dim3 dim3() const noexcept
Definition AMReX_IntVect.H:269
__host__ __device__ constexpr bool operator>(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically greater than rhs.
Definition AMReX_IntVect.H:459
__host__ __device__ constexpr IntVectND< dim > & shift(int coord, int s) noexcept
Modify IntVectND by adding s to given coordinate.
Definition AMReX_IntVect.H:748
__host__ __device__ constexpr int min() const noexcept
minimum (no absolute values) value
Definition AMReX_IntVect.H:331
__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:881
__host__ __device__ constexpr IntVectND< dim > & operator+=(int s) noexcept
Modifies IntVectND by addition of a scalar to each component.
Definition AMReX_IntVect.H:583
__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:754
int value_type
Definition AMReX_IntVect.H:862
__host__ __device__ constexpr Array< T, dim > toArray() const noexcept
Definition AMReX_IntVect.H:296
__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:355
static const IntVectND< dim > Zero
Definition AMReX_IntVect.H:907
shift_hasher hasher
Definition AMReX_IntVect.H:194
__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:248
__host__ static __device__ constexpr IntVectND< dim > TheMaxVector() noexcept
Definition AMReX_IntVect.H:844
__host__ static __device__ constexpr std::size_t size() noexcept
Definition AMReX_IntVect.H:853
__host__ __device__ IntVectND & setVal(int i, int val) noexcept
Set i'th coordinate of IntVectND to val.
Definition AMReX_IntVect.H:380
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:238
__host__ __device__ constexpr bool allGT(int rhs) const noexcept
Returns true if this is greater than argument for all components.
Definition AMReX_IntVect.H:536
__host__ __device__ constexpr int * begin() noexcept
Returns a pointer to the first element of the IntVectND.
Definition AMReX_IntVect.H:364
__host__ __device__ IntVectND< dim > & coarsen(const IntVectND< dim > &p) noexcept
Modify IntVectND<dim> by component-wise integer projection.
Definition AMReX_IntVect.H:974
__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:788
__host__ __device__ int maxDir(bool a_doAbsValue) const noexcept
Definition AMReX_IntVect.H:987
__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:390
__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:809
__host__ __device__ constexpr IntVectND< dim > & min(const IntVectND< dim > &p) noexcept
Modifies IntVectND by taking component-wise min with argument.
Definition AMReX_IntVect.H:711
__host__ __device__ constexpr Dim3 dim3(int fill_extra) const noexcept
Definition AMReX_IntVect.H:282
__host__ __device__ constexpr int sum() const noexcept
Definition AMReX_IntVect.H:309
__host__ __device__ constexpr IntVectND< dim > & scale(int s) noexcept
Modify IntVectND by multiplying each coordinate by s.
Definition AMReX_IntVect.H:729
__host__ __device__ constexpr const int * begin() const noexcept
Returns a pointer to the first element of the IntVectND.
Definition AMReX_IntVect.H:368
__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:549
__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:819
__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:740
__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:839
__host__ __device__ constexpr bool operator==(int val) const noexcept
Returns true if all components are equal to the argument val.
Definition AMReX_IntVect.H:398
__host__ __device__ constexpr IntVectND< dim > & diagShift(int s) noexcept
Modify IntVectND by adding s to each coordinate.
Definition AMReX_IntVect.H:757
__host__ __device__ constexpr IntVectND< dim > operator-() const noexcept
Unary Minus – negates all components.
Definition AMReX_IntVect.H:574
__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:896
__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:778
__host__ __device__ constexpr IntVectND< dim > operator+() const noexcept
Unary plus – for completeness.
Definition AMReX_IntVect.H:571
__host__ __device__ IntVectND< dim > & coarsen(int p) noexcept
Modify IntVectND<dim> by component-wise integer projection.
Definition AMReX_IntVect.H:946
__host__ __device__ constexpr int max() const noexcept
maximum (no absolute values) value
Definition AMReX_IntVect.H:320
constexpr IntVectND(Dim3 const &a) noexcept
Definition AMReX_IntVect.H:254
__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:474
__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:830
__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:511
__host__ __device__ constexpr IntVectND< dim > & operator-=(int s) noexcept
Modifies IntVectND by subtraction of a scalar to each component.
Definition AMReX_IntVect.H:637
__host__ __device__ constexpr IntVectND< dim > operator/(const IntVectND< dim > &p) const noexcept
Returns component-wise division of IntVectND by argument.
Definition AMReX_IntVect.H:697
__host__ __device__ constexpr IntVectND< dim > & operator/=(int s) noexcept
Modifies IntVectND by division by a scalar to each component.
Definition AMReX_IntVect.H:619
__host__ __device__ constexpr int * end() noexcept
Returns a pointer to the (last+1) element of the IntVectND.
Definition AMReX_IntVect.H:372
__host__ static __device__ constexpr int isize() noexcept
Definition AMReX_IntVect.H:858
__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:453
__host__ __device__ constexpr IntVectND(int s) noexcept
Construct an IntVectND whose components are all the same.
Definition AMReX_IntVect.H:216
__host__ __device__ constexpr const int * end() const noexcept
Returns a pointer to the (last+1) element of the IntVectND.
Definition AMReX_IntVect.H:376
__host__ __device__ constexpr bool operator<(const IntVectND< dim > &rhs) const noexcept
Return true if this is lexicographically less than rhs.
Definition AMReX_IntVect.H:440
__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:360
__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:409
__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:499
__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:561
__host__ __device__ constexpr IntVectND< dim > & max(const IntVectND< dim > &p) noexcept
Modifies IntVectND by taking component-wise max with argument.
Definition AMReX_IntVect.H:720
__host__ __device__ constexpr bool allLT(int rhs) const noexcept
Returns true if this is less than argument for all components.
Definition AMReX_IntVect.H:486
constexpr IntVectND() noexcept
Construct an IntVectND whose components are all zero.
Definition AMReX_IntVect.H:200
int vect[dim]
Definition AMReX_IntVect.H:914
__host__ static __device__ constexpr IntVectND< dim > TheMinVector() noexcept
Definition AMReX_IntVect.H:848
static const IntVectND< dim > Unit
Definition AMReX_IntVect.H:912
__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:465
__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:870
__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:797
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:1471
__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:1512
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:92
__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:54
__host__ __device__ constexpr T elemwiseMin(T const &a, T const &b) noexcept
Definition AMReX_Algorithm.H:75
Definition AMReX_Amr.cpp:50
__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:1360
@ F
Definition AMReX_Order.H:7
__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:1321
__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:1119
__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:1162
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:1149
IntVectND(const Array< int, dim > &) -> IntVectND< dim >
__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:1336
__host__ __device__ constexpr auto Apply(F &&f, IntVectND< dim > const &iv)
Definition AMReX_IntVect.H:1383
@ x
Definition AMReX_Orientation.H:14
__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:1135
void Error(const std::string &msg)
Print a message to stderr and abort the program.
Definition AMReX.cpp:233
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
__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:1348
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:1967
__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:1305
std::ostream & operator<<(std::ostream &os, AmrMesh const &amr_mesh)
Stream helper; forwards to the friend declared inside AmrMesh.
Definition AMReX_AmrMesh.cpp:1379
__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 the Idx-th element of IntVectND<dim>.
Definition AMReX_IntVect.H:1367
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:161
std::size_t operator()(const IntVectND< dim > &vec) const noexcept
Definition AMReX_IntVect.H:162
int type
Definition AMReX_IntVect.H:1399
static constexpr std::size_t value
Definition AMReX_IntVect.H:1393