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

Enforced that number of ghost cells is positive for calculations and non-negative for training.

parent c7d51a28
No related branches found
No related tags found
No related merge requests found
......@@ -30,8 +30,7 @@ TODO: Enforce Boxplot folds with decorator -> Done
TODO: Enforce boundary for initial condition in exact solution only -> Done
TODO: Adapt number of ghost cells based on ANN stencil -> Done
TODO: Ensure exact solution is calculated in Equation class -> Done
TODO: Extract objects from UpdateScheme
TODO: Enforce num_ghost_cells to be positive integer for DG (not training)
TODO: Enforce num_ghost_cells to be positive integer for DG -> Done
TODO: Add Burger class
TODO: Use cfl_number for updating, not just time (equation-related?)
......@@ -56,6 +55,7 @@ TODO: Add verbose output
TODO: Add tests for all functions
Not feasible yet or doc-related:
TODO: Extract objects from UpdateScheme
TODO: Clean up result plotting (remove object properties of Equation)
TODO: Add functions to create each object from dict
TODO: Move plot_approximation_results() into plotting script
......
......@@ -53,6 +53,11 @@ class Equation(ABC):
cfl_number : float
CFL number to ensure stability.
Raises
------
ValueError
If number of ghost cells in mesh in not positive.
"""
self._quadrature = quadrature
self._init_cond = init_cond
......@@ -62,6 +67,10 @@ class Equation(ABC):
self._wave_speed = wave_speed
self._cfl_number = cfl_number
if self._mesh.num_ghost_cells <= 0:
raise ValueError('Number of ghost cells for calculations has to '
'be positive.')
self._reset()
@property
......
......@@ -59,17 +59,22 @@ class Mesh:
Right boundary of the mesh interval.
num_ghost_cells : int, optional
Number of ghost cells on each side of the mesh, respectively.
Default: False.
Default: 1.
Raises
------
ValueError
If number of cells is not exponential of 2.
If number of ghost cells is negative.
ValueError
If number of cells is not exponential of 2 (and ghost cells exist).
"""
self._num_cells = num_cells
self._num_ghost_cells = num_ghost_cells
if self._num_ghost_cells != 0:
if self._num_ghost_cells < 0:
raise ValueError('The number of ghost cells has to be a '
'non-negative integer')
if not math.log(self._num_cells, 2).is_integer():
raise ValueError('The number of cells in the mesh has to be '
'an exponential of 2')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment