Skip to content

Commit

Permalink
in unit test, set gaussian source cutoff to 0 due to off-by-1 timeste…
Browse files Browse the repository at this point in the history
…p counter bug
  • Loading branch information
oskooi committed Dec 30, 2021
1 parent 8f1088f commit bb9f34e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
4 changes: 2 additions & 2 deletions python/tests/test_dump_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_load_dump_chunk_layout_sim_3d(self):
def _load_dump_fields_2d(self, single_parallel_file=True):
resolution = 50
cell = mp.Vector3(5, 5)
sources = mp.Source(src=mp.GaussianSource(1, fwidth=0.4), center=mp.Vector3(), component=mp.Ez)
sources = mp.Source(src=mp.GaussianSource(1, fwidth=0.4, cutoff=0), center=mp.Vector3(), component=mp.Ez)
one_by_one = mp.Vector3(1, 1, mp.inf)
geometry = [mp.Block(material=mp.Medium(index=3.2), center=mp.Vector3(), size=one_by_one),
mp.Block(material=mp.Medium(epsilon=13), center=mp.Vector3(1), size=one_by_one)]
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_load_dump_fields_sharded_2d(self):
def _load_dump_fields_3d(self, single_parallel_file=True):
resolution = 15
cell = mp.Vector3(2.6, 2.2, 2.3)
sources = mp.Source(src=mp.GaussianSource(1, fwidth=0.4), center=mp.Vector3(), component=mp.Hx)
sources = mp.Source(src=mp.GaussianSource(1, fwidth=0.4, cutoff=0), center=mp.Vector3(), component=mp.Hx)
one_by_one_by_one = mp.Vector3(1, 1, 1)
geometry = [mp.Block(material=mp.Medium(index=2.4), center=mp.Vector3(), size=one_by_one_by_one),
mp.Block(material=mp.Medium(epsilon=7.9), center=mp.Vector3(1), size=one_by_one_by_one)]
Expand Down
8 changes: 2 additions & 6 deletions src/fields_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,12 @@ void fields::load_fields_chunk_field(h5file *h5f, bool single_parallel_file,
size_t n = num_f[(chunk_i * NUM_FIELD_COMPONENTS + c) * 2 + d];
realnum **f = field_ptr_getter(chunks[i], c, d);
if (n == 0) {
delete[] * f;
delete[] *f;
*f = NULL;
} else {
if (n != ntot)
meep::abort("grid size mismatch %zd vs %zd in fields::load", n, ntot);
if (*f) {
delete[] * f;
*f = NULL;
}
*f = new realnum[ntot];
if (!(*f)) *f = new realnum[ntot];
my_ntot += ntot;
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/structure_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,7 @@ void structure::load(const char *filename, bool single_parallel_file) {
}
else {
if (n != ntot) meep::abort("grid size mismatch %zd vs %zd in structure::load", n, ntot);
if (chunks[i]->chi1inv[c][d]) {
delete[] chunks[i]->chi1inv[c][d];
chunks[i]->chi1inv[c][d] = NULL;
}
chunks[i]->chi1inv[c][d] = new realnum[ntot];
if (!chunks[i]->chi1inv[c][d]) chunks[i]->chi1inv[c][d] = new realnum[ntot];
my_ntot += ntot;
}
}
Expand Down

0 comments on commit bb9f34e

Please sign in to comment.