Ejemplo n.º 1
0
# 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

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)
Ejemplo n.º 2
0
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)
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.0
te = 0.0
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)
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
                        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)

# 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,
Ejemplo n.º 5
0
    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)

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))
Ejemplo n.º 6
0
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)
c0.define_via_function(c0_function)

# 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(
    (time.time() - st) * 1000))
Ejemplo n.º 7
0
p_a = 2.0
p_b = 1.0
sin = np.sin
cos = np.cos
esin = lambda x: np.exp(sin(x))
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)
Ejemplo n.º 8
0
                        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)

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

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

st = time.time()

while t < max_time - 1e-10:

    # get the velocity fields at this time
    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))