175 Gpu::DeviceVector<Real> d_xloc(
xloc.size());
176 Gpu::DeviceVector<Real> d_yloc(
yloc.size());
177 Gpu::copy(Gpu::hostToDevice,
xloc.begin(),
xloc.end(), d_xloc.begin());
178 Gpu::copy(Gpu::hostToDevice,
yloc.begin(),
yloc.end(), d_yloc.begin());
180 auto dx = geom.CellSizeArray();
183 const amrex::Box& domain = geom.Domain();
184 int domlo_x = domain.smallEnd(0);
185 int domhi_x = domain.bigEnd(0) + 1;
186 int domlo_y = domain.smallEnd(1);
187 int domhi_y = domain.bigEnd(1) + 1;
188 int domlo_z = domain.smallEnd(2);
189 int domhi_z = domain.bigEnd(2) + 1;
192 mf_vars_simpleAD.setVal(0.0);
194 long unsigned int nturbs =
static_cast<long unsigned int>(
xloc.size());
196 Gpu::DeviceVector<Real> d_freestream_velocity(nturbs);
197 Gpu::DeviceVector<Real> d_freestream_phi(nturbs);
198 Gpu::DeviceVector<Real> d_disk_cell_count(nturbs);
203 Real* d_freestream_velocity_ptr = d_freestream_velocity.data();
204 Real* d_freestream_phi_ptr = d_freestream_phi.data();
205 Real* d_disk_cell_count_ptr = d_disk_cell_count.data();
223 Real area_over_vol =
one/(std::abs(nx)*
dx[0] + std::abs(ny)*
dx[1]);
225 Gpu::DeviceVector<Real> d_wind_speed(
wind_speed.size());
226 Gpu::DeviceVector<Real> d_thrust_coeff(
thrust_coeff.size());
232 const Real* wind_speed_d = d_wind_speed.dataPtr();
233 const Real* thrust_coeff_d = d_thrust_coeff.dataPtr();
234 const int n_spec_table =
static_cast<int>(d_wind_speed.size());
236 for ( MFIter mfi(cons_in,TilingIfNotGPU()); mfi.isValid(); ++mfi) {
238 const Box& gbx = mfi.growntilebox(1);
239 auto SMark_array = mf_SMark.array(mfi);
240 auto simpleAD_array = mf_vars_simpleAD.array(mfi);
242 ParallelFor(gbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept {
243 int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
244 int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
245 int kk = amrex::min(amrex::max(k, domlo_z), domhi_z);
251 int it =
static_cast<int>(SMark_array(ii,jj,kk,1));
254 Real avg_vel = d_freestream_velocity_ptr[it]/(d_disk_cell_count_ptr[it] +
Real(1e-10));
255 Real phi = d_freestream_phi_ptr[it]/(d_disk_cell_count_ptr[it] +
Real(1e-10));
262 Real Uinfty_dot_nhat = avg_vel*(std::cos(phi)*nx + std::sin(phi)*ny);
264 source_x = -
two*std::pow(Uinfty_dot_nhat,
two)*a*(
one-a)*area_over_vol*std::cos(phi);
265 source_y = -
two*std::pow(Uinfty_dot_nhat,
two)*a*(
one-a)*area_over_vol*std::sin(phi);
268 source_x = -
myhalf*C_T*std::pow(Uinfty_dot_nhat,
two)*area_over_vol*std::cos(phi);
269 source_y = -
myhalf*C_T*std::pow(Uinfty_dot_nhat,
two)*area_over_vol*std::sin(phi);
273 simpleAD_array(i,j,k,0) = source_x;
274 simpleAD_array(i,j,k,1) = source_y;
constexpr amrex::Real two
Definition: ERF_Constants.H:10
const Real dx
Definition: ERF_InitCustomPert_ABL.H:44
void get_turb_disk_angle(amrex::Real &turb_disk_angle)
Definition: ERF_NullWindFarm.H:103
amrex::Real turb_disk_angle
Definition: ERF_SimpleAD.H:47