180 Gpu::DeviceVector<Real> d_xloc(
xloc.size());
181 Gpu::DeviceVector<Real> d_yloc(
yloc.size());
182 Gpu::copy(Gpu::hostToDevice,
xloc.begin(),
xloc.end(), d_xloc.begin());
183 Gpu::copy(Gpu::hostToDevice,
yloc.begin(),
yloc.end(), d_yloc.begin());
189 const amrex::Box& domain = geom.Domain();
190 int domlo_x = domain.smallEnd(0);
191 int domhi_x = domain.bigEnd(0) + 1;
192 int domlo_y = domain.smallEnd(1);
193 int domhi_y = domain.bigEnd(1) + 1;
194 int domlo_z = domain.smallEnd(2);
195 int domhi_z = domain.bigEnd(2) + 1;
198 mf_vars_simpleAD.setVal(0.0);
200 long unsigned int nturbs =
static_cast<long unsigned int>(
xloc.size());
202 Gpu::DeviceVector<Real> d_freestream_velocity(nturbs);
203 Gpu::DeviceVector<Real> d_freestream_phi(nturbs);
204 Gpu::DeviceVector<Real> d_disk_cell_count(nturbs);
209 Real* d_freestream_velocity_ptr = d_freestream_velocity.data();
210 Real* d_freestream_phi_ptr = d_freestream_phi.data();
211 Real* d_disk_cell_count_ptr = d_disk_cell_count.data();
229 Real area_over_vol =
one/(std::abs(
nx)*
dx[0] + std::abs(
ny)*
dx[1]);
231 Gpu::DeviceVector<Real> d_wind_speed(
wind_speed.size());
232 Gpu::DeviceVector<Real> d_thrust_coeff(
thrust_coeff.size());
238 const Real* wind_speed_d = d_wind_speed.dataPtr();
239 const Real* thrust_coeff_d = d_thrust_coeff.dataPtr();
240 const int n_spec_table =
static_cast<int>(d_wind_speed.size());
242 for ( MFIter mfi(cons_in,TilingIfNotGPU()); mfi.isValid(); ++mfi) {
244 const Box& gbx = mfi.growntilebox(1);
245 auto SMark_array = mf_SMark.array(mfi);
246 auto simpleAD_array = mf_vars_simpleAD.array(mfi);
248 ParallelFor(gbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept {
249 int ii = amrex::min(amrex::max(i, domlo_x), domhi_x);
250 int jj = amrex::min(amrex::max(j, domlo_y), domhi_y);
251 int kk = amrex::min(amrex::max(k, domlo_z), domhi_z);
254 Real source_x =
zero;
255 Real source_y =
zero;
257 int it =
static_cast<int>(SMark_array(ii,jj,kk,1));
260 Real avg_vel = d_freestream_velocity_ptr[it]/(d_disk_cell_count_ptr[it] + Real(1e-10));
261 Real
phi = d_freestream_phi_ptr[it]/(d_disk_cell_count_ptr[it] + Real(1e-10));
263 Real C_T =
interpolate_1d(wind_speed_d, thrust_coeff_d, avg_vel, n_spec_table);
268 Real Uinfty_dot_nhat = avg_vel*(std::cos(
phi)*
nx + std::sin(
phi)*
ny);
270 source_x = -
two*std::pow(Uinfty_dot_nhat,
two)*a*(
one-a)*area_over_vol*std::cos(
phi);
271 source_y = -
two*std::pow(Uinfty_dot_nhat,
two)*a*(
one-a)*area_over_vol*std::sin(
phi);
274 source_x = -
myhalf*C_T*std::pow(Uinfty_dot_nhat,
two)*area_over_vol*std::cos(
phi);
275 source_y = -
myhalf*C_T*std::pow(Uinfty_dot_nhat,
two)*area_over_vol*std::sin(
phi);
279 simpleAD_array(i,j,k,0) = source_x;
280 simpleAD_array(i,j,k,1) = source_y;
GpuArray< Real, AMREX_SPACEDIM > dx
Definition: ERF_ActuatorSpreading.cpp:131
const int nx
Definition: ERF_InitCustomPertVels_CloudChamber.H:14
const int ny
Definition: ERF_InitCustomPertVels_CloudChamber.H:15
amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > LengthScaleCellSize(const amrex::Geometry &geom)
Definition: ERF_LengthScaleCellSize.H:28
constexpr amrex::Real two
Definition: ERF_NumericalConstants.H:38
void get_turb_disk_angle(amrex::Real &turb_disk_angle)
Definition: ERF_NullWindFarm.H:130
amrex::Real turb_disk_angle
Definition: ERF_SimpleAD.H:49