Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Aug 30, 2023
1 parent 3f5debe commit 3e80450
Show file tree
Hide file tree
Showing 34 changed files with 101 additions and 134 deletions.
18 changes: 9 additions & 9 deletions src/initialization/InitAmrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace details
default_init_AMReX();
}

amrex::ParmParse pp_amr("amr");
amrex::ParmParse const pp_amr("amr");

amrex::Vector<int> n_cell(AMREX_SPACEDIM);
bool const has_ncell = pp_amr.queryarr("n_cell", n_cell);
Expand All @@ -86,18 +86,18 @@ namespace details
AmrCoreData
amrex_amrcore_gridding ()
{
amrex::ParmParse pp_amr("amr");
amrex::ParmParse const pp_amr("amr");

// Domain index space - we use temporary values here, then fix later
amrex::Vector<int> n_cell = {AMREX_D_DECL(256,256,256)};
amrex::Box domain(amrex::IntVect(0), amrex::IntVect(n_cell));
amrex::Vector<int> const n_cell = {AMREX_D_DECL(256,256,256)};
amrex::Box const domain(amrex::IntVect(0), amrex::IntVect(n_cell));

// Domain physical size
// we might resize this dynamically
auto rb = details::init_physical_domain();

// Periodicity (none)
amrex::Array<int, AMREX_SPACEDIM> is_periodic{AMREX_D_DECL(0,0,0)};
amrex::Array<int, AMREX_SPACEDIM> const is_periodic{AMREX_D_DECL(0,0,0)};

// Mesh-refinement
int max_level = 0;
Expand All @@ -116,21 +116,21 @@ namespace details
const int nprocs = amrex::ParallelDescriptor::NProcs();
const amrex::IntVect high_end = amr_info.blocking_factor[0]
* amrex::IntVect(AMREX_D_DECL(nprocs,1,1)) - amrex::IntVect(1);
amrex::Box domain(amrex::IntVect(0), high_end);
amrex::Box const domain(amrex::IntVect(0), high_end);
// adding amr.n_cell for consistency
amrex::ParmParse pp_amr("amr");
auto const n_cell_iv = domain.size();
amrex::Vector<int> n_cell_v(n_cell_iv.begin(), n_cell_iv.end());
amrex::Vector<int> const n_cell_v(n_cell_iv.begin(), n_cell_iv.end());
pp_amr.addarr("n_cell", n_cell_v);

// Domain physical size
// we might resize this dynamically
auto rb = details::init_physical_domain();

// Periodicity (none)
amrex::Array<int, AMREX_SPACEDIM> is_periodic{AMREX_D_DECL(0,0,0)};
amrex::Array<int, AMREX_SPACEDIM> const is_periodic{AMREX_D_DECL(0,0,0)};

amrex::Geometry geom(domain, rb, amrex::CoordSys::cartesian, is_periodic);
amrex::Geometry const geom(domain, rb, amrex::CoordSys::cartesian, is_periodic);
return {geom, amr_info};
}
} // namespace impactx::initialization
2 changes: 1 addition & 1 deletion src/initialization/InitElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace detail
* @param[in] nslice_default
* @param[in] mapsteps_default
*/
void read_element (std::string element_name,
void read_element (const std::string& element_name,
std::list<KnownElements> & m_lattice,
int nslice_default,
int mapsteps_default)
Expand Down
2 changes: 1 addition & 1 deletion src/initialization/InitMeshRefinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace impactx
};

// charge (rho) mesh
amrex::BoxArray const cba = ba;
amrex::BoxArray const& cba = ba;
// for MR levels (TODO):
//cba.coarsen(refRatio(lev - 1));

Expand Down
4 changes: 2 additions & 2 deletions src/particles/ImpactXParticleContainer.H
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace impactx
* @param refpart reference particle
*/
void
SetRefParticle (RefPart const refpart);
SetRefParticle (RefPart refpart);

/** Get reference particle attributes
*
Expand Down Expand Up @@ -224,7 +224,7 @@ namespace impactx
*
* @param order the order of the particle shape
*/
void SetParticleShape (int const order);
void SetParticleShape (int order);

/** Compute the min and max of the particle position in each dimension
*
Expand Down
6 changes: 3 additions & 3 deletions src/particles/diagnostics/DiagnosticOutput.H
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ namespace impactx::diagnostics
* @param append open a new file with a fresh header (false) or append data to an existing file (true)
*/
void DiagnosticOutput (ImpactXParticleContainer const & pc,
OutputType const otype,
OutputType otype,
std::string file_name,
int const step = 0,
bool const append = false);
int step = 0,
bool append = false);

} // namespace impactx::diagnostics

Expand Down
4 changes: 3 additions & 1 deletion src/particles/diagnostics/DiagnosticOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <AMReX_REAL.H> // for ParticleReal
#include <AMReX_Print.H> // for PrintToFile

#include <utility>


namespace impactx::diagnostics
{
Expand All @@ -33,7 +35,7 @@ namespace impactx::diagnostics
using namespace amrex::literals; // for _rt and _prt

// keep file open as we add more and more lines
amrex::AllPrintToFile file_handler(file_name);
amrex::AllPrintToFile file_handler(std::move(file_name));

// write file header per MPI RANK
if (!append) {
Expand Down
18 changes: 9 additions & 9 deletions src/particles/diagnostics/NonlinearLensInvariants.H
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,16 @@ namespace impactx::diagnostics
using Complex = amrex::GpuComplex<amrex::ParticleReal>;

// convert transverse phase space coordinates to normalized units
amrex::ParticleReal xn = x/(m_cn*sqrt(m_beta));
amrex::ParticleReal yn = y/(m_cn*sqrt(m_beta));
amrex::ParticleReal pxn = px*sqrt(m_beta)/m_cn + m_alpha*x;
amrex::ParticleReal pyn = py*sqrt(m_beta)/m_cn + m_alpha*y;
amrex::ParticleReal const xn = x/(m_cn*sqrt(m_beta));
amrex::ParticleReal const yn = y/(m_cn*sqrt(m_beta));
amrex::ParticleReal const pxn = px*sqrt(m_beta)/m_cn + m_alpha*x;
amrex::ParticleReal const pyn = py*sqrt(m_beta)/m_cn + m_alpha*y;

// assign complex position zeta = x + iy
Complex zeta(xn, yn);
Complex zetaconj(xn, -yn);
Complex re1(1.0_prt, 0.0_prt);
Complex im1(0.0_prt, 1.0_prt);
Complex const zeta(xn, yn);
Complex const zetaconj(xn, -yn);
Complex const re1(1.0_prt, 0.0_prt);
Complex const im1(0.0_prt, 1.0_prt);

// compute croot = sqrt(1-zeta**2)
Complex croot = amrex::pow(zeta, 2);
Expand All @@ -113,7 +113,7 @@ namespace impactx::diagnostics
amrex::ParticleReal Iinv = Ipotential.m_real;

// compute invariants H and I
amrex::ParticleReal Jz = xn*pyn - yn*pxn;
amrex::ParticleReal const Jz = xn*pyn - yn*pxn;
Hinv = (pow(xn,2) + pow(yn,2) + pow(pxn,2) + pow(pyn,2))/2
+ m_tn*Hinv;
Iinv = pow(Jz,2) + pow(pxn,2) + pow(xn,2) + m_tn*Iinv;
Expand Down
7 changes: 2 additions & 5 deletions src/particles/distribution/All.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
#include <variant>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
using KnownDistributions = std::variant<
None, /* must be first, so KnownDistributions creates a default constructor */
Expand All @@ -37,7 +35,6 @@ namespace distribution
Waterbag
>;

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_ALL_H
7 changes: 2 additions & 5 deletions src/particles/distribution/Gaussian.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <cmath>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
struct Gaussian
{
Expand Down Expand Up @@ -112,7 +110,6 @@ namespace distribution
amrex::ParticleReal m_muxpx,m_muypy,m_mutpt; //! correlation length-momentum
};

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_GAUSSIAN
9 changes: 3 additions & 6 deletions src/particles/distribution/KVdist.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <cmath>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
struct KVdist
{
Expand Down Expand Up @@ -94,7 +92,7 @@ namespace distribution
pt = ln1*cos(2_prt*pi*u2);

// Scale to produce the identity covariance matrix:
amrex::ParticleReal c = sqrt(3.0_prt);
amrex::ParticleReal const c = sqrt(3.0_prt);
x = 2_prt*x;
y = 2_prt*y;
t = c*t;
Expand Down Expand Up @@ -125,7 +123,6 @@ namespace distribution
amrex::ParticleReal m_muxpx,m_muypy,m_mutpt; //! correlation length-momentum
};

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_KVDIST
9 changes: 3 additions & 6 deletions src/particles/distribution/Kurth4D.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <cmath>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
struct Kurth4D
{
Expand Down Expand Up @@ -104,7 +102,7 @@ namespace distribution
pt = ln1*cos(2_prt*pi*u2);

// Scale to produce the identity covariance matrix:
amrex::ParticleReal c = sqrt(3.0_prt);
amrex::ParticleReal const c = sqrt(3.0_prt);
x = 2_prt*x;
y = 2_prt*y;
t = c*t;
Expand Down Expand Up @@ -135,7 +133,6 @@ namespace distribution
amrex::ParticleReal m_muxpx,m_muypy,m_mutpt; //! correlation length-momentum
};

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_KURTH4D
9 changes: 3 additions & 6 deletions src/particles/distribution/Kurth6D.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <cmath>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
struct Kurth6D
{
Expand Down Expand Up @@ -110,7 +108,7 @@ namespace distribution
pt = pr*costheta - p2*sintheta;

// Scale to produce the identity covariance matrix:
amrex::ParticleReal c = sqrt(5.0_prt);
amrex::ParticleReal const c = sqrt(5.0_prt);
x = c*x;
y = c*y;
t = c*t;
Expand Down Expand Up @@ -141,7 +139,6 @@ namespace distribution
amrex::ParticleReal m_muxpx,m_muypy,m_mutpt; //! correlation length-momentum
};

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_KURTH6D
7 changes: 2 additions & 5 deletions src/particles/distribution/None.H
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
#include <AMReX_REAL.H>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
struct None
{
Expand Down Expand Up @@ -52,7 +50,6 @@ namespace distribution
}
};

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_NONE
9 changes: 3 additions & 6 deletions src/particles/distribution/Semigaussian.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <cmath>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
struct Semigaussian
{
Expand Down Expand Up @@ -83,7 +81,7 @@ namespace distribution
t = 2_prt*(t-0.5_prt);

// Scale to produce the identity covariance matrix:
amrex::ParticleReal c = sqrt(3.0_prt);
amrex::ParticleReal const c = sqrt(3.0_prt);
x = 2_prt*x;
y = 2_prt*y;
t = c*t;
Expand Down Expand Up @@ -124,7 +122,6 @@ namespace distribution
amrex::ParticleReal m_muxpx,m_muypy,m_mutpt; //! correlation length-momentum
};

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_SEMIGAUSSIAN
7 changes: 2 additions & 5 deletions src/particles/distribution/Triangle.H
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
#include <cmath>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
struct Triangle
{
Expand Down Expand Up @@ -139,7 +137,6 @@ namespace distribution
amrex::ParticleReal m_muxpx, m_muypy, m_mutpt; //! correlation length-momentum
};

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_TRIANGLE
7 changes: 2 additions & 5 deletions src/particles/distribution/Waterbag.H
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
#include <cmath>


namespace impactx
{
namespace distribution
namespace impactx::distribution
{
struct Waterbag
{
Expand Down Expand Up @@ -129,7 +127,6 @@ namespace distribution
amrex::ParticleReal m_muxpx,m_muypy,m_mutpt; //! correlation length-momentum
};

} // namespace distribution
} // namespace impactx
} // namespace impactx::distribution

#endif // IMPACTX_DISTRIBUTION_WATERBAG
6 changes: 3 additions & 3 deletions src/particles/elements/ChrDrift.H
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ namespace impactx
amrex::ParticleReal const t = p.pos(RealAoS::t);

// initialize output values of momenta
amrex::ParticleReal pxout = px;
amrex::ParticleReal pyout = py;
amrex::ParticleReal ptout = pt;
amrex::ParticleReal const pxout = px;
amrex::ParticleReal const pyout = py;
amrex::ParticleReal const ptout = pt;

// length of the current slice
amrex::ParticleReal const slice_ds = m_ds / nslice();
Expand Down
Loading

0 comments on commit 3e80450

Please sign in to comment.