Line data Source code
1 : //
2 : // Class Maxwell
3 : // Base class for solvers for Maxwell's equations
4 : //
5 :
6 : #ifndef IPPL_MAXWELL_H
7 : #define IPPL_MAXWELL_H
8 :
9 : #include "Types/Vector.h"
10 :
11 : #include "Field/Field.h"
12 :
13 : #include "Utility/ParameterList.h"
14 : #include "FieldLayout/FieldLayout.h"
15 : #include "Meshes/UniformCartesian.h"
16 :
17 : namespace ippl {
18 :
19 : template <typename EMField, typename SourceField>
20 : class Maxwell {
21 : public:
22 : constexpr static unsigned Dim = EMField::dim;
23 :
24 : /*!
25 : * Default constructor for Maxwell solvers;
26 : */
27 0 : Maxwell() {}
28 :
29 : /*!
30 : * Constructor which allows to initialize the field pointers
31 : * (J, E, B) in the Maxwell solvers class
32 : * @param four_current The four current field (rho, J)
33 : * @param E The electric field
34 : * @param B The magnetic field
35 : */
36 0 : Maxwell(SourceField& four_current, EMField& E, EMField& B) {
37 0 : setSources(four_current);
38 0 : setEMFields(E, B);
39 0 : }
40 :
41 : /*!
42 : * Set the problem RHS (charge & current densities)
43 : * @param four_current The four current field (rho, J)
44 : */
45 0 : virtual void setSources(SourceField& four_current) { JN_mp = &four_current; }
46 :
47 : /*!
48 : * Set the problem LHS (electromagnetic fields)
49 : * @param E The electric field
50 : * @param B The magnetic field
51 : */
52 0 : void setEMFields(EMField& E, EMField& B) {
53 0 : En_mp = &E;
54 0 : Bn_mp = &B;
55 0 : }
56 :
57 :
58 : /*!
59 : * Merges another parameter set into the solver's parameters, overwriting
60 : * existing parameters in case of conflict
61 : * @param params Parameter list with desired values
62 : */
63 0 : void mergeParameters(const ParameterList& params) { params_m.merge(params); }
64 :
65 : /*!
66 : * Solve the electromagnetic problem (Maxwell's eqs)
67 : */
68 : virtual void solve() = 0;
69 :
70 0 : virtual ~Maxwell() {}
71 :
72 : protected:
73 : // Parameters
74 : ParameterList params_m;
75 :
76 : // Field for four-current (rho, J)
77 : SourceField* JN_mp = nullptr;
78 :
79 : // E and B fields
80 : EMField* En_mp = nullptr;
81 : EMField* Bn_mp = nullptr;
82 : };
83 : } // namespace ippl
84 :
85 : #endif
|