Commit 73d32f98 authored by Philippe Delandmeter's avatar Philippe Delandmeter
Browse files

now extrusion also works with nc files in parallel

parent 5354ff02
Pipeline #1275 passed with stage
in 28 minutes and 24 seconds
......@@ -842,9 +842,16 @@ def get_distance(region, physical_tags):
def extrude(mesh_file_name, bath_file_name, nb_layers=None, z_layers=None, layers_function=None, mesh_file_name_out='', factor_show=0, periodicity=None):
bathnc = False
if bath_file_name[0][-3:] == ".nc":
netcdf_to_msh(mesh_file_name, bath_file_name[0], bath_file_name[1], bath_file_name[0][:-3])
bath_file_name = bath_file_name[0][:-3]+'.msh'
groups = dgpy.dgGroupCollection(mesh_file_name)
f = slim_private._load_function((bath_file_name[0],bath_file_name[1]),groups)
dof = dgpy.dgDofContainer(groups,1)
dof.interpolate(f)
exporter = dgpy.dgIdxExporter(dof, '__tmp_bath')
exporter.exportIdx()
bath_file_name = '__tmp_bath/__tmp_bath.idx'
bathnc = True
if dgpy.Msg.GetCommRank() == 0:
......@@ -907,6 +914,9 @@ def extrude(mesh_file_name, bath_file_name, nb_layers=None, z_layers=None, layer
slim_private.extrude.extrude(mesh, getLayers).write(mesh3d)
if factor_show > 0:
slim_private.extrude.extrude(mesh, getLayersShow).write(mesh3dShow)
if bathnc and dgpy.Msg.GetCommRank() == 0:
slim_private.shutil.rmtree('__tmp_bath')
dgpy.Msg.Barrier()
return
......
......@@ -24,29 +24,26 @@ print('mesh done')
import slimPre
mesh_file = 'box2d.msh'
nPart = slimPre.dgpy.Msg.GetCommSize()
if nPart > 1:
if slimPre.dgpy.Msg.GetCommRank() == 0:
slimPre.dgpy.dgMeshPartition(mesh_file, nPart)
slimPre.dgpy.Msg.Barrier()
mesh_file = mesh_file[:-4] + '_' + str(nPart) + '.msh'
pre_data_dir_base = 'data_'+slimPre.partition_nb()+'/'
pre_data_dir = pre_data_dir_base+slimPre.partition_id()+'/'
slimPre.make_directory(pre_data_dir)
mesh2d = slimPre.Mesh(mesh_file)
region_global = slimPre.Region(mesh2d)
xyz = region_global.coordinates
bath = 50 *(1-xyz[:,0]/5000.)/2. + 50 *(1+xyz[:,0]/5000.)/2.
slimPre.write_file('bath_2d.nc', region=region_global, time=None, data=[('bath',bath)])
slimPre.write_file(pre_data_dir+'bath_2d.nc', region=region_global, time=None, data=[('bath',bath)])
slimPre.extrude(mesh_file, ('bath_2d.nc','bath'), nb_layers = 4, mesh_file_name_out='box.msh')
slimPre.extrude(mesh_file, (pre_data_dir+'bath_2d.nc','bath'), nb_layers = 4, mesh_file_name_out='box.msh')
mesh_file = 'box.msh'
mesh = slimPre.Mesh(mesh_file)
region_global = slimPre.Region(mesh, 'top')
region_global = slimPre.Region(mesh)
xyz = region_global.coordinates
import numpy
etaInit = 0.1 * numpy.exp(-(xyz[:,0]/2000)**2)
slimPre.write_file('etaInit.nc', region=region_global, time=None, data=[('eta',etaInit)])
slimPre.write_file(pre_data_dir+'etaInit.nc', region=region_global, time=None, data=[('eta',etaInit)])
print('prepro done')
......@@ -63,7 +60,7 @@ equations.set_limiter(True)
equations.set_initial_temperature('vertical_gradient', None, 3, -2/50.) #temporary. Change size after
equations.set_initial_salinity('vertical_gradient', None, 4, 0.)
equations.set_initial_elevation(('etaInit.nc', 'eta'))
equations.set_initial_elevation((pre_data_dir+'etaInit.nc', 'eta'))
time_loop = slim3d.Loop(equations,
......
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