Skip to content

Commit

Permalink
IVEC_LOOP_COUNTER macro
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengj committed Jul 8, 2021
1 parent f5d61dd commit 73154b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ void dft_chunk::update_dft(double time) {
int numcmp = fc->f[c][1] ? 2 : 1;

PLOOP_OVER_IVECS(fc->gv, is, ie, idx) {
size_t idx_dft = (loop_i1 * loop_n2 + loop_i2) * loop_n3 + loop_i3;
size_t idx_dft = IVEC_LOOP_COUNTER;
double w;
if (include_dV_and_interp_weights) {
w = IVEC_LOOP_WEIGHT(s0, s1, e0, e1, dV0 + dV1 * loop_i2);
Expand Down
3 changes: 3 additions & 0 deletions src/meep/vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,9 @@ _Pragma("omp parallel for collapse(2)")
(IVEC_LOOP_WEIGHT1(s0, s1, e0, e1, 3) * \
(IVEC_LOOP_WEIGHT1(s0, s1, e0, e1, 2) * ((dV)*IVEC_LOOP_WEIGHT1(s0, s1, e0, e1, 1))))

// equivalent to incrementing a counter, starting from 0, in the loop body
#define IVEC_LOOP_COUNTER ((loop_i1 * loop_n2 + loop_i2) * loop_n3 + loop_i3)

inline signed_direction flip(signed_direction d) {
signed_direction d2 = d;
d2.flipped = !d.flipped;
Expand Down

0 comments on commit 73154b4

Please sign in to comment.