2nd-order acoustic free-surface with 1D extrapolations
Schism is capable of implementing immersed boundaries based on 1D approximations of boundary conditions in the style of Mulder 2017. The process of doing so is similar to that detailed previously, albeit with some minor differences.
# 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 flat 2D sdfsdf = read_sdf('horizontal', 2)plt.imshow(sdf.data.T, origin='lower')plt.title("Boundary geometry SDF")plt.colorbar()plt.show()
As before, a BoundaryGeometry object is constructed.
from schism import BoundaryGeometrybg = BoundaryGeometry(sdf)grid = bg.grid # Gets the grid from the signed distance function
Operator `normals` ran in 0.01 s
And again, define a TimeFunction for pressure.
import devito as dvs_o =4p = dv.TimeFunction(name='p', grid=grid, space_order=s_o, time_order=2)
Now the boundary conditions are defined. To use 1D extrapolations to impose the immersed boundary, 1D approximations of the 2D boundary conditions will need to be supplied. Note that Schism is capable of separating boundary conditions pertaining to different extrapolations from one another.
from schism import BoundaryConditionsbc_list = [dv.Eq(p, 0), # Zero pressure on free surface dv.Eq(p.dy2, 0), # Zero second derivative dv.Eq(p.dy4, 0)] # Zero fourth derivativebcs = BoundaryConditions(bc_list)
Now the Boundary is assembled. However, to use 1D approximations, some additional keyword arguments are required. The first of these is has_1D_basis=True, and it is also advisable to set strategy='reduce'. The latter of these changes the strategy used when insufficient information is available for extrapolation. Instead of expanding the stencil, the order of the extrapolation is reduced.
from schism import Boundaryboundary = Boundary(bcs, bg, has_1D_basis=True, strategy='reduce')
As before, the substitution for the p.dy2 expression is requested.