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
101 {
102  amrex::IntVect line_lo, line_hi;
103 
104  if (std::is_same<IndexSelector, XDir>::value) {
105  line_lo = {bx.smallEnd(0), iv[1], iv[2]};
106  line_hi = {bx.bigEnd(0), iv[1], iv[2]};
107  } else if (std::is_same<IndexSelector, YDir>::value) {
108  line_lo = {iv[0], bx.smallEnd(1), iv[2]};
109  line_hi = {iv[0], bx.bigEnd(1), iv[2]};
110  } else {
111  line_lo = {iv[0], iv[1], bx.smallEnd(2)};
112  line_hi = {iv[0], iv[1], bx.bigEnd(2)};
113  }
114 
115  amrex::Box lbx(line_lo, line_hi, bx.type());
116 
117  return lbx;
118 }

◆ 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
69 {
70  amrex::IntVect plane_lo, plane_hi;
71 
72  if (std::is_same<IndexSelector, XDir>::value) {
73  plane_lo = {iv[0], bx.smallEnd(1), bx.smallEnd(2)};
74  plane_hi = {iv[0], bx.bigEnd(1) , bx.bigEnd(2) };
75  } else if (std::is_same<IndexSelector, YDir>::value) {
76  plane_lo = {bx.smallEnd(0), iv[1], bx.smallEnd(2)};
77  plane_hi = {bx.bigEnd(0) , iv[1], bx.bigEnd(2) };
78  } else {
79  plane_lo = {bx.smallEnd(0), bx.smallEnd(1), iv[2]};
80  plane_hi = {bx.bigEnd(0) , bx.bigEnd(1) , iv[2]};
81  }
82 
83  amrex::Box pbx(plane_lo, plane_hi, bx.type());
84 
85  return pbx;
86 }