This notebook showcases a slightly more complex boundary, cutting through the domain at 45 degrees.
# Load the signed distance function for the boundary geometryimport pickleimport matplotlib.pyplot as pltdef read_sdf(surface, dims):"""Unpickle an sdf""" fname ='../tests/sdfs/'+ surface +'_'+str(dims) +'d.dat'withopen(fname, 'rb') as f: sdf = pickle.load(f)return sdf# Load the diagonal 2D sdfsdf = read_sdf('45', 2)plt.imshow(sdf.data.T, origin='lower')plt.title("Boundary geometry SDF")plt.colorbar()plt.show()
from schism import BoundaryGeometrybg = BoundaryGeometry(sdf)grid = bg.grid # Gets the grid from the signed distance function
Operator `normals` ran in 0.01 s
import devito as dvs_o =4p = dv.TimeFunction(name='p', grid=grid, space_order=s_o, time_order=2)
from schism import BoundaryConditionsbc_list = [dv.Eq(p, 0), # Zero pressure on free surface dv.Eq(p.dx2+p.dy2, 0), # Zero laplacian dv.Eq(p.dx4 +2*p.dx2dy2 + p.dy4, 0)] # Zero biharmonicbcs = BoundaryConditions(bc_list)
from schism import Boundaryboundary = Boundary(bcs, bg)