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

Enforced margin for two-sided Heaviside to be non-negative.

parent 1afbd39f
No related branches found
No related tags found
No related merge requests found
......@@ -767,6 +767,11 @@ class HeavisideTwoSided(InitialCondition):
config : dict
Additional parameters for initial condition.
Raises
------
ValueError
If margin is negative.
"""
super()._reset(config)
......@@ -776,6 +781,9 @@ class HeavisideTwoSided(InitialCondition):
self._right_factor = config.pop('right_factor', 2)
self._margin = config.pop('margin', None)
if self._margin is not None and self._margin < 0:
raise ValueError('The margin has to be non-negative.')
def is_smooth(self):
"""Returns flag that function is not smooth."""
return False
......@@ -816,9 +824,9 @@ class HeavisideTwoSided(InitialCondition):
Value of function evaluates at x-value.
"""
x_shift = -mesh.cell_len/3 if self._margin is None else self._margin
x_shift = mesh.cell_len/3 if self._margin is None else self._margin
return self._left_factor \
+ (self._middle_factor - self._left_factor) * np.heaviside(
x - x_shift, 0)\
x + x_shift, 0)\
+ (self._right_factor - self._middle_factor) * np.heaviside(
x + x_shift, 0)
x - x_shift, 0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment