Example #1
0
from pylagrit import PyLaGriT
import numpy as np

lg = PyLaGriT()

# Create base layer from x=10 to x=21 to match bert02 mesh
x = np.linspace(10., 21, (21. - 10.) / 0.25 + 1)
y = [0., 0.25]
top = lg.gridder(x, y, elem_type='quad', connect=True)

# Create top of mesh
# Collapse y values
top.addatt('y_save', type='vdouble', rank='scalar')
top.copyatt('yic', 'y_save')
top.setatt('yic', 0.)

# Read in top elevations
d = np.genfromtxt("./Topo_Profile_NS_ERT.csv", delimiter=",", names=True)
surf_pts = lg.points(x=d['Distance_m'], z=d['Z'], elem_type='quad')
surf_pts.addatt('z_save', type='vdouble', rank='scalar')
surf_pts.copyatt('zic', 'z_save')
surf_pts.setatt('zic', 0.)

# Interpolate surface elevations to top
top.addatt('z_val', type='vdouble', rank='scalar')
top.interpolate_voronoi('z_val', surf_pts, 'z_save')
top.copyatt('y_save', 'yic')
top.copyatt('z_val', 'zic')

# Save top
top.setatt('imt', 1)
Example #2
0
from pylagrit import PyLaGriT

# Create pylagrit object
lg = PyLaGriT()

# Define polygon points in clockwise direction
# and create tri mesh object
coords = [[0.0, 0.0, 0.0], [0.0, 1000.0, 0.0], [2200.0, 200.0, 0.0],
          [2200.0, 0.0, 0.0]]
motri = lg.tri_mo_from_polyline(coords)

# Triangulate polygon
motri.triangulate()
motri.setatt('imt', 1)
motri.setatt('itetclr', 1)

# refine mesh with successively smaller edge length constraints
edge_length = [1000, 500, 250, 125, 75, 40, 20, 15]
for i, l in enumerate(edge_length):
    motri.resetpts_itp()
    motri.refine(refine_option='rivara',
                 refine_type='edge',
                 values=[l],
                 inclusive_flag='inclusive')
    motri.smooth()
    motri.recon(0)

# provide additional smoothing after the last refine
for i in range(5):
    motri.smooth()
    motri.recon(0)
Example #3
0
"""
https://lanl.github.io/LaGriT/pages/docs/tutorial.html
This tutorial explains how to generate a grid in a
unit cube containing two materials separated by a
plane. (translated from LaGriT to PyLaGriT)
"""

from pylagrit import PyLaGriT
import numpy as np
"""
(1) Define mesh objects
---------------------------------------------------
- create a 3D tetrahedral mesh object and name it 3dmesh
"""
lg = PyLaGriT()
m = lg.create(name='3Dmesh')
"""
(2) Define an enclosing volume
---------------------------------------------------
- Define an enclosing volume using the surface command
- Since we are defining an exterior boundary, the boundary type is reflect.
"""
#  # not really sure how to do this in pylagrit...
#  mini = 0.0
#  maxi = 1.0
#  x = np.array([mini,maxi])
#  y = x
#  z = y
#
#  cube = lg.gridder(x,y,z)
Example #4
0
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()
Example #5
0
#  X
#-----
# blocks on either side of the fracture
l_block = np.linspace(-dm, -df / 2, 10)  # left block
r_block = -1 * l_block[::-1]  # right block
# assemble
x = np.concatenate((l_block, r_block), axis=0)
#-----
#  Y
#-----
y = x  #for now, same as x
#-----
#  Z
#-----
z = np.linspace(-L, 0., int(L) + 1)
"""
Build mesh
"""
#---- Create pylagrit object
l = PyLaGriT()
#---- create mesh object using xyz arrays in gridder
m = l.gridder(x, y, z)
#---- connect points
m.connect()

#---- visualize connected mesh using ParaView
# (assumes pylagritc is being used)
#--THIS NEEDS TO BE HERE     (otherwise mo1.inp file doesn't get created)
m.paraview(
)  # will throw an error on server, can still view mo1.inp on locally mounted paraview
Example #6
0
r_block = -1 * l_block[::-1]  # right block
# assemble
x = np.concatenate((l_block, r_block), axis=0)
#-----
#  Y
#-----
y = x  #for now, same as x
#-----
#  Z
#-----
z = np.linspace(-L, 0., int(L) + 1)
"""
Build mesh
"""
#---- Create pylagrit object
lg = PyLaGriT()
#---- create mesh object using xyz arrays
m = lg.gridder(x, y, z)
#---- connect points
m.connect()

#---- visualize connected mesh using ParaView
# (assumes pylagritc is being used)
#--THIS NEEDS TO BE HERE     (otherwise mo1.inp file doesn't get created)
m.paraview(filename='fracture_region.inp')

# fault coordinates
cs = [[-0.0005, -10., 0.], [-0.0005, 10., 0.], [0.0005, 10., 0.],
      [0.0005, 10., -100.], [0.0005, -10., -100.], [-0.0005, 10., -100.],
      [-0.0005, -10., -100.], [-0.0005, -10., -100.]]
cs = np.array(cs)
Example #7
0
N = numpy.where(numpy.isnan(d)==False)[0].shape[0]
fh.write(str(N)+' 0 0 0 0\n')
# 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)
Example #8
0
from pylagrit import PyLaGriT
import numpy
import sys

df = 0.0005  # Fault half aperture
lr = 7  # Levels of refinement
nx = 4  # Number of base mesh blocks in x direction
nz = 20  # Number of base mesh blocks in z direction
d_base = df * 2**(lr + 1)  # Calculated dimension of base block
w = d_base * nx  # Calculated width of model
d = d_base * nz  # Calculated depth of model

lg = PyLaGriT()

# Create discrete fracture mesh
dxyz = numpy.array([d_base, d_base, 0.])
mins = numpy.array([0., -d, 0.])
maxs = numpy.array([w, 0, 0])
mqua = lg.createpts_dxyz(dxyz,
                         mins,
                         maxs,
                         'quad',
                         hard_bound=('min', 'max', 'min'),
                         connect=True)

for i in range(lr):
    prefine = mqua.pset_geom_xyz(mins - 0.1, (0.0001, 0.1, 0))
    erefine = prefine.eltset()
    erefine.refine()
    prefine.delete()
    erefine.delete()
Example #9
0
from pylagrit import PyLaGriT
import numpy

x = numpy.arange(0, 10.1, 1)
y = [0, 1]
#z = [0,1]

lg = PyLaGriT()
layer = lg.gridder(x=x, y=y, elem_type='quad', connect=True)
layer.rotateln([0, layer.ymin - 0.10, 0], [0, layer.ymax + 0.1, 0], 25)
layer.dump('tmp_lay_top.inp')

# Layer depths?
#           1   2   3    4    5    6    7   8    9   10
layers = [.1, 1.]
addnum = [4, 2]
#matnum = [2]*len(layers)
matnum = [2, 1]
layer_interfaces = numpy.cumsum(layers)

mtop = layer.copy()
stack_files = ['tmp_lay_top.inp 1,9']
#stack_files.append('tmp_lay_peat_bot.inp 1,33')

i = 1
for li, m, a in zip(layer_interfaces, matnum, addnum):
    layer.math('sub', 'zic', value=li, cmosrc=mtop)
    stack_files.append('tmp_lay' + str(i) + '.inp ' + str(int(m)) + ', ' +
                       str(a))
    layer.dump('tmp_lay' + str(i) + '.inp')
    i += 1
Example #10
0
# blocks on either side of the fracture
l_block = np.linspace(-dm, -df / 2, 10)  # left block
r_block = -1 * l_block[::-1]  # right block
# assemble
x = np.concatenate((l_block, r_block), axis=0)
#-----
#  Y
#-----
y = x  #for now, same as x
#-----
#  Z
#-----
z = np.linspace(-L, 0., int(L) + 1)

#---- Define mesh objects
lg = PyLaGriT()
m = lg.gridder(x,
               y,
               z,
               connect=True,
               elem_type='hex',
               name='3Dfracture_mesh',
               filename='mesh.inp')
#  m = lg.create(name='3Dfracture_mesh')

# Define enclosing volume
box = lg.surface_box([-10., -10., -100.], [10., 10., 0.],
                     name='fullbox',
                     ibtype='reflect')

# NOT SURE IF NEED TO DEFINE INTERIOR INTERFACE(S)
# Import PyLaGriT class from pylagrit module
from pylagrit import PyLaGriT
import numpy

# Variables
maxX = 4000  # Max value in x direction
maxY = 4000  # Max value in y direction
maxZ = 3000  # Max value in z direction
numX = 51  # Number of points in x direction
numY = 51  # Number of points in y direction
numZ = 26  # Number of points in z direction

# Create PyLaGriT object
# This assumes that pylagritrc is being used so that lagrit_exe option does not need to be specified
lg = PyLaGriT()

#********************************************
# 01 Built HEX Mesh
#********************************************
# Create mesh object
mo = lg.create_hex()
mo.createpts_brick_xyz((numX, numY, numZ), (0, 0, 0), (maxX, maxY, maxZ))

# Save the mesh object
mo.dump('tmp_hex_01.inp')

# Set vertices (imt) and cells (itetlcr) to 1
mo.setatt('imt', 1)
mo.setatt('itetclr', 1)
Example #12
0
from pylagrit import PyLaGriT
import numpy as np

lg = PyLaGriT()

# Create base layer, with x matching s from the csv file 
x = np.linspace(0.,29.75,(29.75-0.)/0.25+1)
y = [0.,0.25]
top = lg.gridder(x,y,elem_type='quad',connect=True)

# Create top of mesh
# Collapse y values
top.addatt('y_save',vtype='vdouble',rank='scalar')
top.copyatt('yic','y_save')
top.setatt('yic',0.)

# Read in top elevations
d = np.genfromtxt("transectNWSE.csv", delimiter=",", names=True)
coords = np.column_stack([d['s'],np.zeros_like(d['s']),d['z']])
surf_pts = lg.points(coords,elem_type='quad')
surf_pts.addatt('z_save',vtype='vdouble',rank='scalar')
surf_pts.copyatt('zic','z_save')
surf_pts.setatt('zic',0.)

# Interpolate surface elevations to top
top.addatt('z_val',vtype='vdouble',rank='scalar')
top.interpolate_voronoi('z_val',surf_pts,'z_save')
top.copyatt('y_save','yic')
top.copyatt('z_val','zic')

# Save top
Example #13
0
from pylagrit import PyLaGriT
l = PyLaGriT()
mhex = l.read_fehm('fehm.grid')
#mhex.paraview()

mtet = l.create(elem_type='tet')
mtet = mhex.copypts()
mtet.connect()
mtet.paraview()


Example #14
0
def main(argv=None):
    
    if argv == None:
        argv = sys.argv
    
    parser = argparse.ArgumentParser(description = "Convert Modflow to Amanzi")
    parser.add_argument("-p", "--pfile", help="name of parameter file", default=PARAMETER_FILE)
    parser.add_argument("-v", "--view", help="view in Paraview", action="store_true", default = False)
    args = parser.parse_args()
    
    PFILE = args.pfile
    VIEW_IN_PARAVIEW = args.view
    
    # Initialize LaGriT
    l = PyLaGriT()
    
    # Load parameters file & check for missing values
    params = load_params(PFILE)
    verify_params(params)
    
    # Assign parameters to variables
    input_bnds = params['input_bnds']
    export_name = params['export_name']
    nrows = int(params['nrows'])
    ncols = int(params['ncols'])
    llcorner = [float(params['minx']),float(params['miny'])]
    D_XY=[float(params['dx']),float(params['dy'])]
    
    # IBND and IMAT materials properties
    ibnd = {"active": int(params['ibnd_active']), "noflow": int(params['ibnd_noflow']),\
            "head": int(params['ibnd_head']), "edge": int(params['ibnd_edge']), "halite": int(params['ibnd_halite'])}
    imat = {"active": int(params['imat_active']), "noflow": int(params['imat_noflow']),\
            "head": int(params['imat_head']), "edge": int(params['imat_edge']), "halite": int(params['imat_halite'])}

    # Cycle through these keys instead of dictionary to preserve sequence
    mat_keys = ['active','noflow','head','edge','halite']

    fs_bottom = int(params['fs_bottom'])
    fs_top = int(params['fs_top'])
    fs_east = int(params['fs_east'])
    fs_north = int(params['fs_north'])
    fs_west = int(params['fs_west'])
    fs_south = int(params['fs_south'])
    fs_halite = int(params['fs_halite'])
    fs_head = int(params['fs_head'])
    fs_noflow = int(params['fs_noflow'])
    
    rmmat_edge = int(params['rmmat_edge'])
    maxmat = int(params['maxmat'])
    
    EXO_FILE=params['exo_file']
    
    # Generate hexmesh with cell-centered materials and optional elevation
    hexmesh = l.read_modflow(input_bnds, nrows, ncols, DXY=D_XY, name=MESH_NAME)
    
    # Eltset stuff
    for i, key in enumerate(mat_keys):
        hexmesh.eltset_attribute("mod_bnds", ibnd[key], boolstr='eq', name="e{}".format(i+1))
        hexmesh.setatt("itetclr",imat[key],stride=["eltset","get","e{}".format(i+1)])
    
    l.sendline('cmo/select/{}'.format(hexmesh.name)) # tmp ---------------------------------------------------
    
    # Remove edge cells
    hexmesh.eltset_attribute("itetclr",rmmat_edge,boolstr='eq',name="eremove") # Find edge cells
    hexmesh.rmpoint_eltset("eremove") # Remove edge cells
    hexmesh.rmpoint_compress(filter_bool=False, resetpts_itp=True) # compress and reset
    
    # Temp facesets for internal side interfaces
    mo_sides = l.extract_surfmesh(name="mo_sides",cmo_in=hexmesh,stride=[1,0,0],append='-all-',reorder=False,resetpts_itp=False)
    l.sendline("cmo/select/mo_sides")
    
    # Create psets from attributes 1 & 2
    ptop = mo_sides.pset_attribute("pts_topbot",2,comparison='eq',stride=(1,0,0),name="ptop")
    pbot = mo_sides.pset_attribute("pts_topbot",1,comparison='eq',stride=(1,0,0),name="pbot")
    
    # Generate eltsets from psets
    etop = ptop.eltset(membership='exclusive',name='etop')
    ebot = pbot.eltset(membership='exclusive',name='ebot')
    
    # Create a single eltset from the above two & remove
    e_delete = mo_sides.eltset_bool([etop,ebot],boolstr='union',name='e_delete')
    mo_sides.rmpoint_eltset("e_delete",compress=True,resetpts_itp=False)
    
    # NOFLOW faces (west corner)
    mo_tmp = l.copy(mo_sides, name="mo_tmp")
    edel = mo_tmp.eltset_attribute("itetclr0",imat["noflow"],boolstr='ne',name='edel')
    mo_tmp.rmpoint_eltset("edel",compress=True,resetpts_itp=True)
    mo_fs1 = l.copy(mo_tmp,name="mo_fs1")
    mo_tmp.delete()
    
    # Halite faces (eastern curve)
    mo_tmp = l.copy(mo_sides,name="mo_tmp")
    l.sendline("cmo/select/mo_tmp")
    edel = mo_tmp.eltset_attribute("itetclr0",imat["halite"],boolstr='ne',name='edel')
    mo_tmp.rmpoint_eltset("edel",compress=True,resetpts_itp=True)
    mo_fs2 = l.copy(mo_tmp,name="mo_fs2")
    mo_tmp.delete()
    
    mo_sides.delete()
    
    l.sendline("cmo/select/{}".format(hexmesh.name))
    edel = hexmesh.eltset_attribute("itetclr",maxmat,boolstr='gt',name='edel')
    hexmesh.rmpoint_eltset("edel",compress=True,resetpts_itp=True)
    
    # Final facesets for cropped mesh
    mo_surf = l.extract_surfmesh(name="mo_surf",cmo_in=hexmesh,stride=[1,0,0],append='external',reorder=False,resetpts_itp=False)
    mo_surf.addatt("id_normal",vtype='vint',rank='scalar',length='nelements',interpolate='',persistence='',ioflag='',value='')
    mo_surf.addatt("id_tmp",vtype='vint',rank='scalar',length='nelements',interpolate='',persistence='',ioflag='',value='')
    l.sendline("cmo/select/mo_surf")
    mo_surf.settets(method='normal')
    mo_surf.copyatt('itetclr',attname_sink='id_normal',mo_src=mo_surf)
    
    # Tag top and bottom face sets
    ptop = mo_surf.pset_attribute("pts_topbot",2,comparison='eq',stride=(1,0,0),name="ptop")
    pbot = mo_surf.pset_attribute("pts_topbot",1,comparison='eq',stride=(1,0,0),name="pbot")
    etop = ptop.eltset(membership='exclusive',name='etop')
    ebot = pbot.eltset(membership='exclusive',name='ebot')
    mo_surf.setatt("itetclr",2,stride=["eltset","get","etop"])
    mo_surf.setatt("itetclr",1,stride=["eltset","get","ebot"])
    
    mo_fs1.setatt("itetclr",1)
    mo_surf.setatt("id_tmp",0)
    mo_surf.interpolate('map','id_tmp',mo_fs1,'itetclr',stride=[1,0,0])
    etmp = mo_surf.eltset_attribute('id_tmp',1,boolstr='eq',name='etmp')
    mo_surf.setatt('itetclr',fs_noflow,stride=['eltset','get','etmp'])
    etmp.delete()

    # Interface between material 1 and halite and head cells
    mo_fs2.setatt('itetclr',1)
    mo_surf.setatt('id_tmp',0)
    mo_surf.interpolate('map','id_tmp',mo_fs2,'itetclr',stride=[1,0,0])
    etmp = mo_surf.eltset_attribute('id_tmp',1,boolstr='eq',name='etmp')
    mo_surf.setatt('itetclr',fs_halite,stride=['eltset','get','etmp'])
    etmp.delete()

    mo_surf.addatt('id_side',vtype='VINT',rank='scalar',length='nelements',interpolate='',persistence='',ioflag='',value='')
    mo_surf.copyatt('itetclr',attname_sink='id_side',mo_src=mo_surf)
    
    # Check for continuous connected boundary of 1
    mo_chk = l.copy(mo_surf,name='mo_chk')
    l.boundary_components(style='element',reset=False)
    mo_chk.delete()
    
    # Make sure to remove all attributes except idelem1 and idface1
    bad_atts = ['id_normal','itetclr0','idnode0','idelem0','facecol','itetclr1','idface0','id_tmp','ncon50','nconbnd','icontab']
    for att in bad_atts:
        mo_surf.delatt(att)
    
    l.sendline("cmo/select/mo_surf")
    filenames = ['bottom','top','east','north','west','south','head','noflow']
    ss_ids = [1,2,3,4,5,6,7,8]
    
    # WRITE ALL FACESET FILES
    for i in range(0,len(ss_ids)):
        l.sendline('define/FILENAME/fs_{}.faceset'.format(filenames[i]))
        l.sendline('define/SS_ID/{}'.format(ss_ids[i]))
        write_fs_file(l)
    
    
    #hexmesh.dump_exo(EXO_FILE,facesets=['fs_bottom.faceset','fs_top.faceset','fs_east.faceset'])
    l.sendline('dump / exo / {} / {} / / / facesets &\n fs_bottom.faceset fs_top.faceset fs_east.faceset &\n fs_north.faceset fs_west.faceset fs_south.faceset &\n fs_head.faceset fs_noflow.faceset'.format(EXO_FILE, hexmesh.name))
    
    hexmesh.dump_avs2(export_name)
    
    if (VIEW_IN_PARAVIEW == True):
        hexmesh.paraview()
Example #15
0
"""
3D Quarter-model mesh domain of fracture and cavity (no matrix).
author: jportiz
11/15/18
"""
from pylagrit import PyLaGriT
import numpy as np
from math import log10


l = PyLaGriT()

# domain lengths in each dimension
xl = 50. #[m] 
yl = 50. #[m]
zl = 100. #[m] depth
df = 0.05
largedf = 0.05 #[m] fracture aperture
lr = 3 #levels of mesh refinement
#  d_base = df/2.*2**(lr+1) #calculated dimension of base block
cav_center_depth = 70. #[m] depth of cavity center
radius = 20. #[m] cavity radius

# grid discretization
dx = 1.
dy = 1.
dz = 1.
dxyz = np.array([dx,dy,dz])

# (1) ---- Model domain 
x = np.arange(0,xl+dx,dx)
Example #16
0
"""
Making a sphere object in pylagrit.
(For cavity/chimney).
"""

# Import PyLaGriT class from pylagrit module
from pylagrit import PyLaGriT
import numpy as np


l = PyLaGriT()
# create emppty mesh object data structure
m = l.create()

#  """
#  Define enclosing volume useing 'surface'
#  """
sph_surf =





Example #17
0
from pylagrit import PyLaGriT
import numpy

x = numpy.arange(0, 10.1, 1)
y = x
z = [0, 1]

lg = PyLaGriT()
mqua = lg.gridder(x, y, z, elem_type='hex', connect=True)

mqua.rotateln([mqua.xmin - 0.1, 0, 0], [mqua.xmax + 0.1, 0, 0], 25)

mqua.dump_exo('rotated.exo')
mqua.dump_ats_xml('rotated.xml', 'rotated.exo')

mqua.paraview()
Example #18
0
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
Example #19
0
"""
3D Quarter-model mesh domain of DFN fracture
and simplified explosion cavity (quarter-sphere).
author: jportiz
7/17/18
"""
from pylagrit import PyLaGriT
import numpy as np
from math import log10

l = PyLaGriT()

# domain lengths in each dimension
xl = 50.  #[m]
yl = 50.  #[m]
zl = 100.  #[m] depth
df = 0.01  #[m] fracture aperture
lr = 3  #levels of mesh refinement
d_base = df / 2. * 2**(lr + 1)  #calculated dimension of base block
cav_center_depth = 70.  #[m] depth of cavity center
radius = 20.  #[m] cavity radius

# grid discretization
dx = 1.
dy = 1.
dz = 1.
dxyz = np.array([dx, dy, dz])

# (1) ---- Model domain
x = np.arange(0, xl + dx, dx)
telx = np.concatenate((np.array([0., df / 2.]),
Example #20
0
from pylagrit import PyLaGriT
import numpy

# Variables
nx = 50  # Number of points in x direction
dy = 0.25  # width of cells in y direction
distance = 12.34364319  # distance in x direction

l = PyLaGriT()

# 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
Example #21
0
from pylagrit import PyLaGriT
lg = PyLaGriT()
mesh = lg.create()
mins = (0, 0, 0)
maxs = (5, 5, 5)
eighth = mesh.surface_box(mins, maxs)
boolstr1 = 'le ' + eighth.name
boolstr2 = 'gt ' + eighth.name
reg1 = mesh.region(boolstr1)
reg2 = mesh.region(boolstr2)
mreg1 = mesh.mregion(boolstr1)
mreg2 = mesh.mregion(boolstr2)
mesh.createpts_brick_xyz((10, 10, 10), (0, 0, 0), (10, 10, 10))
mesh.rmregion(reg1)
mesh.dump('reg_test.gmv')
Example #22
0
"""
2D mesh domain of fracture and matrix for
uniform contaminated zone comparison with
3D quarter-sphere cavity.
author: jportiz
7/16/18
"""
from pylagrit import PyLaGriT
import numpy as np
from math import log10


l = PyLaGriT()

# domain lengths in each dimension
xl = 50. #[m] 
yl = 50. #[m]
zl = 100. #[m] depth
df = 0.001 #[m] fracture aperture
largedf = 0.05 #[m] fracture aperture
lr = 3 #levels of mesh refinement
#  d_base = df/2.*2**(lr+1) #calculated dimension of base block
cav_center_depth = 80. #[m] depth of cavity center
radius = 10. #[m] cavity radius

# grid discretization
dx = 1.
dy = 1.
dz = 1.
dxyz = np.array([dx,dy,dz])
#  dxz = np.array([dx,dz])
Example #23
0
from pylagrit import PyLaGriT
l = PyLaGriT()

# Create 2x2x2 cell mesh
m = l.create()
m.createpts_dxyz((0.5,0.5,0.5),(0.,0.,0.),(1.,1.,1.),rz_switch=[1,1,1],connect=True)
m.paraview()
#m.gmv()

# Create 2x2x2 mesh where maxs will be truncated to nearest value under given maxs
m_under = l.create()
m_under.createpts_dxyz((0.4,0.4,0.4),(0.,0.,0.),(1.,1.,1.),rz_switch=[1,1,1],connect=True)
m_under.paraview()
#m_under.gmv()

# Create 3x3x3 mesh where maxs will be truncated to nearest value over given maxs
m_over = l.create()
m_over.createpts_dxyz((0.4,0.4,0.4),(0.,0.,0.),(1.,1.,1.),clip='over',rz_switch=[1,1,1],connect=True)
m_over.paraview()
#m_over.gmv()

# Create 3x3x3 mesh where x and y maxs will be truncated to nearest value over given maxs
# and z min will be truncated  to nearest value 
m_mixed = l.create()
m_mixed.createpts_dxyz((0.4,0.4,0.4),(0.,0.,-1.),(1.,1.,0.),hard_bound=('min','min','max'),clip=('under','under','over'),rz_switch=[1,1,1],connect=True)
m_mixed.paraview()
#m_over.gmv()