ImpactX
Programmable.H
Go to the documentation of this file.
1 /* Copyright 2022-2023 The Regents of the University of California, through Lawrence
2  * Berkeley National Laboratory (subject to receipt of any required
3  * approvals from the U.S. Dept. of Energy). All rights reserved.
4  *
5  * This file is part of ImpactX.
6  *
7  * Authors: Axel Huebl
8  * License: BSD-3-Clause-LBNL
9  */
10 #ifndef IMPACTX_ELEMENTS_PROGRAMMABLE_H
11 #define IMPACTX_ELEMENTS_PROGRAMMABLE_H
12 
13 #include "mixin/thick.H"
15 
16 #include <AMReX_Extension.H>
17 #include <AMReX_REAL.H>
18 
19 #include <functional>
20 
21 
22 namespace impactx
23 {
24  struct Programmable
25  {
26  static constexpr auto name = "Programmable";
28 
31  Programmable (amrex::ParticleReal ds=0.0, int nslice=1)
32  : m_ds(ds), m_nslice(nslice)
33  {}
34 
40  void operator() (
42  int step
43  ) const;
44 
46  void operator() (
48  RefPart & ref_part
49  ) const;
50 
55  void operator() (
56  RefPart & refpart
57  ) const;
58 
64  int nslice () const
65  {
66  return m_nslice;
67  }
68 
74  amrex::ParticleReal ds () const
75  {
76  return m_ds;
77  }
78 
79  public:
80  amrex::ParticleReal m_ds = 0.0;
81  int m_nslice = 1;
82 
90  bool m_threadsafe = false;
91 
92  std::function<void(ImpactXParticleContainer *, int)> m_push;
93  std::function<void(ImpactXParticleContainer::iterator *, RefPart &)> m_beam_particles;
94  std::function<void(RefPart &)> m_ref_particle;
95  };
96 
97 } // namespace impactx
98 
99 #endif // IMPACTX_ELEMENTS_PROGRAMMABLE_H
Definition: ImpactXParticleContainer.H:95
Definition: ImpactX.cpp:31
Definition: Programmable.H:24
amrex::ParticleReal m_ds
Definition: Programmable.H:80
static constexpr auto name
Definition: Programmable.H:26
bool m_threadsafe
number of slices used for the application of space charge
Definition: Programmable.H:90
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition: Programmable.H:64
int m_nslice
segment length in m
Definition: Programmable.H:81
#define AMREX_FORCE_INLINE
void operator()(ImpactXParticleContainer &pc, int step) const
Definition: Programmable.cpp:18
#define AMREX_GPU_HOST_DEVICE
std::function< void(ImpactXParticleContainer *, int)> m_push
Definition: Programmable.H:92
std::function< void(ImpactXParticleContainer::iterator *, RefPart &)> m_beam_particles
hook for push of whole container
Definition: Programmable.H:93
Definition: ReferenceParticle.H:29
Programmable(amrex::ParticleReal ds=0.0, int nslice=1)
Definition: Programmable.H:31
Definition: ImpactXParticleContainer.H:126
std::function< void(RefPart &)> m_ref_particle
hook for beam particles
Definition: Programmable.H:94
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition: Programmable.H:74