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

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)
f = EmbeddedFunction(ebdyc)
f.define_via_function(force_func)
ua = EmbeddedFunction(ebdyc)
ua.define_via_function(solution_func)
bcs = BoundaryFunction(ebdyc)
bcs.define_via_function(solution_func)

################################################################################
# Setup Poisson Solver

solver = PoissonSolver(ebdyc, solver_type=solver_type)
ue = solver(f, tol=1e-12, verbose=verbose)

if plot:
    fig, ax = plt.subplots()
    ue.plot(ax)
    ax.plot(ebdy.bdy.x, ebdy.bdy.y, color='black', linewidth=3)
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)
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
c = c0.copy()
t = 0

dt = dt_lagrangian
예제 #3
0
])
# 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)

original_ebdy = ebdy

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

fig, ax = plt.subplots()

# now timestep
c = c0.copy()
t = 0
while t < max_time - 1e-10:

    st = time.time()
    # get the velocity fields
    u = EmbeddedFunction(ebdyc)
    u.define_via_function(lambda x, y: u_function(x, y, t))
    v = EmbeddedFunction(ebdyc)
    v.define_via_function(lambda x, y: v_function(x, y, t))
    print('Time to compute u:                            {:0.1f}'.format(
                        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)

# now timestep
c = c0.copy()
t = 0.0

x_tracers = []
y_tracers = []
ts = []

new_ebdyc = ebdyc

qfs1 = QFS_Evaluator(new_ebdyc.ebdys[0].bdy_qfs,
                     True, [
                         Singular_SLP1,
                     ],
예제 #5
0
psix = lambda x, y: esin(a * x) * cos(b * y)
psiy = lambda x, y: esin(a * x) * sin(b * y)
u_function = lambda x, y: psix(x, y)
v_function = lambda x, y: -a / b * cos(a * x) * psiy(x, y)
p_function = lambda x, y: cos(p_a * x) + esin(p_b * y)
fu_function = lambda x, y: (a**2 * (sin(a * x) - cos(a * x)**2) + b**2) * psix(
    x, y) - p_a * sin(p_a * x)
fv_function = lambda x, y: -a * b * cos(a * x) * psiy(
    x, y) * (1 + (a / b)**2 * sin(a * x) *
             (3 + sin(a * x))) + p_b * cos(p_b * y) * esin(p_b * y)
fu = EmbeddedFunction(ebdyc)
fv = EmbeddedFunction(ebdyc)
ua = EmbeddedFunction(ebdyc)
va = EmbeddedFunction(ebdyc)
pa = EmbeddedFunction(ebdyc)
fu.define_via_function(fu_function)
fv.define_via_function(fv_function)
ua.define_via_function(u_function)
va.define_via_function(v_function)
pa.define_via_function(p_function)
bcu = u_function(ebdyc[0].bdy.x, ebdyc[0].bdy.y)
bcv = v_function(ebdyc[0].bdy.x, ebdyc[0].bdy.y)

# setup the solver
solver = StokesSolver(ebdyc, solver_type=solver_type)
u, v, p = solver(fu, fv, tol=1e-14, verbose=verbose, maxiter=200, restart=50)


# this isn't correct yet because we haven't applied boundary conditions
def Stokes_Pressure_Fix(src, trg):
    Nxx = trg.normal_x[:, None] * src.normal_x