Skip to content

Commit

Permalink
clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
llibert94 committed Feb 21, 2024
1 parent 2a36db1 commit a483a4e
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 35 deletions.
13 changes: 7 additions & 6 deletions Examples/Fluid_Kerr/Fluxes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ vars_t<data_t> compute_flux(const data_t P_over_rho, const vars_t<data_t> &vars,

data_t WW = 1. / (1. - v2);
data_t hh = 1. + vars.eps + P_over_rho;
data_t rho_conformal = vars.rho / pow(vars.chi, 1.5);

data_t rho_conformal = vars.rho / pow(vars.chi, 1.5);

FOR(j)
{
out.Sj[j] = vars.lapse * rho_conformal * hh * WW * vars.vi[idir] * vi_D[j] -
vars.shift[idir] * vars.Sj[j];
out.Sj[j] =
vars.lapse * rho_conformal * hh * WW * vars.vi[idir] * vi_D[j] -
vars.shift[idir] * vars.Sj[j];
FOR(k)
out.Sj[j] +=
vars.lapse * rho_conformal * P_over_rho * h_UU[idir][k] * vars.h[j][k];
out.Sj[j] += vars.lapse * rho_conformal * P_over_rho * h_UU[idir][k] *
vars.h[j][k];
}

out.tau = vars.lapse * (Sj_U[idir] - vars.D * vars.vi[idir]) -
Expand Down
9 changes: 6 additions & 3 deletions Examples/Fluid_Kerr/PerfectFluid.impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,15 @@ void PerfectFluid<eos_t>::add_matter_rhs(
data_t advec_chi = 0.;
FOR(i) advec_chi += vars.shift[i] * d1.chi[i] / chi_regularised;
rhs.D = source.D /*- vars.D * (vars.lapse * vars.K - divshift +
GR_SPACEDIM / 2. * advec_chi)*/;
GR_SPACEDIM / 2. * advec_chi)*/
;
FOR(i)
rhs.Sj[i] = source.Sj[i] /*- vars.Sj[i] * (vars.lapse * vars.K - divshift +
GR_SPACEDIM / 2. * advec_chi)*/;
GR_SPACEDIM / 2. * advec_chi)*/
;
rhs.tau = source.tau /*- vars.tau * (vars.lapse * vars.K - divshift +
GR_SPACEDIM / 2. * advec_chi)*/;
GR_SPACEDIM / 2. * advec_chi)*/
;
/*FOR(i)
{
vars_t<data_t> flux = Fluxes::compute_flux(P_over_rho, vars, i);
Expand Down
2 changes: 1 addition & 1 deletion Examples/Fluid_Kerr/PerfectFluidLevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void PerfectFluidLevel::specificEvalRHS(GRLevelData &a_soln, GRLevelData &a_rhs,
BoxLoops::loop(make_compute_pack(TraceARemoval(), PositiveDensity(),
PositiveChiAndAlpha(),
PrimitiveRecovery()),
a_soln, a_soln, INCLUDE_GHOST_CELLS/*, disable_simd()*/);
a_soln, a_soln, INCLUDE_GHOST_CELLS /*, disable_simd()*/);

// Calculate MatterCCZ4 right hand side with matter_t = ScalarField
EoS eos(m_p.eos_params);
Expand Down
3 changes: 2 additions & 1 deletion Examples/Fluid_Kerr/PerfectFluidLevel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class PerfectFluidLevel : public GRAMRLevel

//! Things to do in UpdateODE step, after soln + rhs update
virtual void specificUpdateODE(GRLevelData &a_soln,
const GRLevelData &a_rhs, Real a_dt) override;
const GRLevelData &a_rhs,
Real a_dt) override;

/// Things to do before tagging cells (i.e. filling ghosts)
virtual void preTagCells() override;
Expand Down
8 changes: 4 additions & 4 deletions Examples/Fluid_Kerr/PrimitiveRecovery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
#include "CCZ4Geometry.hpp"
#include "Cell.hpp"
#include "DefaultEoS.hpp"
#include "simd.hpp"
#include "Tensor.hpp"
#include "TensorAlgebra.hpp"
#include "UserVariables.hpp"
#include "UsingNamespace.H"
#include "VarsTools.hpp"
#include "simd.hpp"

// template <class eos_t = DefaultEoS>
class PrimitiveRecovery
Expand Down Expand Up @@ -60,10 +60,10 @@ class PrimitiveRecovery

int i = 0;

data_t empty;
while (!simd_all_false(simd_compare_lt(tolerance, diff), empty))
data_t empty;
while (!simd_all_false(simd_compare_lt(tolerance, diff), empty))
{
i++;
i++;
Wa = sqrt(pow(xa, 2.) / (pow(xa, 2.) - r));

vars.rho = pow(vars.chi, 1.5) * vars.D / Wa;
Expand Down
13 changes: 6 additions & 7 deletions Examples/Fluid_Kerr/Sources.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,18 @@ vars_t<data_t> compute_source(const data_t P_over_rho,
out.Sj[j] += vars.lapse / 2. *
(d1.h[i][k][j] -
vars.h[i][k] * d1.chi[j] / chi_regularised) *
(rho_conformal * hh * WW * vars.vi[i] * vars.vi[k] /
chi_regularised +
P_over_rho * h_UU[i][k]);
(rho_conformal * hh * WW * vars.vi[i] *
vars.vi[k] / chi_regularised +
P_over_rho * h_UU[i][k]);
}
}
}
out.tau = 0.;
FOR(i, j)
{
out.tau += vars.lapse *
(vars.A[i][j] + vars.h[i][j] / 3. * vars.K) *
(rho_conformal *
hh * WW * vars.vi[i] * vars.vi[j] / chi_regularised +
out.tau += vars.lapse * (vars.A[i][j] + vars.h[i][j] / 3. * vars.K) *
(rho_conformal * hh * WW * vars.vi[i] * vars.vi[j] /
chi_regularised +
P_over_rho * h_UU[i][j]) -
vars.chi * h_UU[i][j] * vars.Sj[i] * d1.lapse[j];
}
Expand Down
15 changes: 9 additions & 6 deletions Source/simd/arm/neon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ template <> struct simd<double> : public simd_base<double>
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
uint64x2_t high_bits = vshrq_n_u64(input, 63);
//Lanes are indexed like bits (big-endian)
int moved_mask = vgetq_lane_u64(high_bits, 0) | (vgetq_lane_u64(high_bits, 1) << 1);
// Lanes are indexed like bits (big-endian)
int moved_mask =
vgetq_lane_u64(high_bits, 0) | (vgetq_lane_u64(high_bits, 1) << 1);
return moved_mask == 0 ? true : false;
}

Expand Down Expand Up @@ -181,12 +182,14 @@ template <> struct simd<float> : public simd_base<float>
friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
uint32x4_t high_bits = vshrq_n_u32(input, 31);
//Lanes are indexed like bits (big-endian)
int moved_mask = vgetq_lane_u32(high_bits, 0) | (vgetq_lane_u32(high_bits, 1) << 1)
| (vgetq_lane_u32(high_bits, 2) << 2) (vgetq_lane_u32(high_bits, 3) << 3);
// Lanes are indexed like bits (big-endian)
int moved_mask = vgetq_lane_u32(high_bits, 0) |
(vgetq_lane_u32(high_bits, 1) << 1) |
(vgetq_lane_u32(high_bits, 2)
<< 2)(vgetq_lane_u32(high_bits, 3) << 3);
return moved_mask == 0 ? true : false;
}

friend ALWAYS_INLINE simd simd_sqrt(const simd &a) { return vsqrtq_f32(a); }
};

Expand Down
6 changes: 4 additions & 2 deletions Source/simd/arm/sve.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ template <> struct simd<double> : public simd_base<double>

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
//Would be nice to implement a movemask here, for extensions to lane-specific info
// Would be nice to implement a movemask here, for extensions to
// lane-specific info
return !svptest_any(svptrue_b64(), cond);
}

Expand Down Expand Up @@ -214,7 +215,8 @@ template <> struct simd<float> : public simd_base<float>

friend ALWAYS_INLINE bool simd_all_false(const mask_t cond, const simd &b)
{
//Would be nice to implement a movemask here, for extensions to lane-specific info
// Would be nice to implement a movemask here, for extensions to
// lane-specific info
return !svptest_any(svptrue_b32(), cond);
}

Expand Down
8 changes: 3 additions & 5 deletions Source/simd/simd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ template <typename t> struct simd
return (a > b) ? a : b;
}

friend ALWAYS_INLINE bool simd_all_false(const bool cond)
{
return !cond;
}
friend ALWAYS_INLINE bool simd_all_false(const bool cond) { return !cond; }
};

// Define all the simd-functions whose implementation does not depend on the
Expand Down Expand Up @@ -176,7 +173,8 @@ template <typename t> ALWAYS_INLINE t simd_max(const t &a, const t &b)
}

// Here, t is some simd variable
template <typename t> ALWAYS_INLINE bool simd_all_false(const bool cond, const t &b)
template <typename t>
ALWAYS_INLINE bool simd_all_false(const bool cond, const t &b)
{
return !cond;
}
Expand Down

0 comments on commit a483a4e

Please sign in to comment.