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

Introduced 'training_data_mode' to allow forbidden mesh size during ANN training.

parent c6c21a11
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,8 @@ class Mesh: ...@@ -41,7 +41,8 @@ class Mesh:
""" """
def __init__(self, num_grid_cells: int, num_ghost_cells: int, def __init__(self, num_grid_cells: int, num_ghost_cells: int,
left_bound: float, right_bound: float) -> None: left_bound: float, right_bound: float,
training_data_mode: bool = False) -> None:
"""Initialize Mesh. """Initialize Mesh.
Parameters Parameters
...@@ -55,11 +56,16 @@ class Mesh: ...@@ -55,11 +56,16 @@ class Mesh:
Left boundary of the mesh interval. Left boundary of the mesh interval.
right_bound : float right_bound : float
Right boundary of the mesh interval. Right boundary of the mesh interval.
training_data_mode : bool, optional
Flag indicating whether the mesh is used for training data
generation. Default: False.
""" """
self._num_grid_cells = num_grid_cells self._num_grid_cells = num_grid_cells
if not training_data_mode:
if not math.log(self._num_grid_cells, 2).is_integer(): if not math.log(self._num_grid_cells, 2).is_integer():
raise ValueError('The number of cells in the mesh has to be an ' raise ValueError('The number of cells in the mesh has to be '
'exponential of 2') '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
...@@ -130,7 +136,8 @@ class Mesh: ...@@ -130,7 +136,8 @@ class Mesh:
# Return new mesh instance # Return new mesh instance
return Mesh(left_bound=point - stencil_length/2 * grid_spacing, return Mesh(left_bound=point - stencil_length/2 * grid_spacing,
right_bound=point + stencil_length/2 * grid_spacing, right_bound=point + stencil_length/2 * grid_spacing,
num_grid_cells=stencil_length, num_ghost_cells=2) num_grid_cells=stencil_length, num_ghost_cells=2,
training_data_mode=True)
def calculate_approximate_solution( def calculate_approximate_solution(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment