Skip to content

Commit f781521

Browse files
committed
Address code review feedback
- iterative.hpp: Add epsilon to Z_L/Z_R denominators to prevent division by zero - Solver.cpp: Add explicit error for unsupported BC types (ShearingPeriodic)
1 parent 94a97e3 commit f781521

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/shammodels/gsph/include/shammodels/gsph/math/riemann/iterative.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,13 @@ namespace shammodels::gsph::riemann {
122122

123123
// Derivatives dW/dp for Newton-Raphson
124124
// Z_L = -dW_L/dp * W_L (note the sign convention)
125+
// Add smallp to denominator to prevent division by zero near vacuum/shock
125126
Tscal Z_L = Tscal{4} * V_L * W_L * W_L;
126-
Z_L = -Z_L * W_L / (Z_L - gp1 * (p_star - p_L));
127+
Z_L = -Z_L * W_L / (Z_L - gp1 * (p_star - p_L) + smallp);
127128

128129
// Z_R = dW_R/dp * W_R
129130
Tscal Z_R = Tscal{4} * V_R * W_R * W_R;
130-
Z_R = Z_R * W_R / (Z_R - gp1 * (p_star - p_R));
131+
Z_R = Z_R * W_R / (Z_R - gp1 * (p_star - p_R) + smallp);
131132

132133
// Intermediate velocities from each side
133134
// u*_L = u_L - (p* - p_L) / W_L

src/shammodels/gsph/src/Solver.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ void shammodels::gsph::Solver<Tvec, Kern>::gen_ghost_handler(Tscal time_val) {
132132
SolverBCPeriodic *c
133133
= std::get_if<SolverBCPeriodic>(&solver_config.boundary_config.config)) {
134134
storage.ghost_handler.set(GhostHandle{scheduler(), BCPeriodic{}, storage.patch_rank_owner});
135+
} else {
136+
// ShearingPeriodic and other BC types not yet supported in GSPH
137+
shambase::throw_with_loc<std::runtime_error>(
138+
"GSPH: Unsupported boundary condition type. Only Free and Periodic are supported.");
135139
}
136140
}
137141

@@ -481,6 +485,10 @@ void shammodels::gsph::Solver<Tvec, Kern>::apply_position_boundary(Tscal time_va
481485
SolverBCPeriodic *c
482486
= std::get_if<SolverBCPeriodic>(&solver_config.boundary_config.config)) {
483487
integrators.fields_apply_periodicity(ixyz, std::pair{bmin, bmax});
488+
} else {
489+
// ShearingPeriodic and other BC types not yet supported in GSPH
490+
shambase::throw_with_loc<std::runtime_error>(
491+
"GSPH: Unsupported boundary condition type. Only Free and Periodic are supported.");
484492
}
485493

486494
reatrib.reatribute_patch_objects(storage.serial_patch_tree.get(), "xyz");

0 commit comments

Comments
 (0)