Skip to content

Commit

Permalink
check is_D for FourierFields adjoint (#2085)
Browse files Browse the repository at this point in the history
* Update dft.cpp

* is_E_or_D and is_H_or_B

* Update dft.cpp

* typo

* typo

* Update src/meep/vec.hpp

Co-authored-by: Steven G. Johnson <stevenj@mit.edu>
  • Loading branch information
mochen4 and stevengj authored May 27, 2022
1 parent 0d89d88 commit 543e8e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,7 @@ std::vector<struct sourcedata> dft_fields::fourier_sourcedata(const volume &wher
temp_struct.idx_arr.push_back(idx);
for (size_t i = 0; i < Nfreq; ++i) {
EH0 = dJ_weight*dJ[reduced_grid_size*i+idx_1d];
if (is_electric(temp_struct.near_fd_comp)) EH0 *= -1;
if (is_E_or_D(temp_struct.near_fd_comp)) EH0 *= -1;
EH0 /= f->S.multiplicity(ix0);
temp_struct.amp_arr.push_back(EH0);
}
Expand All @@ -1503,7 +1503,7 @@ std::vector<struct sourcedata> dft_fields::fourier_sourcedata(const volume &wher
temp_struct.idx_arr.push_back(site_ind[j]);
for (size_t i = 0; i < Nfreq; ++i) {
EH0 = dJ_weight*dJ[reduced_grid_size*i+idx_1d]*0.25; // split the amplitude of the adjoint source into four parts
if (is_electric(temp_struct.near_fd_comp)) EH0 *= -1;
if (is_E_or_D(temp_struct.near_fd_comp)) EH0 *= -1;
EH0 /= f->S.multiplicity(ix0);
temp_struct.amp_arr.push_back(EH0);
}
Expand Down
2 changes: 2 additions & 0 deletions src/meep/vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ inline bool is_electric(component c) { return c < Hx; }
inline bool is_magnetic(component c) { return c >= Hx && c < Dx; }
inline bool is_D(component c) { return c >= Dx && c < Bx; }
inline bool is_B(component c) { return c >= Bx && c < Dielectric; }
inline bool is_E_or_D(component c) {return is_electric(c) || is_D(c); }
inline bool is_H_or_B(component c) {return is_magnetic(c) || is_B(c); }
inline bool is_derived(int c) { return c >= Sx; }
inline bool is_poynting(derived_component c) { return c < EnergyDensity; }
inline bool is_energydensity(derived_component c) { return c >= EnergyDensity; }
Expand Down

0 comments on commit 543e8e7

Please sign in to comment.