[CIG-SHORT] mesh resolution

Charles Williams willic3 at gmail.com
Wed Mar 7 11:03:14 PST 2018


Dear Tu,

Look at the Trelis documentation for 'Exodus II-based Field Function’.  I can’t remember exactly, but I think it is a general guideline that controls cell size.  If you want to set the cell size to a specific value on the fault, you can either do this in your sizing function (you will need the nodeset for the fault), or you can set it explicitly in your journal file after you’ve done the cell sizing function.

Cheers,
Charles


> On 7/03/2018, at 8:12 PM, tu xiang <tuxiang2016 at outlook.com> wrote:
> 
> Hello, everyone
> I want to construct a mesh grid model which is dense near the fault and is sparse far from the fault. The example of "cubit_cellsize" is a good example. But I do not know what is the meaning of the variable "cell_size_fn". Is it the maximum distance from one node to another? or the maximum size of the cell on the fault? or other meaning? 
> If I want ensure that the size of the cell on the fault must smaller than one constant value, what should I do?
> 
> The code of the example of "cubit_cellsize"
> #!/usr/bin/env nemesis
> # ----------------------------------------------------------------------
> # PREREQUISITES: numpy, netCDF4, spatialdata (PyLith)
> 
> filenameExodus = "mesh_cellsize.exo"
> filenameDB = "matprops.spatialdb"
> minPeriod = 10.0
> 
> # ======================================================================
> import sys
> import numpy
> import netCDF4
> 
> # ----------------------------------------------------------------------
> # Cell size based on minimum wavelength with Vs from spatial database
> def getCellSizeDB(points):
> 
>     from spatialdata.geocoords.CSCart import CSCart
>     from spatialdata.spatialdb.SimpleDB import SimpleDB
>     from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
> 
>     # Coordinate system for mesh (must match coordsys in ExodusII file)
>     cs = CSCart()
>     cs._configure()
>     cs.initialize()
> 
>     # Spatial database with physical properties (Vs)
>     dbIO = SimpleIOAscii()
>     dbIO.inventory.filename = filenameDB
>     dbIO._configure()
>     db = SimpleDB()
>     db.inventory.iohandler = dbIO
>     db.inventory.label = "Physical properties"
>     db.inventory.queryType = "linear"
>     db._configure()
>     
>     (npoints, spacedim) = points.shape
> 
>     # Query database
>     db.open()
>     db.queryVals(["vs"])
>     data = numpy.zeros((npoints, 1), dtype=numpy.float64)
>     err = numpy.zeros((npoints,), dtype=numpy.int32)
>     db.multiquery(data, err, points, cs)
>     db.close()
> 
>     vs = data[:,0]
>     cellSize = minPeriod*vs / 10.0
>     return cellSize
> 
> 
> # ----------------------------------------------------------------------
> # Cell size based on analytical function of vertex coordinates.
> def getCellSizeFn(points):
>     """
>     Cell size is based on distance from a target and grows at a
>     geometric rate.
>     """
>     # Coordinates of target
>     target = (5.0e+3, -10.0e+3, -10.0e+3)
>     
>     # Compute distance from target
>     dist = ((points[:,0] - target[0])**2 + \
>                 (points[:,1] - target[1])**2 + \
>                 (points[:,2] - target[2])**2)**0.5
>     bias_factor = 1.05 # Geometric rate
>     dxStart = 1.0e+3 # Discretization size at target
>     npts = numpy.ceil( numpy.log(1-dist/dxStart*(1-bias_factor))/numpy.log(bias_factor))
>     cellSize = dxStart*bias_factor**npts
>     return cellSize
> 
> 
> # ----------------------------------------------------------------------
> # Get coordinates of points from ExodusII file.
> exodus = netCDF4.Dataset(filenameExodus, 'a')
> points = exodus.variables['coord'][:].transpose()
> cellSizeDB = getCellSizeDB(points)
> cellSizeFn = getCellSizeFn(points)
> 
> # Add cell size info to ExodusII file
> if not 'num_nod_var' in exodus.dimensions.keys():
>     exodus.createDimension('num_nod_var', 2)
> 
>     name_nod_var = exodus.createVariable('name_nod_var', 'S1',
>                                        ('num_nod_var', 'len_string',))
>     name_nod_var[0,:] = netCDF4.stringtoarr("cell_size_db", 33)
>     name_nod_var[1,:] = netCDF4.stringtoarr("cell_size_fn", 33)
>     
>     vals_nod_var = exodus.createVariable('vals_nod_var', numpy.float64,
>                                        ('time_step', 'num_nod_var', 'num_nodes',))
> 
> 
> time_whole = exodus.variables['time_whole']
> time_whole[0] = 0.0
> vals_nod_var = exodus.variables['vals_nod_var']
> vals_nod_var[0,0,:] = cellSizeDB.transpose()
> vals_nod_var[0,1,:] = cellSizeFn.transpose()
> 
> exodus.close()
> 
> # End of file
> 
> 
> Hope someone would like to help me .
> Best regards,
> Tu Xiang
> 
> _______________________________________________
> CIG-SHORT mailing list
> CIG-SHORT at geodynamics.org <mailto:CIG-SHORT at geodynamics.org>
> http://lists.geodynamics.org/cgi-bin/mailman/listinfo/cig-short <http://lists.geodynamics.org/cgi-bin/mailman/listinfo/cig-short>
Charles Williams I Geodynamic Modeler
GNS Science I Te Pῡ Ao
1 Fairway Drive, Avalon 5010, PO Box 30368, Lower Hutt 5040, New Zealand
Ph 0064-4-570-4566 I Mob 0064-22-350-7326 I Fax 0064-4-570-4600
http://www.gns.cri.nz/ <http://www.gns.cri.nz/> I Email: C.Williams at gns.cri.nz <mailto:your.email at gns.cri.nz>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.geodynamics.org/pipermail/cig-short/attachments/20180308/1d93e0a6/attachment-0001.html>


More information about the CIG-SHORT mailing list