/home/runner/work/amr-wind/amr-wind/amr-wind/utilities/DirectionSelector.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/utilities/DirectionSelector.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
DirectionSelector.H
Go to the documentation of this file.
1//
2// DirectionSelector.H
3// amr-wind
4//
5//
6
7#ifndef DirectionSelector_H
8#define DirectionSelector_H
9
10#include "AMReX_Box.H"
11#include "AMReX_Gpu.H"
12
14template <int Index>
16{
17 int operator()(int i, int j, int k) const;
18};
19
20template <>
22{
23 AMREX_GPU_HOST_DEVICE int
24 operator()(int i, int /*unused*/, int /*unused*/) const
25 {
26 return i;
27 };
28 int odir1 = 1;
29 int odir2 = 2;
30};
31
32template <>
34{
35 AMREX_GPU_HOST_DEVICE int
36 operator()(int /*unused*/, int j, int /*unused*/) const
37 {
38 return j;
39 };
40 int odir1 = 0;
41 int odir2 = 2;
42};
43
44template <>
46{
47 AMREX_GPU_HOST_DEVICE int
48 operator()(int /*unused*/, int /*unused*/, int k) const
49 {
50 return k;
51 };
52 int odir1 = 0;
53 int odir2 = 1;
54};
55
59
60// Given a box, return a 2D box perpendicular to the selected axis.
61// For example, if we're using ZDir, return a box covering the x-y plane.
62// The IntVect is used to set the constant index in the parallel direction.
63template <typename IndexSelector>
64AMREX_GPU_HOST_DEVICE amrex::Box
65perpendicular_box(const amrex::Box& bx, const amrex::IntVect& iv)
66{
67 amrex::IntVect plane_lo, plane_hi;
68
69 if (std::is_same_v<IndexSelector, XDir>) {
70 plane_lo = {iv[0], bx.smallEnd(1), bx.smallEnd(2)};
71 plane_hi = {iv[0], bx.bigEnd(1), bx.bigEnd(2)};
72 } else if (std::is_same_v<IndexSelector, YDir>) {
73 plane_lo = {bx.smallEnd(0), iv[1], bx.smallEnd(2)};
74 plane_hi = {bx.bigEnd(0), iv[1], bx.bigEnd(2)};
75 } else {
76 plane_lo = {bx.smallEnd(0), bx.smallEnd(1), iv[2]};
77 plane_hi = {bx.bigEnd(0), bx.bigEnd(1), iv[2]};
78 }
79
80 amrex::Box pbx(plane_lo, plane_hi);
81
82 return pbx;
83}
84
85// Given a box, return a 1D box parallel to the selected axis.
86// For example, if we're using ZDir, return a box covering the z axis.
87// The IntVect is used to set the constant indices in the perpendicular
88// direction.
89template <typename IndexSelector>
90AMREX_GPU_HOST_DEVICE amrex::Box
91parallel_box(const amrex::Box& bx, const amrex::IntVect& iv)
92{
93 amrex::IntVect line_lo, line_hi;
94
95 if (std::is_same_v<IndexSelector, XDir>) {
96 line_lo = {bx.smallEnd(0), iv[1], iv[2]};
97 line_hi = {bx.bigEnd(0), iv[1], iv[2]};
98 } else if (std::is_same_v<IndexSelector, YDir>) {
99 line_lo = {iv[0], bx.smallEnd(1), iv[2]};
100 line_hi = {iv[0], bx.bigEnd(1), iv[2]};
101 } else {
102 line_lo = {iv[0], iv[1], bx.smallEnd(2)};
103 line_hi = {iv[0], iv[1], bx.bigEnd(2)};
104 }
105
106 amrex::Box lbx(line_lo, line_hi);
107
108 return lbx;
109}
110
111namespace amr_wind {
112
113AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int
114direction_selector(const int i, const int j, const int k, const int dir)
115{
116 return (dir == 0) ? i : (dir == 1) ? j : k;
117}
118
119} /* namespace amr_wind */
120#endif /* DirectionSelector_H */
AMREX_GPU_HOST_DEVICE amrex::Box perpendicular_box(const amrex::Box &bx, const amrex::IntVect &iv)
Definition DirectionSelector.H:65
AMREX_GPU_HOST_DEVICE amrex::Box parallel_box(const amrex::Box &bx, const amrex::IntVect &iv)
Definition DirectionSelector.H:91
Definition BCInterface.cpp:7
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int direction_selector(const int i, const int j, const int k, const int dir)
Definition DirectionSelector.H:114
Definition DirectionSelector.H:22
AMREX_GPU_HOST_DEVICE int operator()(int i, int, int) const
Definition DirectionSelector.H:24
Definition DirectionSelector.H:34
AMREX_GPU_HOST_DEVICE int operator()(int, int j, int) const
Definition DirectionSelector.H:36
Definition DirectionSelector.H:46
AMREX_GPU_HOST_DEVICE int operator()(int, int, int k) const
Definition DirectionSelector.H:48
Definition DirectionSelector.H:16
int operator()(int i, int j, int k) const