AMReX-Hydro
AMReX-based hydro routines for low Mach number flows
 
Loading...
Searching...
No Matches
hydro_ebgodunov_transverse_2D_K.H
Go to the documentation of this file.
1/**
2 * \file hydro_ebgodunov_transverse_2D_K.H
3 * \addtogroup EBGodunov
4 * @{
5 *
6 */
7
8#ifndef HYDRO_EBGODUNOV_TRANSVERSE_2D_K_H_
9#define HYDRO_EBGODUNOV_TRANSVERSE_2D_K_H_
10
11#include <AMReX_Array4.H>
12#include <AMReX_Extension.H>
13#include <AMReX_GpuQualifiers.H>
14#include <AMReX_REAL.H>
15
17
21 amrex::Real x1, amrex::Real val1,
22 amrex::Real x2, amrex::Real val2)
23{
24 return (val1 + (xout-x1)/(x2-x1) * (val2-val1));
25}
26
28void create_transverse_terms_for_xface(int ic, int j, int k,
33 amrex::Real& trans_y,
34 const amrex::Real dy)
35{
36 using namespace amrex;
37
38 Real v_tmp_j, v_tmp_jp1;
39 Real y_hat_j, y_hat_jp1;
40
41 // Tangential extrapolation in the x-direction at j-1/2
42 if (apy(ic,j,k) == amrex::Real(1.0))
43 {
44 v_tmp_j = v_ad(ic,j,k);
45 y_hat_j = yhat(ic,j,k);
46 }
47 else
48 {
49 // Tangential extrapolation in x-direction at j-1/2
50 int jc = j;
51 int ii = (fcy(ic,jc,k,0) <= amrex::Real(0.0)) ? ic-1 : ic+1;
52 Real xoff = (fcy(ic,jc,k,0) <= amrex::Real(0.0)) ? -amrex::Real(1.) : amrex::Real(1.);
53
54 v_tmp_j = linear_interp(amrex::Real(0.0), fcy(ic,jc,k), v_ad(ic,jc,k), (xoff+fcy(ii,jc,k)), v_ad(ii,jc,k));
55 y_hat_j = linear_interp(amrex::Real(0.0), fcy(ic,jc,k), yhat(ic,jc,k), (xoff+fcy(ii,jc,k)), yhat(ii,jc,k));
56 }
57
58 // Tangential extrapolation in the x-direction at j+1/2
59 if (apy(ic,j+1,k) == amrex::Real(1.0))
60 {
61 v_tmp_jp1 = v_ad(ic,j+1,k);
62 y_hat_jp1 = yhat(ic,j+1,k);
63 }
64 else
65 {
66 // Tangential extrapolation in x-direction at j+1/2
67 int jc = j+1;
68 int ii = (fcy(ic,jc,k,0) <= amrex::Real(0.0)) ? ic-1 : ic+1;
69 Real xoff = (fcy(ic,jc,k,0) <= amrex::Real(0.0)) ? -amrex::Real(1.) : amrex::Real(1.);
70
71 v_tmp_jp1 = linear_interp(amrex::Real(0.0), fcy(ic,jc,k), v_ad(ic,jc,k), (xoff+fcy(ii,jc,k)), v_ad(ii,jc,k));
72 y_hat_jp1 = linear_interp(amrex::Real(0.0), fcy(ic,jc,k), yhat(ic,jc,k), (xoff+fcy(ii,jc,k)), yhat(ii,jc,k));
73 }
74
75 trans_y = amrex::Real(0.5) * (v_tmp_jp1 + v_tmp_j) * (y_hat_jp1 - y_hat_j) / dy;
76}
77
79void create_transverse_terms_for_yface(int i, int jc, int k,
84 amrex::Real& trans_x,
85 const amrex::Real dx)
86{
87 using namespace amrex;
88
89 Real u_tmp_i, u_tmp_ip1;
90 Real x_hat_i, x_hat_ip1;
91
92 // Tangential extrapolation in the y-direction at i-1/2
93 if (apx(i,jc,k) == amrex::Real(1.0))
94 {
95 u_tmp_i = u_ad(i,jc,k);
96 x_hat_i = xhat(i,jc,k);
97 }
98 else
99 {
100 // Tangential extrapolation in y-direction at i-1/2
101 int ic = i;
102 int jj = (fcx(ic,jc,k,0) <= amrex::Real(0.0)) ? jc-1 : jc+1;
103 Real yoff = (fcx(ic,jc,k,0) <= amrex::Real(0.0)) ? -amrex::Real(1.) : amrex::Real(1.);
104
105 u_tmp_i = linear_interp(amrex::Real(0.0), fcx(ic,jc,k), u_ad(ic,jc,k), (yoff+fcx(ic,jj,k)), u_ad(ic,jj,k));
106 x_hat_i = linear_interp(amrex::Real(0.0), fcx(ic,jc,k), xhat(ic,jc,k), (yoff+fcx(ic,jj,k)), xhat(ic,jj,k));
107 }
108
109 // Tangential extrapolation in the x-direction at i+1/2
110 if (apx(i+1,jc,k) == amrex::Real(1.0))
111 {
112 u_tmp_ip1 = u_ad(i+1,jc,k);
113 x_hat_ip1 = xhat(i+1,jc,k);
114 }
115 else
116 {
117 // Tangential extrapolation in y-direction at i+1/2
118 int ic = i+1;
119 int jj = (fcx(ic,jc,k,0) <= amrex::Real(0.0)) ? jc-1 : jc+1;
120 Real yoff = (fcx(ic,jc,k,0) <= amrex::Real(0.0)) ? -amrex::Real(1.) : amrex::Real(1.);
121
122 u_tmp_ip1 = linear_interp(amrex::Real(0.0), fcx(ic,jc,k), u_ad(ic,jc,k), (yoff+fcx(ic,jj,k)), u_ad(ic,jj,k));
123 x_hat_ip1 = linear_interp(amrex::Real(0.0), fcx(ic,jc,k), xhat(ic,jc,k), (yoff+fcx(ic,jj,k)), xhat(ic,jj,k));
124 }
125
126 trans_x = amrex::Real(0.5) * (u_tmp_ip1 + u_tmp_i) * (x_hat_ip1 - x_hat_i) / dx;
127}
128
129} // namespace EBGodunovTransverse
130
131#endif
132/** @} */
#define AMREX_INLINE
#define AMREX_GPU_HOST_DEVICE
amrex_real Real
Definition hydro_ebgodunov_transverse_2D_K.H:16
AMREX_GPU_HOST_DEVICE AMREX_INLINE amrex::Real linear_interp(amrex::Real xout, amrex::Real x1, amrex::Real val1, amrex::Real x2, amrex::Real val2)
Definition hydro_ebgodunov_transverse_2D_K.H:20
AMREX_GPU_HOST_DEVICE AMREX_INLINE void create_transverse_terms_for_yface(int i, int jc, int k, amrex::Array4< amrex::Real const > const &u_ad, amrex::Array4< amrex::Real const > const &xhat, amrex::Array4< amrex::Real const > const &apx, amrex::Array4< amrex::Real const > const &fcx, amrex::Real &trans_x, const amrex::Real dx)
Definition hydro_ebgodunov_transverse_2D_K.H:79
AMREX_GPU_HOST_DEVICE AMREX_INLINE void create_transverse_terms_for_xface(int ic, int j, int k, amrex::Array4< amrex::Real const > const &v_ad, amrex::Array4< amrex::Real const > const &yhat, amrex::Array4< amrex::Real const > const &apy, amrex::Array4< amrex::Real const > const &fcy, amrex::Real &trans_y, const amrex::Real dy)
Definition hydro_ebgodunov_transverse_2D_K.H:28