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

Go to the source code of this file.

Functions

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real interpolatedVal (amrex::Real avg1, amrex::Real avg2, amrex::Real avg3, amrex::Real diff1, amrex::Real diff2, amrex::Real diff3, amrex::Real scaled_upw, const AdvType adv_type)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolateInX (int i, int j, int k, const amrex::Array4< const amrex::Real > &qty, int qty_index, amrex::Real upw, const AdvType adv_type)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolateInY (int i, int j, int k, const amrex::Array4< const amrex::Real > &qty, int qty_index, amrex::Real upw, const AdvType adv_type)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolateInZ (int i, int j, int k, const amrex::Array4< const amrex::Real > &qty, int qty_index, amrex::Real upw, const AdvType adv_type)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolatePertFromCell (int i, int j, int k, const amrex::Array4< const amrex::Real > &qty, int qty_index, amrex::Real upw, Coord coordDir, const AdvType adv_type, const amrex::Array4< const amrex::Real > &r0_arr)
 
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolateDensityPertFromCellToFace (int i, int j, int k, const amrex::Array4< const amrex::Real > &cons_in, amrex::Real upw, Coord coordDir, const AdvType adv_type, const amrex::Array4< const amrex::Real > &r0_arr)
 

Function Documentation

◆ InterpolateDensityPertFromCellToFace()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolateDensityPertFromCellToFace ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  cons_in,
amrex::Real  upw,
Coord  coordDir,
const AdvType  adv_type,
const amrex::Array4< const amrex::Real > &  r0_arr 
)
208 {
209  return InterpolatePertFromCell(i, j, k, cons_in, Rho_comp, upw, coordDir, adv_type, r0_arr);
210 }
#define Rho_comp
Definition: ERF_IndexDefines.H:36
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolatePertFromCell(int i, int j, int k, const amrex::Array4< const amrex::Real > &qty, int qty_index, amrex::Real upw, Coord coordDir, const AdvType adv_type, const amrex::Array4< const amrex::Real > &r0_arr)
Definition: ERF_Interpolation.H:132
Here is the call graph for this function:

◆ interpolatedVal()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real interpolatedVal ( amrex::Real  avg1,
amrex::Real  avg2,
amrex::Real  avg3,
amrex::Real  diff1,
amrex::Real  diff2,
amrex::Real  diff3,
amrex::Real  scaled_upw,
const AdvType  adv_type 
)

Interpolation operators used in construction of advective fluxes using non-WENO schemes

19 {
20  amrex::Real myInterpolatedVal(0.);
21  if (adv_type == AdvType::Centered_2nd) {
22  myInterpolatedVal = 0.5 * avg1;
23  } else if (adv_type == AdvType::Upwind_3rd) {
24  myInterpolatedVal = (7.0/12.0)*avg1 -(1.0/12.0)*avg2 + (scaled_upw/12.0)*(diff2 - 3.0*diff1);
25  } else if (adv_type == AdvType::Centered_4th) {
26  myInterpolatedVal = (7.0/12.0)*avg1 -(1.0/12.0)*avg2;
27  } else if (adv_type == AdvType::Upwind_5th) {
28  myInterpolatedVal = (37.0/60.0)*avg1 -(2.0/15.0)*avg2 +(1.0/60.0)*avg3
29  -(scaled_upw/60.0)*(diff3 - 5.0*diff2 + 10.0*diff1);
30  } else if (adv_type == AdvType::Centered_6th) {
31  myInterpolatedVal = (37.0/60.0)*avg1 -(2.0/15.0)*avg2 +(1.0/60.0)*avg3;
32  }
33  return myInterpolatedVal;
34 }
@ Centered_4th
@ Centered_6th
@ Centered_2nd

Referenced by InterpolateInX(), InterpolateInY(), InterpolateInZ(), and InterpolatePertFromCell().

Here is the caller graph for this function:

◆ InterpolateInX()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolateInX ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  qty,
int  qty_index,
amrex::Real  upw,
const AdvType  adv_type 
)
41 {
42 
43  if (adv_type == AdvType::Centered_2nd) {
44  return 0.5 * (qty(i,j,k,qty_index) + qty(i-1,j,k,qty_index));
45  } else {
46 
47  amrex::Real avg1 = 0.; amrex::Real avg2 = 0.; amrex::Real avg3 = 0.;
48  amrex::Real diff1 = 0.; amrex::Real diff2 = 0.; amrex::Real diff3 = 0.;
49  amrex::Real scaled_upw = 0.;
50  //
51  // The value that comes in has not been normalized so we do that here
52  if (upw != 0.)
53  scaled_upw = (upw > 0) ? 1. : -1.;
54 
55  avg1 = (qty(i, j, k, qty_index) + qty(i-1, j, k, qty_index));
56  diff1 = (qty(i, j, k, qty_index) - qty(i-1, j, k, qty_index));
57  avg2 = (qty(i+1, j, k, qty_index) + qty(i-2, j, k, qty_index));
58  diff2 = (qty(i+1, j, k, qty_index) - qty(i-2, j, k, qty_index));
59  if (adv_type == AdvType::Upwind_5th || adv_type == AdvType::Centered_6th)
60  {
61  avg3 = (qty(i+2, j, k, qty_index) + qty(i-3, j, k, qty_index));
62  diff3 = (qty(i+2, j, k, qty_index) - qty(i-3, j, k, qty_index));
63  }
64  return interpolatedVal(avg1,avg2,avg3,diff1,diff2,diff3,scaled_upw,adv_type);
65  }
66 }
AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real interpolatedVal(amrex::Real avg1, amrex::Real avg2, amrex::Real avg3, amrex::Real diff1, amrex::Real diff2, amrex::Real diff3, amrex::Real scaled_upw, const AdvType adv_type)
Definition: ERF_Interpolation.H:16
Here is the call graph for this function:

◆ InterpolateInY()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolateInY ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  qty,
int  qty_index,
amrex::Real  upw,
const AdvType  adv_type 
)
73 {
74  if (adv_type == AdvType::Centered_2nd) {
75  return 0.5 * (qty(i,j,k,qty_index) + qty(i,j-1,k,qty_index));
76  } else {
77 
78  amrex::Real avg1; amrex::Real avg2; amrex::Real avg3 = 0.;
79  amrex::Real diff1; amrex::Real diff2; amrex::Real diff3 = 0.;
80  amrex::Real scaled_upw = 0.;
81 
82  // The value that comes in has not been normalized so we do that here
83  if (upw != 0.)
84  scaled_upw = (upw > 0) ? 1. : -1.;
85 
86  avg1 = (qty(i, j , k, qty_index) + qty(i, j-1, k, qty_index));
87  diff1 = (qty(i, j , k, qty_index) - qty(i, j-1, k, qty_index));
88  avg2 = (qty(i, j+1, k, qty_index) + qty(i, j-2, k, qty_index));
89  diff2 = (qty(i, j+1, k, qty_index) - qty(i, j-2, k, qty_index));
90  if (adv_type == AdvType::Upwind_5th || adv_type == AdvType::Centered_6th)
91  {
92  avg3 = (qty(i, j+2, k, qty_index) + qty(i, j-3, k, qty_index));
93  diff3 = (qty(i, j+2, k, qty_index) - qty(i, j-3, k, qty_index));
94  }
95  return interpolatedVal(avg1,avg2,avg3,diff1,diff2,diff3,scaled_upw,adv_type);
96  }
97 }
Here is the call graph for this function:

◆ InterpolateInZ()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolateInZ ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  qty,
int  qty_index,
amrex::Real  upw,
const AdvType  adv_type 
)
104 {
105  if (adv_type == AdvType::Centered_2nd) {
106  return 0.5 * (qty(i,j,k,qty_index) + qty(i,j,k-1,qty_index));
107  } else {
108 
109  amrex::Real avg1 = 0.; amrex::Real avg2 = 0.; amrex::Real avg3 = 0.;
110  amrex::Real diff1 = 0.; amrex::Real diff2 = 0.; amrex::Real diff3 = 0.;
111  amrex::Real scaled_upw = 0.;
112  // The value that comes in has not been normalized so we do that here
113  if (upw != 0.)
114  scaled_upw = (upw > 0) ? 1. : -1.;
115 
116  avg1 = (qty(i, j, k , qty_index) + qty(i, j, k-1, qty_index));
117  diff1 = (qty(i, j, k , qty_index) - qty(i, j, k-1, qty_index));
118  avg2 = (qty(i, j, k+1, qty_index) + qty(i, j, k-2, qty_index));
119  diff2 = (qty(i, j, k+1, qty_index) - qty(i, j, k-2, qty_index));
120  if (adv_type == AdvType::Upwind_5th || adv_type == AdvType::Centered_6th)
121  {
122  avg3 = (qty(i, j, k+2, qty_index) + qty(i, j, k-3, qty_index));
123  diff3 = (qty(i, j, k+2, qty_index) - qty(i, j, k-3, qty_index));
124  }
125  return interpolatedVal(avg1,avg2,avg3,diff1,diff2,diff3,scaled_upw,adv_type);
126  }
127 }
Here is the call graph for this function:

◆ InterpolatePertFromCell()

AMREX_GPU_DEVICE AMREX_FORCE_INLINE amrex::Real InterpolatePertFromCell ( int  i,
int  j,
int  k,
const amrex::Array4< const amrex::Real > &  qty,
int  qty_index,
amrex::Real  upw,
Coord  coordDir,
const AdvType  adv_type,
const amrex::Array4< const amrex::Real > &  r0_arr 
)
136 {
137  amrex::Real avg1 = 0.; amrex::Real avg2 = 0.; amrex::Real avg3 = 0.;
138  amrex::Real diff1 = 0.; amrex::Real diff2 = 0.; amrex::Real diff3 = 0.;
139  amrex::Real scaled_upw = 0.;
140 
141  // The value that comes in has not been normalized so we do that here
142  if (upw != 0.)
143  scaled_upw = upw / std::abs(upw);
144 
145  if (coordDir == Coord::x) {
146  avg1 = (qty(i , j, k, qty_index) + qty(i-1, j, k, qty_index));
147  avg1 -= (r0_arr(i,j,k) + r0_arr(i-1,j,k));
148  diff1 = (qty(i , j, k, qty_index) - qty(i-1, j, k, qty_index));
149  if (adv_type != AdvType::Centered_2nd)
150  {
151  avg2 = (qty(i+1, j, k, qty_index) + qty(i-2, j, k, qty_index));
152  avg2 -= (r0_arr(i+1,j,k) + r0_arr(i-2,j,k));
153  diff2 = (qty(i+1, j, k, qty_index) - qty(i-2, j, k, qty_index));
154  }
155  if (adv_type == AdvType::Upwind_5th || adv_type == AdvType::Centered_6th)
156  {
157  avg3 = (qty(i+2, j, k, qty_index) + qty(i-3, j, k, qty_index));
158  avg3 -= (r0_arr(i+2,j,k) + r0_arr(i-3,j,k));
159  diff3 = (qty(i+2, j, k, qty_index) - qty(i-3, j, k, qty_index));
160  }
161  } else if (coordDir == Coord::y) {
162  avg1 = (qty(i, j , k, qty_index) + qty(i, j-1, k, qty_index));
163  avg1 -= (r0_arr(i,j,k) + r0_arr(i,j-1,k));
164  diff1 = (qty(i, j , k, qty_index) - qty(i, j-1, k, qty_index));
165  if (adv_type != AdvType::Centered_2nd)
166  {
167  avg2 = (qty(i, j+1, k, qty_index) + qty(i, j-2, k, qty_index));
168  avg2 -= (r0_arr(i,j+1,k) + r0_arr(i,j-2,k));
169  diff2 = (qty(i, j+1, k, qty_index) - qty(i, j-2, k, qty_index));
170  }
171  if (adv_type == AdvType::Upwind_5th || adv_type == AdvType::Centered_6th)
172  {
173  avg3 = (qty(i, j+2, k, qty_index) + qty(i, j-3, k, qty_index));
174  avg3 -= (r0_arr(i,j+2,k) + r0_arr(i,j-3,k));
175  diff3 = (qty(i, j+2, k, qty_index) - qty(i, j-3, k, qty_index));
176  }
177  } else {
178  avg1 = (qty(i, j, k , qty_index) + qty(i, j, k-1, qty_index));
179  diff1 = (qty(i, j, k , qty_index) - qty(i, j, k-1, qty_index));
180  avg1 -= (r0_arr(i,j,k) + r0_arr(i,j,k-1));
181  diff1 -= (r0_arr(i,j,k) - r0_arr(i,j,k-1));
182 
183  if (adv_type != AdvType::Centered_2nd)
184  {
185  avg2 = (qty(i, j, k+1, qty_index) + qty(i, j, k-2, qty_index));
186  diff2 = (qty(i, j, k+1, qty_index) - qty(i, j, k-2, qty_index));
187  avg2 -= (r0_arr(i,j,k+1) + r0_arr(i,j,k-2));
188  diff2 -= (r0_arr(i,j,k+1) - r0_arr(i,j,k-2));
189  }
190  if (adv_type == AdvType::Upwind_5th || adv_type == AdvType::Centered_6th)
191  {
192  avg3 = (qty(i, j, k+2, qty_index) + qty(i, j, k-3, qty_index));
193  diff3 = (qty(i, j, k+2, qty_index) - qty(i, j, k-3, qty_index));
194  avg3 -= (r0_arr(i,j,k+2) + r0_arr(i,j,k-3));
195  diff3 -= (r0_arr(i,j,k+2) - r0_arr(i,j,k-3));
196  }
197  }
198 
199  return interpolatedVal(avg1,avg2,avg3,diff1,diff2,diff3,scaled_upw,adv_type);
200 }

Referenced by InterpolateDensityPertFromCellToFace().

Here is the call graph for this function:
Here is the caller graph for this function: