# Create base layer layer = l.create_qua() layer.createpts_xyz((nx, 2, 1), [0., 0., 0.], [distance, dy, 0.], rz_switch=[1, 1, 1], connect=True) layer.setatt('itetclr', 12) layer.minmax_xyz() # Create top of mesh # Collapse y values layer.addatt('y_save', vtype='vdouble', rank='scalar') layer.copyatt('yic', 'y_save') layer.setatt('yic', 0.) # Read in lidar top elevations peat_surf_pts = l.read('surface_coords2.avs') peat_surf_pts.addatt('z_save', vtype='vdouble', rank='scalar') peat_surf_pts.copyatt('zic', 'z_save') peat_surf_pts.setatt('zic', 0.) # Interpolate surface elevations to layer mo layer.addatt('z_val', vtype='vdouble', rank='scalar') layer.interpolate_voronoi('z_val', peat_surf_pts, 'z_save') layer.copyatt('y_save', 'yic') layer.copyatt('z_val', 'zic') # Save peat top layer.setatt('imt', 1) layer.setatt('itetclr', 1) layer.dump('tmp_lay_peat_top.inp') peat_surf_pts.delete()
from pylagrit import PyLaGriT import numpy lg = PyLaGriT() # Read in mesh motet = lg.read('tet_matclr.inp') # Jim Bridger fault coordinates in feet from John Ziao cs = [[498000., 381946., 0.], [497197., 381946., 0.], [494019., 384890., 0.], [490326., 386959., 0.], [487822., 388599., 0.], [486337., 390755., 0.], [486337., 392000., 0.]] # Convert to meters cs = numpy.array(cs) / 3.28 # Create surfaces of fault ss = [] for p1, p2 in zip(cs[:-1], cs[1:]): p3 = p1.copy() p3[2] = -4000. ss.append(lg.surface_plane(p1, p2, p3)) # Create region by boolean operations of fault surfaces boolstr = '' for i, s in enumerate(ss): if not i == 0: boolstr += ' and ' boolstr += 'le ' + s.name r = lg.region_bool(boolstr) # Create pset from region
# Collect data into avs format # JDM: Not sure if this should be nx*ny? davs = numpy.zeros([nx*ny,4]) ind = 0 for i,row in enumerate(d): for j,v in enumerate(row): davs[ind,:] = [ind + 1, xx[i,j], yy[i,j], v] ind += 1 # Write data to avs file numpy.savetxt(fh,davs,fmt=['%4d','%.1lf','%.1lf','%.8lf']) fh.close() # Crank up pylagrit lg = PyLaGriT() # Read in elevations in avs fromat m = lg.read(dem_file_base+'.avs') # Take a look, change paraview exe # Will need to use glyph filter to view points #m.paraview(exe='paraview') # Copy z values over to attribute m.addatt('z_save',type='vdouble',rank='scalar') m.copyatt('zic','z_save') # Not sure why this has to be done, but not data elements don't get removed otherwise m.setatt('zic',0.) # Create connected quad mesh surface m2 = lg.create() #m2.createpts_xyz((nx,ny,1),[xx.min(),yy.min(),0.],[xx.max(),yy.max(),0],rz_switch=[1,1,1],connect=True) m2.createpts_xyz((nx,ny,1),[xx.min(),yy.min(),0.],[xx.max(),yy.max(),0],rz_switch=[1,1,1]) # Create temporary z value attribute
from pylagrit import PyLaGriT import numpy as np # User parameters ####################### # Discretization nx = 61 ny = 61 # Polygon delineation filename polygon_file = '2d_mesh.avs' # User parameters ####################### l = PyLaGriT() # Read in polygon delineation mesh mopoly = l.read(polygon_file) # Create quad using polygon min and max coordinates xs = np.linspace(mopoly.xmin, mopoly.xmax, nx) ys = np.linspace(mopoly.ymin, mopoly.ymax, ny) moquad = l.gridder(xs, ys, elem_type='quad', connect=True) mopoly.setatt('itetclr', 1) # Create extruded quad to tet and center at z=0 mopoly.extrude(1.0) moprism = mopoly.extrude(1.0) moprism.trans((0., 0., 0.), (0., 0., 0.5)) motet = moprism.grid2grid_prismtotet3() # Clean up a little mopoly.delete() moprism.delete()
pset1_fp.setatt('imt', 4) pset2_fp.setatt('imt', 5) pset3_fp.setatt('imt', 6) eltset1_fm.setatt('itetclr', 1) eltset2_fm.setatt('itetclr', 2) eltset3_fm.setatt('itetclr', 3) eltset1_fp.setatt('itetclr', 4) eltset2_fp.setatt('itetclr', 5) eltset3_fp.setatt('itetclr', 6) #******************************************** # 06 Define a polyline and truncate the exterior boundary of the mesh with the polyline #******************************************** # Read boundary polygon file mobndry = lg.read('basin_bnd_ply_rescale.inp') # Extrude the polyline into a vertical surface mofence = mobndry.extrude(3200, 'const', 'volume', [0, 0, -1]) mobndry.minmax_xyz() mofence.minmax_xyz() # Translate the extrusion to make it cover the vertical extent of the hex mesh mofence.trans((0, 0, -3100), (0, 0, 0)) mofence.minmax_xyz() #mofence.paraview() #mofence.dump('3D_vertical_surface.inp') #mo.dump('cube.inp')