aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/FiniteDifferenceSolver/FiniteDifferenceSolver.H
blob: 98a34e634a5c8b672a1d31c162bcbb7c209111bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef WARPX_FINITE_DIFFERENCE_SOLVER_H_
#define WARPX_FINITE_DIFFERENCE_SOLVER_H_

/**
 * \brief Top-level class for the electromagnetic finite-difference solver
 *
 * TODO
 */
class FiniteDifferenceSolver
{
    public:

        using VectorField = std::array< std::unique_ptr<amrex::MultiFab>, 3 >;
        using ConstVectorField = std::array< std::unique_ptr<amrex::MultiFab const>, 3 >;

        // Constructor
        void FiniteDifferenceSolver::FiniteDifferenceSolver ( std::array<Real,3> cell_size ) {
            // Select algorithm (The choice of algorithm is a runtime option,
            // but we compile code for each algorithm, using templates)
            if (fdtd_algo == MaxwellSolverAlgo::Yee){
                YeeAlgorithm::InitializeStencilCoefficients( cell_size,
                    stencil_coefs_x, stencil_coefs_y, stencil_coefs_z );
            } else if (fdtd_algo == MaxwellSolverAlgo::CKC) {
                CKCAlgorithm::InitializeStencilCoefficients( cell_size,
                    stencil_coefs_x, stencil_coefs_y, stencil_coefs_z );
            } else {
                amrex::Abort("Unknown algorithm");
            }
        };

        void EvolveB ( VectorField Bfield,
                       ConstVectorField Efield,
                       amrex::Real dt ) const;

        };

    private:

        int fdtd_algo;

        amrex::Gpu::ManagedVector<amrex::Real> stencil_coefs_x;
        amrex::Gpu::ManagedVector<amrex::Real> stencil_coefs_y;
        amrex::Gpu::ManagedVector<amrex::Real> stencil_coefs_z;

        template< typename fdtd_algo >
        void EvolveBwithAlgo ( VectorField Bfield,
                               ConstVectorField Efield,
                               amrex::Real dt ) const;

};

#endif // WARPX_FINITE_DIFFERENCE_SOLVER_H_