Skip to content

Commit

Permalink
Fix bug in check for invalid sources at r=0 in cylindrical coordina…
Browse files Browse the repository at this point in the history
…tes (#2459)

* Fix bug in check for invalid sources at r=0 in cylindrical coordinates

* fix precommit errors
  • Loading branch information
oskooi authored Apr 5, 2023
1 parent 1fe3899 commit b481302
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,23 @@ static void src_vol_chunkloop(fields_chunk *fc, int ichunk, component c, ivec is

// check for invalid sources at r=0 in cylindrical coordinates
if (fc->gv.dim == Dcyl && loc.r() == 0 && amps_array[idx_vol] != 0.0) {
if (fc->m == 0 && (component_direction(c) == R || component_direction(c) == P))
meep::abort("Not possible to place a %s source at r=0 in "
"cylindrical coordinates for m = 0.",
component_name(c));
else if (fabs(fc->m) == 1.0 && component_direction(c) == Z)
meep::abort("Not possible to place a %s source at r=0 in "
"cylindrical coordinates for |m| = 1.0.",
component_name(c));
else
if (fc->m == 0) {
if (component_direction(c) == R || component_direction(c) == P)
meep::abort("Not possible to place a %s source at r=0 in "
"cylindrical coordinates for m = 0.",
component_name(c));
}
else if (fabs(fc->m) == 1.0) {
if (component_direction(c) == Z)
meep::abort("Not possible to place a %s source at r=0 in "
"cylindrical coordinates for |m| = 1.0.",
component_name(c));
}
else {
meep::abort("Not possible to place a source at r=0 in "
"cylindrical coordinates for m = %g.",
fc->m);
}
}

/* for "D" sources, multiply by epsilon. FIXME: this is not quite
Expand Down

0 comments on commit b481302

Please sign in to comment.