Skip to content
Snippets Groups Projects
Commit 76e3c1a5 authored by Laura Christine Kühle's avatar Laura Christine Kühle
Browse files

Vectorized 'apply()' in MinMod limiter.

parent 074f94d4
Branches
No related tags found
No related merge requests found
...@@ -134,15 +134,23 @@ class MinMod(Limiter): ...@@ -134,15 +134,23 @@ class MinMod(Limiter):
""" """
new_projection = projection.copy() 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) cell_slopes = self._set_cell_slope(projection)
modification_mask = self._determine_mask(projection, cell_slopes) modification_mask = self._determine_mask(projection, cell_slopes)
for cell in cells: cells = np.array(cells)
if not modification_mask[cell]: mask = np.zeros_like(new_projection, dtype=bool)
adapted_projection = projection[:, cell+1].copy() mask[self._erase_degree+1:, cells+1] = np.tile(
for i in range(len(adapted_projection)): np.logical_not(modification_mask)[cells],
if i > self._erase_degree: (len(projection)-self._erase_degree-1, 1))
adapted_projection[i] = 0
new_projection[:, cell+1] = adapted_projection # Limit troubled cells for higher degrees
new_projection[mask] = 0
return new_projection return new_projection
def _determine_mask(self, projection, slopes): def _determine_mask(self, projection, slopes):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment