Skip to content

Commit

Permalink
fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
WeiqunZhang committed Dec 31, 2023
1 parent 3e5d6a1 commit c712173
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<amrex::MultiFab*>(smf)->FillBoundary
(0,1,amrex::IntVect(1),geom.periodicity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PIdx>(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();
Expand All @@ -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");
Expand All @@ -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";
Expand Down Expand Up @@ -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";
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Diagnostics/RecordingPlaneDiagnostics.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
21 changes: 9 additions & 12 deletions Source/Diagnostics/RecordingPlaneDiagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Diagnostics/WarpXOpenPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
//
Expand Down
16 changes: 8 additions & 8 deletions Source/Initialization/WarpXInitData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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){
Expand All @@ -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";
}
Expand Down
8 changes: 4 additions & 4 deletions Source/Laser/LaserProfiles.H
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 10 additions & 6 deletions Source/Laser/LaserProfilesImpl/LaserProfileStationField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -171,7 +173,9 @@ void StationFieldLaserProfile::fill_amplitude (
auto const xi = (Xp[ip]-plo[0])*dxi;
auto const i = static_cast<int>(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)
Expand Down
2 changes: 1 addition & 1 deletion Source/WarpX.H
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public:
Efield_aux[lev][2].get()
};
}
std::array<const amrex::MultiFab* const, 6>
[[nodiscard]] std::array<const amrex::MultiFab* const, 6>
get_array_EBfield_fp (const int lev) const{
return {
Efield_fp[lev][0].get(),
Expand Down

0 comments on commit c712173

Please sign in to comment.