# Load the signed distance function for the boundary geometry
import pickle
import matplotlib.pyplot as plt
import numpy as np
def read_sdf(surface, dims):
"""Unpickle an sdf"""
fname = '../tests/sdfs/' + surface + '_' + str(dims) + 'd.dat'
with open(fname, 'rb') as f:
sdf = pickle.load(f)
return sdf
# Load the diagonal 2D sdf
sdf = read_sdf('sinusoid_new_hi_res', 2)
# Load the staggered sdfs
sdf_x = read_sdf('sinusoid_new_hi_res_x', 2)
sdf_y = read_sdf('sinusoid_new_hi_res_y', 2)
plt.imshow(sdf.data.T, origin='lower')
plt.title("Boundary geometry SDF")
plt.colorbar()
plt.show()
# It is a good idea to make sure your signed distance functions are aligned
# Misaligned SDFs can result in considerable weirdness
plt.imshow(sdf_x.data.T-sdf.data.T, origin='lower')
plt.title("Alignment check x")
plt.colorbar()
plt.show()
plt.imshow(sdf_y.data.T-sdf.data.T, origin='lower')
plt.title("Alignment check y")
plt.colorbar()
plt.show()





