Commit c814206a authored by Philippe Delandmeter's avatar Philippe Delandmeter
Browse files

slim3d: simple testcase with a wave and an openbnd

parent 1c582a25
Pipeline #1560 passed with stage
in 32 minutes
L = 10e3;
l = 125;
Point(1) = {-L, -l, 0};
Point(2) = {L, -l, 0};
Point(3) = {L, l, 0};
Point(4) = {-L, l, 0};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(1) = {3, 4, 1, 2};
Plane Surface(1) = {1};
Transfinite Line{2} = 2;
Transfinite Line{4} = 2;
Transfinite Line{1} = 80+1;
Transfinite Line{3} = 80+1;
Mesh.Algorithm=8;
Recombine Surface{1};
Physical Surface("sea")={1};
Physical Line("coastR") = {2};
Physical Line("coastL") = {4};
Physical Line("cut") = {3};
Physical Line("paste") = {1};
import slimPre
import numpy as np
### Generate Mesh ###
from dgpy.scripts import Common
Common.genMesh("box.geo", 2)
run_dir = 'data/'
slimPre.make_directory(run_dir)
slimPre.write_file('bath.nc',None,None,[('bath',20)])
mesh_file = 'box.msh'
def shiftOperation(node, iPerBound) :
n = [node[0], node[1] - 250, node[2]]
return n
cutTags = ["cut"]
pasteTags = ["paste"]
mapFilename = run_dir+"periodicMesh.txt"
periodicity = (shiftOperation, cutTags, pasteTags, mapFilename)
print('Extruding mesh')
slimPre.extrude(mesh_file, ('bath.nc','bath'), nb_layers=3, mesh_file_name_out=run_dir+'mesh3d.msh',factor_show=200, periodicity=periodicity)
print('Loading 3D mesh')
mesh_file = run_dir + "mesh3d.msh"
mesh = slimPre.Mesh(mesh_file)
tau=1000
tvec = np.linspace(0,tau,num=tau+1,endpoint=True)
time = slimPre.Time(time_vector=tvec, periodic = True)
eta = np.ones_like(tvec)
eta[:] = 0.1*np.sin(2*np.pi*tvec[:]/tau)
slimPre.write_file(run_dir+'eta.nc', region=None, time=time, data=[('eta', eta)])
print('preprocessing done')
slimPre.exit(0)
import slim3d
runFile = 'data/'
meshFile = runFile+'mesh3d.msh'
sim_Ti = "2012-03-24 00:00:00"
sim_Tf = "2012-03-24 10:00:00"
sim_export = 100.
sim_exportFullRatio = -1 #each day
output_directory = "./output"
domain = slim3d.Domain(meshFile, periodic_map_file=runFile+"periodicMesh.txt")
equations = slim3d.Slim3d_equations(domain, temperature=True)
equations.set_horizontal_viscosity('smagorinsky')
#equations.set_bottom_friction(False)
equations.set_initial_salinity('vertical_gradient', salinity=None, surface_salinity=0, vertical_gradient=0)
equations.set_initial_temperature('vertical_gradient', temperature=None, surface_temperature=30., vertical_gradient=0.1)
equations.set_boundary_open("coastL", eta=(runFile+"eta.nc","eta"))
equations.set_boundary_open("coastR")
time_loop = slim3d.Loop(equations, time_step=20, export_time_step=sim_export, ratio_full_export=sim_exportFullRatio, initial_time=sim_Ti, final_time=sim_Tf, output_directory=output_directory)
time_loop.export_elevation()
time_loop.export_temperature()
time_loop.export_uv()
time_loop.export_uv2d()
time_loop.loop()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment