Block-Structured AMR Software Framework
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
AMReX_MLEBTensor_K.H
Go to the documentation of this file.
1#ifndef AMREX_MLEBTENSOR_K_H_
2#define AMREX_MLEBTENSOR_K_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_FArrayBox.H>
6
7namespace amrex {
8
10Real mlebtensor_weight (int d) {
11 return (d==2) ? Real(0.5) : ((d==1) ? Real(1.0) : Real(0.0));
12}
13
15Real mlebtensor_dy_on_xface (int i, int, int k, int n,
16 Array4<Real const> const& vel, Real dyi,
17 Real whi, Real wlo,
18 int jhip, int jhim, int jlop, int jlom) noexcept
19{
20 return Real(0.5)*dyi * ((vel(i ,jhip,k,n)-vel(i ,jhim,k,n))*whi +
21 (vel(i-1,jlop,k,n)-vel(i-1,jlom,k,n))*wlo);
22}
23
25Real mlebtensor_dx_on_yface (int, int j, int k, int n,
26 Array4<Real const> const& vel, Real dxi,
27 Real whi, Real wlo,
28 int ihip, int ihim, int ilop, int ilom) noexcept
29{
30 return Real(0.5)*dxi * ((vel(ihip,j ,k,n)-vel(ihim,j ,k,n))*whi +
31 (vel(ilop,j-1,k,n)-vel(ilom,j-1,k,n))*wlo);
32}
33
35Real mlebtensor_dy_on_xface (int i, int j, int k, int n,
36 Array4<Real const> const& vel, Real dyi,
37 Array4<Real const> const& bvxlo,
38 Array4<Real const> const& bvxhi,
40 0,2*AMREX_SPACEDIM,
41 0,AMREX_SPACEDIM> const& bct,
42 Dim3 const& dlo, Dim3 const& dhi,
43 Real whi, Real wlo,
44 int jhip, int jhim, int jlop, int jlom) noexcept
45{
46 Real ddy;
47 if (i == dlo.x) {
48 if (bct(Orientation::xlo(),n) == AMREX_LO_DIRICHLET && bvxlo) {
49 if (j == dlo.y) {
50 ddy = (bvxlo(i-1,j ,k,n) * Real(-1.5) +
51 bvxlo(i-1,j+1,k,n) * Real(2.) +
52 bvxlo(i-1,j+2,k,n) * Real(-0.5)) * dyi;
53 } else if (j == dhi.y) {
54 ddy = -(bvxlo(i-1,j ,k,n) * Real(-1.5) +
55 bvxlo(i-1,j-1,k,n) * Real(2.) +
56 bvxlo(i-1,j-2,k,n) * Real(-0.5)) * dyi;
57 } else {
58 ddy = wlo*dyi*(bvxlo(i-1,jlop,k,n)-bvxlo(i-1,jlom,k,n));
59 }
60 } else if (bct(Orientation::xlo(),n) == AMREX_LO_NEUMANN) {
61 ddy = whi*dyi*(vel(i,jhip,k,n)-vel(i,jhim,k,n));
62 } else { // AMREX_LO_REFLECT_ODD or homogeneous Dirichlet
63 ddy = Real(0.);
64 }
65 } else if (i == dhi.x+1) {
66 if (bct(Orientation::xhi(),n) == AMREX_LO_DIRICHLET && bvxhi) {
67 if (j == dlo.y) {
68 ddy = (bvxhi(i,j ,k,n) * Real(-1.5) +
69 bvxhi(i,j+1,k,n) * Real(2.) +
70 bvxhi(i,j+2,k,n) * Real(-0.5)) * dyi;
71 } else if (j == dhi.y) {
72 ddy = -(bvxhi(i,j ,k,n) * Real(-1.5) +
73 bvxhi(i,j-1,k,n) * Real(2.) +
74 bvxhi(i,j-2,k,n) * Real(-0.5)) * dyi;
75 } else {
76 ddy = whi*dyi*(bvxhi(i,jhip,k,n)-bvxhi(i,jhim,k,n));
77 }
78 } else if (bct(Orientation::xhi(),n) == AMREX_LO_NEUMANN) {
79 ddy = wlo*dyi*(vel(i-1,jlop,k,n)-vel(i-1,jlom,k,n));
80 } else { // AMREX_LO_REFLECT_ODD or homogeneous Dirichlet
81 ddy = Real(0.);
82 }
83 } else {
84 ddy = mlebtensor_dy_on_xface(i,j,k,n,vel,dyi,whi,wlo,jhip,jhim,jlop,jlom);
85 }
86 return ddy;
87}
88
90Real mlebtensor_dx_on_yface (int i, int j, int k, int n,
91 Array4<Real const> const& vel, Real dxi,
92 Array4<Real const> const& bvylo,
93 Array4<Real const> const& bvyhi,
95 0,2*AMREX_SPACEDIM,
96 0,AMREX_SPACEDIM> const& bct,
97 Dim3 const& dlo, Dim3 const& dhi,
98 Real whi, Real wlo,
99 int ihip, int ihim, int ilop, int ilom) noexcept
100{
101 Real ddx;
102 if (j == dlo.y) {
103 if (bct(Orientation::ylo(),n) == AMREX_LO_DIRICHLET && bvylo) {
104 if (i == dlo.x) {
105 ddx = (bvylo(i ,j-1,k,n) * Real(-1.5) +
106 bvylo(i+1,j-1,k,n) * Real(2.) +
107 bvylo(i+2,j-1,k,n) * Real(-0.5)) * dxi;
108 } else if (i == dhi.x) {
109 ddx = -(bvylo(i ,j-1,k,n) * Real(-1.5) +
110 bvylo(i-1,j-1,k,n) * Real(2.) +
111 bvylo(i-2,j-1,k,n) * Real(-0.5)) * dxi;
112 } else {
113 ddx = wlo*dxi*(bvylo(ilop,j-1,k,n)-bvylo(ilom,j-1,k,n));
114 }
115 } else if (bct(Orientation::ylo(),n) == AMREX_LO_NEUMANN) {
116 ddx = whi*dxi*(vel(ihip,j,k,n)-vel(ihim,j,k,n));
117 } else { // AMREX_LO_REFLECT_ODD or homogeneous Dirichlet
118 ddx = Real(0.);
119 }
120 } else if (j == dhi.y+1) {
121 if (bct(Orientation::yhi(),n) == AMREX_LO_DIRICHLET && bvyhi) {
122 if (i == dlo.x) {
123 ddx = (bvyhi(i ,j,k,n) * Real(-1.5) +
124 bvyhi(i+1,j,k,n) * Real(2.) +
125 bvyhi(i+2,j,k,n) * Real(-0.5)) * dxi;
126 } else if (i == dhi.x) {
127 ddx = -(bvyhi(i ,j,k,n) * Real(-1.5) +
128 bvyhi(i-1,j,k,n) * Real(2.) +
129 bvyhi(i-2,j,k,n) * Real(-0.5)) * dxi;
130 } else {
131 ddx = whi*dxi*(bvyhi(ihip,j,k,n)-bvyhi(ihim,j,k,n));
132 }
133 } else if (bct(Orientation::yhi(),n) == AMREX_LO_NEUMANN) {
134 ddx = wlo*dxi*(vel(ilop,j-1,k,n)-vel(ilom,j-1,k,n));
135 } else { // AMREX_LO_REFLECT_ODD or homogeneous Dirichlet
136 ddx = Real(0.);
137 }
138 } else {
139 ddx = mlebtensor_dx_on_yface(i,j,k,n,vel,dxi,whi,wlo,ihip,ihim,ilop,ilom);
140 }
141 return ddx;
142}
143
144}
145
146#if (AMREX_SPACEDIM == 1)
147#elif (AMREX_SPACEDIM == 2)
149#else
151#endif
152
153#endif
#define AMREX_FORCE_INLINE
Definition AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_LO_NEUMANN
Definition AMReX_LO_BCTYPES.H:6
#define AMREX_LO_DIRICHLET
Definition AMReX_LO_BCTYPES.H:5
Maintain an identifier for boundary condition types.
Definition AMReX_BoundCond.H:20
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE constexpr int yhi() noexcept
Int value of the y-hi-face.
Definition AMReX_Orientation.H:110
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE constexpr int xhi() noexcept
Int value of the x-hi-face.
Definition AMReX_Orientation.H:102
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE constexpr int xlo() noexcept
Int value of the x-lo-face.
Definition AMReX_Orientation.H:98
AMREX_GPU_HOST_DEVICE static AMREX_FORCE_INLINE constexpr int ylo() noexcept
Int value of the y-lo-face.
Definition AMReX_Orientation.H:106
Definition AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlebtensor_weight(int d)
Definition AMReX_MLEBTensor_K.H:10
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlebtensor_dx_on_yface(int, int j, int k, int n, Array4< Real const > const &vel, Real dxi, Real whi, Real wlo, int ihip, int ihim, int ilop, int ilom) noexcept
Definition AMReX_MLEBTensor_K.H:25
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE Real mlebtensor_dy_on_xface(int i, int, int k, int n, Array4< Real const > const &vel, Real dyi, Real whi, Real wlo, int jhip, int jhim, int jlop, int jlom) noexcept
Definition AMReX_MLEBTensor_K.H:15
Definition AMReX_Array.H:282
Definition AMReX_Array4.H:61
Definition AMReX_Dim3.H:12