1 #ifndef AMREX_PARTICLE_MOD_K_H_
2 #define AMREX_PARTICLE_MOD_K_H_
3 #include <AMReX_Config.H>
17 #if (AMREX_SPACEDIM == 1)
18 amrex::Real lx = (p.pos(0) - plo[0]) * dxi[0] + Real(0.5);
20 int i =
static_cast<int>(amrex::Math::floor(lx));
22 amrex::Real xint = lx -
static_cast<Real
>(i);
24 amrex::Real sx[2] = {Real(1.0) - xint, xint};
26 for (
int ii = 0; ii <= 1; ++ii) {
30 for (
int comp=1; comp < nc; ++comp) {
31 for (
int ii = 0; ii <= 1; ++ii) {
33 static_cast<Real
>(sx[ii]*p.rdata(0)*p.rdata(comp)));
36 #elif (AMREX_SPACEDIM == 2)
37 amrex::Real lx = (p.pos(0) - plo[0]) * dxi[0] + Real(0.5);
38 amrex::Real ly = (p.pos(1) - plo[1]) * dxi[1] + Real(0.5);
40 int i =
static_cast<int>(amrex::Math::floor(lx));
41 int j =
static_cast<int>(amrex::Math::floor(ly));
43 amrex::Real xint = lx -
static_cast<Real
>(i);
44 amrex::Real yint = ly -
static_cast<Real
>(j);
46 amrex::Real sx[2] = {Real(1.0) - xint, xint};
47 amrex::Real sy[2] = {Real(1.0) - yint, yint};
49 for (
int jj = 0; jj <= 1; ++jj) {
50 for (
int ii = 0; ii <= 1; ++ii) {
52 static_cast<Real
>(sx[ii]*sy[jj]*p.rdata(0)));
56 for (
int comp=1; comp < nc; ++comp) {
57 for (
int jj = 0; jj <= 1; ++jj) {
58 for (
int ii = 0; ii <= 1; ++ii) {
60 static_cast<Real
>(sx[ii]*sy[jj]*p.rdata(0)*p.rdata(comp)));
65 #elif (AMREX_SPACEDIM == 3)
66 amrex::Real lx = (p.pos(0) - plo[0]) * dxi[0] + Real(0.5);
67 amrex::Real ly = (p.pos(1) - plo[1]) * dxi[1] + Real(0.5);
68 amrex::Real lz = (p.pos(2) - plo[2]) * dxi[2] + Real(0.5);
70 int i =
static_cast<int>(amrex::Math::floor(lx));
71 int j =
static_cast<int>(amrex::Math::floor(ly));
72 int k =
static_cast<int>(amrex::Math::floor(lz));
74 amrex::Real xint = lx -
static_cast<Real
>(i);
75 amrex::Real yint = ly -
static_cast<Real
>(j);
76 amrex::Real zint = lz -
static_cast<Real
>(k);
78 amrex::Real sx[] = {Real(1.0) - xint, xint};
79 amrex::Real sy[] = {Real(1.0) - yint, yint};
80 amrex::Real sz[] = {Real(1.0) - zint, zint};
82 for (
int kk = 0; kk <= 1; ++kk) {
83 for (
int jj = 0; jj <= 1; ++jj) {
84 for (
int ii = 0; ii <= 1; ++ii) {
86 static_cast<Real
>(sx[ii]*sy[jj]*sz[kk]*p.rdata(0)));
91 for (
int comp=1; comp < nc; ++comp) {
92 for (
int kk = 0; kk <= 1; ++kk) {
93 for (
int jj = 0; jj <= 1; ++jj) {
94 for (
int ii = 0; ii <= 1; ++ii) {
96 static_cast<Real
>(sx[ii]*sy[jj]*sz[kk]*p.rdata(0)*p.rdata(comp)));
106 template <
typename P>
113 #if (AMREX_SPACEDIM == 1)
114 amrex::Real factor = (pdxi[0]/dxi[0]);
116 amrex::Real lx = (p.pos(0) - plo[0] - Real(0.5)/pdxi[0]) * dxi[0];
118 amrex::Real hx = (p.pos(0) - plo[0] + Real(0.5)/pdxi[0]) * dxi[0];
120 int lo_x =
static_cast<int>(amrex::Math::floor(lx));
122 int hi_x =
static_cast<int>(amrex::Math::floor(hx));
124 for (
int i = lo_x; i <= hi_x; ++i) {
125 if (i < rho.begin.x || i >= rho.
end.
x) {
continue; }
126 amrex::Real wx =
amrex::min(hx -
static_cast<Real
>(i), amrex::Real(1.0)) -
amrex::max(lx -
static_cast<Real
>(i), amrex::Real(0.0));
127 amrex::Real weight = wx*factor;
131 for (
int comp = 1; comp < nc; ++comp)
133 for (
int i = lo_x; i <= hi_x; ++i) {
134 if (i < rho.begin.x || i >= rho.
end.
x) {
continue; }
135 amrex::Real wx =
amrex::min(hx -
static_cast<Real
>(i), amrex::Real(1.0)) -
amrex::max(lx -
static_cast<Real
>(i), amrex::Real(0.0));
136 amrex::Real weight = wx*factor;
141 #elif (AMREX_SPACEDIM == 2)
142 amrex::Real factor = (pdxi[0]/dxi[0])*(pdxi[1]/dxi[1]);
144 amrex::Real lx = (p.pos(0) - plo[0] - Real(0.5)/pdxi[0]) * dxi[0];
145 amrex::Real ly = (p.pos(1) - plo[1] - Real(0.5)/pdxi[1]) * dxi[1];
147 amrex::Real hx = (p.pos(0) - plo[0] + Real(0.5)/pdxi[0]) * dxi[0];
148 amrex::Real hy = (p.pos(1) - plo[1] + Real(0.5)/pdxi[1]) * dxi[1];
150 int lo_x =
static_cast<int>(amrex::Math::floor(lx));
151 int lo_y =
static_cast<int>(amrex::Math::floor(ly));
153 int hi_x =
static_cast<int>(amrex::Math::floor(hx));
154 int hi_y =
static_cast<int>(amrex::Math::floor(hy));
156 for (
int j = lo_y; j <= hi_y; ++j) {
157 if (j < rho.begin.y || j >= rho.
end.
y) {
continue; }
158 amrex::Real wy =
amrex::min(hy -
static_cast<Real
>(j), amrex::Real(1.0)) -
amrex::max(ly -
static_cast<Real
>(j), amrex::Real(0.0));
159 for (
int i = lo_x; i <= hi_x; ++i) {
160 if (i < rho.begin.x || i >= rho.
end.
x) {
continue; }
161 amrex::Real wx =
amrex::min(hx -
static_cast<Real
>(i), amrex::Real(1.0)) -
amrex::max(lx -
static_cast<Real
>(i), amrex::Real(0.0));
162 amrex::Real weight = wx*wy*factor;
167 for (
int comp = 1; comp < nc; ++comp) {
168 for (
int j = lo_y; j <= hi_y; ++j) {
169 if (j < rho.begin.y || j >= rho.
end.
y) {
continue; }
170 amrex::Real wy =
amrex::min(hy -
static_cast<Real
>(j), amrex::Real(1.0)) -
amrex::max(ly -
static_cast<Real
>(j), amrex::Real(0.0));
171 for (
int i = lo_x; i <= hi_x; ++i) {
172 if (i < rho.begin.x || i >= rho.
end.
x) {
continue; }
173 amrex::Real wx =
amrex::min(hx -
static_cast<Real
>(i), amrex::Real(1.0)) -
amrex::max(lx -
static_cast<Real
>(i), amrex::Real(0.0));
174 amrex::Real weight = wx*wy*factor;
180 #elif (AMREX_SPACEDIM == 3)
181 amrex::Real factor = (pdxi[0]/dxi[0])*(pdxi[1]/dxi[1])*(pdxi[2]/dxi[2]);
183 amrex::Real lx = (p.pos(0) - plo[0] - Real(0.5)/pdxi[0]) * dxi[0];
184 amrex::Real ly = (p.pos(1) - plo[1] - Real(0.5)/pdxi[1]) * dxi[1];
185 amrex::Real lz = (p.pos(2) - plo[2] - Real(0.5)/pdxi[2]) * dxi[2];
187 amrex::Real hx = (p.pos(0) - plo[0] + Real(0.5)/pdxi[0]) * dxi[0];
188 amrex::Real hy = (p.pos(1) - plo[1] + Real(0.5)/pdxi[1]) * dxi[1];
189 amrex::Real hz = (p.pos(2) - plo[2] + Real(0.5)/pdxi[2]) * dxi[2];
191 int lo_x =
static_cast<int>(amrex::Math::floor(lx));
192 int lo_y =
static_cast<int>(amrex::Math::floor(ly));
193 int lo_z =
static_cast<int>(amrex::Math::floor(lz));
195 int hi_x =
static_cast<int>(amrex::Math::floor(hx));
196 int hi_y =
static_cast<int>(amrex::Math::floor(hy));
197 int hi_z =
static_cast<int>(amrex::Math::floor(hz));
199 for (
int k = lo_z; k <= hi_z; ++k) {
200 if (k < rho.begin.z || k >= rho.
end.
z) {
continue; }
201 amrex::Real wz =
amrex::min(hz -
static_cast<Real
>(k), amrex::Real(1.0)) -
amrex::max(lz -
static_cast<Real
>(k), amrex::Real(0.0));
202 for (
int j = lo_y; j <= hi_y; ++j) {
203 if (j < rho.begin.y || j >= rho.
end.
y) {
continue; }
204 amrex::Real wy =
amrex::min(hy -
static_cast<Real
>(j), amrex::Real(1.0)) -
amrex::max(ly -
static_cast<Real
>(j), amrex::Real(0.0));
205 for (
int i = lo_x; i <= hi_x; ++i) {
206 if (i < rho.begin.x || i >= rho.
end.
x) {
continue; }
207 amrex::Real wx =
amrex::min(hx -
static_cast<Real
>(i), amrex::Real(1.0)) -
amrex::max(lx -
static_cast<Real
>(i), amrex::Real(0.0));
208 amrex::Real weight = wx*wy*wz*factor;
214 for (
int comp = 1; comp < nc; ++comp) {
215 for (
int k = lo_z; k <= hi_z; ++k) {
216 if (k < rho.begin.z || k >= rho.
end.
z) {
continue; }
217 amrex::Real wz =
amrex::min(hz -
static_cast<Real
>(k), amrex::Real(1.0)) -
amrex::max(lz -
static_cast<Real
>(k), amrex::Real(0.0));
218 for (
int j = lo_y; j <= hi_y; ++j) {
219 if (j < rho.begin.y || j >= rho.
end.
y) {
continue; }
220 amrex::Real wy =
amrex::min(hy -
static_cast<Real
>(j), amrex::Real(1.0)) -
amrex::max(ly -
static_cast<Real
>(j), amrex::Real(0.0));
221 for (
int i = lo_x; i <= hi_x; ++i) {
222 if (i < rho.begin.x || i >= rho.
end.
x) {
continue; }
223 amrex::Real wx =
amrex::min(hx -
static_cast<Real
>(i), amrex::Real(1.0)) -
amrex::max(lx -
static_cast<Real
>(i), amrex::Real(0.0));
224 amrex::Real weight = wx*wy*wz*factor;
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
#define AMREX_GPU_HOST_DEVICE
Definition: AMReX_GpuQualifiers.H:20
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void AddNoRet(T *sum, T value) noexcept
Definition: AMReX_GpuAtomic.H:281
static constexpr int P
Definition: AMReX_OpenBC.H:14
Definition: AMReX_Amr.cpp:49
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_deposit_cic(P const &p, int nc, amrex::Array4< amrex::Real > const &rho, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi)
Definition: AMReX_Particle_mod_K.H:13
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & max(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:35
AMREX_GPU_HOST_DEVICE constexpr AMREX_FORCE_INLINE const T & min(const T &a, const T &b) noexcept
Definition: AMReX_Algorithm.H:21
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void amrex_deposit_particle_dx_cic(P const &p, int nc, amrex::Array4< amrex::Real > const &rho, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &plo, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &dxi, amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > const &pdxi)
Definition: AMReX_Particle_mod_K.H:108
void Abort(const std::string &msg)
Print out message to cerr and exit via abort().
Definition: AMReX.cpp:221
Definition: AMReX_Array4.H:61
Dim3 end
Definition: AMReX_Array4.H:67
int x
Definition: AMReX_Dim3.H:12
int z
Definition: AMReX_Dim3.H:12
int y
Definition: AMReX_Dim3.H:12
Definition: AMReX_Array.H:33