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

Reworked limit masking to apply over array instead of cell.

parent 8d1035fa
No related branches found
No related tags found
No related merge requests found
...@@ -135,11 +135,9 @@ class MinMod(Limiter): ...@@ -135,11 +135,9 @@ class MinMod(Limiter):
""" """
new_projection = projection.copy() new_projection = projection.copy()
cell_slopes = self._set_cell_slope(projection) cell_slopes = self._set_cell_slope(projection)
modification_mask = self._determine_mask(projection, cell_slopes)
for cell in cells: for cell in cells:
is_good_cell = self._determine_modification(projection, cell, if not modification_mask[cell]:
cell_slopes)
if not is_good_cell:
adapted_projection = projection[:, cell+1].copy() adapted_projection = projection[:, cell+1].copy()
for i in range(len(adapted_projection)): for i in range(len(adapted_projection)):
if i > self._erase_degree: if i > self._erase_degree:
...@@ -147,22 +145,20 @@ class MinMod(Limiter): ...@@ -147,22 +145,20 @@ class MinMod(Limiter):
new_projection[:, cell+1] = adapted_projection new_projection[:, cell+1] = adapted_projection
return new_projection return new_projection
def _determine_modification(self, projection, cell, slopes): def _determine_mask(self, projection, slopes):
"""Determines whether limiting is applied. """Determine limiting mask.
Parameters Parameters
---------- ----------
projection : ndarray projection : ndarray
Matrix of projection for each polynomial degree. Matrix of projection for each polynomial degree.
cell : int
Index of cell.
slopes : ndarray slopes : ndarray
Vector of slopes of projection cells. Vector of slopes of projection cells.
Returns Returns
------- -------
bool ndarray
Flag whether cell should be adjusted. Mask whether cells should be adjusted.
""" """
forward_slopes = (projection[0, 2:]-projection[0, 1:-1]) * (0.5**0.5) forward_slopes = (projection[0, 2:]-projection[0, 1:-1]) * (0.5**0.5)
...@@ -175,7 +171,7 @@ class MinMod(Limiter): ...@@ -175,7 +171,7 @@ class MinMod(Limiter):
backward_slopes <= 0)) backward_slopes <= 0))
slope_mask = np.logical_or(pos_mask, neg_mask) slope_mask = np.logical_or(pos_mask, neg_mask)
return slope_mask[cell] return slope_mask
@staticmethod @staticmethod
def _set_cell_slope(projection): def _set_cell_slope(projection):
...@@ -240,25 +236,21 @@ class ModifiedMinMod(MinMod): ...@@ -240,25 +236,21 @@ class ModifiedMinMod(MinMod):
"""Returns string of class name concatenated with the erase-degree.""" """Returns string of class name concatenated with the erase-degree."""
return self.__class__.__name__ + str(self._erase_degree) return self.__class__.__name__ + str(self._erase_degree)
def _determine_modification(self, projection, cell, slopes): def _determine_mask(self, projection, slopes):
"""Determines whether limiting is applied. """Determine limiting mask.
Parameters Parameters
---------- ----------
projection : ndarray projection : ndarray
Matrix of projection for each polynomial degree. Matrix of projection for each polynomial degree.
cell : int
Index of cell.
slopes : ndarray slopes : ndarray
Vector of slopes of projection cells. Vector of slopes of projection cells.
Returns Returns
------- -------
bool ndarray
Flag whether cell should be adjusted. Mask whether cells should be adjusted.
""" """
if abs(slopes[cell]) <= self._threshold: return np.logical_or(abs(slopes) <= self._threshold,
return True super()._determine_mask(projection, slopes))
return super()._determine_modification(projection, cell, slopes)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment