IPPL API Reference
Independent Parallel Particle Layer C++ API
Loading...
Searching...
No Matches
FDTDSolverBase.h
1#ifndef IPPL_FDTD_H
2#define IPPL_FDTD_H
3#include <cstddef>
4using std::size_t;
5#include "Types/Vector.h"
6
7#include "FieldLayout/FieldLayout.h"
8#include "MaxwellSolvers/AbsorbingBC.h"
9#include "MaxwellSolvers/Maxwell.h"
10#include "Meshes/UniformCartesian.h"
11#include "Particle/ParticleBase.h"
12
13namespace ippl {
14 enum fdtd_bc {
15 periodic,
16 absorbing
17 };
18
27 template <typename EMField, typename SourceField, fdtd_bc boundary_conditions>
28 class FDTDSolverBase : public Maxwell<EMField, SourceField> {
29 public:
30 constexpr static unsigned Dim = EMField::dim;
31 using scalar = typename EMField::value_type::value_type;
33 using SourceVector_t = typename SourceField::value_type;
34
42 FDTDSolverBase(SourceField& source, EMField& E, EMField& B);
43
47 void solve() override;
48
53
59 scalar getDt() const { return dt; }
60
61 SourceField A_n; // Current field.
62 SourceField A_np1; // Field at the next time step.
63 SourceField A_nm1; // Field at the previous time step.
64
68 void timeShift();
69
73 virtual void step() = 0;
77 void evaluate_EB();
78
82 virtual void initialize() = 0;
83
84 protected:
88 void applyBCs();
89
90 typename SourceField::Mesh_t* mesh_mp; // Pointer to the mesh.
91 FieldLayout<Dim>* layout_mp; // Pointer to the layout
92 NDIndex<Dim> domain_m; // Domain of the mesh.
93 Vector_t hr_m; // Mesh spacing.
94
95 Vector<int, Dim> nr_m; // Number of grid points in each direction.
96 scalar dt; // Time step size.
97 };
98} // namespace ippl
99
100#include "FDTDSolverBase.hpp"
101#endif
Base class for FDTD solvers in the ippl library.
Definition FDTDSolverBase.h:28
void evaluate_EB()
Evaluates the electric and magnetic fields.
Definition FDTDSolverBase.hpp:92
void applyBCs()
Applies the boundary conditions.
Definition FDTDSolverBase.hpp:72
virtual void initialize()=0
Initializes the solver. This is a pure virtual function.
void setPeriodicBoundaryConditions()
Sets periodic boundary conditions.
Definition FDTDSolverBase.hpp:37
scalar getDt() const
Gets the time step size.
Definition FDTDSolverBase.h:59
virtual void step()=0
Steps the solver forward in time. This is a pure virtual function.
void solve() override
Solves the FDTD equations.
Definition FDTDSolverBase.hpp:23
void timeShift()
Shifts the saved fields in time.
Definition FDTDSolverBase.hpp:60
Definition FieldLayout.h:166
Definition Maxwell.h:20
Definition NDIndex.h:21
Definition Archive.h:20