17 template <
typename EMField,
typename SourceField, fdtd_bc boundary_conditions>
31 template <
typename EMField,
typename SourceField, fdtd_bc boundary_conditions>
44 template <
typename EMField,
typename SourceField, fdtd_bc boundary_conditions>
47 typename SourceField::BConds_t vector_bcs;
48 auto bcsetter_single = [&vector_bcs]<
size_t Idx>(
const std::index_sequence<Idx>&) {
49 vector_bcs[Idx] = std::make_shared<ippl::PeriodicFace<SourceField>>(Idx);
52 auto bcsetter = [bcsetter_single]<
size_t... Idx>(
const std::index_sequence<Idx...>&) {
53 int x = (bcsetter_single(std::index_sequence<Idx>{}) ^ ...);
56 bcsetter(std::make_index_sequence<Dim * 2>{});
57 A_n.setFieldBC(vector_bcs);
58 A_np1.setFieldBC(vector_bcs);
59 A_nm1.setFieldBC(vector_bcs);
68 template <
typename EMField,
typename SourceField, fdtd_bc boundary_conditions>
71 Kokkos::deep_copy(this->
A_nm1.getView(), this->A_n.getView());
72 Kokkos::deep_copy(this->
A_n.getView(), this->A_np1.getView());
80 template <
typename EMField,
typename SourceField, fdtd_bc boundary_conditions>
82 if constexpr (boundary_conditions ==
periodic) {
83 A_n.getFieldBC().apply(
A_n);
88 true_nr += (
A_n.getNghost() * 2);
90 bcs.
apply(A_n, A_nm1, A_np1, this->dt, true_nr, layout_mp->getLocalNDIndex());
100 template <
typename EMField,
typename SourceField, fdtd_bc boundary_conditions>
115 Kokkos::parallel_for(
116 this->
A_n.getFieldRangePolicy(), KOKKOS_LAMBDA(
size_t i,
size_t j,
size_t k) {
118 dAdt[0] = (
A_np1(i, j, k)[1] -
A_n(i, j, k)[1]) * idt;
119 dAdt[1] = (
A_np1(i, j, k)[2] -
A_n(i, j, k)[2]) * idt;
120 dAdt[2] = (
A_np1(i, j, k)[3] -
A_n(i, j, k)[3]) * idt;
123 (
A_n(i + 1, j, k) -
A_n(i - 1, j, k)) * inverse_2_spacing[0];
125 (
A_n(i, j + 1, k) -
A_n(i, j - 1, k)) * inverse_2_spacing[1];
127 (
A_n(i, j, k + 1) -
A_n(i, j, k - 1)) * inverse_2_spacing[2];
135 Eview(i, j, k) = -dAdt - grad_phi;
136 Bview(i, j, k) = curlA;
void apply(field_type &FA_n, field_type &FA_nm1, field_type &FA_np1, dt_type dt, ippl::Vector< uint32_t, 3 > true_nr, ippl::NDIndex< 3 > lDom)
Applies second-order Mur ABC to the boundaries of the field.
void evaluate_EB()
Evaluates the electric and magnetic fields.
void applyBCs()
Applies the boundary conditions.
void setPeriodicBoundaryConditions()
Sets periodic boundary conditions.
virtual void step()=0
Steps the solver forward in time. This is a pure virtual function.
void solve() override
Solves the FDTD equations.
void timeShift()
Shifts the saved fields in time.
typename EMField::value_type::value_type scalar
FDTDSolverBase(SourceField &source, EMField &E, EMField &B)
Constructor for the FDTDSolverBase class.
void setEMFields(EMField &E, EMField &B)
virtual void setSources(SourceField &four_current)