OPALX (Object Oriented Parallel Accelerator Library for Exascal) MINIorX
OPALX
Stepper.h
Go to the documentation of this file.
1//
2// Class Stepper
3// Time integrator base class
4//
5// Copyright (c) 2017, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18#ifndef STEPPER_H
19#define STEPPER_H
20
21#include "OPALTypes.h"
22
23#include "PartBunch/PartBunch.h"
24
25#include <functional>
26
35
36template <typename FieldFunction, typename... Arguments>
37class Stepper {
38public:
39 Stepper(const FieldFunction& fieldfunc) : fieldfunc_m(fieldfunc) {
40 }
41
42 virtual bool advance(
43 PartBunch_t* bunch, const size_t& i, const double& t, const double dt,
44 Arguments&... args) const {
45 bool isGood = doAdvance_m(bunch, i, t, dt, args...);
46
47 bool isNaN = false;
48 for (int j = 0; j < 3; ++j) {
49 // \todo if (std::isnan(bunch->R(i)[j]) || std::isnan(bunch->P(i)[j])
50 // || std::abs(bunch->R(i)[j]) > 1.0e10 || std::abs(bunch->P(i)[j]) > 1.0e10) {
51 // isNaN = true;
52 // break;
53 // }
54 }
55
56 bool isBad = (!isGood || isNaN);
57 if (isBad) {
58 // \todo bunch->Bin(i) = -1;
59 }
60 return isBad;
61 };
62 virtual ~Stepper(){};
63
64protected:
65 const FieldFunction& fieldfunc_m;
66
67private:
68 virtual bool doAdvance_m(
69 PartBunch_t* bunch, const size_t& i, const double& t, const double dt,
70 Arguments&... args) const = 0;
71};
72
73#endif
PartBunch< PLayout_t< double, 3 >, double, 3 > PartBunch_t
virtual bool doAdvance_m(PartBunch_t *bunch, const size_t &i, const double &t, const double dt, Arguments &... args) const =0
Stepper(const FieldFunction &fieldfunc)
Definition Stepper.h:39
const FieldFunction & fieldfunc_m
Definition Stepper.h:65
virtual bool advance(PartBunch_t *bunch, const size_t &i, const double &t, const double dt, Arguments &... args) const
Definition Stepper.h:42
virtual ~Stepper()
Definition Stepper.h:62