Block-Structured AMR Software Framework
 
Loading...
Searching...
No Matches
AMReX_FluxReg_2D_C.H
Go to the documentation of this file.
1#ifndef AMREX_FLUXREG_2D_C_H_
2#define AMREX_FLUXREG_2D_C_H_
3#include <AMReX_Config.H>
4
5#if (AMREX_SPACEDIM == 2)
6
7#include <AMReX_FArrayBox.H>
8
9namespace amrex {
10
11
28AMREX_GPU_HOST_DEVICE inline void
29fluxreg_fineadd (Box const& bx, Array4<Real> const& reg, const int rcomp,
30 Array4<Real const> const& flx, const int fcomp, const int ncomp,
31 const int dir, Dim3 const& ratio, const Real mult) noexcept
32{
33 const auto lo = amrex::lbound(bx);
34 const auto hi = amrex::ubound(bx);
35
36 switch (dir) {
37 case 0:
38 {
39 const int ic = lo.x;
40 const int i = ic*ratio.x;
41 for (int n = 0; n < ncomp; ++n) {
42 for (int jc = lo.y; jc <= hi.y; ++jc) {
43 for (int joff = 0; joff < ratio.y; ++joff) {
44 const int j = ratio.y*jc + joff;
45 reg(ic,jc,0,n+rcomp) += mult*flx(i,j,0,n+fcomp);
46 }
47 }
48 }
49 break;
50 }
51 default:
52 {
53 const int jc = lo.y;
54 const int j = jc*ratio.y;
55 for (int n = 0; n < ncomp; ++n) {
56 for (int ic = lo.x; ic <= hi.x; ++ic) {
57 for (int ioff = 0; ioff < ratio.x; ++ioff) {
58 const int i = ratio.x*ic + ioff;
59 reg(ic,jc,0,n+rcomp) += mult*flx(i,j,0,n+fcomp);
60 }
61 }
62 }
63 }
64 }
65}
66
67
85AMREX_GPU_HOST_DEVICE inline void
86fluxreg_fineareaadd (Box const& bx, Array4<Real> const& reg, const int rcomp,
87 Array4<Real const> const& area,
88 Array4<Real const> const& flx, const int fcomp, const int ncomp,
89 const int dir, Dim3 const& ratio, const Real mult) noexcept
90{
91 const auto lo = amrex::lbound(bx);
92 const auto hi = amrex::ubound(bx);
93
94 switch (dir) {
95 case 0:
96 {
97 const int ic = lo.x;
98 const int i = ic*ratio.x;
99 for (int n = 0; n < ncomp; ++n) {
100 for (int jc = lo.y; jc <= hi.y; ++jc) {
101 for (int joff = 0; joff < ratio.y; ++joff) {
102 const int j = ratio.y*jc + joff;
103 reg(ic,jc,0,n+rcomp) += mult*area(i,j,0)
104 * flx(i,j,0,n+fcomp);
105 }
106 }
107 }
108 break;
109 }
110 default:
111 {
112 const int jc = lo.y;
113 const int j = jc*ratio.y;
114 for (int n = 0; n < ncomp; ++n) {
115 for (int ic = lo.x; ic <= hi.x; ++ic) {
116 for (int ioff = 0; ioff < ratio.x; ++ioff) {
117 const int i = ratio.x*ic + ioff;
118 reg(ic,jc,0,n+rcomp) += mult*area(i,j,0)
119 * flx(i,j,0,n+fcomp);
120 }
121 }
122 }
123 break;
124 }
125 }
126}
127
128AMREX_GPU_HOST_DEVICE inline void
129fluxreg_reflux (Box const& bx, Array4<Real> const& s, const int scomp,
130 Array4<Real const> const& f, Array4<Real const> const& v,
131 const int ncomp, const Real mult, const Orientation face) noexcept
132{
133 const auto lo = amrex::lbound(bx);
134 const auto hi = amrex::ubound(bx);
135
136 if (face.isLow()) {
137 const int dir = face.coordDir();
138 switch (dir) {
139 case 0:
140 {
141 for (int n = 0; n < ncomp; ++n) {
142 for (int j = lo.y; j <= hi.y; ++j) {
143 for (int i = lo.x; i <= hi.x; ++i) {
144 s(i,j,0,n+scomp) += -mult*(f(i+1,j,0,n)/v(i,j,0));
145 }
146 }
147 }
148 break;
149 }
150 default:
151 {
152 for (int n = 0; n < ncomp; ++n) {
153 for (int j = lo.y; j <= hi.y; ++j) {
154 for (int i = lo.x; i <= hi.x; ++i) {
155 s(i,j,0,n+scomp) += -mult*(f(i,j+1,0,n)/v(i,j,0));
156 }
157 }
158 }
159 break;
160 }
161 }
162 } else {
163 for (int n = 0; n < ncomp; ++n) {
164 for (int j = lo.y; j <= hi.y; ++j) {
165 for (int i = lo.x; i <= hi.x; ++i) {
166 s(i,j,0,n+scomp) += mult*(f(i,j,0,n)/v(i,j,0));
167 }
168 }
169 }
170 }
171}
172
173}
174
175#endif
176
177#endif
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
Definition AMReX_Amr.cpp:49
__host__ __device__ Dim3 ubound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:319
__host__ __device__ void fluxreg_reflux(Box const &bx, Array4< Real > const &s, const int scomp, Array4< Real const > const &f, Array4< Real const > const &v, const int ncomp, const Real mult, const Orientation face) noexcept
Definition AMReX_FluxReg_3D_C.H:185
BoxND< 3 > Box
Definition AMReX_BaseFwd.H:27
__host__ __device__ void fluxreg_fineadd(Box const &bx, Array4< Real > const &reg, const int rcomp, Array4< Real const > const &flx, const int fcomp, const int ncomp, const int dir, Dim3 const &ratio, const Real mult) noexcept
Add fine grid flux to flux register. Flux array is a fine grid edge based object, Register is a coars...
Definition AMReX_FluxReg_3D_C.H:27
__host__ __device__ void fluxreg_fineareaadd(Box const &bx, Array4< Real > const &reg, const int rcomp, Array4< Real const > const &area, Array4< Real const > const &flx, const int fcomp, const int ncomp, const int dir, Dim3 const &ratio, const Real mult) noexcept
Add fine grid flux times area to flux register. Flux array is a fine grid edge based object,...
Definition AMReX_FluxReg_3D_C.H:113
__host__ __device__ Dim3 lbound(Array4< T > const &a) noexcept
Definition AMReX_Array4.H:312