diff --git a/CHANGES b/CHANGES index e8a03bfe6..511f819e6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,18 @@ +# 24.11 + -- AMReX submodule set to 24.11 release hash (4a6e7c8) + + -- AMR functionality (#1916-1920) + + -- GAD functionality (#1912, #1875) + + -- Remove QKE (#1905) + + -- NOAH-MP interface (#1835) + + -- Line and plane sampling (#1897) + + -- AMReX & KOKKOS docs (#1889) + # 24.10 -- Add WENO7 advection operators (#1858) diff --git a/Source/ERF_read_waves.cpp b/Source/ERF_read_waves.cpp index cbc8b83ba..d15eb2b4b 100644 --- a/Source/ERF_read_waves.cpp +++ b/Source/ERF_read_waves.cpp @@ -22,71 +22,68 @@ ERF::read_waves (int lev) for ( MFIter mfi(*Hwave_onegrid[lev],false); mfi.isValid(); ++mfi) { + const auto & bx = mfi.validbox(); + + amrex::Print() << " Just called ERF::read_waves to receive from WW3 " << bx << std::endl; + amrex::Array4 my_H_arr = Hwave_onegrid[lev]->array(mfi); + amrex::Array4 my_L_arr = Lwave_onegrid[lev]->array(mfi); + + Real* my_H_ptr = my_H_arr.dataPtr(); + Real* my_L_ptr = my_L_arr.dataPtr(); + + int rank_offset = amrex::MPMD::MyProc() - amrex::ParallelDescriptor::MyProc(); + int this_root, other_root; + if (rank_offset == 0) { // First program + this_root = 0; + other_root = amrex::ParallelDescriptor::NProcs(); + } else { + this_root = rank_offset; + other_root = 0; + } + + int nx=2147483647; + int ny=2147483647; // sanity check + + //JUST RECEIVED + if (amrex::MPMD::MyProc() == this_root) { + if (rank_offset == 0) // First program + { + MPI_Recv(&nx, 1, MPI_INT, other_root, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Recv(&ny, 1, MPI_INT, other_root, 7, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + } + else // Second program + { + MPI_Recv(&nx, 1, MPI_INT, other_root, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Recv(&ny, 1, MPI_INT, other_root, 6, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + } + //This may not be necessary + ParallelDescriptor::Bcast(&nx, 1); + ParallelDescriptor::Bcast(&ny, 1); + } + + if((nx)*(ny) > 0) { + int nsealm = (nx)*ny; + + if (amrex::MPMD::MyProc() == this_root) { + if (rank_offset == 0) // the first program + { + MPI_Recv(my_H_ptr, nsealm, MPI_DOUBLE, other_root, 3, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Recv(my_L_ptr, nsealm, MPI_DOUBLE, other_root, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + } + else // the second program + { + MPI_Recv(my_H_ptr, nsealm, MPI_DOUBLE, other_root, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + MPI_Recv(my_L_ptr, nsealm, MPI_DOUBLE, other_root, 4, MPI_COMM_WORLD, MPI_STATUS_IGNORE); + } + } - const auto & bx = mfi.validbox(); - - amrex::Print() << " Just called ERF::read_waves to receive from WW3 " << bx << std::endl; - amrex::Array4 my_H_arr = Hwave_onegrid[lev]->array(mfi); - amrex::Array4 my_L_arr = Lwave_onegrid[lev]->array(mfi); - - Real* my_H_ptr = my_H_arr.dataPtr(); - Real* my_L_ptr = my_L_arr.dataPtr(); - - int rank_offset = amrex::MPMD::MyProc() - amrex::ParallelDescriptor::MyProc(); - int this_root, other_root; - if (rank_offset == 0) { // First program - this_root = 0; - other_root = amrex::ParallelDescriptor::NProcs(); - } else { - this_root = rank_offset; - other_root = 0; - } - - - int nx=2147483647; - int ny=2147483647; // sanity check - - //JUST RECEIVED - if (amrex::MPMD::MyProc() == this_root) { - if (rank_offset == 0) // First program - { - MPI_Recv(&nx, 1, MPI_INT, other_root, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&ny, 1, MPI_INT, other_root, 7, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - } - else // Second program - { - MPI_Recv(&nx, 1, MPI_INT, other_root, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(&ny, 1, MPI_INT, other_root, 6, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - } - //This may not be necessary - ParallelDescriptor::Bcast(&nx, 1); - ParallelDescriptor::Bcast(&ny, 1); - } - - if((nx)*(ny) > 0) { - int nsealm = (nx)*ny; - - if (amrex::MPMD::MyProc() == this_root) { - if (rank_offset == 0) // the first program - { - MPI_Recv(my_H_ptr, nsealm, MPI_DOUBLE, other_root, 3, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(my_L_ptr, nsealm, MPI_DOUBLE, other_root, 5, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - } - else // the second program - { - MPI_Recv(my_H_ptr, nsealm, MPI_DOUBLE, other_root, 2, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - MPI_Recv(my_L_ptr, nsealm, MPI_DOUBLE, other_root, 4, MPI_COMM_WORLD, MPI_STATUS_IGNORE); - } - } - - amrex::AllPrintToFile("output_HS_cpp.txt")<ParallelCopy(*Hwave_onegrid[lev]); @@ -99,21 +96,24 @@ ERF::read_waves (int lev) Box bx = mfi.tilebox(); const Array4& Hwave_arr = Hwave[lev]->const_array(mfi); const Array4& Lmask_arr = lmask_lev[lev][0]->array(mfi); - ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k){ + ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) + { if (Hwave_arr(i,j,k)<0) { Lmask_arr(i,j,k) = 1; - } else { + } else { Lmask_arr(i,j,k) = 0; } }); } - // amrex::Real myclock = ParallelDescriptor::second(); - // amrex::AllPrintToFile("timer.txt") << "At " << myclock << " seconds, I reached the end of read_waves" << std::endl; + // amrex::Real myclock = ParallelDescriptor::second(); + // amrex::AllPrintToFile("timer.txt") << "At " << myclock << " seconds, I reached the end of read_waves" << std::endl; timedif = ( ((double) clock()) / CLOCKS_PER_SEC) - clkStart; - amrex::AllPrintToFile("timer.txt") << "It took " << timedif << " seconds to reach the end of read_waves" << std::endl; + amrex::AllPrintToFile("timer.txt") << "It took " << timedif + << " seconds to reach the end of read_waves" + << std::endl; } void @@ -168,12 +168,8 @@ ERF::send_to_ww3 (int lev) // Initialize Multifabs to store x_avg, y_avg, u_mag, u_dir at cell centers MultiFab x_avg(lev_new[Vars::cons].boxArray(), lev_new[Vars::cons].DistributionMap(), 1, lev_new[Vars::cons].nGrowVect()); - MultiFab y_avg(lev_new[Vars::cons].boxArray(), lev_new[Vars::cons].DistributionMap(), 1, lev_new[Vars::cons].nGrowVect()); - MultiFab u_mag(lev_new[Vars::cons].boxArray(), lev_new[Vars::cons].DistributionMap(), 1, lev_new[Vars::cons].nGrowVect()); - - MultiFab u_dir(lev_new[Vars::cons].boxArray(), lev_new[Vars::cons].DistributionMap(), 1, lev_new[Vars::cons].nGrowVect()); @@ -191,7 +187,10 @@ ERF::send_to_ww3 (int lev) ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k){ u_vel(i,j,k) = 0.5 *( velx_arr(i,j,k) + velx_arr(i+1,j,k) ); - amrex::AllPrintToFile("uvel.txt") << amrex::IntVect(i,j,k) << " [" <> theta_onegrid; - // create a new BoxArray and DistributionMapping for a MultiFab with 1 box - BoxArray ba_onegrid(geom[lev].Domain()); - BoxList bl2d_onegrid = ba_onegrid.boxList(); - for (auto& b : bl2d_onegrid) { - b.setRange(2,0); - } - BoxArray ba2d_onegrid(std::move(bl2d_onegrid)); - Vector pmap; - pmap.resize(1); - pmap[0]=0; - DistributionMapping dm_onegrid(ba2d_onegrid); - dm_onegrid.define(pmap); - - ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k){ + // create a new BoxArray and DistributionMapping for a MultiFab with 1 box + BoxArray ba_onegrid(geom[lev].Domain()); + BoxList bl2d_onegrid = ba_onegrid.boxList(); + for (auto& b : bl2d_onegrid) { + b.setRange(2,0); + } + BoxArray ba2d_onegrid(std::move(bl2d_onegrid)); + Vector pmap; + pmap.resize(1); + pmap[0]=0; + DistributionMapping dm_onegrid(ba2d_onegrid); + dm_onegrid.define(pmap); - // magnitude(i,j,k) = std::sqrt( pow(u(i,j,k), 2) + pow(v(i,j,k), 2) ); + ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) + { + //magnitude(i,j,k) = std::sqrt( pow(u(i,j,k), 2) + pow(v(i,j,k), 2) ); double u_val = u(i, j, k); double v_val = v(i, j, k); @@ -257,47 +259,49 @@ ERF::send_to_ww3 (int lev) theta(i,j,k) = atan ( v_val / u_val ); } - - amrex::AllPrintToFile("mag_theta.txt") << amrex::IntVect(i,j,k) << " Magnitude: " << magnitude(i,j,k) << " Theta: " << theta(i,j,k) < magnitude_values(n_elements); - std::vector theta_values(n_elements); - std::vector indices(n_elements); - // Copy values - int counter = 0; - for (BoxIterator bi(slice_box_ref); bi.ok(); ++bi) { - IntVect iv = bi(); - magnitude_values[counter] = magnitude(iv); - theta_values[counter] = theta(iv); - indices[counter] = iv; - ++counter; - } -// timedif2 = ( ((double) clock()) / CLOCKS_PER_SEC) - clkStart2; -// amrex::AllPrintToFile("timer.txt") << "It took " << (double) timedif2 << " seconds to reach the part before sending" << std::endl; -//amrex::Print() << "It took " << (double) timedif2 << " seconds to reach the part before sending" << std::endl; - -// Print magnitude values and corresponding IntVect indices -for (int j = 0; j < n_elements; ++j) { - amrex::AllPrintToFile("debug_send.txt") - << "dz, k_ref " << dz << ", " << k_ref << " " - << "Index: " << j - << ", IntVect: (" << indices[j][0] << ", " << indices[j][1] << ", " << indices[j][2] << ")" - << ", Magnitude: " << magnitude_values[j] - << ", Theta: " << theta_values[j] - << std::endl; -} + // Calculate the number of elements in the current box + int n_elements = slice_box_ref.numPts(); + + // Initialize vectors to send to WW3 + std::vector magnitude_values(n_elements); + std::vector theta_values(n_elements); + std::vector indices(n_elements); + // Copy values + int counter = 0; + for (BoxIterator bi(slice_box_ref); bi.ok(); ++bi) { + IntVect iv = bi(); + magnitude_values[counter] = magnitude(iv); + theta_values[counter] = theta(iv); + indices[counter] = iv; + ++counter; + } + + // timedif2 = ( ((double) clock()) / CLOCKS_PER_SEC) - clkStart2; + // amrex::AllPrintToFile("timer.txt") << "It took " << (double) timedif2 << " seconds to reach the part before sending" << std::endl; + //amrex::Print() << "It took " << (double) timedif2 << " seconds to reach the part before sending" << std::endl; + + // Print magnitude values and corresponding IntVect indices + for (int j = 0; j < n_elements; ++j) { + amrex::AllPrintToFile("debug_send.txt") + << "dz, k_ref " << dz << ", " << k_ref << " " + << "Index: " << j + << ", IntVect: (" << indices[j][0] << ", " << indices[j][1] << ", " << indices[j][2] << ")" + << ", Magnitude: " << magnitude_values[j] + << ", Theta: " << theta_values[j] + << std::endl; + } int rank_offset = amrex::MPMD::MyProc() - amrex::ParallelDescriptor::MyProc(); int this_root, other_root; @@ -309,35 +313,32 @@ for (int j = 0; j < n_elements; ++j) { other_root = 0; } - amrex::Print()<< "Sending " << n_elements << " from ERF::send_to_ww3 now" << std::endl; if (amrex::MPMD::MyProc() == this_root) { - if (rank_offset == 0) // First program - { - MPI_Send(&n_elements, 1, MPI_INT, other_root, 11, MPI_COMM_WORLD); -MPI_Send(magnitude_values.data(), n_elements, MPI_DOUBLE, other_root, 13, MPI_COMM_WORLD); -MPI_Send(theta_values.data(), n_elements, MPI_DOUBLE, other_root, 15, MPI_COMM_WORLD); + if (rank_offset == 0) { // First program + MPI_Send(&n_elements, 1, MPI_INT, other_root, 11, MPI_COMM_WORLD); + MPI_Send(magnitude_values.data(), n_elements, MPI_DOUBLE, other_root, 13, MPI_COMM_WORLD); + MPI_Send(theta_values.data(), n_elements, MPI_DOUBLE, other_root, 15, MPI_COMM_WORLD); } else // Second program { MPI_Send(&n_elements, 1, MPI_INT, other_root, 10, MPI_COMM_WORLD); -MPI_Send(magnitude_values.data(), n_elements, MPI_DOUBLE, other_root, 12, MPI_COMM_WORLD); -MPI_Send(theta_values.data(), n_elements, MPI_DOUBLE, other_root, 14, MPI_COMM_WORLD); + MPI_Send(magnitude_values.data(), n_elements, MPI_DOUBLE, other_root, 12, MPI_COMM_WORLD); + MPI_Send(theta_values.data(), n_elements, MPI_DOUBLE, other_root, 14, MPI_COMM_WORLD); //MPI_Recv(&nx, 1, MPI_INT, other_root, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); //MPI_Recv(&ny, 1, MPI_INT, other_root, 6, MPI_COMM_WORLD, MPI_STATUS_IGNORE); } } - timedif = ( ((double) clock()) / CLOCKS_PER_SEC) - clkStart; - -// amrex::Real myclock = ParallelDescriptor::second(); -// amrex::AllPrintToFile("timer.txt") << "At " << myclock << " seconds I reached the end of send_to_ww3" << std::endl; + timedif = ( ((double) clock()) / CLOCKS_PER_SEC) - clkStart; - amrex::AllPrintToFile("timer.txt") << "It took " << timedif << " seconds to reach the end of send_to_WW3" << std::endl; - - -} + // amrex::Real myclock = ParallelDescriptor::second(); + // amrex::AllPrintToFile("timer.txt") << "At " << myclock << " seconds I reached the end of send_to_ww3" << std::endl; + amrex::AllPrintToFile("timer.txt") << "It took " << timedif + << " seconds to reach the end of send_to_WW3" + << std::endl; + } // mfi } #endif diff --git a/Source/Utils/ERF_InteriorGhostCells.cpp b/Source/Utils/ERF_InteriorGhostCells.cpp index 76a57beea..19c07d684 100644 --- a/Source/Utils/ERF_InteriorGhostCells.cpp +++ b/Source/Utils/ERF_InteriorGhostCells.cpp @@ -119,7 +119,7 @@ realbdy_compute_interior_ghost_rhs (const Real& bdy_time_interval, Vector>& bdy_data_ylo, Vector>& bdy_data_yhi) { - BL_PROFILE_REGION("wrfbdy_compute_interior_ghost_RHS()"); + BL_PROFILE_REGION("realbdy_compute_interior_ghost_RHS()"); // NOTE: We pass the full width into this routine. // For relaxation, the last cell is a halo @@ -395,11 +395,11 @@ realbdy_compute_interior_ghost_rhs (const Real& bdy_time_interval, continue; } - wrfbdy_set_rhs_in_spec_region(delta_t, icomp, 1, - width, set_width, dom_lo, dom_hi, - tbx_xlo, tbx_xhi, tbx_ylo, tbx_yhi, - arr_xlo, arr_xhi, arr_ylo, arr_yhi, - data_arr, rhs_arr); + realbdy_set_rhs_in_spec_region(delta_t, icomp, 1, + width, set_width, dom_lo, dom_hi, + tbx_xlo, tbx_xhi, tbx_ylo, tbx_yhi, + arr_xlo, arr_xhi, arr_ylo, arr_yhi, + data_arr, rhs_arr); } // mfi } // ivar } // set_width @@ -455,11 +455,11 @@ realbdy_compute_interior_ghost_rhs (const Real& bdy_time_interval, continue; } - wrfbdy_compute_laplacian_relaxation(icomp, 1, - width2, set_width, dom_lo, dom_hi, F1, F2, - tbx_xlo, tbx_xhi, tbx_ylo, tbx_yhi, - arr_xlo, arr_xhi, arr_ylo, arr_yhi, - data_arr, rhs_arr); + realbdy_compute_laplacian_relaxation(icomp, 1, + width2, set_width, dom_lo, dom_hi, F1, F2, + tbx_xlo, tbx_xhi, tbx_ylo, tbx_yhi, + arr_xlo, arr_xhi, arr_ylo, arr_yhi, + data_arr, rhs_arr); /* // UNIT TEST DEBUG diff --git a/Source/Utils/ERF_Interpolation.H b/Source/Utils/ERF_Interpolation.H index a1a8f05fb..f2e196e76 100644 --- a/Source/Utils/ERF_Interpolation.H +++ b/Source/Utils/ERF_Interpolation.H @@ -49,8 +49,7 @@ InterpolateInX (int i, int j, int k, const amrex::Array4& qty amrex::Real scaled_upw = 0.; // // The value that comes in has not been normalized so we do that here - if (upw != 0.) - scaled_upw = (upw > 0) ? 1. : -1.; + if (upw != 0.) { scaled_upw = (upw > 0) ? 1. : -1.; } avg1 = (qty(i, j, k, qty_index) + qty(i-1, j, k, qty_index)); diff1 = (qty(i, j, k, qty_index) - qty(i-1, j, k, qty_index)); @@ -80,8 +79,7 @@ InterpolateInY (int i, int j, int k, const amrex::Array4& qty amrex::Real scaled_upw = 0.; // The value that comes in has not been normalized so we do that here - if (upw != 0.) - scaled_upw = (upw > 0) ? 1. : -1.; + if (upw != 0.) { scaled_upw = (upw > 0) ? 1. : -1.; } avg1 = (qty(i, j , k, qty_index) + qty(i, j-1, k, qty_index)); diff1 = (qty(i, j , k, qty_index) - qty(i, j-1, k, qty_index)); @@ -110,8 +108,7 @@ InterpolateInZ (int i, int j, int k, const amrex::Array4& qty amrex::Real diff1 = 0.; amrex::Real diff2 = 0.; amrex::Real diff3 = 0.; amrex::Real scaled_upw = 0.; // The value that comes in has not been normalized so we do that here - if (upw != 0.) - scaled_upw = (upw > 0) ? 1. : -1.; + if (upw != 0.) { scaled_upw = (upw > 0) ? 1. : -1.; } avg1 = (qty(i, j, k , qty_index) + qty(i, j, k-1, qty_index)); diff1 = (qty(i, j, k , qty_index) - qty(i, j, k-1, qty_index)); @@ -139,8 +136,7 @@ InterpolatePertFromCell (int i, int j, int k, amrex::Real scaled_upw = 0.; // The value that comes in has not been normalized so we do that here - if (upw != 0.) - scaled_upw = upw / std::abs(upw); + if (upw != 0.) { scaled_upw = (upw > 0) ? 1. : -1.; } if (coordDir == Coord::x) { avg1 = (qty(i , j, k, qty_index) + qty(i-1, j, k, qty_index)); diff --git a/Source/Utils/ERF_Utils.H b/Source/Utils/ERF_Utils.H index f713347f2..cfe2922d2 100644 --- a/Source/Utils/ERF_Utils.H +++ b/Source/Utils/ERF_Utils.H @@ -145,23 +145,23 @@ Time_Avg_Vel_atCC (const amrex::Real& dt, AMREX_GPU_HOST AMREX_FORCE_INLINE void -wrfbdy_set_rhs_in_spec_region (const amrex::Real& dt, - const int& icomp, - const int& num_var, - const int& width, - const int& set_width, - const amrex::Dim3& dom_lo, - const amrex::Dim3& dom_hi, - const amrex::Box& bx_xlo, - const amrex::Box& bx_xhi, - const amrex::Box& bx_ylo, - const amrex::Box& bx_yhi, - const amrex::Array4& arr_xlo, - const amrex::Array4& arr_xhi, - const amrex::Array4& arr_ylo, - const amrex::Array4& arr_yhi, - const amrex::Array4& data_arr, - const amrex::Array4& rhs_arr) +realbdy_set_rhs_in_spec_region (const amrex::Real& dt, + const int& icomp, + const int& num_var, + const int& width, + const int& set_width, + const amrex::Dim3& dom_lo, + const amrex::Dim3& dom_hi, + const amrex::Box& bx_xlo, + const amrex::Box& bx_xhi, + const amrex::Box& bx_ylo, + const amrex::Box& bx_yhi, + const amrex::Array4& arr_xlo, + const amrex::Array4& arr_xhi, + const amrex::Array4& arr_ylo, + const amrex::Array4& arr_yhi, + const amrex::Array4& data_arr, + const amrex::Array4& rhs_arr) { int Spec_z = set_width; amrex::ParallelFor(bx_xlo, num_var, [=] AMREX_GPU_DEVICE (int i, int j, int k, int n) noexcept @@ -235,24 +235,24 @@ wrfbdy_set_rhs_in_spec_region (const amrex::Real& dt, AMREX_GPU_HOST AMREX_FORCE_INLINE void -wrfbdy_compute_laplacian_relaxation (const int& icomp, - const int& num_var, - const int& width, - const int& set_width, - const amrex::Dim3& dom_lo, - const amrex::Dim3& dom_hi, - const amrex::Real& F1, - const amrex::Real& F2, - const amrex::Box& bx_xlo, - const amrex::Box& bx_xhi, - const amrex::Box& bx_ylo, - const amrex::Box& bx_yhi, - const amrex::Array4& arr_xlo, - const amrex::Array4& arr_xhi, - const amrex::Array4& arr_ylo, - const amrex::Array4& arr_yhi, - const amrex::Array4& data_arr, - const amrex::Array4& rhs_arr) +realbdy_compute_laplacian_relaxation (const int& icomp, + const int& num_var, + const int& width, + const int& set_width, + const amrex::Dim3& dom_lo, + const amrex::Dim3& dom_hi, + const amrex::Real& F1, + const amrex::Real& F2, + const amrex::Box& bx_xlo, + const amrex::Box& bx_xhi, + const amrex::Box& bx_ylo, + const amrex::Box& bx_yhi, + const amrex::Array4& arr_xlo, + const amrex::Array4& arr_xhi, + const amrex::Array4& arr_ylo, + const amrex::Array4& arr_yhi, + const amrex::Array4& data_arr, + const amrex::Array4& rhs_arr) { // RHS computation int Spec_z = set_width; diff --git a/Source/WindFarmParametrization/ERF_InitWindFarm.cpp b/Source/WindFarmParametrization/ERF_InitWindFarm.cpp index 6f48a711b..933e1ada8 100644 --- a/Source/WindFarmParametrization/ERF_InitWindFarm.cpp +++ b/Source/WindFarmParametrization/ERF_InitWindFarm.cpp @@ -31,10 +31,10 @@ WindFarm::read_tables (std::string windfarm_loc_table, } void -WindFarm::read_windfarm_locations_table(const std::string windfarm_loc_table, - bool x_y, bool lat_lon, - const Real windfarm_x_shift, - const Real windfarm_y_shift) +WindFarm::read_windfarm_locations_table (const std::string windfarm_loc_table, + bool x_y, bool lat_lon, + const Real windfarm_x_shift, + const Real windfarm_y_shift) { if(x_y) { init_windfarm_x_y(windfarm_loc_table); @@ -150,7 +150,7 @@ WindFarm::init_windfarm_x_y (const std::string windfarm_loc_table) void -WindFarm::read_windfarm_spec_table(const std::string windfarm_spec_table) +WindFarm::read_windfarm_spec_table (const std::string windfarm_spec_table) { //The first line is the number of pairs entries for the power curve and thrust coefficient. //The second line gives first the height in meters of the turbine hub, second, the diameter in @@ -198,7 +198,7 @@ WindFarm::read_windfarm_spec_table(const std::string windfarm_spec_table) } void -WindFarm::read_windfarm_blade_table(const std::string windfarm_blade_table) +WindFarm::read_windfarm_blade_table (const std::string windfarm_blade_table) { std::ifstream filename(windfarm_blade_table); std::string line; @@ -231,7 +231,7 @@ WindFarm::read_windfarm_blade_table(const std::string windfarm_blade_table) } void -WindFarm::read_windfarm_spec_table_extra(const std::string windfarm_spec_table_extra) +WindFarm::read_windfarm_spec_table_extra (const std::string windfarm_spec_table_extra) { // Open the file std::ifstream file(windfarm_spec_table_extra); @@ -270,8 +270,8 @@ WindFarm::read_windfarm_spec_table_extra(const std::string windfarm_spec_table_e void -WindFarm::read_windfarm_airfoil_tables(const std::string windfarm_airfoil_tables, - const std::string windfarm_blade_table) +WindFarm::read_windfarm_airfoil_tables (const std::string windfarm_airfoil_tables, + const std::string windfarm_blade_table) { DIR* dir; struct dirent* entry; @@ -350,8 +350,8 @@ WindFarm::read_windfarm_airfoil_tables(const std::string windfarm_airfoil_tables } void -WindFarm::fill_Nturb_multifab(const Geometry& geom, - MultiFab& mf_Nturb) +WindFarm::fill_Nturb_multifab (const Geometry& geom, + MultiFab& mf_Nturb) { amrex::Gpu::DeviceVector d_xloc(xloc.size()); @@ -398,10 +398,10 @@ WindFarm::fill_Nturb_multifab(const Geometry& geom, } void -WindFarm::fill_SMark_multifab(const Geometry& geom, - MultiFab& mf_SMark, - const Real& sampling_distance_by_D, - const Real& turb_disk_angle) +WindFarm::fill_SMark_multifab (const Geometry& geom, + MultiFab& mf_SMark, + const Real& sampling_distance_by_D, + const Real& turb_disk_angle) { amrex::Gpu::DeviceVector d_xloc(xloc.size()); amrex::Gpu::DeviceVector d_yloc(yloc.size()); @@ -482,7 +482,7 @@ WindFarm::fill_SMark_multifab(const Geometry& geom, } void -WindFarm::write_turbine_locations_vtk() +WindFarm::write_turbine_locations_vtk () { if (ParallelDescriptor::IOProcessor()){ FILE* file_turbloc_vtk; @@ -501,7 +501,7 @@ WindFarm::write_turbine_locations_vtk() void -WindFarm::write_actuator_disks_vtk(const Geometry& geom) +WindFarm::write_actuator_disks_vtk (const Geometry& geom) { if (ParallelDescriptor::IOProcessor()){ diff --git a/Source/WindFarmParametrization/ERF_WindFarm.H b/Source/WindFarmParametrization/ERF_WindFarm.H index 945483bbe..a94778fdf 100644 --- a/Source/WindFarmParametrization/ERF_WindFarm.H +++ b/Source/WindFarmParametrization/ERF_WindFarm.H @@ -15,9 +15,9 @@ class WindFarm : public NullWindFarm { public: - WindFarm(){} + WindFarm (){} - virtual ~WindFarm() = default; + virtual ~WindFarm () = default; WindFarm (int nlev, const WindFarmType& a_windfarm_type) @@ -50,37 +50,37 @@ public: const amrex::Real windfarm_x_shift = 0.0, const amrex::Real windfarm_y_shift = 0.0); - void init_windfarm_lat_lon(const std::string windfarm_loc_table, - const amrex::Real windfarm_x_shift, - const amrex::Real windfarm_y_shift); + void init_windfarm_lat_lon (const std::string windfarm_loc_table, + const amrex::Real windfarm_x_shift, + const amrex::Real windfarm_y_shift); - void init_windfarm_x_y(const std::string windfarm_loc_table); + void init_windfarm_x_y (const std::string windfarm_loc_table); - void read_windfarm_locations_table(const std::string windfarm_loc_table, - bool x_y, bool lat_lon, - const amrex::Real windfarm_x_shift = 0.0, - const amrex::Real windfarm_y_shift = 0.0); + void read_windfarm_locations_table (const std::string windfarm_loc_table, + bool x_y, bool lat_lon, + const amrex::Real windfarm_x_shift = 0.0, + const amrex::Real windfarm_y_shift = 0.0); - void read_windfarm_spec_table(const std::string windfarm_spec_table); + void read_windfarm_spec_table (const std::string windfarm_spec_table); - void read_windfarm_blade_table(const std::string windfarm_blade_table); + void read_windfarm_blade_table (const std::string windfarm_blade_table); - void read_windfarm_airfoil_tables(const std::string windfarm_airfoil_tables, - const std::string windfarm_blade_table); + void read_windfarm_airfoil_tables (const std::string windfarm_airfoil_tables, + const std::string windfarm_blade_table); - void read_windfarm_spec_table_extra(const std::string windfarm_spec_table_extra); + void read_windfarm_spec_table_extra (const std::string windfarm_spec_table_extra); - void fill_Nturb_multifab(const amrex::Geometry& geom, - amrex::MultiFab& mf_Nturb); + void fill_Nturb_multifab (const amrex::Geometry& geom, + amrex::MultiFab& mf_Nturb); - void fill_SMark_multifab(const amrex::Geometry& geom, - amrex::MultiFab& mf_SMark, - const amrex::Real& sampling_distance_by_D, - const amrex::Real& turb_disk_angle); + void fill_SMark_multifab (const amrex::Geometry& geom, + amrex::MultiFab& mf_SMark, + const amrex::Real& sampling_distance_by_D, + const amrex::Real& turb_disk_angle); - void write_turbine_locations_vtk(); + void write_turbine_locations_vtk (); - void write_actuator_disks_vtk(const amrex::Geometry& geom); + void write_actuator_disks_vtk (const amrex::Geometry& geom); void advance (const amrex::Geometry& a_geom, const amrex::Real& dt_advance, @@ -97,10 +97,10 @@ public: U_old, V_old, W_old, mf_Nturb, mf_SMark, time); } - void set_turb_spec(const amrex::Real& a_rotor_rad, const amrex::Real& a_hub_height, - const amrex::Real& a_thrust_coeff_standing, const amrex::Vector& a_wind_speed, - const amrex::Vector& a_thrust_coeff, - const amrex::Vector& a_power) override + void set_turb_spec (const amrex::Real& a_rotor_rad, const amrex::Real& a_hub_height, + const amrex::Real& a_thrust_coeff_standing, const amrex::Vector& a_wind_speed, + const amrex::Vector& a_thrust_coeff, + const amrex::Vector& a_power) override { m_windfarm_model[0]->set_turb_spec(a_rotor_rad, a_hub_height, a_thrust_coeff_standing, a_wind_speed, a_thrust_coeff, a_power); diff --git a/Source/WindFarmParametrization/EWP/ERF_EWP.H b/Source/WindFarmParametrization/EWP/ERF_EWP.H index fbf10efca..119590a27 100644 --- a/Source/WindFarmParametrization/EWP/ERF_EWP.H +++ b/Source/WindFarmParametrization/EWP/ERF_EWP.H @@ -10,9 +10,9 @@ class EWP : public NullWindFarm { public: - EWP(){} + EWP (){} - virtual ~EWP() = default; + virtual ~EWP () = default; void advance (const amrex::Geometry& geom, const amrex::Real& dt_advance, diff --git a/Source/WindFarmParametrization/Fitch/ERF_AdvanceFitch.cpp b/Source/WindFarmParametrization/Fitch/ERF_AdvanceFitch.cpp index 68cce5558..6f1036339 100644 --- a/Source/WindFarmParametrization/Fitch/ERF_AdvanceFitch.cpp +++ b/Source/WindFarmParametrization/Fitch/ERF_AdvanceFitch.cpp @@ -7,9 +7,9 @@ using namespace amrex; AMREX_FORCE_INLINE AMREX_GPU_DEVICE -Real compute_A(const Real z, - const Real hub_height, - const Real rotor_rad) +Real compute_A (const Real z, + const Real hub_height, + const Real rotor_rad) { Real d = std::min(std::fabs(z - hub_height), rotor_rad); @@ -22,10 +22,10 @@ Real compute_A(const Real z, AMREX_FORCE_INLINE AMREX_GPU_DEVICE -Real compute_Aijk(const Real z_k, - const Real z_kp1, - const Real hub_height, - const Real rotor_rad) +Real compute_Aijk (const Real z_k, + const Real z_kp1, + const Real hub_height, + const Real rotor_rad) { Real A_k = compute_A(z_k, hub_height, rotor_rad); diff --git a/Source/WindFarmParametrization/Fitch/ERF_Fitch.H b/Source/WindFarmParametrization/Fitch/ERF_Fitch.H index 906a55835..baa557e22 100644 --- a/Source/WindFarmParametrization/Fitch/ERF_Fitch.H +++ b/Source/WindFarmParametrization/Fitch/ERF_Fitch.H @@ -10,9 +10,9 @@ class Fitch : public NullWindFarm { public: - Fitch() {} + Fitch () {} - virtual ~Fitch() = default; + virtual ~Fitch () = default; void advance (const amrex::Geometry& geom, const amrex::Real& dt_advance, diff --git a/Source/WindFarmParametrization/GeneralActuatorDisk/ERF_AdvanceGeneralAD.cpp b/Source/WindFarmParametrization/GeneralActuatorDisk/ERF_AdvanceGeneralAD.cpp index 3c4da9eb1..2f5873f63 100644 --- a/Source/WindFarmParametrization/GeneralActuatorDisk/ERF_AdvanceGeneralAD.cpp +++ b/Source/WindFarmParametrization/GeneralActuatorDisk/ERF_AdvanceGeneralAD.cpp @@ -7,15 +7,15 @@ using namespace amrex; void GeneralAD::advance (const Geometry& geom, - const Real& dt_advance, - MultiFab& cons_in, - MultiFab& mf_vars_generalAD, - MultiFab& U_old, - MultiFab& V_old, - MultiFab& W_old, - const MultiFab& mf_Nturb, - const MultiFab& mf_SMark, - const Real& time) + const Real& dt_advance, + MultiFab& cons_in, + MultiFab& mf_vars_generalAD, + MultiFab& U_old, + MultiFab& V_old, + MultiFab& W_old, + const MultiFab& mf_Nturb, + const MultiFab& mf_SMark, + const Real& time) { AMREX_ALWAYS_ASSERT(W_old.nComp() > 0); AMREX_ALWAYS_ASSERT(mf_Nturb.nComp() > 0); @@ -28,11 +28,11 @@ GeneralAD::advance (const Geometry& geom, void GeneralAD::update (const Real& dt_advance, - MultiFab& cons_in, - MultiFab& U_old, - MultiFab& V_old, - MultiFab& W_old, - const MultiFab& mf_vars_generalAD) + MultiFab& cons_in, + MultiFab& U_old, + MultiFab& V_old, + MultiFab& W_old, + const MultiFab& mf_vars_generalAD) { for ( MFIter mfi(cons_in,TilingIfNotGPU()); mfi.isValid(); ++mfi) { @@ -63,10 +63,10 @@ GeneralAD::update (const Real& dt_advance, } } -void GeneralAD::compute_freestream_velocity(const MultiFab& cons_in, - const MultiFab& U_old, - const MultiFab& V_old, - const MultiFab& mf_SMark) +void GeneralAD::compute_freestream_velocity (const MultiFab& cons_in, + const MultiFab& U_old, + const MultiFab& V_old, + const MultiFab& mf_SMark) { get_turb_loc(xloc, yloc); freestream_velocity.clear(); @@ -141,9 +141,9 @@ void GeneralAD::compute_freestream_velocity(const MultiFab& cons_in, AMREX_FORCE_INLINE AMREX_GPU_DEVICE -int find_rad_loc_index(const Real rad, - const Real* bld_rad_loc, - const int n_bld_sections) +int find_rad_loc_index (const Real rad, + const Real* bld_rad_loc, + const int n_bld_sections) { // Find the index of the radial location int index=-1; @@ -285,9 +285,9 @@ compute_source_terms_Fn_Ft (const Real rad, void GeneralAD::source_terms_cellcentered (const Geometry& geom, - const MultiFab& cons_in, - const MultiFab& mf_SMark, - MultiFab& mf_vars_generalAD) + const MultiFab& cons_in, + const MultiFab& mf_SMark, + MultiFab& mf_vars_generalAD) { get_turb_loc(xloc, yloc); diff --git a/Source/WindFarmParametrization/GeneralActuatorDisk/ERF_GeneralAD.H b/Source/WindFarmParametrization/GeneralActuatorDisk/ERF_GeneralAD.H index 9092ea312..e4f8d75ed 100644 --- a/Source/WindFarmParametrization/GeneralActuatorDisk/ERF_GeneralAD.H +++ b/Source/WindFarmParametrization/GeneralActuatorDisk/ERF_GeneralAD.H @@ -9,9 +9,9 @@ class GeneralAD : public NullWindFarm { public: - GeneralAD() {} + GeneralAD () {} - virtual ~GeneralAD() = default; + virtual ~GeneralAD () = default; void advance (const amrex::Geometry& geom, const amrex::Real& dt_advance, diff --git a/Source/WindFarmParametrization/Null/ERF_NullWindFarm.H b/Source/WindFarmParametrization/Null/ERF_NullWindFarm.H index f0714eef3..6134e976c 100644 --- a/Source/WindFarmParametrization/Null/ERF_NullWindFarm.H +++ b/Source/WindFarmParametrization/Null/ERF_NullWindFarm.H @@ -10,25 +10,25 @@ class NullWindFarm { public: - NullWindFarm() {} + NullWindFarm () {} - virtual ~NullWindFarm() = default; + virtual ~NullWindFarm () = default; virtual void advance (const amrex::Geometry& a_geom, - const amrex::Real& dt_advance, - amrex::MultiFab& cons_in, - amrex::MultiFab& mf_vars_windfarm, - amrex::MultiFab& U_old, - amrex::MultiFab& V_old, - amrex::MultiFab& W_old, - const amrex::MultiFab& mf_Nturb, - const amrex::MultiFab& mf_SMark, - const amrex::Real& time) = 0; - - virtual void set_turb_spec(const amrex::Real& rotor_rad, const amrex::Real& hub_height, - const amrex::Real& thrust_coeff_standing, const amrex::Vector& wind_speed, - const amrex::Vector& thrust_coeff, - const amrex::Vector& power) + const amrex::Real& dt_advance, + amrex::MultiFab& cons_in, + amrex::MultiFab& mf_vars_windfarm, + amrex::MultiFab& U_old, + amrex::MultiFab& V_old, + amrex::MultiFab& W_old, + const amrex::MultiFab& mf_Nturb, + const amrex::MultiFab& mf_SMark, + const amrex::Real& time) = 0; + + virtual void set_turb_spec (const amrex::Real& rotor_rad, const amrex::Real& hub_height, + const amrex::Real& thrust_coeff_standing, const amrex::Vector& wind_speed, + const amrex::Vector& thrust_coeff, + const amrex::Vector& power) { m_rotor_rad = rotor_rad; m_hub_height = hub_height; @@ -50,29 +50,29 @@ public: m_turb_disk_angle = turb_disk_angle; } - virtual void set_blade_spec(const amrex::Vector& bld_rad_loc, - const amrex::Vector& bld_twist, - const amrex::Vector& bld_chord) + virtual void set_blade_spec (const amrex::Vector& bld_rad_loc, + const amrex::Vector& bld_twist, + const amrex::Vector& bld_chord) { m_bld_rad_loc = bld_rad_loc; m_bld_twist = bld_twist; m_bld_chord = bld_chord; } - virtual void set_blade_airfoil_spec(const amrex::Vector>& bld_airfoil_aoa, - const amrex::Vector>& bld_airfoil_Cl, - const amrex::Vector>& bld_airfoil_Cd) + virtual void set_blade_airfoil_spec (const amrex::Vector>& bld_airfoil_aoa, + const amrex::Vector>& bld_airfoil_Cl, + const amrex::Vector>& bld_airfoil_Cd) { m_bld_airfoil_aoa = bld_airfoil_aoa; m_bld_airfoil_Cl = bld_airfoil_Cl; m_bld_airfoil_Cd = bld_airfoil_Cd; } - virtual void set_turb_spec_extra(const amrex::Vector& velocity, - const amrex::Vector& C_P, - const amrex::Vector& C_T, - const amrex::Vector& rotor_RPM, - const amrex::Vector& blade_pitch) + virtual void set_turb_spec_extra (const amrex::Vector& velocity, + const amrex::Vector& C_P, + const amrex::Vector& C_T, + const amrex::Vector& rotor_RPM, + const amrex::Vector& blade_pitch) { m_velocity = velocity; m_C_P = C_P; @@ -105,29 +105,29 @@ public: turb_disk_angle = m_turb_disk_angle; } - void get_blade_spec(amrex::Vector& bld_rad_loc, - amrex::Vector& bld_twist, - amrex::Vector& bld_chord) + void get_blade_spec (amrex::Vector& bld_rad_loc, + amrex::Vector& bld_twist, + amrex::Vector& bld_chord) { bld_rad_loc = m_bld_rad_loc; bld_twist = m_bld_twist; bld_chord = m_bld_chord; } - void get_blade_airfoil_spec(amrex::Vector>& bld_airfoil_aoa, - amrex::Vector>& bld_airfoil_Cl, - amrex::Vector>& bld_airfoil_Cd) + void get_blade_airfoil_spec (amrex::Vector>& bld_airfoil_aoa, + amrex::Vector>& bld_airfoil_Cl, + amrex::Vector>& bld_airfoil_Cd) { bld_airfoil_aoa = m_bld_airfoil_aoa; bld_airfoil_Cl = m_bld_airfoil_Cl; bld_airfoil_Cd = m_bld_airfoil_Cd; } - void get_turb_spec_extra(amrex::Vector& velocity, - amrex::Vector& C_P, - amrex::Vector& C_T, - amrex::Vector& rotor_RPM, - amrex::Vector& blade_pitch) + void get_turb_spec_extra (amrex::Vector& velocity, + amrex::Vector& C_P, + amrex::Vector& C_T, + amrex::Vector& rotor_RPM, + amrex::Vector& blade_pitch) { velocity = m_velocity; C_P = m_C_P; @@ -137,10 +137,10 @@ public: } static AMREX_GPU_DEVICE -bool find_if_marked(amrex::Real x1, amrex::Real x2, amrex::Real y1, amrex::Real y2, - amrex::Real x0, amrex::Real y0, amrex::Real nx, amrex::Real ny, - amrex::Real d_hub_height, amrex::Real d_rotor_rad, - amrex::Real z) +bool find_if_marked (amrex::Real x1, amrex::Real x2, amrex::Real y1, amrex::Real y2, + amrex::Real x0, amrex::Real y0, amrex::Real nx, amrex::Real ny, + amrex::Real d_hub_height, amrex::Real d_rotor_rad, + amrex::Real z) { // Plane is (x-x0)*nx + (y-y0)*ny = 0. And the planes to intersect are diff --git a/Source/WindFarmParametrization/SimpleActuatorDisk/ERF_AdvanceSimpleAD.cpp b/Source/WindFarmParametrization/SimpleActuatorDisk/ERF_AdvanceSimpleAD.cpp index 038022c7b..116de0b48 100644 --- a/Source/WindFarmParametrization/SimpleActuatorDisk/ERF_AdvanceSimpleAD.cpp +++ b/Source/WindFarmParametrization/SimpleActuatorDisk/ERF_AdvanceSimpleAD.cpp @@ -6,15 +6,15 @@ using namespace amrex; void SimpleAD::advance (const Geometry& geom, - const Real& dt_advance, - MultiFab& cons_in, - MultiFab& mf_vars_simpleAD, - MultiFab& U_old, - MultiFab& V_old, - MultiFab& W_old, - const MultiFab& mf_Nturb, - const MultiFab& mf_SMark, - const Real& time) + const Real& dt_advance, + MultiFab& cons_in, + MultiFab& mf_vars_simpleAD, + MultiFab& U_old, + MultiFab& V_old, + MultiFab& W_old, + const MultiFab& mf_Nturb, + const MultiFab& mf_SMark, + const Real& time) { AMREX_ALWAYS_ASSERT(W_old.nComp() > 0); AMREX_ALWAYS_ASSERT(mf_Nturb.nComp() > 0); @@ -25,7 +25,7 @@ SimpleAD::advance (const Geometry& geom, } void -SimpleAD::compute_power_output(const Real& time) +SimpleAD::compute_power_output (const Real& time) { get_turb_loc(xloc, yloc); get_turb_spec(rotor_rad, hub_height, thrust_coeff_standing, @@ -81,10 +81,10 @@ SimpleAD::update (const Real& dt_advance, } } -void SimpleAD::compute_freestream_velocity(const MultiFab& cons_in, - const MultiFab& U_old, - const MultiFab& V_old, - const MultiFab& mf_SMark) +void SimpleAD::compute_freestream_velocity (const MultiFab& cons_in, + const MultiFab& U_old, + const MultiFab& V_old, + const MultiFab& mf_SMark) { get_turb_loc(xloc, yloc); freestream_velocity.clear(); diff --git a/Source/WindFarmParametrization/SimpleActuatorDisk/ERF_SimpleAD.H b/Source/WindFarmParametrization/SimpleActuatorDisk/ERF_SimpleAD.H index 855f4a99e..2889e8ecb 100644 --- a/Source/WindFarmParametrization/SimpleActuatorDisk/ERF_SimpleAD.H +++ b/Source/WindFarmParametrization/SimpleActuatorDisk/ERF_SimpleAD.H @@ -9,9 +9,9 @@ class SimpleAD : public NullWindFarm { public: - SimpleAD() {} + SimpleAD () {} - virtual ~SimpleAD() = default; + virtual ~SimpleAD () = default; void advance (const amrex::Geometry& geom, const amrex::Real& dt_advance, @@ -24,10 +24,10 @@ public: const amrex::MultiFab& mf_SMark, const amrex::Real& time) override; - void compute_freestream_velocity(const amrex::MultiFab& cons_in, - const amrex::MultiFab& U_old, - const amrex::MultiFab& V_old, - const amrex::MultiFab& mf_SMark); + void compute_freestream_velocity (const amrex::MultiFab& cons_in, + const amrex::MultiFab& U_old, + const amrex::MultiFab& V_old, + const amrex::MultiFab& mf_SMark); void source_terms_cellcentered (const amrex::Geometry& geom, const amrex::MultiFab& cons_in, @@ -40,7 +40,7 @@ public: amrex::MultiFab& V_old, const amrex::MultiFab& mf_vars); - void compute_power_output(const amrex::Real& time); + void compute_power_output (const amrex::Real& time); protected: amrex::Vector xloc, yloc; diff --git a/Submodules/AMReX b/Submodules/AMReX index b9d549bcf..4a6e7c87e 160000 --- a/Submodules/AMReX +++ b/Submodules/AMReX @@ -1 +1 @@ -Subproject commit b9d549bcf4a6e035e6050c92083d42a30a4078b1 +Subproject commit 4a6e7c87e1494d10893b36f0d7ce6bf9df19fe0d