diff --git a/exercise3/wave_1d_parallel.c b/exercise3/wave_1d_parallel.c index ef9847c..fc2ac7c 100644 --- a/exercise3/wave_1d_parallel.c +++ b/exercise3/wave_1d_parallel.c @@ -106,8 +106,12 @@ void time_step(void) { // Neumann (reflective) boundary condition. void boundary_condition(void) { // BEGIN: T6 - U(-1) = U(1); - U(N) = U(N - 2); + if (comm_rank == ROOT) { + U(-1) = U(1); + } + if (comm_rank == comm_size - 1) { + U(n) = U(n - 2); + } // END: T6 }