Esempio n. 1
0
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
uar = solution_func(ebdy.radial_x, ebdy.radial_y)
bc = solution_func(ebdy.bdy.x, ebdy.bdy.y)
Esempio n. 2
0
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
p_b = 5 * kk
sin = np.sin
cos = np.cos
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)
v_func = lambda x, y: -np.cos(x)*np.sin(y)
u = u_func(x, y)
v = v_func(x, y)