Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use clang-format v19.1.0 #130

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 7 additions & 2 deletions .github/workflows/ci-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ jobs:
cppcheck --force --error-exitcode=1 --language=c++ --std=c++20 --enable=all --inconclusive --suppress=knownConditionTrueFalse --suppress=constParameterCallback --suppress=redundantAssignment --suppress=knownArgument --suppress=missingIncludeSystem --suppress=unusedFunction --check-level=exhaustive .

clang-format:
runs-on: ubuntu-24.04
runs-on: macos-14
steps:
- uses: actions/checkout@v4

- name: install clang-format
run: |
brew update
brew install clang-format || true

- name: Run clang-format style check
uses: jidicula/clang-format-action@v4.13.0
with:
clang-format-version: '18'
clang-format-version: '19'
check-path: .

clang-tidy:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
args: [--fix=lf]
- id: trailing-whitespace
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: 'v18.1.8'
rev: 'v19.1.0'
hooks:
- id: clang-format
files: '\.(c|cc|cpp|h|hpp|cxx|hh|inc)$'
Expand Down
16 changes: 8 additions & 8 deletions decay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,8 @@ auto sample_decaytime(const int decaypathindex, const double tdecaymin, const do
}

constexpr auto calculate_decaychain(const double firstinitabund, const std::vector<double> &lambdas,
const int num_nuclides, const double timediff,
const bool useexpansionfactor) -> double {
const int num_nuclides, const double timediff, const bool useexpansionfactor)
-> double {
// calculate final number abundance from multiple decays, e.g., Ni56 -> Co56 -> Fe56 (nuc[0] -> nuc[1] -> nuc[2])
// the top nuclide initial abundance is set and the chain-end abundance is returned (all intermediates nuclides
// are assumed to start with zero abundance)
Expand Down Expand Up @@ -615,8 +615,8 @@ auto get_nuc_massfrac(const int modelgridindex, const int z, const int a, const
return nuctotal;
}

auto get_endecay_to_tinf_per_ejectamass_at_time(const int modelgridindex, const int decaypathindex,
const double time) -> double
auto get_endecay_to_tinf_per_ejectamass_at_time(const int modelgridindex, const int decaypathindex, const double time)
-> double
// returns decay energy [erg/g] that would be released from time tstart [s] to time infinity by a given decaypath
{
// e.g. Ni56 -> Co56, represents the decay of Co56 nuclei
Expand Down Expand Up @@ -653,8 +653,8 @@ auto get_endecay_to_tinf_per_ejectamass_at_time(const int modelgridindex, const
}

auto get_endecay_per_ejectamass_t0_to_time_withexpansion_chain_numerical(const int modelgridindex,
const int decaypathindex,
const double tstart) -> double
const int decaypathindex, const double tstart)
-> double
// just here as as check on the analytic result from get_endecay_per_ejectamass_t0_to_time_withexpansion()
// this version does an Euler integration
{
Expand Down Expand Up @@ -1112,8 +1112,8 @@ void free_decaypath_energy_per_mass() {
}

// energy release rate in form of kinetic energy of positrons, electrons, and alpha particles in [erg/s/g]
[[nodiscard]] auto get_particle_injection_rate(const int modelgridindex, const double t,
const int decaytype) -> double {
[[nodiscard]] auto get_particle_injection_rate(const int modelgridindex, const double t, const int decaytype)
-> double {
double dep_sum = 0.;
const auto num_nuclides = get_num_nuclides();
for (int nucindex = 0; nucindex < num_nuclides; nucindex++) {
Expand Down
22 changes: 13 additions & 9 deletions grid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ void set_elem_untrackedstable_abund_from_total(const int mgi, const int element,
}

// if (globals::rank_in_node == 0)
{ modelgrid[mgi].initmassfracuntrackedstable[element] = massfrac_untrackedstable; }
{
modelgrid[mgi].initmassfracuntrackedstable[element] = massfrac_untrackedstable;
}

// (isofracsum + massfracstable) might not exactly match elemabundance if we had to boost it to reach isofracsum
set_elem_abundance(mgi, element, isofracsum + massfrac_untrackedstable);
Expand Down Expand Up @@ -1598,11 +1600,12 @@ template <size_t S1>
return -1.;
}

auto get_coordboundary_distances_cylindrical2d(
const std::array<double, 3> &pkt_pos, const std::array<double, 3> &pkt_dir,
const std::array<double, 3> &pktposgridcoord, const std::array<double, 3> &pktvelgridcoord, const int cellindex,
const double tstart,
const std::array<double, 3> &cellcoordmax) -> std::tuple<std::array<double, 3>, std::array<double, 3>> {
auto get_coordboundary_distances_cylindrical2d(const std::array<double, 3> &pkt_pos,
const std::array<double, 3> &pkt_dir,
const std::array<double, 3> &pktposgridcoord,
const std::array<double, 3> &pktvelgridcoord, const int cellindex,
const double tstart, const std::array<double, 3> &cellcoordmax)
-> std::tuple<std::array<double, 3>, std::array<double, 3>> {
// to get the cylindrical intersection, get the spherical intersection with Z components set to zero, and the
// propagation speed set to the xy component of the 3-velocity

Expand Down Expand Up @@ -2421,9 +2424,10 @@ auto get_totmassradionuclide(const int z, const int a) -> double {
}

// compute distance to a cell boundary.
[[nodiscard]] __host__ __device__ auto boundary_distance(
const std::array<double, 3> &dir, const std::array<double, 3> &pos, const double tstart, const int cellindex,
enum cell_boundary *pkt_last_cross) -> std::tuple<double, int> {
[[nodiscard]] __host__ __device__ auto boundary_distance(const std::array<double, 3> &dir,
const std::array<double, 3> &pos, const double tstart,
const int cellindex, enum cell_boundary *pkt_last_cross)
-> std::tuple<double, int> {
if constexpr (FORCE_SPHERICAL_ESCAPE_SURFACE) {
if (get_cell_r_inner(cellindex) > globals::vmax * globals::tmin) {
return {0., -99};
Expand Down
4 changes: 2 additions & 2 deletions ltepop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ auto calculate_levelpop(const int modelgridindex, const int element, const int i
}

// Calculate the population of a level from either LTE or NLTE information
__host__ __device__ auto get_levelpop(const int modelgridindex, const int element, const int ion,
const int level) -> double {
__host__ __device__ auto get_levelpop(const int modelgridindex, const int element, const int ion, const int level)
-> double {
double nn = 0.;
if (use_cellcache) {
assert_testmodeonly(modelgridindex == globals::cellcache[cellcacheslotid].cellnumber);
Expand Down
8 changes: 4 additions & 4 deletions ltepop.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
[[nodiscard]] auto calculate_levelpop(int modelgridindex, int element, int ion, int level) -> double;
[[nodiscard]] auto calculate_levelpop_lte(int modelgridindex, int element, int ion, int level) -> double;
[[nodiscard]] auto get_levelpop(int modelgridindex, int element, int ion, int level) -> double;
[[nodiscard]] auto calculate_sahafact(int element, int ion, int level, int upperionlevel, double T,
double E_threshold) -> double;
[[nodiscard]] auto calculate_sahafact(int element, int ion, int level, int upperionlevel, double T, double E_threshold)
-> double;
[[nodiscard]] auto get_nnion(int modelgridindex, int element, int ion) -> double;
void calculate_ion_balance_nne(int modelgridindex);
void calculate_cellpartfuncts(int modelgridindex, int element);
[[nodiscard]] auto calculate_ionfractions(int element, int modelgridindex, double nne,
bool use_phi_lte) -> std::vector<double>;
[[nodiscard]] auto calculate_ionfractions(int element, int modelgridindex, double nne, bool use_phi_lte)
-> std::vector<double>;
void set_groundlevelpops(int modelgridindex, int element, float nne, bool force_lte);

#endif // LTEPOP_H
8 changes: 4 additions & 4 deletions macroatom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ auto calculate_macroatom_transitionrates(const int modelgridindex, const int ele
return processrates;
}

auto do_macroatom_internal_down_same(const int element, const int ion, const int level,
const CellCacheLevels &chlevel) -> int {
auto do_macroatom_internal_down_same(const int element, const int ion, const int level, const CellCacheLevels &chlevel)
-> int {
const int ndowntrans = get_ndowntrans(element, ion, level);

// printout("[debug] do_ma: internal downward jump within current ionstage\n");
Expand Down Expand Up @@ -904,8 +904,8 @@ auto col_deexcitation_ratecoeff(const float T_e, const float nne, const double e

// multiply by lower level population to get a rate per second
auto col_excitation_ratecoeff(const float T_e, const float nne, const int element, const int ion, const int lower,
const int uptransindex, const double epsilon_trans,
const double lowerstatweight) -> double {
const int uptransindex, const double epsilon_trans, const double lowerstatweight)
-> double {
const auto &uptr = get_uptranslist(element, ion, lower)[uptransindex];
const double coll_strength = uptr.coll_str;
const double eoverkt = epsilon_trans / (KB * T_e);
Expand Down
8 changes: 4 additions & 4 deletions macroatom.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ void macroatom_close_file();
void do_macroatom(Packet &pkt, const MacroAtomState &pktmastate);

[[nodiscard]] auto rad_deexcitation_ratecoeff(int modelgridindex, int element, int ion, int lower, double epsilon_trans,
float A_ul, double upperstatweight, double nnlevelupper,
double t_current) -> double;
float A_ul, double upperstatweight, double nnlevelupper, double t_current)
-> double;
[[nodiscard]] auto rad_excitation_ratecoeff(int modelgridindex, int element, int ion, int lower, int uptransindex,
double epsilon_trans, double nnlevel_lower, int lineindex,
double t_current) -> double;
double epsilon_trans, double nnlevel_lower, int lineindex, double t_current)
-> double;
[[nodiscard]] auto rad_recombination_ratecoeff(float T_e, float nne, int element, int upperion, int upperionlevel,
int lowerionlevel, int modelgridindex) -> double;
[[nodiscard]] auto stim_recombination_ratecoeff(float nne, int element, int upperion, int upper, int lower,
Expand Down
4 changes: 2 additions & 2 deletions nltepop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ void filter_nlte_matrix(const int element, gsl_matrix *rate_matrix, gsl_vector *
}

[[nodiscard]] auto get_total_rate(const int index_selected, const gsl_matrix *rate_matrix, const gsl_vector *popvec,
const bool into_level, const bool only_levels_below,
const bool only_levels_above) -> double {
const bool into_level, const bool only_levels_below, const bool only_levels_above)
-> double {
double total_rate = 0.;
assert_always(!only_levels_below || !only_levels_above);

Expand Down
24 changes: 12 additions & 12 deletions nonthermal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -694,8 +694,8 @@ auto get_xs_ionization_vector(std::array<double, SFPTS> &xs_vec, const collionro

// distribution of secondary electron energies for primary electron with energy e_p
// Opal, Peterson, & Beaty (1971)
[[nodiscard]] constexpr auto Psecondary(const double e_p, const double epsilon, const double I,
const double J) -> double {
[[nodiscard]] constexpr auto Psecondary(const double e_p, const double epsilon, const double I, const double J)
-> double {
const double e_s = epsilon - I;

if (e_p <= I || e_s < 0.) {
Expand Down Expand Up @@ -1081,8 +1081,8 @@ auto get_oneoverw(const int element, const int ion, const int modelgridindex) ->

// the fraction of deposited energy that goes into ionising electrons in a particular shell
auto calculate_nt_frac_ionization_shell(const int modelgridindex, const int element, const int ion,
const collionrow &collionrow,
const std::array<double, SFPTS> &yfunc) -> double {
const collionrow &collionrow, const std::array<double, SFPTS> &yfunc)
-> double {
const double nnion = get_nnion(modelgridindex, element, ion);
const double ionpot_ev = collionrow.ionpot_ev;

Expand All @@ -1105,8 +1105,8 @@ auto nt_ionization_ratecoeff_wfapprox(const int modelgridindex, const int elemen
}

auto calculate_nt_ionization_ratecoeff(const int modelgridindex, const int element, const int ion,
const bool assumeshellpotentialisvalence,
const std::array<double, SFPTS> &yfunc) -> double
const bool assumeshellpotentialisvalence, const std::array<double, SFPTS> &yfunc)
-> double
// Integrate the ionization cross section over the electron degradation function to get the ionization rate coefficient
// i.e. multiply this by ion population to get a rate of ionizations per second
// Do not call during packet propagation, as the y vector may not be in memory!
Expand Down Expand Up @@ -1286,8 +1286,8 @@ auto nt_ionization_ratecoeff_sf(const int modelgridindex, const int element, con
// returns the index of the first valid cross section point (en >= epsilon_trans)
// all elements below this index are invalid and should not be used
auto get_xs_excitation_vector(const int element, const int ion, const int lower, const int uptransindex,
const double statweight_lower,
const double epsilon_trans) -> std::tuple<std::array<double, SFPTS>, int> {
const double statweight_lower, const double epsilon_trans)
-> std::tuple<std::array<double, SFPTS>, int> {
std::array<double, SFPTS> xs_excitation_vec{};
const auto &uptr = get_uptranslist(element, ion, lower)[uptransindex];
if (uptr.coll_str >= 0) {
Expand Down Expand Up @@ -1344,8 +1344,8 @@ auto get_xs_excitation_vector(const int element, const int ion, const int lower,
// returns the rate coefficient in s^-1 divided by deposition rate density in erg/cm^3/s
auto calculate_nt_excitation_ratecoeff_perdeposition(const std::array<double, SFPTS> &yvec, const int element,
const int ion, const int lower, const int uptransindex,
const double statweight_lower,
const double epsilon_trans) -> double {
const double statweight_lower, const double epsilon_trans)
-> double {
const auto [xs_excitation_vec, xsstartindex] =
get_xs_excitation_vector(element, ion, lower, uptransindex, statweight_lower, epsilon_trans);

Expand Down Expand Up @@ -2264,8 +2264,8 @@ __host__ __device__ auto nt_ionization_ratecoeff(const int modelgridindex, const
}

__host__ __device__ auto nt_excitation_ratecoeff(const int modelgridindex, const int element, const int ion,
const int lowerlevel, const int uptransindex,
const int lineindex) -> double {
const int lowerlevel, const int uptransindex, const int lineindex)
-> double {
if constexpr (!NT_EXCITATION_ON) {
return 0.;
}
Expand Down
4 changes: 2 additions & 2 deletions radfield.cc
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,8 @@ __host__ __device__ auto radfield(const double nu, const int modelgridindex) ->

// return the integral of nu^3 / (exp(h nu / k T) - 1) from nu_lower to nu_upper
// or if times_nu is true, the integral of nu^4 / (exp(h nu / k T) - 1) from nu_lower to nu_upper
auto planck_integral_analytic(const double T_R, const double nu_lower, const double nu_upper,
const bool times_nu) -> double {
auto planck_integral_analytic(const double T_R, const double nu_lower, const double nu_upper, const bool times_nu)
-> double {
double integral = 0.;

if (times_nu) {
Expand Down
4 changes: 2 additions & 2 deletions radfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void do_MPI_Bcast(int modelgridindex, int root, int root_node_id);
void write_restart_data(FILE *gridsave_file);
void read_restart_data(FILE *gridsave_file);
void normalise_bf_estimators(int nts, int nts_prev, int titer, double deltat);
[[nodiscard]] auto get_bfrate_estimator(int element, int lowerion, int lower, int phixstargetindex,
int modelgridindex) -> double;
[[nodiscard]] auto get_bfrate_estimator(int element, int lowerion, int lower, int phixstargetindex, int modelgridindex)
-> double;
void print_bfrate_contributions(int element, int lowerion, int lower, int phixstargetindex, int modelgridindex,
double nnlowerlevel, double nnlowerion);
void reset_bfrate_contributions(int modelgridindex);
Expand Down
4 changes: 2 additions & 2 deletions ratecoeff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,8 @@ __host__ __device__ auto get_spontrecombcoeff(int element, const int ion, const
// multiply by upper ion population (or ground population if per_groundmultipletpop is true) and nne to get a rate
auto calculate_ionrecombcoeff(const int modelgridindex, const float T_e, const int element, const int upperion,
const bool assume_lte, const bool collisional_not_radiative, const bool printdebug,
const bool lower_superlevel_only, const bool per_groundmultipletpop,
const bool stimonly) -> double {
const bool lower_superlevel_only, const bool per_groundmultipletpop, const bool stimonly)
-> double {
const int lowerion = upperion - 1;
if (lowerion < 0) {
return 0.;
Expand Down
16 changes: 8 additions & 8 deletions ratecoeff.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ void setup_photoion_luts();

[[nodiscard]] auto select_continuum_nu(int element, int lowerion, int lower, int upperionlevel, float T_e) -> double;

[[nodiscard]] auto interpolate_corrphotoioncoeff(int element, int ion, int level, int phixstargetindex,
double T) -> double;
[[nodiscard]] auto interpolate_corrphotoioncoeff(int element, int ion, int level, int phixstargetindex, double T)
-> double;

[[nodiscard]] auto get_spontrecombcoeff(int element, int ion, int level, int phixstargetindex, float T_e) -> double;
[[nodiscard]] auto get_stimrecombcoeff(int element, int lowerion, int level, int phixstargetindex,
int modelgridindex) -> double;
[[nodiscard]] auto get_stimrecombcoeff(int element, int lowerion, int level, int phixstargetindex, int modelgridindex)
-> double;

[[nodiscard]] auto get_bfcoolingcoeff(int element, int ion, int level, int phixstargetindex, float T_e) -> double;

[[nodiscard]] auto get_corrphotoioncoeff(int element, int ion, int level, int phixstargetindex,
int modelgridindex) -> double;
[[nodiscard]] auto get_corrphotoioncoeff_ana(int element, int ion, int level, int phixstargetindex,
int modelgridindex) -> double;
[[nodiscard]] auto get_corrphotoioncoeff(int element, int ion, int level, int phixstargetindex, int modelgridindex)
-> double;
[[nodiscard]] auto get_corrphotoioncoeff_ana(int element, int ion, int level, int phixstargetindex, int modelgridindex)
-> double;

[[nodiscard]] auto iongamma_is_zero(int nonemptymgi, int element, int ion) -> bool;

Expand Down
Loading