diff --git a/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneFunctor.cpp index 505e94149b5..f98ca7dca5d 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneFunctor.cpp @@ -82,7 +82,7 @@ RecordingPlaneFunctor::operator() (amrex::MultiFab& mf_dst, int dcomp, int /*i_b // slice is cell-centered in z-direction and nodal in others. There is // only one cell in the z-direction. - for (auto& smf : m_arr_mf_src) { + for (auto const& smf : m_arr_mf_src) { AMREX_ALWAYS_ASSERT(smf->nGrowVect().allGE(amrex::IntVect(1))); const_cast(smf)->FillBoundary (0,1,amrex::IntVect(1),geom.periodicity()); diff --git a/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneParticleFunctor.H b/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneParticleFunctor.H index 36042f40bf6..057b20945f9 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneParticleFunctor.H +++ b/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneParticleFunctor.H @@ -120,7 +120,7 @@ struct PlaneCrossingTime dst.m_aos[i_dst].pos(0) = xp; dst.m_aos[i_dst].pos(1) = zp; amrex::ignore_unused(yp); -#elif defined (WARPX_DIM_1D) +#elif defined (WARPX_DIM_1D_Z) dst.m_aos[i_dst].pos(0) = zp; amrex::ignore_unused(xp, yp); #else @@ -149,7 +149,6 @@ struct PlaneCrossingTime amrex::Real m_z_station; amrex::Real m_current_time; int m_index; - amrex::Real m_Phys_c; amrex::Real m_inv_c2; }; diff --git a/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneParticleFunctor.cpp b/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneParticleFunctor.cpp index d000cf9ecf7..aae8706325b 100644 --- a/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneParticleFunctor.cpp +++ b/Source/Diagnostics/ComputeDiagFunctors/RecordingPlaneParticleFunctor.cpp @@ -37,12 +37,15 @@ RecordParticles::RecordParticles (const WarpXParIter &a_pti, TmpParticles& tmp_p PlaneCrossingTime::PlaneCrossingTime (const WarpXParIter& a_pti, TmpParticles& tmp_particle_data, amrex::Real current_time, amrex::Real z_station_location, int a_index, int a_offset) - : m_z_station(z_station_location), m_current_time(current_time), m_index(a_index) + : m_z_station(z_station_location), + m_current_time(current_time), + m_index(a_index), + m_inv_c2(amrex::Real(1.0)/(PhysConst::c * PhysConst::c)) { using namespace amrex::literals; m_get_position = GetParticlePosition(a_pti, a_offset); - auto& attribs = a_pti.GetAttribs(); + auto const& attribs = a_pti.GetAttribs(); m_wpnew = attribs[PIdx::w].dataPtr(); m_uxnew = attribs[PIdx::ux].dataPtr(); m_uynew = attribs[PIdx::uy].dataPtr(); @@ -57,14 +60,11 @@ PlaneCrossingTime::PlaneCrossingTime (const WarpXParIter& a_pti, TmpParticles& t m_uxpold = tmp_particle_data[lev][index][TmpIdx::uxold].dataPtr(); m_uypold = tmp_particle_data[lev][index][TmpIdx::uyold].dataPtr(); m_uzpold = tmp_particle_data[lev][index][TmpIdx::uzold].dataPtr(); - - m_Phys_c = PhysConst::c; - m_inv_c2 = 1._rt/(m_Phys_c * m_Phys_c); } RecordingPlaneParticleFunctor::RecordingPlaneParticleFunctor ( WarpXParticleContainer *pc_src, std::string species_name, int num_station_buffers) - : m_pc_src(pc_src), m_species_name(species_name), m_num_station_buffers(num_station_buffers) + : m_pc_src(pc_src), m_species_name(std::move(species_name)), m_num_station_buffers(num_station_buffers) { WARPX_ALWAYS_ASSERT_WITH_MESSAGE(m_num_station_buffers == 1, "RecordingPlaneParticleFunctor: num of station buffers must be 1"); @@ -74,7 +74,7 @@ void RecordingPlaneParticleFunctor::operator () (PinnedMemoryParticleContainer& pc_dst, int &TotalParticleCounter, int /*i_buffer*/) const { amrex::Print() << " in station particle operator " << m_record_particles << "\n"; - if (!m_record_particles) return; + if (!m_record_particles) { return; } auto & warpx = WarpX::GetInstance(); auto tmp_particle_data = m_pc_src->getTmpParticleData(); amrex::Print() << " got tmp particle ddata in operator \n"; @@ -132,7 +132,7 @@ RecordingPlaneParticleFunctor::operator () (PinnedMemoryParticleContainer& pc_ds } } } - TotalParticleCounter = pc_dst.TotalNumberOfParticles(); + TotalParticleCounter = int(pc_dst.TotalNumberOfParticles()); amrex::Print() << " end of operator : " << TotalParticleCounter << "\n"; } diff --git a/Source/Diagnostics/RecordingPlaneDiagnostics.H b/Source/Diagnostics/RecordingPlaneDiagnostics.H index 7f65598b18b..30600f647f9 100644 --- a/Source/Diagnostics/RecordingPlaneDiagnostics.H +++ b/Source/Diagnostics/RecordingPlaneDiagnostics.H @@ -76,7 +76,7 @@ private: amrex::Box m_buffer_box; int m_flush_counter = 0; - bool GetZSliceInDomain (const int lev); + bool GetZSliceInDomain (int lev); bool m_last_timeslice_filled = false; }; diff --git a/Source/Diagnostics/RecordingPlaneDiagnostics.cpp b/Source/Diagnostics/RecordingPlaneDiagnostics.cpp index 15cf0b59d68..ecf27baf61e 100644 --- a/Source/Diagnostics/RecordingPlaneDiagnostics.cpp +++ b/Source/Diagnostics/RecordingPlaneDiagnostics.cpp @@ -113,11 +113,12 @@ RecordingPlaneDiagnostics::ReadParameters () MultiParticleContainer& mpc = warpx.GetPartContainer(); int write_species = 1; pp_diag_name.query("write_species", write_species); - if (m_output_species_names.size() == 0 and write_species == 1) + if (m_output_species_names.empty() && write_species == 1) { m_output_species_names = mpc.GetSpeciesNames(); + } bool m_record_particles = false; - if (m_output_species_names.size() > 0 and write_species == 1) { + if (! m_output_species_names.empty() && write_species == 1) { m_record_particles = true; } if (m_record_particles) { @@ -207,16 +208,12 @@ RecordingPlaneDiagnostics::PrepareFieldDataForOutput () } bool -RecordingPlaneDiagnostics::GetZSliceInDomain (const int lev) +RecordingPlaneDiagnostics::GetZSliceInDomain (int lev) { auto & warpx = WarpX::GetInstance(); const amrex::RealBox& prob_domain = warpx.Geom(lev).ProbDomain(); - if ( ( m_station_loc <= prob_domain.lo(WARPX_ZINDEX) ) || - ( m_station_loc >= prob_domain.hi(WARPX_ZINDEX) ) ) - { - return false; - } - return true; + return m_station_loc > prob_domain.lo(WARPX_ZINDEX) + && m_station_loc < prob_domain.hi(WARPX_ZINDEX); } void @@ -302,7 +299,7 @@ RecordingPlaneDiagnostics::PrepareParticleDataForOutput () void RecordingPlaneDiagnostics::Flush (int i_buffer, bool /* force_flush */) { - if (m_slice_counter == 0) return; + if (m_slice_counter == 0) { return; } const std::string filename = m_file_prefix; constexpr int permission_flag_rwxrxrx = 0755; @@ -392,11 +389,11 @@ RecordingPlaneDiagnostics::Flush (int i_buffer, bool /* force_flush */) } for (int isp = 0; isp < m_particles_buffer[0].size(); ++isp) { - m_totalParticles_flushed_already[i_buffer][isp] += m_particles_buffer[i_buffer][isp]->TotalNumberOfParticles(); + m_totalParticles_flushed_already[i_buffer][isp] += int(m_particles_buffer[i_buffer][isp]->TotalNumberOfParticles()); m_totalParticles_in_buffer[i_buffer][isp] = 0; } - if (m_output_species_names.size() > 0) + if (! m_output_species_names.empty()) { ClearParticlesBuffer(i_buffer); } diff --git a/Source/Diagnostics/WarpXOpenPMD.cpp b/Source/Diagnostics/WarpXOpenPMD.cpp index 5100291a94a..aebfd42afac 100644 --- a/Source/Diagnostics/WarpXOpenPMD.cpp +++ b/Source/Diagnostics/WarpXOpenPMD.cpp @@ -403,9 +403,9 @@ WarpXOpenPMDPlot::GetFileName (std::string& filepath) { filepath.append("/"); // transform paths for Windows - #ifdef _WIN32 +#ifdef _WIN32 filepath = openPMD::auxiliary::replace_all(filepath, "/", "\\"); - #endif +#endif std::string filename = "openpmd"; // diff --git a/Source/Initialization/WarpXInitData.cpp b/Source/Initialization/WarpXInitData.cpp index 3b36a6336bf..dfefec50bbb 100644 --- a/Source/Initialization/WarpXInitData.cpp +++ b/Source/Initialization/WarpXInitData.cpp @@ -184,10 +184,10 @@ WarpX::PrintMainPICparameters () amrex::Print() << "Geometry: | 2D (RZ)" << "\n"; } - #ifdef WARPX_DIM_RZ +#ifdef WARPX_DIM_RZ amrex::Print() << " | - n_rz_azimuthal_modes = " << WarpX::n_rz_azimuthal_modes << "\n"; - #endif // WARPX_USE_RZ +#endif // WARPX_USE_RZ //Print solver's operation mode (e.g., EM or electrostatic) if (electrostatic_solver_id == ElectrostaticSolverAlgo::LabFrame) { amrex::Print() << "Operation mode: | Electrostatic" << "\n"; @@ -266,7 +266,7 @@ WarpX::PrintMainPICparameters () else if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::HybridPIC){ amrex::Print() << "Maxwell Solver: | Hybrid-PIC (Ohm's law) \n"; } - #ifdef WARPX_USE_PSATD +#ifdef WARPX_USE_PSATD // Print PSATD solver's configuration if (WarpX::electromagnetic_solver_id == ElectromagneticSolverAlgo::PSATD){ amrex::Print() << "Maxwell Solver: | PSATD \n"; @@ -301,12 +301,12 @@ WarpX::PrintMainPICparameters () if (fft_do_time_averaging == 1){ amrex::Print()<<" | - time-averaged is ON \n"; } - #endif // WARPX_USE_PSATD +#endif // WARPX_USE_PSATD if (grid_type == GridType::Collocated){ amrex::Print() << " | - collocated grid \n"; } - #ifdef WARPX_USE_PSATD +#ifdef WARPX_USE_PSATD if ( (grid_type == GridType::Staggered) && (field_gathering_algo == GatheringAlgo::EnergyConserving) ){ amrex::Print()<<" | - staggered grid " << "\n"; } @@ -359,7 +359,7 @@ WarpX::PrintMainPICparameters () amrex::Print() << "Guard cells | - ng_alloc_EB = " << guard_cells.ng_alloc_EB << "\n"; amrex::Print() << " (allocated for E/B) | \n"; - #endif // WARPX_USE_PSATD +#endif // WARPX_USE_PSATD amrex::Print() << "-------------------------------------------------------------------------------" << "\n"; //Print main boosted frame algorithm's parameters if (WarpX::gamma_boost!=1){ @@ -375,11 +375,11 @@ WarpX::PrintMainPICparameters () if (WarpX::moving_window_dir == 0){ amrex::Print() << " | - moving_window_dir = x \n"; } - #if defined(WARPX_DIM_3D) +#if defined(WARPX_DIM_3D) else if (WarpX::moving_window_dir == 1){ amrex::Print() << " | - moving_window_dir = y \n"; } - #endif +#endif else if (WarpX::moving_window_dir == WARPX_ZINDEX) { amrex::Print() << " | - moving_window_dir = z \n"; } diff --git a/Source/Laser/LaserProfiles.H b/Source/Laser/LaserProfiles.H index c19a47fc68a..e5566482d02 100644 --- a/Source/Laser/LaserProfiles.H +++ b/Source/Laser/LaserProfiles.H @@ -389,11 +389,11 @@ public: void update (amrex::Real t) override; - void fill_amplitude (const int np, - amrex::Real const * AMREX_RESTRICT const Xp, - amrex::Real const * AMREX_RESTRICT const Yp, + void fill_amplitude (int np, + amrex::Real const * AMREX_RESTRICT Xp, + amrex::Real const * AMREX_RESTRICT Yp, amrex::Real t, - amrex::Real * AMREX_RESTRICT const amplitude) const override; + amrex::Real * AMREX_RESTRICT amplitude) const override; private: CommonLaserParameters m_common_params; diff --git a/Source/Laser/LaserProfilesImpl/LaserProfileStationField.cpp b/Source/Laser/LaserProfilesImpl/LaserProfileStationField.cpp index d582319c5e1..0e6be3168c9 100644 --- a/Source/Laser/LaserProfilesImpl/LaserProfileStationField.cpp +++ b/Source/Laser/LaserProfilesImpl/LaserProfileStationField.cpp @@ -135,7 +135,9 @@ void StationFieldLaserProfile::update (amrex::Real t) auto const& a = m_slice_fab->array(); amrex::ParallelFor(b, [=] AMREX_GPU_DEVICE (int i, int j, int) { -#if (AMREX_SPACEDIM == 2) +#if (AMREX_SPACEDIM == 1) + amrex::ignore_unused(i,j,w,a); +#elif (AMREX_SPACEDIM == 2) a(i,j,0) = (a(i,0,0)*(amrex::Real(1.0)-w) + a(i,1,0)*w); #elif (AMREX_SPACEDIM == 3) a(i,j,0) = (a(i,j,0)*(amrex::Real(1.0)-w) + a(i,j,1)*w); @@ -149,11 +151,11 @@ void StationFieldLaserProfile::update (amrex::Real t) } void StationFieldLaserProfile::fill_amplitude ( - const int np, - amrex::Real const * AMREX_RESTRICT const Xp, - amrex::Real const * AMREX_RESTRICT const Yp, + int np, + amrex::Real const * AMREX_RESTRICT Xp, + amrex::Real const * AMREX_RESTRICT Yp, amrex::Real /*t*/, - amrex::Real * AMREX_RESTRICT const amplitude) const + amrex::Real * AMREX_RESTRICT amplitude) const { amrex::ignore_unused(Yp); using namespace amrex::literals; @@ -171,7 +173,9 @@ void StationFieldLaserProfile::fill_amplitude ( auto const xi = (Xp[ip]-plo[0])*dxi; auto const i = static_cast(std::floor(xi)); amrex::Real const wx = xi - amrex::Real(i); -#if (AMREX_SPACEDIM == 2) +#if (AMREX_SPACEDIM == 1) + amrex::ignore_unused(wx,a); +#elif (AMREX_SPACEDIM == 2) amplitude[ip] = (1._rt-wx)*a(i ,0,0) + wx *a(i+1,0,0); #elif (AMREX_SPACEDIM == 3) diff --git a/Source/WarpX.H b/Source/WarpX.H index 31c15418935..c995974527c 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -480,7 +480,7 @@ public: Efield_aux[lev][2].get() }; } - std::array + [[nodiscard]] std::array get_array_EBfield_fp (const int lev) const{ return { Efield_fp[lev][0].get(),