Skip to content

Commit 68cb024

Browse files
committed
checks_impl: override continuity check at open BC
There was apparently one thing I missed that still used ghost J... The continuity check is definitely worse now, since actual errors might be inadvertently hidden by this approach. However, I'm not a fan of pretending that the ghost current is accurate when it isn't. In particular, current in ghost corners deposited by inflow/outflow is not accurate due to how inter/intrapatch communication works.
1 parent 86ccc73 commit 68cb024

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

src/libpsc/psc_checks/checks_impl.hxx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,23 @@ public:
7171
auto item_divj = Item_divj<MfieldsState>{};
7272

7373
auto rho_p = psc::mflds::interior(grid, item_rho(mprts));
74-
auto divj = psc::mflds::interior(grid, item_divj(mflds));
7574
auto d_rho = rho_p - rho_m_;
75+
76+
auto divj = psc::mflds::interior(grid, item_divj(mflds));
77+
78+
// account for insertion/deletion of incoming/outgoing particles
79+
for (int p = 0; p < grid.n_patches(); p++) {
80+
for (int d = 0; d < 3; d++) {
81+
if (grid.atBoundaryLo(p, d) && grid.bc.fld_lo[d] == BND_FLD_OPEN) {
82+
Int3 r = grid.ldims;
83+
r[d] = 1;
84+
85+
divj.view(_s(0, r[0]), _s(0, r[1]), _s(0, r[2]), 0, p) =
86+
-d_rho.view(_s(0, r[0]), _s(0, r[1]), _s(0, r[2]), 0, p) / grid.dt;
87+
}
88+
}
89+
}
90+
7691
auto dt_divj = grid.dt * divj;
7792

7893
double local_err = gt::norm_linf(d_rho + dt_divj);
@@ -144,14 +159,12 @@ public:
144159
auto rho = psc::mflds::interior(grid, item_rho(mprts));
145160
auto dive = psc::mflds::interior(grid, item_dive(mflds));
146161

162+
// account for virtual charges implied by BCs
147163
for (int p = 0; p < grid.n_patches(); p++) {
148164
for (int d = 0; d < 3; d++) {
149165
if (grid.atBoundaryLo(p, d) &&
150166
(grid.bc.fld_lo[d] == BND_FLD_CONDUCTING_WALL ||
151167
grid.bc.fld_lo[d] == BND_FLD_OPEN)) {
152-
153-
// account for implicit surface charges
154-
155168
Int3 r = grid.ldims;
156169
r[d] = 1;
157170

0 commit comments

Comments
 (0)