Skip to content

Commit

Permalink
Added centered interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasHelfer committed Jan 22, 2024
1 parent 3596677 commit 287137c
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions GeneralRelativity/Interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down Expand Up @@ -271,7 +278,6 @@ def plot_grid_position(self):
color="blue",
marker="o",
)

plt.scatter(
positions[:, :, 4, 0],
positions[:, :, 4, 1],
Expand Down

0 comments on commit 287137c

Please sign in to comment.