1#ifndef DRIFT_DIFFUSION_H
2#define DRIFT_DIFFUSION_H
18template<
typename PVAR_t>
32 PVAR_t vx_, PVAR_t vy_,
34 :
x(x_),
y(y_),
vx(vx_),
vy(vy_),
dt{dt_} { }
43 void operator() (
int n) {
50 y[n] = fmin (1.999, fmax (0.001,
y[n]));
51 x[n] = fmin (1.999, fmax (0.001,
x[n]));
57template<
typename PVAR_t,
typename GVAR_t,
typename P2C_t>
76 p2g_step1 (
const PVAR_t x_,
const PVAR_t y_, GVAR_t M_,
77 GVAR_t gvar_,
const P2C_t ptcl_to_grd_,
const idx_t nrows_,
78 const real_t hx_,
const real_t hy_,
const PVAR_t dprop1_,
const PVAR_t dprop2_,
bool apply_mass_)
79 :
x(x_),
y(y_),
M(M_),
gvar(gvar_),
94 for (
idx_t inode = 0; inode < 4; ++inode) {
96 qgt::shp (xx, yy, inode, c, r,
hx,
hy);
104template<
typename PVAR_t,
typename GVAR_t,
typename P2C_t>
125 p2gd_step2 (
const PVAR_t x_,
const PVAR_t y_,
const GVAR_t M_,
126 GVAR_t gvar_,
const P2C_t ptcl_to_grd_,
const idx_t nrows_,
127 const real_t hx_,
const real_t hy_,
const real_t D_,
const PVAR_t dpropx_,
const PVAR_t dpropy_,
bool apply_mass_)
128 :
x(x_),
y(y_),
M(M_),
gvar(gvar_),
136 real_t Nx = 0.0, Ny = 0.0;
141 for (
idx_t inode = 0; inode < 4; ++inode) {
142 Nx =
apply_mass ? qgt::shg (xx, yy, 0, inode, c, r,
hx,
hy) /
M[qgt::gt(inode, c, r,
nrows)] :
143 qgt::shg (xx, yy, 0, inode, c, r,
hx,
hy);
144 Ny =
apply_mass ? qgt::shg (xx, yy, 1, inode, c, r,
hx,
hy) /
M[qgt::gt(inode, c, r,
nrows)] :
145 qgt::shg (xx, yy, 1, inode, c, r,
hx,
hy);
154template<
typename GVAR_t,
typename PVAR_t,
typename P2C_t>
174 const GVAR_t gvar1_,
const GVAR_t gvar2_,
const P2C_t ptcl_to_grd_,
const idx_t nrows_,
175 const real_t hx_,
const real_t hy_, PVAR_t dprop_,
bool apply_mass_)
189 for (
idx_t inode = 0; inode < 4; ++inode) {
191 qgt::shp (xx, yy, inode, c, r,
hx,
hy);
198template<
typename GVAR_t,
typename PVAR_t,
typename P2C_t>
217 const GVAR_t gvar1_,
const GVAR_t gvar2_,
const GVAR_t gvar3_,
const GVAR_t gvar4_,
const P2C_t ptcl_to_grd_,
const idx_t nrows_,
228 real_t Nx = 0.0, Ny = 0.0;
234 for (
idx_t inode = 0; inode < 4; ++inode) {
236 qgt::shg (xx, yy, 0, inode, c, r,
hx,
hy) *
M[qgt::gt(inode, c, r,
nrows)] :
237 qgt::shg (xx, yy, 0, inode, c, r,
hx,
hy);
239 qgt::shg (xx, yy, 1, inode, c, r,
hx,
hy) *
M[qgt::gt(inode, c, r,
nrows)] :
240 qgt::shg (xx, yy, 1, inode, c, r,
hx,
hy);
248template<
typename PVAR_t>
void atomicAdd(T *x, const T y)
g2p_step3(PVAR_t x_, PVAR_t y_, const GVAR_t M_, const GVAR_t gvar1_, const GVAR_t gvar2_, const P2C_t ptcl_to_grd_, const idx_t nrows_, const real_t hx_, const real_t hy_, PVAR_t dprop_, bool apply_mass_)
g2pd_step4(PVAR_t x_, PVAR_t y_, const GVAR_t M_, const GVAR_t gvar1_, const GVAR_t gvar2_, const GVAR_t gvar3_, const GVAR_t gvar4_, const P2C_t ptcl_to_grd_, const idx_t nrows_, const real_t hx_, const real_t hy_, PVAR_t dprop_, bool apply_mass_)
DEVICE void operator()(idx_t ip)
p2g_step1(const PVAR_t x_, const PVAR_t y_, GVAR_t M_, GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_, const real_t hx_, const real_t hy_, const PVAR_t dprop1_, const PVAR_t dprop2_, bool apply_mass_)
p2gd_step2(const PVAR_t x_, const PVAR_t y_, const GVAR_t M_, GVAR_t gvar_, const P2C_t ptcl_to_grd_, const idx_t nrows_, const real_t hx_, const real_t hy_, const real_t D_, const PVAR_t dpropx_, const PVAR_t dpropy_, bool apply_mass_)
Functor class for moving particles.
std::vector< double > & vx
std::vector< double > & y
stepper(PVAR_t x_, PVAR_t y_, PVAR_t vx_, PVAR_t vy_, real_t dt_)
std::vector< double > & x
std::vector< double > & vy
updateRho(PVAR_t rho_, PVAR_t divV_, real_t dt_)
quadgrid_t< vector_t< real_t > >::idx_t idx_t
datatype for indexing into vectors of properties