In [1]:
import sys,os
sys.path.append(os.path.join(os.environ['ATS_SRC_DIR'],'tools','meshing_ats'))
import meshing_ats
import numpy as np
In [2]:
# create the surface strip mesh
xz = np.loadtxt("nathan_polygon.txt")
m2 = meshing_ats.Mesh2D.from_Transect(xz[:,0],xz[:,1])
In [4]:
# build up the layering structure as we extrude in the vertical
# first cut: 4 layers, each with uniform dz in the layer
layer_types = ['constant','constant','constant','constant']
layer_dzs = [0.01, 0.02, 0.05, 1]
ncells_per_layer = [2, 9, 40, 49]
layer_material_id = [101, 101, 101, 101]
m3 = meshing_ats.Mesh3D.extruded_Mesh2D(m2, layer_types, layer_dzs,
ncells_per_layer, layer_material_id)
m3.write_exodus("nathan_mesh1.exo")
In [3]:
# make a fancier version:
# make the top layer a variable thickness layer
def dz_layer1(s):
return (np.sin(2*np.pi * s / 23.0) + 0.02)**2
dzs_layer1 = np.array([dz_layer1(x) for x in m2.coords[:,0]])
# make the second and third layer constant dz, and make the
# fourth layer "snap" to the bottom coordinate of z = -45m.
# This results in a flat-bottomed mesh, and the bottom layer
# adjusts dz to match that bottom.
layer_types = ['node','constant','constant','snapped']
layer_data = [dzs_layer1, 1, 2, -45.0]
ncells_per_layer = [2, 9, 5, 10]
layer_material_ids = [101, 101, 101, 101]
m3 = meshing_ats.Mesh3D.extruded_Mesh2D(m2, layer_types,
layer_data,
ncells_per_layer,
layer_material_ids)
m3.write_exodus("nathan_mesh2.exo")