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

Applied self-referencing in Mesh.

parent c5958fde
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
""" """
from __future__ import annotations
from functools import cache from functools import cache
from typing import Tuple from typing import Tuple
import numpy as np import numpy as np
...@@ -100,7 +101,7 @@ class Mesh: ...@@ -100,7 +101,7 @@ class Mesh:
'right_bound': self._right_bound, 'right_bound': self._right_bound,
'num_ghost_cells': self._num_ghost_cells} 'num_ghost_cells': self._num_ghost_cells}
def random_stencil(self, stencil_length: int) -> 'Mesh': def random_stencil(self, stencil_length: int) -> Mesh:
"""Return random stencil. """Return random stencil.
Build mesh with given number of cell centers around a random point Build mesh with given number of cell centers around a random point
...@@ -116,7 +117,6 @@ class Mesh: ...@@ -116,7 +117,6 @@ class Mesh:
point = np.random.uniform(self._left_bound, self._right_bound) point = np.random.uniform(self._left_bound, self._right_bound)
# Adjust grid spacing to be within interval if necessary # Adjust grid spacing to be within interval if necessary
# creation
grid_spacing = self.cell_len grid_spacing = self.cell_len
while point - stencil_length/2 * grid_spacing < self._left_bound \ while point - stencil_length/2 * grid_spacing < self._left_bound \
or point + stencil_length/2 * grid_spacing > self._right_bound: or point + stencil_length/2 * grid_spacing > self._right_bound:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment