97 Gpu::DeviceVector<Real> d_freestream_velocity(
xloc.size());
98 Gpu::DeviceVector<Real> d_freestream_phi(
yloc.size());
99 Gpu::DeviceVector<Real> d_disk_cell_count(
yloc.size());
104 Real* d_freestream_velocity_ptr = d_freestream_velocity.data();
105 Real* d_freestream_phi_ptr = d_freestream_phi.data();
106 Real* d_disk_cell_count_ptr = d_disk_cell_count.data();
109 for ( MFIter mfi(cons_in,TilingIfNotGPU()); mfi.isValid(); ++mfi) {
111 auto SMark_array = mf_SMark.array(mfi);
112 auto u_vel = U_old.array(mfi);
113 auto v_vel = V_old.array(mfi);
114 Box tbx = mfi.nodaltilebox(0);
116 ParallelFor(tbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept {
118 if(SMark_array(i,j,k,0) != -
one) {
119 int turb_index =
static_cast<int>(SMark_array(i,j,k,0));
120 Real phi = std::atan2(v_vel(i,j,k),u_vel(i,j,k));
121 Gpu::Atomic::Add(&d_freestream_velocity_ptr[turb_index],std::pow(u_vel(i,j,k)*u_vel(i,j,k) + v_vel(i,j,k)*v_vel(i,j,k),
myhalf));
122 Gpu::Atomic::Add(&d_disk_cell_count_ptr[turb_index],
one);
123 Gpu::Atomic::Add(&d_freestream_phi_ptr[turb_index],phi);
129 Gpu::copy(Gpu::deviceToHost, d_freestream_velocity.begin(), d_freestream_velocity.end(),
freestream_velocity.begin());
130 Gpu::copy(Gpu::deviceToHost, d_freestream_phi.begin(), d_freestream_phi.end(),
freestream_phi.begin());
131 Gpu::copy(Gpu::deviceToHost, d_disk_cell_count.begin(), d_disk_cell_count.end(),
disk_cell_count.begin());
136 amrex::ParallelContext::CommunicatorAll());
140 amrex::ParallelContext::CommunicatorAll());
145 amrex::ParallelContext::CommunicatorAll());
constexpr amrex::Real one
Definition: ERF_Constants.H:7
constexpr amrex::Real zero
Definition: ERF_Constants.H:6
constexpr amrex::Real myhalf
Definition: ERF_Constants.H:11
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { const auto prob_lo=geomdata.ProbLo();const auto dx=geomdata.CellSize();const Real x=(prob_lo[0]+(i+myhalf) *dx[0])/mf_m(i, j, 0);const Real z=z_cc(i, j, k);Real L=std::sqrt(std::pow((x - x_c)/x_r, 2)+std::pow((z - z_c)/z_r, 2));if(L<=one) { Real dT=T_pert *(std::cos(PI *L)+one)/two;Real Tbar_hse=p_hse(i, j, k)/(R_d *r_hse(i, j, k));Real theta_perturbed=(Tbar_hse+dT) *std::pow(p_0/p_hse(i, j, k), rdOcp);Real theta_0=(Tbar_hse) *std::pow(p_0/p_hse(i, j, k), rdOcp);if(const_rho) { state_pert(i, j, k, RhoTheta_comp)=r_hse(i, j, k) *(theta_perturbed - theta_0);} else { state_pert(i, j, k, Rho_comp)=getRhoThetagivenP(p_hse(i, j, k))/theta_perturbed - r_hse(i, j, k);} } })
amrex::Real Real
Definition: ERF_ShocInterface.H:19
void get_turb_loc(amrex::Vector< amrex::Real > &xloc, amrex::Vector< amrex::Real > &yloc)
Definition: ERF_NullWindFarm.H:96
amrex::Vector< amrex::Real > disk_cell_count
Definition: ERF_SimpleAD.H:50
amrex::Vector< amrex::Real > freestream_velocity
Definition: ERF_SimpleAD.H:50
amrex::Vector< amrex::Real > xloc
Definition: ERF_SimpleAD.H:46
amrex::Vector< amrex::Real > yloc
Definition: ERF_SimpleAD.H:46
amrex::Vector< amrex::Real > freestream_phi
Definition: ERF_SimpleAD.H:50