OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
Stepper.h
Go to the documentation of this file.
1 #ifndef STEPPER_H
2 #define STEPPER_H
3 
5 #include "Algorithms/Vektor.h"
6 
7 #include <functional>
8 
18 template <typename FieldFunction, typename ... Arguments>
19 class Stepper {
20 
21 public:
22 
23  Stepper(const FieldFunction& fieldfunc) : fieldfunc_m(fieldfunc) { }
24 
25  virtual bool advance(PartBunchBase<double, 3>* bunch,
26  const size_t& i,
27  const double& t,
28  const double dt,
29  Arguments& ... args) const
30  {
31  bool isGood = doAdvance_m(bunch, i, t, dt, args...);
32 
33  bool isNaN = false;
34  for (int j = 0; j < 3; ++j) {
35  if (std::isnan(bunch->R[i](j)) ||
36  std::isnan(bunch->P[i](j)) ||
37  std::abs(bunch->R[i](j)) > 1.0e10 ||
38  std::abs(bunch->P[i](j)) > 1.0e10) {
39  isNaN = true;
40  break;
41  }
42  }
43 
44  bool isBad = (!isGood || isNaN);
45  if ( isBad ) {
46  bunch->Bin[i] = -1;
47  }
48  return isBad;
49  };
50  virtual ~Stepper() {};
51 
52 protected:
53  const FieldFunction& fieldfunc_m;
54 
55 private:
56  virtual bool doAdvance_m(PartBunchBase<double, 3>* bunch,
57  const size_t& i,
58  const double& t,
59  const double dt,
60  Arguments& ... args) const = 0;
61 };
62 
63 #endif
ParticleAttrib< Vector_t > P
Stepper(const FieldFunction &fieldfunc)
Definition: Stepper.h:23
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
virtual ~Stepper()
Definition: Stepper.h:50
virtual bool advance(PartBunchBase< double, 3 > *bunch, const size_t &i, const double &t, const double dt, Arguments &...args) const
Definition: Stepper.h:25
const FieldFunction & fieldfunc_m
Definition: Stepper.h:50
T isnan(T x)
isnan function with adjusted return type
Definition: matheval.hpp:74
virtual bool doAdvance_m(PartBunchBase< double, 3 > *bunch, const size_t &i, const double &t, const double dt, Arguments &...args) const =0
ParticleAttrib< int > Bin
ParticlePos_t & R