commit 1717fd34e29665d3f29e8e4295521a87af4701a0
parent a4b15bce9aaf0ed66e0022e68ef9f5c48404cb64
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Mon, 17 Jun 2024 15:38:22 +0200
Updated error handling when resolving multiple probes
The function that calculates a probe returns an error as soon as a
realization fails, i.e. its return code is not RES_OK. But a RES_BAD_OP
return code means that the realization is only rejected, but that the
calculation can still be executed, as for the calculation of a single
probe. Thus, from now on, if the realization returns RES_BAD_OP, we do
not update the Monte Carlo weight and continue the simulation.
Diffstat:
2 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/src/sdis_solve_probe_Xd.h b/src/sdis_solve_probe_Xd.h
@@ -153,19 +153,21 @@ XD(solve_one_probe)
realis_args.diff_algo = args->diff_algo;
dX(set)(realis_args.position, args->position);
res = XD(probe_realisation)(scn, &realis_args, &w);
- if(res != RES_OK) goto error;
-
- /* Stop time registration */
- time_sub(&t0, time_current(&t1), &t0);
- usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
-
- /* Update MC weights */
- acc_temp->sum += w;
- acc_temp->sum2 += w*w;
- acc_temp->count += 1;
- acc_time->sum += usec;
- acc_time->sum2 += usec*usec;
- acc_time->count += 1;
+ if(res != RES_OK && res != RES_BAD_OP) goto error;
+
+ if(res == RES_OK) {
+ /* Stop time registration */
+ time_sub(&t0, time_current(&t1), &t0);
+ usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
+
+ /* Update MC weights */
+ acc_temp->sum += w;
+ acc_temp->sum2 += w*w;
+ acc_temp->count += 1;
+ acc_time->sum += usec;
+ acc_time->sum2 += usec*usec;
+ acc_time->count += 1;
+ }
}
exit:
diff --git a/src/sdis_solve_probe_boundary_Xd.h b/src/sdis_solve_probe_boundary_Xd.h
@@ -195,19 +195,21 @@ XD(solve_one_probe_boundary)
realis_args.uv[1] = args->uv[1];
#endif
res = XD(boundary_realisation)(scn, &realis_args, &w);
- if(res != RES_OK) goto error;
+ if(res != RES_OK && res != RES_BAD_OP) goto error;
- /* Stop time registration */
- time_sub(&t0, time_current(&t1), &t0);
- usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
-
- /* Update MC weights */
- acc_temp->sum += w;
- acc_temp->sum2 += w*w;
- acc_temp->count += 1;
- acc_time->sum += usec;
- acc_time->sum2 += usec*usec;
- acc_time->count += 1;
+ if(res == RES_OK) {
+ /* Stop time registration */
+ time_sub(&t0, time_current(&t1), &t0);
+ usec = (double)time_val(&t0, TIME_NSEC) * 0.001;
+
+ /* Update MC weights */
+ acc_temp->sum += w;
+ acc_temp->sum2 += w*w;
+ acc_temp->count += 1;
+ acc_time->sum += usec;
+ acc_time->sum2 += usec*usec;
+ acc_time->count += 1;
+ }
}
exit:
return res;