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 Real *dx=geomdata.CellSize();const Real x=(i+0.5) *dx[0];const Real y=(j+0.5) *dx[1];const Real Omg=erf_vortex_Gaussian(x, y, xc, yc, R, beta, sigma);const Real deltaT=-(gamma - 1.0)/(2.0 *sigma *sigma) *Omg *Omg;const Real rho_norm=std::pow(1.0+deltaT, inv_gm1);const Real T=(1.0+deltaT) *T_inf;const Real p=std::pow(rho_norm, Gamma)/Gamma *rho_0 *a_inf *a_inf;const Real rho_theta=rho_0 *rho_norm *(T *std::pow(p_0/p, rdOcp));state_pert(i, j, k, RhoTheta_comp)=rho_theta - getRhoThetagivenP(p_hse(i, j, k));const Real r2d_xy=std::sqrt((x-xc) *(x-xc)+(y-yc) *(y-yc));state_pert(i, j, k, RhoScalar_comp)=0.25 *(1.0+std::cos(PI *std::min(r2d_xy, R)/R));})
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