Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ff55be0
test with clang-tidy settings from AMReX
AlexanderSinn Dec 9, 2025
225ff36
cat log file
AlexanderSinn Dec 9, 2025
102406f
fix
AlexanderSinn Dec 9, 2025
678aed3
diable readability checks
AlexanderSinn Dec 9, 2025
4d44016
fix issues in headers
AlexanderSinn Dec 9, 2025
0157a1b
fix
AlexanderSinn Dec 9, 2025
4cd27e4
remove using namespace amrex
AlexanderSinn Dec 9, 2025
ad76be0
use std move
AlexanderSinn Dec 9, 2025
da2f9da
fix Gpu::gpuStream()
AlexanderSinn Dec 9, 2025
18dec00
remove std::endl
AlexanderSinn Dec 9, 2025
8e7c1c0
more fixes
AlexanderSinn Dec 9, 2025
2fae2fa
fix poisson solvers
AlexanderSinn Dec 10, 2025
cbb32a5
more fixes
AlexanderSinn Dec 10, 2025
a170e75
try fix clang-tidy crash
AlexanderSinn Dec 10, 2025
45b784d
more float conversion fixes
AlexanderSinn Dec 10, 2025
dbcd3fa
fix more implicit conversions
AlexanderSinn Dec 10, 2025
36d42b0
more implicit conversions fixes
AlexanderSinn Dec 10, 2025
e21b681
more implicit conversion fixes
AlexanderSinn Dec 10, 2025
e04277b
replace long with int for pidx
AlexanderSinn Dec 10, 2025
a6ce946
remove performance-inefficient-string-concatenation check
AlexanderSinn Dec 10, 2025
3c963d9
fix int conversion
AlexanderSinn Dec 10, 2025
e30213f
Merge branch 'development' into test_with_clang_tidy_settings_from_AMReX
AlexanderSinn Dec 18, 2025
48bdfdf
fix merge
AlexanderSinn Dec 18, 2025
9b6d065
fix clang tidy issues
AlexanderSinn Dec 18, 2025
3546f96
fix clang tidy issues 2
AlexanderSinn Dec 18, 2025
6b93b26
Merge branch 'development' into test_with_clang_tidy_settings_from_AMReX
AlexanderSinn Jan 5, 2026
c5e2768
Merge branch 'development' into test_with_clang_tidy_settings_from_AMReX
AlexanderSinn Feb 22, 2026
c13874d
add move and fix Real conversion
AlexanderSinn Feb 23, 2026
2a3f7c7
fix more Real conversion
AlexanderSinn Feb 23, 2026
14f7afb
fix cast
AlexanderSinn Feb 23, 2026
3b69e1f
Merge branch 'Hi-PACE:development' into test_with_clang_tidy_settings…
AlexanderSinn Feb 23, 2026
367bbb4
add nodiscard
AlexanderSinn Feb 23, 2026
56f3ffa
Merge branch 'development' into test_with_clang_tidy_settings_from_AMReX
AlexanderSinn Mar 25, 2026
e018dbe
Merge branch 'development' into test_with_clang_tidy_settings_from_AMReX
AlexanderSinn Mar 27, 2026
56ce2bd
fix merge
AlexanderSinn Mar 27, 2026
d342767
Merge branch 'development' into test_with_clang_tidy_settings_from_AMReX
AlexanderSinn Apr 14, 2026
c058157
Merge branch 'Hi-PACE:development' into test_with_clang_tidy_settings…
AlexanderSinn Apr 22, 2026
68ecf31
Fix new issues
AlexanderSinn Apr 22, 2026
d9bfc99
update to C++20
AlexanderSinn Apr 22, 2026
48046bb
Merge branch 'development' into test_with_clang_tidy_settings_from_AMReX
AlexanderSinn Apr 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,40 @@ Checks: '
bugprone-*,
-bugprone-easily-swappable-parameters,
-bugprone-implicit-widening-of-multiplication-result,
-bugprone-misplaced-widening-cast,
-bugprone-narrowing-conversions,
cppcoreguidelines-avoid-goto
clang-analyzer-*,
-clang-analyzer-optin.mpi.MPI-Checker,
clang-diagnostic-*,
cppcoreguidelines-*,
-cppcoreguidelines-avoid-c-arrays,
-cppcoreguidelines-avoid-do-while,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-init-variables,
-cppcoreguidelines-interfaces-global-init,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory,
-cppcoreguidelines-pro-*,
google-build-explicit-make-pair,
google-build-namespaces,
google-global-names-in-headers,
misc-*,
-misc-const-correctness,
-misc-include-cleaner,
-misc-non-private-member-variables-in-classes,
-misc-no-recursion,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-macro-to-enum,
-modernize-return-braced-init-list,
-modernize-use-auto,
-modernize-use-trailing-return-type,
performance-*,
-performance-enum-size,
-performance-inefficient-string-concatenation,
portability-*,
mpi-*
'

HeaderFilterRegex: 'src[a-z_A-Z0-9\/]+\.H$'
4 changes: 4 additions & 0 deletions .github/workflows/clangtidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ jobs:
- name: Build & Install
run: |
./tools/runClangTidy.sh
- name: Output clang-tidy log
if: always()
run: |
cat ./build_clang_tidy/clang-tidy.log

9 changes: 7 additions & 2 deletions src/Hipace.H
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
namespace hpmg { class MultiGrid; }

namespace FieldBoundary {
enum type {
enum type : int {
Dirichlet,
Periodic,
Open
};
}

namespace ParticleBoundary {
enum type {
enum type : int {
Reflecting,
Periodic,
Absorbing
Expand All @@ -60,6 +60,11 @@ struct Hipace_early_init
/** Destructor for FFT cleanup */
~Hipace_early_init ();

Hipace_early_init (const Hipace_early_init& rhs) = delete;
Hipace_early_init (Hipace_early_init&& rhs) = delete;
Hipace_early_init& operator= (const Hipace_early_init& rhs) = delete;
Hipace_early_init& operator= (Hipace_early_init&& rhs) = delete;

/** Struct containing physical constants (which values depends on the unit system, determined
* at runtime): SI or normalized units. */
PhysConst m_phys_const;
Expand Down
62 changes: 33 additions & 29 deletions src/Hipace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ Hipace::ReadParameters ()

queryWithParser(pph, "collisions", m_collision_names);
/** Initialize the collision objects */
m_ncollisions = m_collision_names.size();
m_ncollisions = static_cast<int>(m_collision_names.size());
for (int i = 0; i < m_ncollisions; ++i) {
m_all_collisions.emplace_back(CoulombCollision());
m_all_collisions.back().ReadParameters(m_multi_plasma.m_names, m_multi_beam.m_names, m_collision_names[i]);
Expand Down Expand Up @@ -385,8 +385,8 @@ Hipace::MakeGeometry ()
};

std::array<amrex::Real, 2> patch_len_lev {
n_cells_lev[0] * m_3D_geom[0].CellSize(0) / ref_ratio[0],
n_cells_lev[1] * m_3D_geom[0].CellSize(1) / ref_ratio[1],
amrex::Real(n_cells_lev[0]) * m_3D_geom[0].CellSize(0) / ref_ratio[0],
amrex::Real(n_cells_lev[1]) * m_3D_geom[0].CellSize(1) / ref_ratio[1],
};

std::array<amrex::Real, 2> old_patch_len {
Expand Down Expand Up @@ -424,8 +424,8 @@ Hipace::MakeGeometry ()
int(amrex::Math::round((patch_hi_lev[2] - pos_offset_z) * m_3D_geom[0].InvCellSize(2)))
);

patch_lo_lev[2] = (zeta_lo-0.5_rt)*m_3D_geom[0].CellSize(2) + pos_offset_z;
patch_hi_lev[2] = (zeta_hi+0.5_rt)*m_3D_geom[0].CellSize(2) + pos_offset_z;
patch_lo_lev[2] = (amrex::Real(zeta_lo)-0.5_rt)*m_3D_geom[0].CellSize(2) + pos_offset_z;
patch_hi_lev[2] = (amrex::Real(zeta_hi)+0.5_rt)*m_3D_geom[0].CellSize(2) + pos_offset_z;

const amrex::Box domain_3D_lev{amrex::IntVect(0,0,zeta_lo),
amrex::IntVect(n_cells_lev[0]-1, n_cells_lev[1]-1, zeta_hi)};
Expand Down Expand Up @@ -541,11 +541,13 @@ Hipace::Evolve ()
}

if (m_verbose >= 1) {
std::cout << utils::format_time{amrex::second() - start_time}
<< " Rank " << rank
<< " started step " << step
<< " at time = " << m_physical_time
<< " with dt = " << m_dt << std::endl;
amrex::OutStream()
<< utils::format_time{amrex::second() - start_time}
<< " Rank " << rank
<< " started step " << step
<< " at time = " << m_physical_time
<< " with dt = " << m_dt << '\n';
amrex::OutStream().flush();
}

if (step+1 <= m_max_step) {
Expand Down Expand Up @@ -604,8 +606,8 @@ Hipace::Evolve ()

if (!m_explicit) {
// averaging predictor corrector loop diagnostics
m_predcorr_avg_iterations /= bx.length(Direction::z);
m_predcorr_avg_B_error /= bx.length(Direction::z);
m_predcorr_avg_iterations /= amrex::Real(bx.length(Direction::z));
m_predcorr_avg_B_error /= amrex::Real(bx.length(Direction::z));
if (m_verbose >= 2) {
amrex::AllPrint() << "Rank " << rank
<< ": avg. number of iterations " << m_predcorr_avg_iterations
Expand All @@ -631,37 +633,39 @@ Hipace::Evolve ()
if (HeadRank()) {
const double total_time_s = (amrex::second() - start_time);

amrex::IOFormatSaver iofmtsaver(std::cout);
std::cout << std::setprecision(4);
amrex::IOFormatSaver iofmtsaver(amrex::OutStream());
amrex::OutStream() << std::setprecision(4);

std::cout << '\n' << "Finished Evolve after " << total_time_s << " seconds using "
<< m_numprocs << (m_numprocs > 1 ? " ranks" : " rank" ) << std::endl;
amrex::OutStream() << '\n' << "Finished Evolve after " << total_time_s <<
" seconds using " << m_numprocs << (m_numprocs > 1 ? " ranks" : " rank" ) << '\n';

if (m_num_plasma_particles_pushed + m_num_beam_particles_pushed > 0.) {
std::cout << "Total time per particle push: "
amrex::OutStream() << "Total time per particle push: "
<< 1e9 * total_time_s /
(m_num_plasma_particles_pushed + m_num_beam_particles_pushed)
<< " nanoseconds";
if (m_num_plasma_particles_pushed > 0. && m_num_beam_particles_pushed > 0.) {
std::cout << " ("
amrex::OutStream() << " ("
<< 1e9 * total_time_s / m_num_plasma_particles_pushed << " plasma, "
<< 1e9 * total_time_s / m_num_beam_particles_pushed << " beam)";
}
std::cout << std::endl;
amrex::OutStream() << '\n';
}

if (m_num_field_cells_updated + m_num_laser_cells_updated > 0.) {
std::cout << "Total time per cell update: "
amrex::OutStream() << "Total time per cell update: "
<< 1e9 * total_time_s /
(m_num_field_cells_updated + m_num_laser_cells_updated)
<< " nanoseconds";
if (m_num_field_cells_updated > 0. && m_num_laser_cells_updated > 0.) {
std::cout << " ("
amrex::OutStream() << " ("
<< 1e9 * total_time_s / m_num_field_cells_updated << " field, "
<< 1e9 * total_time_s / m_num_laser_cells_updated << " laser)";
}
std::cout << std::endl;
amrex::OutStream() << '\n';
}

amrex::OutStream().flush();
}
}
}
Expand Down Expand Up @@ -1240,13 +1244,13 @@ Hipace::AddGridExternalFields (const int lev, const int islice)
amrex::ParallelFor(to2D(bx),
[=] AMREX_GPU_DEVICE (int i, int j) noexcept
{
const amrex::Real x = i * dx + poff_x;
const amrex::Real y = j * dy + poff_y;
const amrex::Real xlo = (i-1) * dx + poff_x;
const amrex::Real ylo = (j-1) * dy + poff_y;
const amrex::Real xhi = (i+1) * dx + poff_x;
const amrex::Real yhi = (j+1) * dy + poff_y;
const amrex::Real z = islice * dz + poff_z;
const amrex::Real x = amrex::Real(i) * dx + poff_x;
const amrex::Real y = amrex::Real(j) * dy + poff_y;
const amrex::Real xlo = amrex::Real(i-1) * dx + poff_x;
const amrex::Real ylo = amrex::Real(j-1) * dy + poff_y;
const amrex::Real xhi = amrex::Real(i+1) * dx + poff_x;
const amrex::Real yhi = amrex::Real(j+1) * dy + poff_y;
const amrex::Real z = amrex::Real(islice) * dz + poff_z;

const amrex::Real Bxp = external_fields[0](x, y, z, time);
const amrex::Real Byp = external_fields[1](x, y, z, time);
Expand Down
2 changes: 1 addition & 1 deletion src/diagnostics/Diagnostic.H
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
struct FieldDiagnosticData
{
std::string m_diag_name; /**< name used for input parameters and in the output */
enum struct geom_type {
enum struct geom_type : int {
field,
laser
} m_base_geom_type = geom_type::field; /**< which geometry the diagnostics is based on */
Expand Down
39 changes: 20 additions & 19 deletions src/diagnostics/Diagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Diagnostic::needsRhoIndividual () const {
queryWithParserAlt(pp, "field_data", comps, ppd);
for (auto& c : comps) {
// we don't know the names of all the plasmas here so just look for "rho_..."
if (c.find("rho_") == 0) {
if (c.starts_with("rho_")) {
Comment thread
AlexanderSinn marked this conversation as resolved.
return true;
}
}
Expand All @@ -132,9 +132,9 @@ Diagnostic::needsTempIndividual () const {
queryWithParserAlt(pp, "field_data", comps, ppd);
for (auto& c : comps) {
// we don't know the names of all the plasmas here so just look for "ux_..."
if (c.find("w_") == 0 ||
c.find("ux_") == 0 || c.find("uy_") == 0 || c.find("uz_") == 0 ||
c.find("ux^2_") == 0 || c.find("uy^2_") == 0 || c.find("uz^2_") == 0) {
if (c.starts_with("w_") ||
c.starts_with("ux_") || c.starts_with("uy_") || c.starts_with("uz_") ||
c.starts_with("ux^2_") || c.starts_with("uy^2_") || c.starts_with("uz^2_")) {
return true;
}
}
Expand Down Expand Up @@ -204,14 +204,14 @@ Diagnostic::Initialize (int nlev, bool use_laser) {

std::string base_geom_name = "level_0";

if (diag_name_to_default_geometry.count(fd.m_diag_name) > 0) {
if (diag_name_to_default_geometry.contains(fd.m_diag_name)) {
Comment thread
AlexanderSinn marked this conversation as resolved.
base_geom_name = diag_name_to_default_geometry.at(fd.m_diag_name);
}

queryWithParserAlt(pp, "base_geometry", base_geom_name, ppd);
DeprecatedInput(fd.m_diag_name, "level", "base_geometry");

if (geometry_name_to_geom_type.count(base_geom_name) > 0) {
if (geometry_name_to_geom_type.contains(base_geom_name)) {
fd.m_base_geom_type = geometry_name_to_geom_type.at(base_geom_name);
fd.m_level = geometry_name_to_level.at(base_geom_name);
} else {
Expand Down Expand Up @@ -244,13 +244,13 @@ Diagnostic::Initialize (int nlev, bool use_laser) {
is_global_comp_used[comp_name] = true;
// remove all components
comps_set.clear();
} else if (geometry_name_to_output_comps[base_geom_name].count(comp_name) > 0) {
} else if (geometry_name_to_output_comps[base_geom_name].contains(comp_name)) {
is_global_comp_used[comp_name] = true;
// insert requested component
comps_set.insert(comp_name);
} else if (comp_name.find("remove_") == 0 &&
geometry_name_to_output_comps[base_geom_name].count(
comp_name.substr(std::string("remove_").size(), comp_name.size())) > 0) {
} else if (comp_name.starts_with("remove_") &&
geometry_name_to_output_comps[base_geom_name].contains(
comp_name.substr(std::string("remove_").size(), comp_name.size()))) {
is_global_comp_used[comp_name] = true;
// remove requested component
comps_set.erase(comp_name.substr(std::string("remove_").size(), comp_name.size()));
Expand All @@ -268,7 +268,7 @@ Diagnostic::Initialize (int nlev, bool use_laser) {
}

fd.m_comps_output.assign(comps_set.begin(), comps_set.end());
fd.m_nfields = fd.m_comps_output.size();
fd.m_nfields = static_cast<int>(fd.m_comps_output.size());

// copy the indexes of m_comps_output to the GPU
fd.m_comps_output_idx.resize(fd.m_nfields);
Expand Down Expand Up @@ -310,7 +310,7 @@ Diagnostic::Initialize (int nlev, bool use_laser) {
if(m_output_beam_names.empty()) {
m_output_beam_names = all_beam_names;
} else {
for(std::string beam_name : m_output_beam_names) {
for(const std::string& beam_name : m_output_beam_names) {
if(beam_name == "all" || beam_name == "All") {
m_output_beam_names = all_beam_names;
break;
Expand Down Expand Up @@ -397,10 +397,10 @@ Diagnostic::ResizeFDiagFAB (amrex::Vector<amrex::Geometry>& field_geom,
amrex::RealBox diag_domain = geom.ProbDomain();
for(int dir=0; dir<=2; ++dir) {
// make diag_domain correspond to box
diag_domain.setLo(dir, geom.ProbLo(dir)
+ (domain.smallEnd(dir) - geom.Domain().smallEnd(dir)) * geom.CellSize(dir));
diag_domain.setHi(dir, geom.ProbHi(dir)
+ (domain.bigEnd(dir) - geom.Domain().bigEnd(dir)) * geom.CellSize(dir));
diag_domain.setLo(dir, geom.ProbLo(dir) + amrex::Real(domain.smallEnd(dir)
- geom.Domain().smallEnd(dir)) * geom.CellSize(dir));
diag_domain.setHi(dir, geom.ProbHi(dir) + amrex::Real(domain.bigEnd(dir)
- geom.Domain().bigEnd(dir)) * geom.CellSize(dir));
}
// trim the 3D box to slice box for slice IO
TrimIOBox(fd.m_slice_dir, domain, diag_domain);
Expand Down Expand Up @@ -439,10 +439,11 @@ Diagnostic::ResizeFDiagFAB (amrex::Vector<amrex::Geometry>& field_geom,
void
Diagnostic::TrimIOBox (int slice_dir, amrex::Box& domain_3d, amrex::RealBox& rbox_3d)
{
using namespace amrex::literals;
if (slice_dir >= 0){
const amrex::Real half_cell_size = rbox_3d.length(slice_dir) /
( 2. * domain_3d.length(slice_dir) );
const amrex::Real mid = (rbox_3d.lo(slice_dir) + rbox_3d.hi(slice_dir)) / 2.;
const amrex::Real half_cell_size = amrex::Real(rbox_3d.length(slice_dir)) /
(2._rt * amrex::Real(domain_3d.length(slice_dir)));
const amrex::Real mid = (rbox_3d.lo(slice_dir) + rbox_3d.hi(slice_dir)) / 2._rt;
// Flatten the box down to 1 cell in the approprate direction.
domain_3d.setSmall(slice_dir, 0);
domain_3d.setBig (slice_dir, 0);
Expand Down
13 changes: 9 additions & 4 deletions src/diagnostics/OpenPMDWriter.H
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private:
*/
void WriteBeamParticleData (MultiBeam& beams, openPMD::Iteration& iteration,
const amrex::Geometry& geom,
const amrex::Vector< std::string > beamnames);
const amrex::Vector<std::string>& beamnames);

/** \brief writing openPMD field data
*
Expand Down Expand Up @@ -110,6 +110,11 @@ public:

~OpenPMDWriter ();

OpenPMDWriter (const OpenPMDWriter& rhs) = delete;
OpenPMDWriter (OpenPMDWriter&& rhs) = delete;
OpenPMDWriter& operator= (const OpenPMDWriter& rhs) = delete;
OpenPMDWriter& operator= (OpenPMDWriter&& rhs) = delete;

/** Read parameters from the input file */
void ReadParameters ();

Expand All @@ -122,7 +127,7 @@ public:
* \param[in] beams multi beam container which is written to openPMD file
* \param[in] beamnames list of the names of the beam to be written to file
*/
void InitBeamData (MultiBeam& beams, const amrex::Vector< std::string > beamnames);
void InitBeamData (MultiBeam& beams, const amrex::Vector<std::string>& beamnames);

/** \brief writing openPMD beam data
*
Expand All @@ -134,7 +139,7 @@ public:
*/
void WriteBeamDiagnostics (
MultiBeam& a_multi_beam, const amrex::Real physical_time, const int output_step,
const amrex::Vector< std::string > beamnames,
const amrex::Vector<std::string>& beamnames,
amrex::Vector<amrex::Geometry> const& geom3D);

/** \brief writing openPMD field data
Expand All @@ -153,7 +158,7 @@ public:
* \param[in] beams multi beam container which is written to openPMD file
* \param[in] beamnames list of the names of the beam to be written to file
*/
void CopyBeams (MultiBeam& beams, const amrex::Vector< std::string > beamnames);
void CopyBeams (MultiBeam& beams, const amrex::Vector<std::string>& beamnames);

/** \brief Resets and flushes the openPMD series of all levels
*/
Expand Down
Loading
Loading