Skip to content

Commit

Permalink
New Element: Marker
Browse files Browse the repository at this point in the history
  • Loading branch information
ax3l committed Sep 18, 2024
1 parent b8345b3 commit a79c984
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/particles/elements/All.H
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "ExactDrift.H"
#include "ExactSbend.H"
#include "Kicker.H"
#include "Marker.H"
#include "Multipole.H"
#include "Empty.H"
#include "NonlinearLens.H"
Expand Down Expand Up @@ -60,6 +61,7 @@ namespace impactx
ExactDrift,
ExactSbend,
Kicker,
Marker,
Multipole,
NonlinearLens,
Programmable,
Expand Down
20 changes: 10 additions & 10 deletions src/particles/elements/Empty.H
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace impactx

/** Push all particles - nothing to do here */
void operator() (
ImpactXParticleContainer & /* pc */,
int /* step */
ImpactXParticleContainer & /* pc */,
int /* step */
) {
// nothing to do
}
Expand All @@ -62,14 +62,14 @@ namespace impactx
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void operator() (
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT x,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT y,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT t,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT px,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT py,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT pt,
[[maybe_unused]] uint64_t & AMREX_RESTRICT idcpu,
[[maybe_unused]] RefPart const & refpart
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT x,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT y,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT t,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT px,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT py,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT pt,
[[maybe_unused]] uint64_t & AMREX_RESTRICT idcpu,
[[maybe_unused]] RefPart const & refpart
) const
{
// nothing to do
Expand Down
84 changes: 84 additions & 0 deletions src/particles/elements/Marker.H
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* Copyright 2022-2023 The Regents of the University of California, through Lawrence
* Berkeley National Laboratory (subject to receipt of any required
* approvals from the U.S. Dept. of Energy). All rights reserved.
*
* This file is part of ImpactX.
*
* Authors: Axel Huebl
* License: BSD-3-Clause-LBNL
*/
#ifndef IMPACTX_ELEMENT_MARKER_H
#define IMPACTX_ELEMENT_MARKER_H

#include "particles/ImpactXParticleContainer.H"
#include "mixin/thin.H"
#include "mixin/nofinalize.H"

#include <AMReX_Extension.H>
#include <AMReX_REAL.H>


namespace impactx
{
struct Marker
: public elements::Thin,
public elements::NoFinalize
{
static constexpr auto name = "Marker";
using PType = ImpactXParticleContainer::ParticleType;

/** This element does nothing.
*/
Marker ()
{
}

/** Push all particles - nothing to do here */
void operator() (
ImpactXParticleContainer & /* pc */,
int /* step */
) {
// nothing to do
}

/** Push all particles - nothing to do here */
void operator() (
ImpactXParticleContainer::iterator & /* pti */,
RefPart & AMREX_RESTRICT /* ref_part */
) {
// nothing to do
}

/** Does nothing to a particle.
*
* @param x particle position in x
* @param y particle position in y
* @param t particle position in t
* @param px particle momentum in x
* @param py particle momentum in y
* @param pt particle momentum in t
* @param idcpu particle global index (unused)
* @param refpart reference particle
*/
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
void operator() (
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT x,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT y,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT t,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT px,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT py,
[[maybe_unused]] amrex::ParticleReal & AMREX_RESTRICT pt,
[[maybe_unused]] uint64_t & AMREX_RESTRICT idcpu,
[[maybe_unused]] RefPart const & refpart
) const
{
// nothing to do
}

/** This pushes the reference particle. */
using Thin::operator();
};

} // namespace impactx

#endif // IMPACTX_ELEMENT_MARKER_H
21 changes: 17 additions & 4 deletions src/python/elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,18 +730,31 @@ void init_elements(py::module& m)
;
register_beamoptics_push(py_Multipole);

py::class_<Empty, elements::Thin> py_None(me, "Empty");
py_None
py::class_<Empty, elements::Thin> py_Empty(me, "Empty");
py_Empty
.def("__repr__",
[](Empty const & /* none */) {
[](Empty const & /* empty */) {
return std::string("<impactx.elements.Empty>");
}
)
.def(py::init<>(),
"This element does nothing."
)
;
register_beamoptics_push(py_None);
register_beamoptics_push(py_Empty);

py::class_<Marker, elements::Thin> py_Marker(me, "Marker");
py_Marker
.def("__repr__",
[](Marker const & /* marker */) {
return std::string("<impactx.elements.Marker>");
}
)
.def(py::init<>(),
"This element does nothing."
)
;
register_beamoptics_push(py_Marker);

py::class_<NonlinearLens, elements::Thin, elements::Alignment> py_NonlinearLens(me, "NonlinearLens");
py_NonlinearLens
Expand Down

0 comments on commit a79c984

Please sign in to comment.