diff --git a/projection_utils.py b/projection_utils.py index 27e87af53bb356bc1a73fa76e995c33464e8d9ff..91ba2732f90ceffc12a6d30db56b7c609f4d2be1 100644 --- a/projection_utils.py +++ b/projection_utils.py @@ -41,7 +41,8 @@ class Mesh: """ 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. Parameters @@ -55,11 +56,16 @@ class Mesh: Left boundary of the mesh interval. right_bound : float 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 - 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') + if not training_data_mode: + 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._left_bound = left_bound self._right_bound = right_bound @@ -130,7 +136,8 @@ class Mesh: # Return new mesh instance return Mesh(left_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(