Exemple #1
0
slepian_r = 1.5 * M

# get heaviside function
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, a=0.15, f=5))
# construct a grid
grid = Grid([-1.5, 1.5],
            ng, [-1.5, 1.5],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy,
                        interior,
                        M,
                        grid.xh * 0.75,
                        pad_zone=pad_zone,
                        heaviside=MOL.step)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid)

################################################################################
# Extract radial information from ebdy and construct annular solver

# get the forces and BCs for the problem
# k = 2*np.pi/3
# bdy = GSB(c=tornberg_bdy(nb, 1, 1, [0, -5], [1, 0.2], [-1], [0.2]))
if reparametrize:
    bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# get number of gridpoints to roughly match boundary spacing
ng = 2 * int(1.0 * 2.4 // bh)
# construct a grid
grid = Grid([-1.2, 1.2],
            ng, [-1.2, 1.2],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy,
                        True,
                        M,
                        bh * 1,
                        pad_zone=pad_zone,
                        heaviside=MOL.step)
ebdys = [
    ebdy,
]
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid, verbose=verbose)

################################################################################
# Get solution, forces, BCs
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, a=0.2, f=5))
if reparametrize:
    bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# get number of gridpoints to roughly match boundary spacing
ng = 2 * int(0.5 * 2.4 // bh)
# construct a grid
grid = Grid([-1.2, 1.2],
            ng, [-1.2, 1.2],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, True, M, bh * 1.0, pad_zone, MOL.step)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid, verbose=verbose)
# give ebdyc a bumpy function
ebdyc.ready_bump(MOL.bump, (1.2 - ebdy.radial_width, 1.2 - ebdy.radial_width),
                 ebdy.radial_width)

################################################################################
# Get solution, forces, BCs

k = 8 * np.pi / 3
kx, ky = np.meshgrid(kvx, kvy, indexing='ij')
ikx, iky = 1j * kx, 1j * ky

# get heaviside function
MOL = SlepianMollifier(slepian_r)

# construct boundary and reparametrize
bdy = GSB(c=star(nb, x=0.0, y=0.0, a=0.0, f=3))
bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy,
                        True,
                        M,
                        bh / radial_upsampling,
                        pad_zone=pad_zone,
                        heaviside=MOL.step,
                        qfs_fsuf=qfs_fsuf,
                        coordinate_scheme=coordinate_scheme,
                        coordinate_tolerance=1e-8)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# get a grid
grid = Grid([xmin, xmax],
            ngx, [ymin, ymax],
            ngy,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
ebdyc.register_grid(grid)
Exemple #5
0
kvy[int(ngy / 2)] = 0.0
kx, ky = np.meshgrid(kvx, kvy, indexing='ij')
ikx, iky = 1j * kx, 1j * ky

# initial c field
c0e = c0_function(x, y)

# get heaviside function
MOL = SlepianMollifier(slepian_r)

# construct boundary and reparametrize
bdy = GSB(c=star(nb, x=0.0, y=0.0, a=0.0, f=3))
bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, True, M, bh, pad_zone, MOL.step)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# get a grid
grid = Grid([xmin, xmax],
            ngx, [ymin, ymax],
            ngy,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
ebdyc.register_grid(grid)

original_ebdy = ebdy

# initial c field
c0 = EmbeddedFunction(ebdyc)
Exemple #6
0
grid_upsample = 1

# get heaviside function
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, a=0.2, f=5))
if reparametrize:
    bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
# get h to use for radial solvers and grid
bh = bdy.dt * bdy.speed.min()
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy,
                        True,
                        M,
                        bh / grid_upsample,
                        pad_zone=0,
                        heaviside=MOL.step,
                        qfs_tolerance=qfs_tolerance,
                        coordinate_tolerance=coordinate_tolerance,
                        coordinate_scheme=coordinate_scheme)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
grid = ebdyc.generate_grid(bh / grid_upsample)
ebdyc.register_grid(grid, verbose=verbose)
ebdyc.ready_bump(MOL.bump, (grid.x_bounds[1] - ebdy.radial_width,
                            grid.y_bounds[1] - ebdy.radial_width),
                 ebdyc[0].radial_width)
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid, verbose=verbose)
Exemple #7
0
kx, ky = np.meshgrid(kvx, kvy, indexing='ij')
ikx, iky = 1j*kx, 1j*ky

# get heaviside function
MOL = SlepianMollifier(slepian_r)

# construct boundary and reparametrize
bdy = GSB(c=star(nb, x=0.0, y=0.0, a=0.0, f=3))
bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt*bdy.speed.min()
# construct embedded boundary
tolerances = {
	'qfs'      : qfs_tolerance,
	'qfs_fsuf' : qfs_fsuf,
}
ebdy = EmbeddedBoundary(bdy, True, M, 0.25*bh, pad_zone, MOL.step, tolerances=tolerances)
ebdyc = EmbeddedBoundaryCollection([ebdy,])
# get a grid
grid = Grid([xmin, xmax], ngx, [ymin, ymax], ngy, x_endpoints=[True, False], y_endpoints=[True, False])
ebdyc.register_grid(grid)

# initial c field
c0 = EmbeddedFunction(ebdyc)
c0.define_via_function(c0_function)

def xder(f):
	return np.fft.ifft2(np.fft.fft2(f)*ikx).real
def yder(f):
	return np.fft.ifft2(np.fft.fft2(f)*iky).real

# now timestep
Exemple #8
0
bh1 = bdy1.dt * bdy1.speed.min()
bh2 = bdy2.dt * bdy2.speed.min()
bh3 = bdy3.dt * bdy3.speed.min()
bh = min(bh1, bh2, bh3)
# get number of gridpoints to roughly match boundary spacing
ng = 2 * int(0.5 * 6.4 // bh)
# construct a grid
grid = Grid([-3.0, 3.4],
            ng, [-3.2, 3.2],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
bdys = [bdy1, bdy2, bdy3]
ebdys = [
    EmbeddedBoundary(bdy, bdy is bdy1, M, bh, pad_zone, MOL.step)
    for bdy in bdys
]
ebdyc = EmbeddedBoundaryCollection(ebdys)
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid, verbose=verbose)
# make some plots
if plot:
    fig, ax = plt.subplots()
    colors = ['black', 'blue', 'red', 'purple', 'purple']
    for ebdy in ebdys:
        q = ebdy.bdy_qfs
        q1 = q.interior_source_bdy if ebdy.interior else q.exterior_source_bdy
        q = ebdy.interface_qfs
        q2 = q.interior_source_bdy
Exemple #9
0
# construct boundary
bdy = GSB(c=star(nb, a=0.1, f=5))
if reparametrize:
    bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# construct a grid
grid = Grid([-np.pi / 2, np.pi / 2],
            ng, [-np.pi / 2, np.pi / 2],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy,
                        True,
                        M,
                        grid.xh * 0.75,
                        pad_zone=pad_zone,
                        heaviside=MOL.step,
                        qfs_tolerance=1e-14,
                        qfs_fsuf=2)
ebdys = [
    ebdy,
]
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid)
# give ebdyc a bumpy function
ebdyc.ready_bump(
    MOL.bump, (np.pi / 2 - ebdy.radial_width, np.pi / 2 - ebdy.radial_width),
Exemple #10
0
time_eulerian = time.time() - st

################################################################################
# Semi-Lagrangian Non-linear departure point method

print('Testing Linear Departure Method')

# get heaviside function
MOL = SlepianMollifier(slepian_r)

# construct boundary and reparametrize
bdy = GSB(c=star(nb, x=0.0, y=0.0, a=0.1, f=3))
bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, True, M, bh, pad_zone, MOL.step)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# get a grid
grid = Grid([-1.5, 1.5],
            ng, [-1.5, 1.5],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid)

# initial c field
c0 = EmbeddedFunction(ebdyc)
Exemple #11
0
kx, ky = np.meshgrid(kvx, kvy, indexing='ij')
ikx, iky = 1j * kx, 1j * ky

# get heaviside function
MOL = SlepianMollifier(slepian_r)

# construct boundary and reparametrize
bdy = GSB(c=star(nb, x=0.0, y=0.0, a=0.0, f=3))
bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy,
                        True,
                        M,
                        bh / radial_upsampling,
                        pad_zone=0,
                        heaviside=MOL.step,
                        qfs_fsuf=4,
                        coordinate_scheme='nufft',
                        coordinate_tolerance=1e-12)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# get a grid
grid = Grid([-1.2, 1.7],
            ngx, [-1.5, 1.5],
            ngy,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
ebdyc.register_grid(grid)
Exemple #12
0
# test pcolor
%pylab
import pybie2d
star = pybie2d.misc.curve_descriptions.star
GSB = pybie2d.boundaries.global_smooth_boundary.global_smooth_boundary.Global_Smooth_Boundary
from ipde.embedded_boundary import EmbeddedBoundary
from ipde.heavisides import SlepianMollifier

xv = np.linspace(0, 1, 4, endpoint=False)
yv = np.linspace(0, 1, 4, endpoint=False)
x, y = np.meshgrid(xv, yv, indexing='ij')
f = np.random.rand(4,4)

def periodic_pcolor(xv, yv, f, **kwargs):
	xv = np.concatenate([xv, (xv[-1]+xv[1]-xv[0],)])
	yv = np.concatenate([yv, (yv[-1]+yv[1]-yv[0],)])
	plt.pcolor(xv, yv, f, **kwargs)

periodic_pcolor(xv, yv, f)

bdy = GSB(c=star(100, x=0.0, y=0.0, a=0.1, f=3))
MOL = SlepianMollifier(10)
ebdy = EmbeddedBoundary(bdy, True, 4, bdy.max_h, 0, MOL.step)

rx = radial_rx
def fourier_cheybshev_pcolor(rv, tv, f):


Exemple #13
0
# get number of gridpoints to roughly match boundary spacing
ng = 2 * int(0.5 * 7 // bh)
# construct a grid
grid = Grid([-3.5, 3.5],
            ng, [-3.5, 3.5],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
bdys = [bdy1, bdy2, bdy3]
kwa = {
    'pad_zone': pad_zone,
    'heaviside': MOL.step,
    'interpolation_scheme': 'polyi'
}
ebdys = [EmbeddedBoundary(bdy, bdy is bdy1, M, bh, **kwa) for bdy in bdys]
ebdyc = EmbeddedBoundaryCollection(ebdys)
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid, verbose=verbose)

# timing for grid registration!
for i in range(3):
    st = time.time()
    ebdys[i].register_grid(grid)
    print((time.time() - st) * 1000)

# make some plots
if plot:
    fig, ax = plt.subplots()
    colors = ['black', 'blue', 'red', 'purple', 'purple']
Exemple #14
0
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, a=0.1, f=5))
if reparametrize:
    bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# get number of gridpoints to roughly match boundary spacing
ng = 2 * int(0.5 * 2.4 // bh)
# construct a grid
grid = Grid([-1.2, 1.2],
            ng, [-1.2, 1.2],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, True, M, bh * 1, pad_zone, MOL.step)
# register the grid
print('\nRegistering the grid')
ebdy.register_grid(grid, verbose=verbose)

################################################################################
# Get solution, forces, BCs

k = 1 * np.pi / 3

solution_func = lambda x, y: np.exp(np.sin(k * x)) * np.sin(k * y)
force_func = lambda x, y: helmholtz_k**2 * solution_func(x, y) - k**2 * np.exp(
    np.sin(k * x)) * np.sin(k * y) * (np.cos(k * x)**2 - np.sin(k * x) - 1.0)
f = force_func(ebdy.grid.xg, ebdy.grid.yg) * ebdy.phys
fr = force_func(ebdy.radial_x, ebdy.radial_y)
ua = solution_func(ebdy.grid.xg, ebdy.grid.yg) * ebdy.phys
pad_zone = 4
interior = True
slepian_r = 20
reparametrize = False

# get heaviside function
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, x=np.pi, y=np.pi, a=0.1, f=5))
# reparametrize if reparametrizing
if reparametrize:
	bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
# construct a grid
grid = Grid([0.0, 2*np.pi], ng, [0.0, 2*np.pi], ng, x_endpoints=[True, False], y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, interior, M, grid.xh*0.75, pad_zone, MOL.step)
# register the grid
print('\nRegistering the grid')
ebdy.register_grid(grid, verbose=True)

################################################################################
# Test interpolation on "shifted" region

# coordinates for curvilinear region
x = grid.xg
y = grid.yg
xr = ebdy.radial_x
yr = ebdy.radial_y

# generate a velocity field
u_func = lambda x, y: np.sin(x)*np.cos(y)
Exemple #16
0
star = pybie2d.misc.curve_descriptions.star
squish = pybie2d.misc.curve_descriptions.squished_circle
GSB = pybie2d.boundaries.global_smooth_boundary.global_smooth_boundary.Global_Smooth_Boundary
Grid = pybie2d.grid.Grid

nb = 300
M = 12
slepian_r = 2*M

# get heaviside function
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, a=0.2, f=5))
bh = bdy.dt*bdy.speed.min()
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, True, M, bh*1, heaviside=MOL.step)
ebdys = [ebdy,]
ebdyc = EmbeddedBoundaryCollection([ebdy,])
# register the grid
print('\nRegistering the grid')
# ebdyc.register_grid(grid)
ebdyc.generate_grid(bh, bh)

# construct an embedded function
f = EmbeddedFunction(ebdyc)
f.define_via_function(lambda x, y: np.sin(x)*np.exp(y))

# try saving ebdy
ebdy_dict = ebdy.save()
ebdy2 = LoadEmbeddedBoundary(ebdy_dict)
bh3 = bdy3.dt * bdy3.speed.min()
bh = min(bh1, bh2, bh3)
# get number of gridpoints to roughly match boundary spacing
ng = 2 * int(0.5 * 5.2 // bh)
# construct a grid
grid = Grid([-2.6, 2.6],
            ng, [-2.6, 2.6],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
bdys = [bdy1, bdy2, bdy3]
ebdys = [
    EmbeddedBoundary(bdy,
                     bdy is bdy1,
                     M,
                     bh,
                     pad_zone=pad_zone,
                     heaviside=MOL.step) for bdy in bdys
]
ebdyc = EmbeddedBoundaryCollection(ebdys)
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid, verbose=verbose)
# give ebdyc a bumpy function
ebdyc.ready_bump(MOL.bump,
                 (2.6 - ebdys[0].radial_width, 2.6 - ebdys[0].radial_width),
                 ebdys[0].radial_width)

################################################################################
# Extract radial information from ebdy and construct annular solver
# get heaviside function
MOL = SlepianMollifier(slepian_r)

# construct boundary and reparametrize
bdy = GSB(c=star(nb, x=0.0, y=0.0, a=0.1, f=5))
bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# construct embedded boundary
tolerances = {
    'qfs': qfs_tolerance,
    'qfs_fsuf': qfs_fsuf,
}
ebdy = EmbeddedBoundary(bdy,
                        True,
                        M,
                        bh_ratio * bh,
                        pad_zone,
                        MOL.step,
                        tolerances=tolerances)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# get a grid
grid = Grid([xmin, xmax],
            ngx, [ymin, ymax],
            ngy,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
ebdyc.register_grid(grid)

# initial c field
Exemple #19
0
nb = 400
ng = int(nb/2)
M = 12
pad_zone = 2
interior = False
slepian_r = 10

# get heaviside function
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, a=0.1, f=5))
# construct a grid
grid = Grid([-1.5, 1.5], ng, [-1.5, 1.5], ng, x_endpoints=[True, False], y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, interior, M, grid.xh*0.75, pad_zone, MOL.step)
# register the grid
print('\nRegistering the grid')
ebdy.register_grid(grid)

################################################################################
# Extract radial information from ebdy and construct annular solver

# get the forces and BCs for the problem
x, y = ebdy.radial_x, ebdy.radial_y
k = 2*np.pi/3
solution_func = lambda x, y: np.exp(np.sin(k*x))*np.sin(k*y)
force_func = lambda x, y: k**2*np.exp(np.sin(k*x))*np.sin(k*y)*(np.cos(k*x)**2-np.sin(k*x)-1.0)
force = force_func(x, y)
asol = solution_func(x, y)
ibc = solution_func(ebdy.interface.x, ebdy.interface.y)
    bye = by

################################################################################
# Semi-Lagrangian Non-linear departure point method

print('\nSemi-Lagrangian Method')

# get heaviside function
MOL = SlepianMollifier(slepian_r)

# construct boundary and reparametrize
bdy = GSB(c=star(nb, x=0.0, y=0.0, a=0.0, f=3))
bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, True, M, bh, pad_zone, MOL.step)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# get a grid
grid = Grid([xmin, xmax],
            ngx, [ymin, ymax],
            ngy,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
ebdyc.register_grid(grid)

original_ebdy = ebdy

# initial c field
c0 = EmbeddedFunction(ebdyc)
ng = int(nb)
M = 20
pad_zone = 4
interior = True
slepian_r = 20
reparametrize = False

# get heaviside function
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, x=np.pi, y=np.pi, a=0.1, f=5))
# reparametrize if reparametrizing
if reparametrize:
	bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, interior, M, 0.25/M, pad_zone, MOL.step)

################################################################################
# generate data

# coordinates for curvilinear region
xr = ebdy.radial_x
yr = ebdy.radial_y
rr = ebdy.radial_r
tr = ebdy.radial_t

# generate a velocity field that's zero on both boundaries
fu_func = lambda r, t: r*np.cos(2*t)
fv_func = lambda r, t: np.exp(-r)*np.sin(t)
fur = fu_func(rr, tr)
fvr = fv_func(rr, tr)
Exemple #22
0
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, a=0.1, f=5))
if reparametrize:
    bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# get number of gridpoints to roughly match boundary spacing
ng = 2 * int(0.5 * 2.4 // bh)
# construct a grid
grid = Grid([-1.2, 1.2],
            ng, [-1.2, 1.2],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, True, M, bh * 1, pad_zone, MOL.step)
# register the grid
print('\nRegistering the grid')
ebdy.register_grid(grid)

################################################################################
# Extract radial information from ebdy and construct annular solver

# Testing the radial Stokes solver
print('   Testing Radial Stokes Solver')
# choose a, b so that things are periodic
w = 2.4
kk = 2 * np.pi / w
a = 3 * kk
b = kk
p_a = 2 * kk
ng = 2 * int(0.5 * 2.4 // bh)
# construct a grid
grid = Grid([-1.2, 1.2],
            ng, [-1.2, 1.2],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
tolerances = {
    'qfs': qfs_tolerance,
    'qfs_fsuf': qfs_fsuf,
}
ebdy = EmbeddedBoundary(bdy,
                        True,
                        M,
                        bh * 0.5,
                        pad_zone,
                        MOL.step,
                        tolerances=tolerances)
ebdys = [
    ebdy,
]
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid, verbose=verbose)

################################################################################
# Get solution, forces, BCs
Exemple #24
0
    bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
bh = bdy.dt * bdy.speed.min()
# get number of gridpoints to roughly match boundary spacing
ng = 2 * int(0.5 * 2.4 // bh)
# construct a grid
grid = Grid([-1.2, 1.2],
            ng, [-1.2, 1.2],
            ng,
            x_endpoints=[True, False],
            y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy,
                        True,
                        M,
                        bh * 1,
                        pad_zone=pad_zone,
                        heaviside=MOL.step,
                        qfs_tolerance=qfs_tolerance,
                        coordinate_tolerance=coordinate_tolerance,
                        coordinate_scheme=coordinate_scheme)
ebdyc = EmbeddedBoundaryCollection([
    ebdy,
])
# register the grid
print('\nRegistering the grid')
ebdyc.register_grid(grid, verbose=verbose)
# give ebdyc a bumpy function
ebdyc.ready_bump(MOL.bump, (1.2 - ebdy.radial_width, 1.2 - ebdy.radial_width),
                 ebdyc[0].radial_width)

################################################################################
Exemple #25
0
pad_zone = 4
interior = False
slepian_r = 20
reparametrize = False

# get heaviside function
MOL = SlepianMollifier(slepian_r)
# construct boundary
bdy = GSB(c=star(nb, a=0.1, f=5))
# reparametrize if reparametrizing
if reparametrize:
	bdy = GSB(*arc_length_parameterize(bdy.x, bdy.y))
# construct a grid
grid = Grid([-1.5, 1.5], ng, [-1.5, 1.5], ng, x_endpoints=[True, False], y_endpoints=[True, False])
# construct embedded boundary
ebdy = EmbeddedBoundary(bdy, interior, M, grid.xh*0.75, pad_zone, MOL.step)
# register the grid
print('\nRegistering the grid')
ebdy.register_grid(grid, verbose=True)

################################################################################
# Make basic plots

fig, ax = plt.subplots()
ax.pcolormesh(grid.xg, grid.yg, ebdy.phys)
ax.scatter(bdy.x, bdy.y, color='white', s=20)
ax.set_title('Phys')

fig, ax = plt.subplots()
ax.pcolormesh(grid.xg, grid.yg, ebdy.grid_in_annulus)
ax.scatter(bdy.x, bdy.y, color='white', s=20)