ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
ERF_DirectionSelector.H File Reference
#include "AMReX_Box.H"
#include "AMReX_Gpu.H"
Include dependency graph for ERF_DirectionSelector.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DirectionSelector< Index >
 
struct  DirectionSelector< 0 >
 
struct  DirectionSelector< 1 >
 
struct  DirectionSelector< 2 >
 

Typedefs

using XDir = DirectionSelector< 0 >
 
using YDir = DirectionSelector< 1 >
 
using ZDir = DirectionSelector< 2 >
 

Functions

template<typename IndexSelector >
AMREX_GPU_HOST_DEVICE amrex::Box PerpendicularBox (const amrex::Box &bx, const amrex::IntVect &iv)
 
template<typename IndexSelector >
AMREX_GPU_HOST_DEVICE amrex::Box ParallelBox (const amrex::Box &bx, const amrex::IntVect &iv)
 

Typedef Documentation

◆ XDir

using XDir = DirectionSelector<0>

◆ YDir

using YDir = DirectionSelector<1>

◆ ZDir

using ZDir = DirectionSelector<2>

Function Documentation

◆ ParallelBox()

template<typename IndexSelector >
AMREX_GPU_HOST_DEVICE amrex::Box ParallelBox ( const amrex::Box &  bx,
const amrex::IntVect &  iv 
)

Given a box, return a 1D box parallel to the selected axis. For example, if we're using ZDir, return a box covering the z axis. The IntVect is used to set the constant indices in the perpendicular direction.

Parameters
[in]bxInitial box for computing of perpendicular box
[in]ivIntVect defining the perpendicular direction
84 {
85  amrex::IntVect line_lo, line_hi;
86 
87  if (std::is_same<IndexSelector, XDir>::value) {
88  line_lo = {bx.smallEnd(0), iv[1], iv[2]};
89  line_hi = {bx.bigEnd(0), iv[1], iv[2]};
90  } else if (std::is_same<IndexSelector, YDir>::value) {
91  line_lo = {iv[0], bx.smallEnd(1), iv[2]};
92  line_hi = {iv[0], bx.bigEnd(1), iv[2]};
93  } else {
94  line_lo = {iv[0], iv[1], bx.smallEnd(2)};
95  line_hi = {iv[0], iv[1], bx.bigEnd(2)};
96  }
97 
98  amrex::Box lbx(line_lo, line_hi, bx.type());
99 
100  return lbx;
101 }

◆ PerpendicularBox()

template<typename IndexSelector >
AMREX_GPU_HOST_DEVICE amrex::Box PerpendicularBox ( const amrex::Box &  bx,
const amrex::IntVect &  iv 
)

Given a box, return a 2D box perpendicular to the selected axis. For example, if we're using ZDir, return a box covering the x-y plane. The IntVect is used to set the constant index in the parallel direction.

Parameters
[in]bxInitial box for computing of perpendicular box
[in]ivIntVect defining the perpendicular direction
52 {
53  amrex::IntVect plane_lo, plane_hi;
54 
55  if (std::is_same<IndexSelector, XDir>::value) {
56  plane_lo = {iv[0], bx.smallEnd(1), bx.smallEnd(2)};
57  plane_hi = {iv[0], bx.bigEnd(1), bx.bigEnd(2)};
58  } else if (std::is_same<IndexSelector, YDir>::value) {
59  plane_lo = {bx.smallEnd(0), iv[1], bx.smallEnd(2)};
60  plane_hi = {bx.bigEnd(0), iv[1], bx.bigEnd(2)};
61  } else {
62  plane_lo = {bx.smallEnd(0), bx.smallEnd(1), iv[2]};
63  plane_hi = {bx.bigEnd(0), bx.bigEnd(1), iv[2]};
64  }
65 
66  amrex::Box pbx(plane_lo, plane_hi, bx.type());
67 
68  return pbx;
69 }