Esempio n. 1
0
print(t2 - t1)

print(fac_x)
print(alpha)
print(beta)
print(gamma)

new_mesh = RectangleMesh(880, 20, 220, 10)

bath = Function(FunctionSpace(new_mesh, "CG",
                              1)).project(swp.fwd_solutions_bathymetry[0])

fpath = "hydrodynamics_beach_bath_mov_{:d}_{:d}_{:d}_{:d}_{:d}"
fpath = fpath.format(op.dt_per_export, int(fac_x * 220), alpha, beta, gamma)
export_bathymetry(bath, os.path.join("adapt_output", fpath), op=op)

bath_real = initialise_bathymetry(
    new_mesh, 'fixed_output/hydrodynamics_beach_bath_fixed_440_10')

print('L2')
print(fire.errornorm(bath, bath_real))
print(kappa)

V = FunctionSpace(new_mesh, 'CG', 1)

x, y = SpatialCoordinate(new_mesh)

bath_mod = Function(V).interpolate(conditional(x > 70, bath, Constant(0.0)))
bath_real_mod = Function(V).interpolate(
    conditional(x > 70, bath_real, Constant(0.0)))
Esempio n. 2
0
        abs_hor_vel_norm = Function(swp.bathymetry[0].function_space()).project(conditional(swp.bathymetry[0] > 0.0, Constant(1.0), Constant(0.0)))
    comp_new = project(abs_hor_vel_norm, P1)
    mon_init = project(1.0 + alpha * comp_new, P1)
    return mon_init


swp.set_monitor_functions(velocity_monitor)

t1 = time.time()
swp.solve_forward()
t2 = time.time()

print(t2-t1)

fpath = "hydrodynamics_beach_bath_new_{:d}_basic".format(int(nx*220))
export_bathymetry(swp.fwd_solutions_bathymetry[0], fpath, op=op)

xaxisthetis1 = []
baththetis1 = []

for i in np.linspace(0, 219, 220):
    xaxisthetis1.append(i)
    baththetis1.append(-bath.at([i, 5]))
df = pd.concat([pd.DataFrame(xaxisthetis1, columns=['x']), pd.DataFrame(baththetis1, columns=['bath'])], axis=1)
df.to_csv("final_result_nx" + str(nx) + "_" + str(alpha) + '_' + str(beta) + '_' + str(gamma) + ".csv", index=False)

bath_real = initialise_bathymetry(new_mesh, 'hydrodynamics_beach_bath_new_440')

print('L2')
print(fire.errornorm(bath, bath_real))
Esempio n. 3
0
t1 = time.time()
swp.solve_forward()
t2 = time.time()
if os.getenv('REGRESSION_TEST') is not None:
    sys.exit(0)

print(t2 - t1)

new_mesh = RectangleMesh(880, 20, 220, 10)

bath = Function(FunctionSpace(new_mesh, "CG",
                              1)).project(swp.fwd_solutions_bathymetry[0])

fpath = "hydrodynamics_beach_bath_fixed_{:d}_{:d}".format(
    int(fac_x * 220), int(fac_y * 10))
export_bathymetry(bath, os.path.join("fixed_output", fpath), op=op)

bath_real = initialise_bathymetry(
    new_mesh,
    os.path.join(di, 'fixed_output/hydrodynamics_beach_bath_fixed_440_10'))

print('whole domain error')
print(fire.errornorm(bath, bath_real))

V = FunctionSpace(new_mesh, 'CG', 1)

x, y = SpatialCoordinate(new_mesh)

bath_mod = Function(V).interpolate(conditional(x > 70, bath, Constant(0.0)))
bath_real_mod = Function(V).interpolate(
    conditional(x > 70, bath_real, Constant(0.0)))
Esempio n. 4
0
}

op = TrenchSlantOptions(**kwargs)
if os.getenv('REGRESSION_TEST') is not None:
    op.dt_per_export = 20
    op.end_time = op.dt * op.dt_per_export
swp = AdaptiveProblem(op)

t1 = time.time()
swp.solve_forward()
t2 = time.time()
if os.getenv('REGRESSION_TEST') is not None:
    sys.exit(0)

new_mesh = RectangleMesh(16 * 5 * 4, 5 * 4, 16, 1.1)

bath = Function(FunctionSpace(new_mesh, "CG",
                              1)).project(swp.fwd_solutions_bathymetry[0])

fpath = "hydrodynamics_trench_slant_bath_new_" + str(fac_x)
export_bathymetry(bath, fpath, op=op)

print("total time: ")
print(t2 - t1)
print(fac_x)
bath_real = initialise_bathymetry(new_mesh,
                                  'hydrodynamics_trench_slant_bath_new_4.0')

print('L2')
print(fire.errornorm(bath, bath_real))