Skip to content

Commit

Permalink
Clang-format entire repository (celeritas-project#1084)
Browse files Browse the repository at this point in the history
* Format code base (clang-format version 17.0.2)
* Ignore copyright change in git blame
  • Loading branch information
sethrj committed Jan 17, 2024
1 parent f27dc24 commit 0b80505
Show file tree
Hide file tree
Showing 165 changed files with 454 additions and 445 deletions.
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ c93d9582552e2d7ad4e18d9d74b7e9e62de53c0e
# Update copyrights
7a0f476ae128025a8843ba2b1e6e6284efb7d0dd
c06d0a263847884aff7aefc9280c758860ea5fc2
f27dc24aac631ebfea4f487a0d122a0e69d3c083
# clang-format and IWYU
0e14b341e12eb750b627e7d61602e50c68db2551
954cd07322312b43eb7dc926abd0054f630a8eff
Expand Down
4 changes: 3 additions & 1 deletion app/celer-g4/ExceptionHandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ G4bool ExceptionHandler::Notify(char const* origin_of_exception,
}
else
{
CELER_LOG_LOCAL(critical) << "Aborting run due to exception (" << exception_code << ")";
CELER_LOG_LOCAL(critical)
<< "Aborting run due to exception (" << exception_code
<< ")";
run_man->AbortRun();
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/celer-g4/celer-g4.nogeant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
//---------------------------------------------------------------------------//
//! \file celer-g4/celer-g4.nogeant.cc
//---------------------------------------------------------------------------//
#include <iostream>
#include <cstdlib>
#include <iostream>

//---------------------------------------------------------------------------//
/*!
Expand Down
4 changes: 2 additions & 2 deletions app/demo-geo-check/GCheckKernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ namespace app
// KERNELS
//---------------------------------------------------------------------------//

__global__ void gcheck_kernel(const GeoParamsCRefDevice params,
const GeoStateRefDevice state,
__global__ void gcheck_kernel(GeoParamsCRefDevice const params,
GeoStateRefDevice const state,
GeoTrackInitializer const* init,
int max_steps,
int* ids,
Expand Down
2 changes: 1 addition & 1 deletion app/demo-interactor/Detector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ CELER_FUNCTION void Detector::process_hit(HitId id)

Hit const& hit = state_.hit_buffer.storage[id];
UniformGrid grid(params_.tally_grid);
const real_type z_pos = hit.pos[2];
real_type const z_pos = hit.pos[2];
size_type bin;

if (z_pos <= grid.front())
Expand Down
2 changes: 1 addition & 1 deletion app/demo-interactor/KNDemoKernel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void finalize(ParamsData<Ownership::const_reference, M> const& params,
CELER_EXPECT(edep.size() == params.detector.tally_grid.size);

copy_to_host(state.detector.tally_deposition, edep);
const real_type norm = 1 / real_type(state.size());
real_type const norm = 1 / real_type(state.size());
for (real_type& v : edep)
{
v *= norm;
Expand Down
6 changes: 3 additions & 3 deletions app/demo-rasterizer/RDemoKernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ __device__ int geo_id(GeoTrackView const& geo)
return geo.volume_id().get();
}

__global__ void trace_kernel(const GeoParamsCRefDevice geo_params,
const GeoStateRefDevice geo_state,
const ImageData image_state)
__global__ void trace_kernel(GeoParamsCRefDevice const geo_params,
GeoStateRefDevice const geo_state,
ImageData const image_state)
{
auto tid = KernelParamCalculator::thread_id();
if (tid.get() >= image_state.dims[0])
Expand Down
2 changes: 1 addition & 1 deletion src/accel/ExceptionConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ std::string strip_source_dir(std::string const& filename)
}

std::string::size_type max_pos = 0;
for (const std::string path : {"src/", "app/", "test/"})
for (std::string const path : {"src/", "app/", "test/"})
{
auto pos = filename.rfind(path);

Expand Down
3 changes: 2 additions & 1 deletion src/accel/FastSimulationOffload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ void FastSimulationOffload::DoIt(G4FastTrack const& track, G4FastStep& step)
*
* Note that this is called in \c G4EventManager::DoProcessing(G4Event*) by
* \c G4GlobalFastSimulationManager after the main tracking loop has completed.
* That is done to allow for models that may add "onload" particles back to Geant4.
* That is done to allow for models that may add "onload" particles back to
* Geant4.
*/
void FastSimulationOffload::Flush()
{
Expand Down
2 changes: 1 addition & 1 deletion src/accel/detail/HitManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class HitManager final : public StepInterface
using StepStateHostRef = HostRef<StepStateData>;
using StepStateDeviceRef = DeviceRef<StepStateData>;
using SPConstVecLV
= std::shared_ptr<const std::vector<G4LogicalVolume const*>>;
= std::shared_ptr<std::vector<G4LogicalVolume const*> const>;
using VecVolId = std::vector<VolumeId>;
using VecParticle = std::vector<G4ParticleDefinition const*>;
//!@}
Expand Down
2 changes: 1 addition & 1 deletion src/accel/detail/HitProcessor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class HitProcessor
using StepStateHostRef = HostRef<StepStateData>;
using StepStateDeviceRef = DeviceRef<StepStateData>;
using SPConstVecLV
= std::shared_ptr<const std::vector<G4LogicalVolume const*>>;
= std::shared_ptr<std::vector<G4LogicalVolume const*> const>;
using VecParticle = std::vector<G4ParticleDefinition const*>;
//!@}

Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/FluctuationParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ FluctuationParams::FluctuationParams(ParticleParams const& particles,
// Calculate the parameters for the energy loss fluctuation model (see
// Geant3 PHYS332 2.4 and Geant4 physics reference manual 7.3.2)
UrbanFluctuationParameters params;
const real_type avg_z = mat.electron_density() / mat.number_density();
real_type const avg_z = mat.electron_density() / mat.number_density();
params.oscillator_strength[1] = avg_z > 2 ? 2 / avg_z : 0;
params.oscillator_strength[0] = 1 - params.oscillator_strength[1];
params.binding_energy[1] = 1e-5 * ipow<2>(avg_z);
Expand Down
4 changes: 2 additions & 2 deletions src/celeritas/em/detail/Utils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ class MaxSecondariesCalculator
private:
Values const& data_;
Span<AtomicRelaxSubshell const> shells_;
const Energy electron_cut_;
const Energy gamma_cut_;
Energy const electron_cut_;
Energy const gamma_cut_;
std::unordered_map<SubshellId, size_type> visited_;

// HELPER FUNCTIONS
Expand Down
20 changes: 10 additions & 10 deletions src/celeritas/em/distribution/BhabhaEnergyDistribution.hh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ BhabhaEnergyDistribution::BhabhaEnergyDistribution(real_type electron_mass_c_sq,
template<class Engine>
CELER_FUNCTION real_type BhabhaEnergyDistribution::operator()(Engine& rng)
{
const real_type g_denominator = this->calc_g_fraction(
real_type const g_denominator = this->calc_g_fraction(
min_energy_fraction_, this->max_energy_fraction());

UniformRealDistribution<> sample_inverse_epsilon(
Expand All @@ -110,15 +110,15 @@ CELER_FUNCTION real_type BhabhaEnergyDistribution::operator()(Engine& rng)
CELER_FUNCTION real_type BhabhaEnergyDistribution::calc_g_fraction(
real_type epsilon_min, real_type epsilon_max)
{
const real_type y = 1.0 / (1.0 + gamma_);
const real_type y_sq = ipow<2>(y);
const real_type one_minus_2y = 1.0 - 2.0 * y;

const real_type b1 = 2.0 - y_sq;
const real_type b2 = one_minus_2y * (3.0 + y_sq);
const real_type b4 = ipow<3>(one_minus_2y);
const real_type b3 = ipow<2>(one_minus_2y) + b4;
const real_type beta_sq = 1.0 - (1.0 / ipow<2>(gamma_));
real_type const y = 1.0 / (1.0 + gamma_);
real_type const y_sq = ipow<2>(y);
real_type const one_minus_2y = 1.0 - 2.0 * y;

real_type const b1 = 2.0 - y_sq;
real_type const b2 = one_minus_2y * (3.0 + y_sq);
real_type const b4 = ipow<3>(one_minus_2y);
real_type const b3 = ipow<2>(one_minus_2y) + b4;
real_type const beta_sq = 1.0 - (1.0 / ipow<2>(gamma_));

return 1.0
+ (ipow<4>(epsilon_max) * b4 - ipow<3>(epsilon_min) * b3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class EnergyLossGaussianDistribution
inline CELER_FUNCTION Energy operator()(Generator& rng);

private:
const real_type max_loss_;
real_type const max_loss_;
NormalDistribution<real_type> sample_normal_;
};

Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/distribution/EnergyLossHelper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ EnergyLossHelper::EnergyLossHelper(FluctuationRef const& shared,
}

constexpr real_type half = 0.5;
const real_type gamma = particle.lorentz_factor();
real_type const gamma = particle.lorentz_factor();
beta_sq_ = particle.beta_sq();
two_mebsgs_ = 2 * value_as<Mass>(shared_.electron_mass) * beta_sq_
* ipow<2>(gamma);
Expand Down
16 changes: 8 additions & 8 deletions src/celeritas/em/distribution/EnergyLossUrbanDistribution.hh
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ CELER_FUNCTION EnergyLossUrbanDistribution::EnergyLossUrbanDistribution(
= real_type(0.5)
* min(this->fwhm_min_energy() / max_energy_, real_type(1))
+ real_type(1);
const real_type mean_loss = unscaled_mean_loss.value() / loss_scaling_;
real_type const mean_loss = unscaled_mean_loss.value() / loss_scaling_;

// Material-dependent data
CELER_ASSERT(cur_mat.material_id() < shared.urban.size());
Expand All @@ -167,15 +167,15 @@ CELER_FUNCTION EnergyLossUrbanDistribution::EnergyLossUrbanDistribution(
{
// Common term in the numerator and denominator of PRM Eq. 7.10
// two_mebsgs = 2 * m_e c^2 * beta^2 * gamma^2
const real_type w = std::log(value_as<units::MevMass>(two_mebsgs))
real_type const w = std::log(value_as<units::MevMass>(two_mebsgs))
- beta_sq;
const real_type w_0
real_type const w_0
= value_as<units::LogMevEnergy>(mat.log_mean_excitation_energy());
if (w > w_0)
{
if (w > params.log_binding_energy[1])
{
const real_type c = mean_loss * (1 - this->rate()) / (w - w_0);
real_type const c = mean_loss * (1 - this->rate()) / (w - w_0);
for (int i : range(2))
{
// Excitation macroscopic cross section (PRM Eq. 7.10)
Expand Down Expand Up @@ -304,7 +304,7 @@ EnergyLossUrbanDistribution::sample_ionization_loss(Engine& rng)
real_type result = 0;

constexpr real_type e_0 = EnergyLossUrbanDistribution::ionization_energy();
const real_type energy_ratio = max_energy_ / e_0;
real_type const energy_ratio = max_energy_ / e_0;

// Parameter that determines the upper limit of the energy interval in
// which the fast simulation is used
Expand All @@ -324,15 +324,15 @@ EnergyLossUrbanDistribution::sample_ionization_loss(Engine& rng)
/ (this->max_collisions() * energy_ratio + xs_ion_);

// Mean energy loss for a single collision of this type (Eq. 14)
const real_type mean_loss_coll = alpha * std::log(alpha) / (alpha - 1);
real_type const mean_loss_coll = alpha * std::log(alpha) / (alpha - 1);

// Mean number of collisions of this type (Eq. 16)
mean_num_coll = xs_ion_ * energy_ratio * (alpha - 1)
/ ((energy_ratio - 1) * alpha);

// Mean and standard deviation of the total energy loss (Eqs. 18-19)
const real_type mean = mean_num_coll * mean_loss_coll * e_0;
const real_type stddev
real_type const mean = mean_num_coll * mean_loss_coll * e_0;
real_type const stddev
= e_0 * std::sqrt(xs_ion_ * (alpha - ipow<2>(mean_loss_coll)));

// Sample energy loss from a Gaussian distribution
Expand Down
6 changes: 3 additions & 3 deletions src/celeritas/em/distribution/MollerEnergyDistribution.hh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ MollerEnergyDistribution::MollerEnergyDistribution(real_type electron_mass_c_sq,
template<class Engine>
CELER_FUNCTION real_type MollerEnergyDistribution::operator()(Engine& rng)
{
const real_type g_denominator
real_type const g_denominator
= this->calc_g_fraction(this->max_energy_fraction());

UniformRealDistribution<> sample_inverse_epsilon(
Expand All @@ -107,8 +107,8 @@ CELER_FUNCTION real_type MollerEnergyDistribution::operator()(Engine& rng)
CELER_FUNCTION real_type
MollerEnergyDistribution::calc_g_fraction(real_type epsilon)
{
const real_type two_gamma_term = (2 * gamma_ - 1) / ipow<2>(gamma_);
const real_type complement_frac = 1 - epsilon;
real_type const two_gamma_term = (2 * gamma_ - 1) / ipow<2>(gamma_);
real_type const complement_frac = 1 - epsilon;

return 1 - two_gamma_term * epsilon
+ ipow<2>(epsilon)
Expand Down
14 changes: 7 additions & 7 deletions src/celeritas/em/distribution/SBEnergyDistHelper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class SBEnergyDistHelper

//// IMPLEMENTATION DATA ////

const TwodSubgridCalculator calc_xs_;
const Xs max_xs_;
TwodSubgridCalculator const calc_xs_;
Xs const max_xs_;

const real_type inv_inc_energy_;
const real_type dens_corr_;
const ReciprocalSampler sample_exit_esq_;
real_type const inv_inc_energy_;
real_type const dens_corr_;
ReciprocalSampler const sample_exit_esq_;

//// CONSTRUCTION HELPER FUNCTIONS ////

Expand Down Expand Up @@ -179,8 +179,8 @@ CELER_FUNCTION auto SBEnergyDistHelper::calc_max_xs(SBTables const& xs_params,
CELER_EXPECT(element);
SBElementTableData const& el = xs_params.elements[element];

const size_type x_idx = calc_xs_.x_index();
const real_type x_frac = calc_xs_.x_fraction();
size_type const x_idx = calc_xs_.x_index();
real_type const x_frac = calc_xs_.x_fraction();
real_type result;

// Calc max xs
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/distribution/SBEnergyDistribution.hh
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class SBEnergyDistribution
private:
//// IMPLEMENTATION DATA ////
SBEnergyDistHelper const& helper_;
const real_type inv_max_xs_;
real_type const inv_max_xs_;
XSCorrector scale_xs_;
};

Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/executor/CombinedBremExecutor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CombinedBremExecutor::operator()(CoreTrackView const& track)

// Assume only a single element in the material, for now
CELER_ASSERT(material.num_elements() == 1);
const ElementComponentId selected_element{0};
ElementComponentId const selected_element{0};

auto particle = track.make_particle_view();
auto const& dir = track.make_geo_view().dir();
Expand Down
2 changes: 1 addition & 1 deletion src/celeritas/em/interactor/AtomicRelaxation.hh
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ AtomicRelaxation::operator()(Engine& rng)
// Sample a transition (TODO: refactor to use Selector but with
// "remainder")
AtomicRelaxSubshell const& shell = shells[vacancy_id.get()];
const TransitionId trans_id = this->sample_transition(shell, rng);
TransitionId const trans_id = this->sample_transition(shell, rng);

if (!trans_id)
continue;
Expand Down
4 changes: 2 additions & 2 deletions src/celeritas/em/interactor/AtomicRelaxationHelper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class AtomicRelaxationHelper
private:
AtomicRelaxParamsRef const& shared_;
AtomicRelaxStateRef const& states_;
const ElementId el_id_;
const TrackSlotId track_slot_;
ElementId const el_id_;
TrackSlotId const track_slot_;
};

//---------------------------------------------------------------------------//
Expand Down
14 changes: 7 additions & 7 deletions src/celeritas/em/interactor/BetheHeitlerInteractor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class BetheHeitlerInteractor
// Shared model data
BetheHeitlerData const& shared_;
// Incident gamma energy
const real_type inc_energy_;
real_type const inc_energy_;
// Incident direction
Real3 const& inc_direction_;
// Allocate space for a secondary particle
Expand Down Expand Up @@ -186,13 +186,13 @@ CELER_FUNCTION Interaction BetheHeitlerInteractor::operator()(Engine& rng)
// Calculate the minimum (when \epsilon = 1/2) and maximum (when
// \epsilon = \epsilon_1) values of screening variable, \delta. Above
// 50 MeV, a Coulomb correction function is introduced.
const real_type delta_min = 4 * 136 / element_.cbrt_z() * epsilon0_;
real_type const delta_min = 4 * 136 / element_.cbrt_z() * epsilon0_;
real_type f_z = real_type(8) / real_type(3) * element_.log_z();
if (inc_energy_ > value_as<Energy>(coulomb_corr_threshold()))
{
f_z += 8 * element_.coulomb_correction();
}
const real_type delta_max
real_type const delta_max
= std::exp((real_type(42.038) - f_z) / real_type(8.29))
- real_type(0.958);
CELER_ASSERT(delta_min <= delta_max);
Expand All @@ -203,15 +203,15 @@ CELER_FUNCTION Interaction BetheHeitlerInteractor::operator()(Engine& rng)
// sections, an additional constraint that \epsilon > \epsilon_1 is
// introduced, where \epsilon_1 is the solution to
// \Phi(\delta(\epsilon)) - F(Z)/2 = 0.
const real_type epsilon1
real_type const epsilon1
= half - half * std::sqrt(1 - delta_min / delta_max);
const real_type epsilon_min = celeritas::max(epsilon0_, epsilon1);
real_type const epsilon_min = celeritas::max(epsilon0_, epsilon1);

// Decide to choose f1, g1 or f2, g2 based on N1, N2 (factors from
// corrected Bethe-Heitler cross section; c.f. Eq. 6.6 of Geant4
// Physics Reference 10.6)
const real_type f10 = this->screening_f1(delta_min) - f_z;
const real_type f20 = this->screening_f2(delta_min) - f_z;
real_type const f10 = this->screening_f1(delta_min) - f_z;
real_type const f20 = this->screening_f2(delta_min) - f_z;
BernoulliDistribution choose_f1g1(ipow<2>(half - epsilon_min) * f10,
real_type(1.5) * f20);

Expand Down

0 comments on commit 0b80505

Please sign in to comment.