Validate a route against its local claimed bin(s), without searching.
240 !amrex::Math::isfinite(plan.packet_number) ||
241 !amrex::Math::isfinite(plan.packet_particle_mass) ||
243 plan.destination_count < 0 || plan.destination_count > 2 ||
245 plan.residual_number_weight >
amrex::Real(1.0))
return false;
248 return plan.status == RemapStatus::Ok && plan.destination_count == 0 &&
250 !plan.normalized_roundoff;
253 if (population.moment_mode == MomentMode::TwoMoment) {
254 if (plan.packet_particle_mass ==
amrex::Real(0.0)) {
255 return plan.status == RemapStatus::ZeroWaterResidual &&
256 plan.destination_count == 0 &&
258 !plan.normalized_roundoff;
261 const amrex::Real top = population.edges[population.nbins];
262 int required_bin = -1;
263 amrex::Real expected_mass = plan.packet_particle_mass;
264 bool normalized =
false;
265 if (plan.packet_particle_mass < lower) {
268 expected_mass = lower;
270 }
else if (plan.packet_particle_mass > top) {
272 required_bin = population.nbins - 1;
276 if (plan.status != RemapStatus::Ok || plan.destination_count != 1 ||
278 plan.normalized_roundoff != normalized)
return false;
279 const auto& route = plan.destinations[0];
280 return (required_bin < 0 || route.bin == required_bin) &&
282 route.particle_mass == expected_mass && route.bin >= 0 &&
283 route.bin < population.nbins && expected_mass >= population.edges[route.bin] &&
284 (expected_mass < population.edges[route.bin + 1] ||
285 (route.bin == population.nbins - 1 &&
286 expected_mass <= population.edges[route.bin + 1]));
290 const amrex::Real last = population.pivots[population.nbins - 1];
291 if (plan.packet_particle_mass ==
amrex::Real(0.0)) {
292 return plan.status == RemapStatus::ZeroWaterResidual &&
293 plan.destination_count == 0 &&
295 !plan.normalized_roundoff;
297 if (plan.packet_particle_mass < first) {
300 QuotientStatus::Ok)
return false;
301 return plan.status == RemapStatus::ZeroWaterResidual && !plan.normalized_roundoff &&
302 plan.destination_count == 1 && plan.residual_number_weight ==
303 amrex::Real(1.0) - wet_weight && plan.destinations[0].bin == 0 &&
304 plan.destinations[0].number_weight == wet_weight &&
305 plan.destinations[0].particle_mass == first;
307 if (plan.packet_particle_mass > last || plan.status == RemapStatus::ZeroWaterResidual) {
310 if (plan.destination_count == 1) {
311 const int pivot_bin = plan.destinations[0].bin;
312 if (pivot_bin < 0 || pivot_bin >= population.nbins)
return false;
313 return plan.status == RemapStatus::Ok && !plan.normalized_roundoff &&
314 plan.destination_count == 1 && plan.residual_number_weight ==
amrex::Real(0.0) &&
315 plan.packet_particle_mass == population.pivots[pivot_bin] &&
316 plan.destinations[0].bin == pivot_bin &&
317 plan.destinations[0].number_weight ==
amrex::Real(1.0) &&
318 plan.destinations[0].particle_mass == population.pivots[pivot_bin];
320 if (plan.destination_count != 2)
return false;
321 const int lower_bin = plan.destinations[0].bin;
322 if (lower_bin < 0 || lower_bin + 1 >= population.nbins ||
323 plan.destinations[1].bin != lower_bin + 1)
return false;
324 const amrex::Real lower = population.pivots[lower_bin];
325 const amrex::Real upper = population.pivots[lower_bin + 1];
326 if (!(plan.packet_particle_mass > lower && plan.packet_particle_mass < upper))
return false;
330 if (
checked_quotient(upper - plan.packet_particle_mass, width, lower_weight) !=
331 QuotientStatus::Ok ||
333 QuotientStatus::Ok)
return false;
334 return plan.status == RemapStatus::Ok && !plan.normalized_roundoff &&
335 plan.destination_count == 2 && plan.residual_number_weight ==
amrex::Real(0.0) &&
336 plan.destinations[0].bin == lower_bin &&
337 plan.destinations[0].number_weight == lower_weight &&
338 plan.destinations[0].particle_mass == lower &&
339 plan.destinations[1].bin == lower_bin + 1 &&
340 plan.destinations[1].number_weight == upper_weight &&
341 plan.destinations[1].particle_mass == upper;
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool within_boundary_roundoff(const amrex::Real value, const amrex::Real endpoint, const bool lower_boundary) noexcept
Definition: ERF_SBMRemapping.H:220
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE bool same_population_context(const PopulationRemapView &left, const PopulationRemapView &right) noexcept
Definition: ERF_SBMRemapping.H:127