LCOV - code coverage report
Current view: top level - src/MaxwellSolvers - FDTDSolverBase.h (source / functions) Coverage Total Hit
Test: report.info Lines: 0.0 % 1 0
Test Date: 2025-06-27 19:43:11 Functions: 0.0 % 1 0

            Line data    Source code
       1              : #ifndef IPPL_FDTD_H
       2              : #define IPPL_FDTD_H
       3              : #include <cstddef>
       4              : using 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              : 
      13              : namespace ippl {
      14              :     enum fdtd_bc {
      15              :         periodic,
      16              :         absorbing
      17              :     };
      18              : 
      19              :     /**
      20              :      * @class FDTDSolverBase
      21              :      * @brief Base class for FDTD solvers in the ippl library.
      22              :      *
      23              :      * @tparam EMField The type representing the electromagnetic field.
      24              :      * @tparam SourceField The type representing the source field.
      25              :      * @tparam boundary_conditions The boundary conditions to be applied (default is periodic).
      26              :      */
      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;
      32              :         using Vector_t                = Vector<typename EMField::value_type::value_type, Dim>;
      33              :         using SourceVector_t          = typename SourceField::value_type;
      34              : 
      35              :         /**
      36              :          * @brief Constructor for the FDTDSolverBase class.
      37              :          *
      38              :          * @param source Reference to the source field.
      39              :          * @param E Reference to the electric field.
      40              :          * @param B Reference to the magnetic field.
      41              :          */
      42              :         FDTDSolverBase(SourceField& source, EMField& E, EMField& B);
      43              : 
      44              :         /**
      45              :          * @brief Solves the FDTD equations.
      46              :          */
      47              :         void solve() override;
      48              : 
      49              :         /**
      50              :          * @brief Sets periodic boundary conditions.
      51              :          */
      52              :         void setPeriodicBoundaryConditions();
      53              : 
      54              :         /**
      55              :          * @brief Gets the time step size.
      56              :          *
      57              :          * @return The time step size.
      58              :          */
      59            0 :         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              : 
      65              :         /**
      66              :          * @brief Shifts the saved fields in time.
      67              :          */
      68              :         void timeShift();
      69              : 
      70              :         /**
      71              :          * @brief Steps the solver forward in time. This is a pure virtual function.
      72              :          */
      73              :         virtual void step() = 0;
      74              :         /**
      75              :          * @brief Evaluates the electric and magnetic fields.
      76              :          */
      77              :         void evaluate_EB();
      78              :     
      79              :         /**
      80              :          * @brief Initializes the solver. This is a pure virtual function.
      81              :          */
      82              :         virtual void initialize() = 0;
      83              : 
      84              :     protected:
      85              :         /**
      86              :          * @brief Applies the boundary conditions.
      87              :          */
      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
        

Generated by: LCOV version 2.0-1