diff --git a/scripts/tcd/Limiter.py b/scripts/tcd/Limiter.py index bf9137f55c73aa1c142cb2f45ae2bf271fc58949..258cee142a58c41da6f8aed7b3c62044ff3c27dd 100644 --- a/scripts/tcd/Limiter.py +++ b/scripts/tcd/Limiter.py @@ -134,15 +134,23 @@ class MinMod(Limiter): """ new_projection = projection.copy() + + # If no troubled cells are detected, return copy + if len(cells) == 0: + return new_projection + + # Set mask to limit complete projection cell_slopes = self._set_cell_slope(projection) modification_mask = self._determine_mask(projection, cell_slopes) - for cell in cells: - if not modification_mask[cell]: - adapted_projection = projection[:, cell+1].copy() - for i in range(len(adapted_projection)): - if i > self._erase_degree: - adapted_projection[i] = 0 - new_projection[:, cell+1] = adapted_projection + cells = np.array(cells) + mask = np.zeros_like(new_projection, dtype=bool) + mask[self._erase_degree+1:, cells+1] = np.tile( + np.logical_not(modification_mask)[cells], + (len(projection)-self._erase_degree-1, 1)) + + # Limit troubled cells for higher degrees + new_projection[mask] = 0 + return new_projection def _determine_mask(self, projection, slopes):