OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
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
36template <typename FieldFunction, typename... Arguments>
37class Stepper {
38public:
39 Stepper(const FieldFunction& fieldfunc) : fieldfunc_m(fieldfunc) {}
40
41 virtual bool advance(
42 PartBunch_t* bunch, const size_t& i, const double& t, const double dt,
43 Arguments&... args) const {
44 bool isGood = doAdvance_m(bunch, i, t, dt, args...);
45
46 bool isNaN = false;
47 for (int j = 0; j < 3; ++j) {
48 // \todo if (std::isnan(bunch->R(i)[j]) || std::isnan(bunch->P(i)[j])
49 // || std::abs(bunch->R(i)[j]) > 1.0e10 || std::abs(bunch->P(i)[j]) > 1.0e10) {
50 // isNaN = true;
51 // break;
52 // }
53 }
54
55 bool isBad = (!isGood || isNaN);
56 if (isBad) {
57 // \todo bunch->Bin(i) = -1;
58 }
59 return isBad;
60 };
61 virtual ~Stepper() {};
62
63protected:
64 const FieldFunction& fieldfunc_m;
65
66private:
67 virtual bool doAdvance_m(
68 PartBunch_t* bunch, const size_t& i, const double& t, const double dt,
69 Arguments&... args) const = 0;
70};
71
72#endif
Template PIC bunch: IPPL PicManager, shared field mesh/solver, and multiple particle containers.
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:64
virtual bool advance(PartBunch_t *bunch, const size_t &i, const double &t, const double dt, Arguments &... args) const
Definition Stepper.h:41
virtual ~Stepper()
Definition Stepper.h:61