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

Enforced number of mesh cells to be an exponential of 2.

parent ac49fe3b
Branches
No related tags found
Loading
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
from __future__ import annotations from __future__ import annotations
from functools import cache from functools import cache
from typing import Tuple from typing import Tuple
import math
import numpy as np import numpy as np
from numpy import ndarray from numpy import ndarray
from sympy import Symbol from sympy import Symbol
...@@ -46,8 +47,8 @@ class Mesh: ...@@ -46,8 +47,8 @@ class Mesh:
Parameters Parameters
---------- ----------
num_grid_cells : int num_grid_cells : int
Number of cells in the mesh (ghost cells notwithstanding). Usually Number of cells in the mesh (ghost cells notwithstanding). Has
exponential of 2. to be an exponential of 2.
num_ghost_cells : int num_ghost_cells : int
Number of ghost cells on each side of the mesh. Number of ghost cells on each side of the mesh.
left_bound : float left_bound : float
...@@ -56,6 +57,9 @@ class Mesh: ...@@ -56,6 +57,9 @@ class Mesh:
Right boundary of the mesh interval. Right boundary of the mesh interval.
""" """
self._num_grid_cells = num_grid_cells self._num_grid_cells = num_grid_cells
if not math.log(self._num_grid_cells, 2).is_integer():
raise ValueError('The number of cells in the mesh has to be an '
'exponential of 2')
self._num_ghost_cells = num_ghost_cells self._num_ghost_cells = num_ghost_cells
self._left_bound = left_bound self._left_bound = left_bound
self._right_bound = right_bound self._right_bound = right_bound
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment