From 287137c47e36a11f960f919a37d691066d221532 Mon Sep 17 00:00:00 2001 From: ThomasHelfer Date: Sun, 21 Jan 2024 19:10:18 -0500 Subject: [PATCH] Added centered interpolation --- GeneralRelativity/Interpolation.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/GeneralRelativity/Interpolation.py b/GeneralRelativity/Interpolation.py index 0f565f2..91ae30f 100644 --- a/GeneralRelativity/Interpolation.py +++ b/GeneralRelativity/Interpolation.py @@ -152,20 +152,27 @@ def __init__( self.vecvals_array = [] # Vector values for interpolation self.grid_points_index_array = [] # Grid points indices for interpolation - if not align_grids_with_lower_dim_values: - # Define fixed values for grid alignment + # Define fixed values for grid alignment + if align_grids_with_lower_dim_values: + values = [0.0, 0.50] + else: values = [0.25, 0.75] - self.relative_positions = np.array( - list(itertools.product(values, repeat=3)) - ) + self.relative_positions = np.array(list(itertools.product(values, repeat=3))) + + # Calculate vector values and grid points indices + for interp_point in self.relative_positions: + vecvals, grid_points_index = calculate_stencils(interp_point, 4, 3) + vecvals[np.abs(vecvals) < 1e-10] = 0 + self.vecvals_array.append(vecvals.tolist()) + self.grid_points_index_array.append(grid_points_index.tolist()) - # Calculate vector values and grid points indices - for interp_point in self.relative_positions: - vecvals, grid_points_index = calculate_stencils(interp_point, 4, 3) - self.vecvals_array.append(vecvals.tolist()) - self.grid_points_index_array.append(grid_points_index.tolist()) + # Compute relative indices for interpolated array - # Compute relative indices for interpolated array + if align_grids_with_lower_dim_values: + self.relative_index_for_interpolated_array = np.int8( + np.round(self.relative_positions + 0.5) + ) + else: self.relative_index_for_interpolated_array = np.int8( np.round(self.relative_positions) ) @@ -271,7 +278,6 @@ def plot_grid_position(self): color="blue", marker="o", ) - plt.scatter( positions[:, :, 4, 0], positions[:, :, 4, 1],