本文整理汇总了Python中spatialdata.spatialdb.SimpleIOAscii.SimpleIOAscii类的典型用法代码示例。如果您正苦于以下问题:Python SimpleIOAscii类的具体用法?Python SimpleIOAscii怎么用?Python SimpleIOAscii使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleIOAscii类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: getCellSizeDB
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
开发者ID:panzhengyang,项目名称:pylith,代码行数:34,代码来源:exodus_add_properties.py
示例2: test_preinitialize
def test_preinitialize(self):
"""
Test preinitialize().
WARNING: This is not a rigorous test of initialize() because we
don't verify the results.
"""
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
cell.inventory.dimension = 2
cell.inventory.order = 1
cell.inventory.degree = 1
cell._configure()
from pylith.feassemble.Quadrature import Quadrature
quadrature = Quadrature()
quadrature.inventory.cell = cell
quadrature.inventory.minJacobian = 1.0e-4
quadrature._configure()
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
iohandler = SimpleIOAscii()
iohandler.inventory.filename = "data/matinitialize.spatialdb"
iohandler._configure()
db = SimpleDB()
db.inventory.label = "material properties"
db.inventory.iohandler = iohandler
db._configure()
from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
material = ElasticPlaneStrain()
material.inventory.quadrature = quadrature
material.inventory.dbProperties = db
material.inventory.label = "my material"
material.inventory.id = 54
material._configure()
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 2
cs._configure()
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
normalizer._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
importer.inventory.filename = "data/twoelems.mesh"
importer.inventory.coordsys = cs
importer._configure()
mesh = importer.read(debug=False, interpolate=False)
material.preinitialize(mesh)
# No test of result.
return
开发者ID:youngsolar,项目名称:pylith,代码行数:58,代码来源:TestMaterial.py
示例3: _preinitialize
def _preinitialize(self):
"""
Setup mesh and integrator and preinitialize integrator.
"""
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
normalizer._configure()
# Setup mesh
cs = CSCart()
cs.inventory.spaceDim = 2
cs._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
importer.inventory.filename = "data/tri3.mesh"
importer.inventory.coordsys = cs
importer._configure()
mesh = importer.read(debug=False, interpolate=False)
# Setup material
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
cell.inventory.dimension = 2
cell.inventory.degree = 1
cell.inventory.order = 1
cell._configure()
from pylith.feassemble.Quadrature import Quadrature
quadrature = Quadrature()
quadrature.inventory.cell = cell
quadrature._configure()
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
iohandler = SimpleIOAscii()
iohandler.inventory.filename = "data/elasticplanestrain.spatialdb"
iohandler._configure()
db = SimpleDB()
db.inventory.label = "elastic plane strain"
db.inventory.iohandler = iohandler
db._configure()
from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
material = ElasticPlaneStrain()
material.inventory.label = "elastic plane strain"
material.inventory.id = 0
material.inventory.dbProperties = db
material.inventory.quadrature = quadrature
material._configure()
from pylith.meshio.OutputMatElastic import OutputMatElastic
material.output = OutputMatElastic()
material.output._configure()
material.output.writer._configure()
# Setup integrator
integrator = ElasticityImplicitLgDeform()
integrator.preinitialize(mesh, material)
return (mesh, integrator)
开发者ID:rishabhdutta,项目名称:pylith,代码行数:58,代码来源:TestElasticityImplicitLgDeform.py
示例4: generate
def generate(sim, fileRoot, materials):
for material in materials:
filenameH5 = "../output/%s-%s.h5" % (sim, material)
filenameDB = "%s-%s.spatialdb" % (fileRoot, material)
# Open HDF5 file and get coordinates, cells, and stress.
h5 = h5py.File(filenameH5, "r")
vertices = h5['geometry/vertices'][:]
cells = numpy.array(h5['topology/cells'][:], dtype=numpy.int)
# Get stresses from final time step.
stress = h5['cell_fields/stress'][-1,:,:]
h5.close()
# Compute coordinates of quadrature points.
quadCoords = getCellCenters(vertices, cells)
# Create writer for spatial database file
writer = SimpleIOAscii()
writer.inventory.filename = filenameDB
writer._configure()
values = [{'name': "stress-xx",
'units': "Pa",
'data': stress[:,0]},
{'name': "stress-yy",
'units': "Pa",
'data': stress[:,1]},
{'name': "stress-zz",
'units': "Pa",
'data': stress[:,2]},
{'name': "stress-xy",
'units': "Pa",
'data': stress[:,3]},
{'name': "stress-yz",
'units': "Pa",
'data': stress[:,4]},
{'name': "stress-xz",
'units': "Pa",
'data': stress[:,5]},
]
writer.write({'points': quadCoords,
'coordsys': cs,
'data_dim': 3,
'values': values})
return
开发者ID:geodynamics,项目名称:pylith,代码行数:50,代码来源:generate_initial_stress.py
示例5: run
def run(self):
"""
Generate the database.
"""
# Domain
x = numpy.arange(-4000.0, 4000.1, 1000.0)
y = numpy.arange(-4000.0, 4000.1, 1000.0)
z = numpy.arange(-6000.0, 0000.1, 1000.0)
nptsX = x.shape[0]
nptsY = y.shape[0]
nptsZ = z.shape[0]
xx = x * numpy.ones( (nptsY*nptsZ, 1), dtype=numpy.float64)
yy0 = y * numpy.ones( (nptsZ, 1), dtype=numpy.float64)
yy = yy0.ravel() * numpy.ones( (nptsX, 1), dtype=numpy.float64)
zz = z * numpy.ones( (nptsX*nptsY, 1), dtype=numpy.float64)
xyz = numpy.zeros( (nptsX*nptsY*nptsZ, 3), dtype=numpy.float64)
xyz[:,0] = numpy.ravel(xx)
xyz[:,1] = numpy.ravel(numpy.transpose(yy))
xyz[:,2] = numpy.ravel(numpy.transpose(zz))
from rigidbody_soln import AnalyticalSoln
soln = AnalyticalSoln()
disp = soln.displacement(xyz)
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 3
cs._configure()
data = {'locs': xyz,
'coordsys': cs,
'data_dim': 2,
'values': [{'name': "displacement-x",
'units': "m",
'data': numpy.ravel(disp[:,0])},
{'name': "displacement-y",
'units': "m",
'data': numpy.ravel(disp[:,1])},
{'name': "displacement-z",
'units': "m",
'data': numpy.ravel(disp[:,2])}]}
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
io = SimpleIOAscii()
io.inventory.filename = "rigidbody_disp.spatialdb"
io._configure()
io.write(data)
return
开发者ID:jjle,项目名称:pylith,代码行数:48,代码来源:rigidbody_gendb.py
示例6: run
def run(self):
"""
Generate the database.
"""
# Domain
x = numpy.arange(-4000.0, 4000.1, 500.0)
y = numpy.arange(-4000.0, 4000.1, 500.0)
z = numpy.arange(-6000.0, 0.1, 500.0)
nxpts = x.shape[0]
nypts = y.shape[0]
nzpts = z.shape[0]
xx = numpy.tile(x, (1,nypts*nzpts))
yy = numpy.tile(y, (nxpts,nzpts)).transpose()
zz = numpy.tile(z, (nxpts*nypts,1)).transpose()
xyz = numpy.zeros( (nxpts*nypts*nzpts, 3), dtype=numpy.float64)
xyz[:,0] = numpy.ravel(xx)
xyz[:,1] = numpy.ravel(yy)
xyz[:,2] = numpy.ravel(zz)
from axialdisp_soln import AnalyticalSoln
soln = AnalyticalSoln()
disp = soln.displacement(xyz)
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 3
cs._configure()
data = {'points': xyz,
'coordsys': cs,
'data_dim': 3,
'values': [{'name': "displacement-x",
'units': "m",
'data': numpy.ravel(disp[:,0])},
{'name': "displacement-y",
'units': "m",
'data': numpy.ravel(disp[:,1])},
{'name': "displacement-z",
'units': "m",
'data': numpy.ravel(disp[:,2])}]}
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
io = SimpleIOAscii()
io.inventory.filename = "axial_disp.spatialdb"
io._configure()
io.write(data)
return
开发者ID:jjle,项目名称:pylith,代码行数:48,代码来源:axialdisp_gendb.py
示例7: testDBProperties
def testDBProperties(self):
"""
Test dbProperties().
"""
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
iohandler = SimpleIOAscii()
iohandler.inventory.filename = "data/staticfriction.spatialdb"
iohandler._configure()
db = SimpleDB()
db.inventory.label = "friction properties"
db.inventory.iohandler = iohandler
db._configure()
self.friction.dbProperties(db)
# No test of result.
return
开发者ID:panzhengyang,项目名称:pylith,代码行数:18,代码来源:TestFrictionModel.py
示例8: testDBInitialState
def testDBInitialState(self):
"""
Test dbInitialState().
"""
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
iohandler = SimpleIOAscii()
iohandler.inventory.filename = "data/matinitialize.spatialdb"
iohandler._configure()
db = SimpleDB()
db.inventory.label = "material properties"
db.inventory.iohandler = iohandler
db._configure()
self.material.dbInitialState(db)
# No test of result.
return
开发者ID:youngsolar,项目名称:pylith,代码行数:18,代码来源:TestMaterial.py
示例9: testDBInitialStrain
def testDBInitialStrain(self):
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
iohandler = SimpleIOAscii()
iohandler.inventory.filename = "data/matinitialize.spatialdb"
iohandler._configure()
db = SimpleDB()
db.inventory.label = "material properties"
db.inventory.iohandler = iohandler
db._configure()
material = self.material
material.inventory.label = "Elastic material"
material.inventory.dbInitialStrain = db
material.inventory.useInitialStrain = True
material._configure()
# No test of result.
return
开发者ID:jjle,项目名称:pylith,代码行数:19,代码来源:TestElasticMaterial.py
示例10: run
def run(self):
"""
Generate the database.
"""
from sheardisp_soln import AnalyticalSoln
soln = AnalyticalSoln()
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 3
cs._configure()
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
io = SimpleIOAscii()
for component in ["x","y","z"]:
if component == "y":
xyz = numpy.array([[-40.0e+3, 0.0, 0.0],
[+40.0e+3, 0.0, 0.0]], dtype=numpy.float64)
ic = 1
elif component == "x":
xyz = numpy.array([[0.0, -40.0e+3, 0.0],
[0.0, +40.0e+3, 0.0]], dtype=numpy.float64)
ic = 0
elif component == "z":
xyz = numpy.array([[0.0, 0.0, -40.0e+3],
[0.0, 0.0, 0.0]], dtype=numpy.float64)
ic = 2
disp = soln.displacement(xyz)
io.inventory.filename = "shear_disp%s.spatialdb" % component
io._configure()
data = {'points': xyz,
'coordsys': cs,
'data_dim': 1,
'values': [{'name': "displacement-%s" % component,
'units': "m",
'data': numpy.ravel(disp[0,:,ic])},
]}
io.write(data)
return
开发者ID:rishabhdutta,项目名称:pylith,代码行数:42,代码来源:sheardisp_gendb.py
示例11: run
def run(self):
"""
Generate the database.
"""
# Domain
x = numpy.arange(-4000.0, 4000.1, 1000.0)
y = numpy.arange(-4000.0, 4000.1, 1000.0)
npts = x.shape[0]
xx = x * numpy.ones((npts, 1), dtype=numpy.float64)
yy = y * numpy.ones((npts, 1), dtype=numpy.float64)
xy = numpy.zeros((npts ** 2, 2), dtype=numpy.float64)
xy[:, 0] = numpy.ravel(xx)
xy[:, 1] = numpy.ravel(numpy.transpose(yy))
from sheardisp_soln import AnalyticalSoln
soln = AnalyticalSoln()
disp = soln.displacement(xy)
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 2
cs._configure()
data = {
"points": xy,
"coordsys": cs,
"data_dim": 2,
"values": [
{"name": "displacement-x", "units": "m", "data": numpy.ravel(disp[0, :, 0])},
{"name": "displacement-y", "units": "m", "data": numpy.ravel(disp[0, :, 1])},
],
}
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
io = SimpleIOAscii()
io.inventory.filename = "shear_disp.spatialdb"
io._configure()
io.write(data)
return
开发者ID:panzhengyang,项目名称:pylith,代码行数:42,代码来源:sheardisp_gendb.py
示例12: run
def run(self):
"""
Generate the database.
"""
# Domain
dx = 200.0
x = numpy.arange(-1000.0, 1000.1, dx)
y = numpy.arange(-1000.0, 0.1, dx)
nptsx = x.shape[0]
nptsy = y.shape[0]
xx = x * numpy.ones( (nptsy, 1), dtype=numpy.float64)
yy = y * numpy.ones( (nptsx, 1), dtype=numpy.float64)
xy = numpy.zeros( (nptsx*nptsy, 2), dtype=numpy.float64)
xy[:,0] = numpy.ravel(xx)
xy[:,1] = numpy.ravel(numpy.transpose(yy))
from compressrotate_soln import AnalyticalSoln
soln = AnalyticalSoln()
disp = soln.displacement(xy)
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 2
cs._configure()
data = {'points': xy,
'coordsys': cs,
'data_dim': 2,
'values': [{'name': "displacement-x",
'units': "m",
'data': numpy.ravel(disp[0,:,0])},
{'name': "displacement-y",
'units': "m",
'data': numpy.ravel(disp[0,:,1])}]}
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
io = SimpleIOAscii()
io.inventory.filename = "compressrotate_disp.spatialdb"
io._configure()
io.write(data)
return
开发者ID:geodynamics,项目名称:pylith,代码行数:41,代码来源:compressrotate_gendb.py
示例13: test_initialize
def test_initialize(self):
"""
Test initialize().
"""
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioFinalSlip = SimpleIOAscii()
ioFinalSlip.inventory.filename = "finalslip.spatialdb"
ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
dbFinalSlip.inventory.iohandler = ioFinalSlip
dbFinalSlip.inventory.label = "final slip"
dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
ioSlipTime.inventory.filename = "sliptime.spatialdb"
ioSlipTime._configure()
dbSlipTime = SimpleDB()
dbSlipTime.inventory.iohandler = ioSlipTime
dbSlipTime.inventory.label = "slip time"
dbSlipTime._configure()
slipFn = StepSlipFn()
slipFn.inventory.dbSlip = dbFinalSlip
slipFn.inventory.dbSlipTime = dbSlipTime
slipFn._configure()
slipFn.preinitialize()
slipFn.verifyConfiguration()
slipFn.initialize()
return
开发者ID:panzhengyang,项目名称:pylith,代码行数:31,代码来源:TestStepSlipFn.py
示例14: test_configure
def test_configure(self):
"""
Test initialize().
"""
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
from pyre.units.time import second
ioInitial = SimpleIOAscii()
ioInitial.inventory.filename = "tri3_initialtractions.spatialdb"
ioInitial._configure()
dbInitial = SimpleDB()
dbInitial.inventory.iohandler = ioInitial
dbInitial.inventory.label = "initial tractions"
dbInitial._configure()
ioChange = SimpleIOAscii()
ioChange.inventory.filename = "tri3_changetractions.spatialdb"
ioChange._configure()
dbChange = SimpleDB()
dbChange.inventory.iohandler = ioChange
dbChange.inventory.label = "traction change"
dbChange._configure()
tract = TractPerturbation()
tract.inventory.dbInitial = dbInitial
tract.inventory.dbChange = dbChange
tract._configure()
return
开发者ID:panzhengyang,项目名称:pylith,代码行数:29,代码来源:TestTractPerturbation.py
示例15: run
def run(self):
"""
Generate the database.
"""
# Domain
x = numpy.arange(-4000.0, 4000.1, 500.0)
y = numpy.arange(-4000.0, 4000.1, 500.0)
npts = x.shape[0]
xx = x * numpy.ones( (npts, 1), dtype=numpy.float64)
yy = y * numpy.ones( (npts, 1), dtype=numpy.float64)
xy = numpy.zeros( (npts**2, 2), dtype=numpy.float64)
xy[:,0] = numpy.ravel(xx)
xy[:,1] = numpy.ravel(numpy.transpose(yy))
disp = self.soln.displacement(xy)
from spatialdata.geocoords.CSCart import CSCart
cs = CSCart()
cs.inventory.spaceDim = 2
cs._configure()
data = {'points': xy,
'coordsys': cs,
'data_dim': 2,
'values': [{'name': "displacement-x",
'units': "m",
'data': numpy.ravel(disp[0,:,0])},
{'name': "displacement-y",
'units': "m",
'data': numpy.ravel(disp[0,:,1])}]}
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
io = SimpleIOAscii()
io.inventory.filename = self.filename
io._configure()
io.write(data)
return
开发者ID:rishabhdutta,项目名称:pylith,代码行数:37,代码来源:genspatialdb.py
示例16: test_initialize
def test_initialize(self):
"""
Test initialize().
"""
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
from pyre.units.time import second
ioFinalSlip = SimpleIOAscii()
ioFinalSlip.inventory.filename = "finalslip.spatialdb"
ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
dbFinalSlip.inventory.iohandler = ioFinalSlip
dbFinalSlip.inventory.label = "final slip"
dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
ioSlipTime.inventory.filename = "sliptime.spatialdb"
ioSlipTime._configure()
dbSlipTime = SimpleDB()
dbSlipTime.inventory.iohandler = ioSlipTime
dbSlipTime.inventory.label = "slip time"
dbSlipTime._configure()
from pylith.faults.StepSlipFn import StepSlipFn
slipfn = StepSlipFn()
slipfn.inventory.dbSlip = dbFinalSlip
slipfn.inventory.dbSlipTime = dbSlipTime
slipfn._configure()
eqsrc = EqKinSrc()
eqsrc.inventory.originTime = 5.3*second
eqsrc.inventory.slipfn = slipfn
eqsrc._configure()
eqsrc.preinitialize()
eqsrc.verifyConfiguration()
eqsrc.initialize()
return
开发者ID:youngsolar,项目名称:pylith,代码行数:38,代码来源:TestEqKinSrc.py
示例17: test_initialize
def test_initialize(self):
"""
Test initialize().
"""
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
from spatialdata.spatialdb.TimeHistory import TimeHistory
ioFinalSlip = SimpleIOAscii()
ioFinalSlip.inventory.filename = "finalslip.spatialdb"
ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
dbFinalSlip.inventory.iohandler = ioFinalSlip
dbFinalSlip.inventory.label = "slip amplitude"
dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
ioSlipTime.inventory.filename = "sliptime.spatialdb"
ioSlipTime._configure()
dbSlipTime = SimpleDB()
dbSlipTime.inventory.iohandler = ioSlipTime
dbSlipTime.inventory.label = "slip time"
dbSlipTime._configure()
dbTimeHistory = TimeHistory()
dbTimeHistory.inventory.filename = "slipfn.timedb"
dbTimeHistory.inventory.label = "time history"
dbTimeHistory._configure()
slipFn = TimeHistorySlipFn()
slipFn.inventory.dbslip = dbFinalSlip
slipFn.inventory.dbSlipTime = dbSlipTime
slipFn.inventory.dbTimeHistory = dbTimeHistory
slipFn._configure()
slipFn.preinitialize()
slipFn.verifyConfiguration()
slipFn.initialize()
return
开发者ID:jjle,项目名称:pylith,代码行数:38,代码来源:TestTimeHistorySlipFn.py
示例18: _initialize
def _initialize(self):
"""
Initialize fault.
"""
dt = 2.4
from spatialdata.units.Nondimensional import Nondimensional
normalizer = Nondimensional()
normalizer._configure()
# Setup mesh
cs = CSCart()
cs.inventory.spaceDim = 2
cs._configure()
from pylith.meshio.MeshIOAscii import MeshIOAscii
importer = MeshIOAscii()
importer.inventory.filename = "data/tri3.mesh"
importer.inventory.coordsys = cs
importer._configure()
mesh = importer.read(debug=False, interpolate=False)
# Setup quadrature
from pylith.feassemble.FIATSimplex import FIATSimplex
cell = FIATSimplex()
cell.inventory.dimension = 1
cell.inventory.degree = 1
cell.inventory.order = 1
cell._configure()
from pylith.feassemble.Quadrature import Quadrature
quadrature = Quadrature()
quadrature.inventory.cell = cell
quadrature._configure()
# Setup earthquake source
from spatialdata.spatialdb.SimpleDB import SimpleDB
from spatialdata.spatialdb.SimpleIOAscii import SimpleIOAscii
ioFinalSlip = SimpleIOAscii()
ioFinalSlip.inventory.filename = "data/tri3_finalslip.spatialdb"
ioFinalSlip._configure()
dbFinalSlip = SimpleDB()
dbFinalSlip.inventory.iohandler = ioFinalSlip
dbFinalSlip.inventory.label = "final slip"
dbFinalSlip._configure()
ioSlipTime = SimpleIOAscii()
ioSlipTime.inventory.filename = "data/tri3_sliptime.spatialdb"
ioSlipTime._configure()
dbSlipTime = SimpleDB()
dbSlipTime.inventory.iohandler = ioSlipTime
dbSlipTime.inventory.label = "slip time"
dbSlipTime._configure()
from pylith.faults.StepSlipFn import StepSlipFn
slipfn = StepSlipFn()
slipfn.inventory.dbSlip = dbFinalSlip
slipfn.inventory.dbSlipTime = dbSlipTime
slipfn._configure()
# Setup fault
fault = FaultCohesiveKin()
fault.inventory.output.inventory.writer._configure()
fault.inventory.output._configure()
fault.inventory.matId = 10
fault.inventory.faultLabel = "fault"
fault.inventory.upDir = [0, 0, 1]
fault.inventory.faultQuadrature = quadrature
fault._configure()
eqsrc = fault.eqsrcs.components()[0]
eqsrc.inventory.originTime = 1.23*second
eqsrc.inventory.slipfn = slipfn
eqsrc._configure()
nvertices = fault.numVerticesNoMesh(mesh)
firstFaultVertex = 0
firstLagrangeVertex = nvertices
firstFaultCell = 2*nvertices
fault.adjustTopology(mesh, firstFaultVertex, firstLagrangeVertex,
firstFaultCell)
fault.preinitialize(mesh)
fault.timeStep(dt)
fault.verifyConfiguration()
from pyre.units.time import s
fault.initialize(totalTime=0.0*s, numTimeSteps=1, normalizer=normalizer)
# Setup fields
from pylith.topology.SolutionFields import SolutionFields
fields = SolutionFields(mesh)
fields.add("residual", "residual")
fields.add("dispIncr(t->t+dt)", "displacement_increment")
fields.add("disp(t)", "displacement")
fields.solutionName("dispIncr(t->t+dt)")
residual = fields.get("residual")
residual.subfieldAdd("displacement", cs.spaceDim(), residual.VECTOR)
residual.subfieldAdd("lagrange_multiplier", cs.spaceDim(), residual.VECTOR)
residual.subfieldsSetup()
residual.setupSolnChart()
residual.setupSolnDof(cs.spaceDim())
fault.setupSolnDof(residual)
#.........这里部分代码省略.........
开发者ID:rishabhdutta,项目名称:pylith,代码行数:101,代码来源:TestFaultCohesiveKin.py
示例19: SimpleIOAscii
mask1 = z >= -15.6e+3
Pf = -densityW*gacc*z
Szz = density*gacc*z
Szz[z > -1.0] = (density-densityW)*gacc*-10.0
Syy = mask1*(b22*(Szz+Pf)-0*Pf) + ~mask1*Szz
Sxx = mask1*(b33*(Szz+Pf)-0*Pf) + ~mask1*Szz
Sxy = mask1*(-b23*(Szz+Pf)) + ~mask1*0.0
Syz = 0.0*z
Sxz = 0.0*z
writer = SimpleIOAscii()
writer.inventory.filename = "empty"
writer._configure()
# ----------------------------------------------------------------------
# Initial stresses in domain
writer.filename("%s_initial_stress.spatialdb" % sim)
dataOut = {'points': points,
'coordsys': cs,
'data_dim': 1,
'values': [{'name': 'stress-xx',
'units': 'Pa',
'data': Sxx},
{'name': 'stress-yy',
'units': 'Pa',
开发者ID:geodynamics,项目名称:pylith_benchmarks,代码行数:29,代码来源:create_stresses.py
示例20: _makeSpatialdb
def _makeSpatialdb(self):
"""
Function to generate a set of spatial databases (one for each impulse).
"""
# Create empty arrays for impulse values.
# Only array1 will be modified.
array1 = numpy.zeros( (self.numFaultVertices,), dtype=numpy.float64)
array2 = numpy.zeros( (self.numFaultVertices,), dtype=numpy.float64)
# Set up info for arrays that won't be modified.
if (self.impulseType == "left-lateral-slip"):
info2 = {'name': "fault-opening",
'units': "m",
'data': array2.flatten()}
if (self.spaceDim == 3):
info3 = {'name': "reverse-slip",
'units': "m",
'data': array2.flatten()}
elif (self.impulseType == "fault-opening"):
info2 = {'name': "left-lateral-slip",
'units': "m",
'data': array2.flatten()}
if (self.spaceDim == 3):
info3 = {'name': "reverse-slip",
'units': "m",
'data': array2.flatten()}
elif (self.impulseType == "reverse-slip"):
info2 = {'name': "left-lateral-slip",
'units': "m",
'data': array2.flatten()}
info3 = {'name': "fault-opening",
'units': "m",
'data': array2.flatten()}
# Create root output filename.
suffIndex = self.spatialdbOutputRoot.rfind(".spatialdb")
outputRoot = self.spatialdbOutputRoot
if (suffIndex != -1):
outputRoot = self.spatialdbOutputRoot[:suffIndex - 1]
# Set data dimension.
dataDim = self.spaceDim - 1
# Loop over impulses to generate and modify the appropriate entries.
for impulse in range(self.numFaultVertices):
# Set filename
impulseNum = int(impulse)
impulseString = repr(impulseNum).rjust(self.impulseNumberWidth, '0')
filename = outputRoot + "_i" + impulseString + ".spatialdb"
writer = SimpleIOAscii()
writer.inventory.filename = filename
writer._configure()
# Modify database values.
array1[impulse] = self.impulseValue
if (impulse > 0):
array1[impulse - 1] = -self.impulseValue
if (impulse > 1):
array1[impulse - 2] = 0.0
info1 = {'name': self.impulseType,
'units': "m",
'data': array1.flatten()}
# Create data and write it to a database.
if (self.spaceDim == 2):
data = {'points': self.faultVertices,
'coordsys': self.geometry.coordsys,
'data_dim': dataDim,
'values': [info1, info2]}
else:
data = {'points': self.faultVertices,
'coordsys': self.geometry.coordsys,
'data_dim': dataDim,
'values': [info1, info2, info3]}
writer.write(data)
return
开发者ID:jjle,项目名称:pylith,代码行数:81,代码来源:gfgen.py
注:本文中的spatialdata.spatialdb.SimpleIOAscii.SimpleIOAscii类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论