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 
81  void
82  finalize ();
83 
84  amrex::ParticleReal m_ds = 0.0;
85  int m_nslice = 1;
86 
94  bool m_threadsafe = false;
95 
96  std::function<void(ImpactXParticleContainer *, int)> m_push;
98  std::function<void(RefPart &)> m_ref_particle;
99  std::function<void()> m_finalize;
100  };
101 
102 } // namespace impactx
103 
104 #endif // IMPACTX_ELEMENTS_PROGRAMMABLE_H
#define AMREX_FORCE_INLINE
#define AMREX_GPU_HOST_DEVICE
Definition: ImpactXParticleContainer.H:138
Definition: ImpactXParticleContainer.H:107
Definition: ImpactX.cpp:32
Definition: Programmable.H:25
std::function< void(ImpactXParticleContainer::iterator *, RefPart &)> m_beam_particles
hook for push of whole container
Definition: Programmable.H:97
void finalize()
Definition: Programmable.cpp:56
ImpactXParticleContainer::ParticleType PType
Definition: Programmable.H:27
static constexpr auto name
Definition: Programmable.H:26
int m_nslice
segment length in m
Definition: Programmable.H:85
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition: Programmable.H:74
amrex::ParticleReal m_ds
Definition: Programmable.H:84
Programmable(amrex::ParticleReal ds=0.0, int nslice=1)
Definition: Programmable.H:31
std::function< void(RefPart &)> m_ref_particle
hook for beam particles
Definition: Programmable.H:98
bool m_threadsafe
number of slices used for the application of space charge
Definition: Programmable.H:94
std::function< void(ImpactXParticleContainer *, int)> m_push
Definition: Programmable.H:96
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition: Programmable.H:64
void operator()(ImpactXParticleContainer &pc, int step) const
Definition: Programmable.cpp:18
std::function< void()> m_finalize
hook for reference particle
Definition: Programmable.H:99
Definition: ReferenceParticle.H:30