def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.nverticesO = self.mesh['nvertices'] # Fault x self.mesh['nvertices'] += 8 self.faultMeshX = { 'nvertices': 19, 'spaceDim': 3, 'ncells': 20, 'ncorners': 3 } # Fault y self.mesh['nvertices'] += 2 self.faultMeshY = { 'nvertices': 9, 'spaceDim': 3, 'ncells': 8, 'ncorners': 3 } run_pylith(FaultsIntersectNoSlipApp, GenerateDB) self.outputRoot = "faultsintersectnoslip" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.mesh = { 'ncells-elastic': 180 * 8, 'ncells-viscoelastic': 180 * 8, 'ncorners': 8, 'nvertices': 3591, 'spaceDim': 3, 'tensorSize': 6 } self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 44 self.faultMesh = { 'nvertices': 65, 'spaceDim': 3, 'ncells': 48, 'ncorners': 4 } run_pylith(ShearApp, GenerateDB, nprocs=4) self.outputRoot = "sheardispnosliprefine" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTri3.setUp(self) self.mesh = { 'ncells': 142 * 4, 'ncorners': 3, 'nvertices': 317, 'spaceDim': 2, 'tensorSize': 3 } self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 3 self.faultMesh = { 'nvertices': 5, 'spaceDim': 2, 'ncells': 2 * 2, 'ncorners': 2 } run_pylith(ShearApp, GenerateDB, nprocs=3) self.outputRoot = "sheardispnosliprefine" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.mesh = { 'ncells-elastic': 1266 * 8, 'ncells-viscoelastic': 1276 * 8, 'ncorners': 4, 'nvertices': 4016, 'spaceDim': 3, 'tensorSize': 6 } self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 36 self.faultMesh = { 'nvertices': 57, 'spaceDim': 3, 'ncells': 80, 'ncorners': 3 } run_pylith(ShearApp, GenerateDB, nprocs=4) self.outputRoot = "sheardispnosliprefine" self.soln = AnalyticalSoln() return
class TestShearDisp(TestTri3): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestTri3.setUp(self) run_pylith(ShearApp, GenerateDB) self.outputRoot = "sheardisp" self.soln = AnalyticalSoln() return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros((ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress" or name == "cauchy_stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar
def setUp(self): """ Setup for test. """ TestTri3.setUp(self) run_pylith(ShearApp, GenerateDB) self.outputRoot = "sheardisp" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 8 self.faultMesh = {'nvertices': 19, 'spaceDim': 3, 'ncells': 20, 'ncorners': 3} run_pylith(ShearApp, GenerateDB, nprocs=3) self.outputRoot = "sheardispnoslip" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.nverticesO = self.mesh['nvertices'] # Fault x self.mesh['nvertices'] += 8 self.faultMeshX = {'nvertices': 19, 'spaceDim': 3, 'ncells': 20, 'ncorners': 3} # Fault y self.mesh['nvertices'] += 2 self.faultMeshY = {'nvertices': 9, 'spaceDim': 3, 'ncells': 8, 'ncorners': 3} run_pylith() self.outputRoot = "faultsintersectnoslip" self.soln = AnalyticalSoln() return
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
def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 10 self.faultMesh = {'nvertices': 21, 'spaceDim': 3, 'ncells': 12, 'ncorners': 4} run_pylith(ShearApp, GenerateDB, nprocs=3) self.outputRoot = "frictionnoslip" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTri3.setUp(self) run_pylith() self.outputRoot = "sheardisp" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestQuad4.setUp(self) run_pylith(ShearApp, GenerateDB) self.outputRoot = "sheardisp" self.soln = AnalyticalSoln() return
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
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
class TestShearDisp(TestTet4): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestTet4.setUp(self) run_pylith() self.outputRoot = "sheardisp" self.soln = AnalyticalSoln() return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros( (ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar
def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.nverticesO = self.mesh["nvertices"] self.mesh["nvertices"] += 10 self.faultMesh = {"nvertices": 21, "spaceDim": 3, "ncells": 12, "ncorners": 4} run_pylith() self.outputRoot = "frictionnoslip" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 8 self.faultMesh = {'nvertices': 19, 'spaceDim': 3, 'ncells': 20, 'ncorners': 3} run_pylith() self.outputRoot = "sheardispnoslip" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTri3.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 1 self.faultMesh = {'nvertices': 3, 'spaceDim': 2, 'ncells': 2, 'ncorners': 2} run_pylith(ShearApp, GenerateDB, nprocs=2) self.outputRoot = "sheardispnoslip" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTri3.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 1 self.faultMesh = {'nvertices': 3, 'spaceDim': 2, 'ncells': 2, 'ncorners': 2} run_pylith() self.outputRoot = "sheardispfriction" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 21 self.faultMesh = {'nvertices': 34, 'spaceDim': 3, 'ncells': 23, 'ncorners': 4} run_pylith() self.outputRoot = "frictionnoslip_halo" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTri3.setUp(self) self.mesh = {'ncells': 142*4, 'ncorners': 3, 'nvertices': 317, 'spaceDim': 2, 'tensorSize': 3} self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 3 self.faultMesh = {'nvertices': 5, 'spaceDim': 2, 'ncells': 2*2, 'ncorners': 2} run_pylith() self.outputRoot = "sheardispnosliprefine" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.mesh = {'ncells-elastic': 1266*8, 'ncells-viscoelastic': 1276*8, 'ncorners': 4, 'nvertices': 4016, 'spaceDim': 3, 'tensorSize': 6} self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 36 self.faultMesh = {'nvertices': 57, 'spaceDim': 3, 'ncells': 80, 'ncorners': 3} run_pylith() self.outputRoot = "sheardispnosliprefine" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.mesh = {'ncells-elastic': 180*8, 'ncells-viscoelastic': 180*8, 'ncorners': 8, 'nvertices': 3591, 'spaceDim': 3, 'tensorSize': 6} self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 44 self.faultMesh = {'nvertices': 65, 'spaceDim': 3, 'ncells': 48, 'ncorners': 4} run_pylith() self.outputRoot = "sheardispnosliprefine" self.soln = AnalyticalSoln() return
class TestShearDispNoSlip(TestTet4): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 8 self.faultMesh = {'nvertices': 19, 'spaceDim': 3, 'ncells': 20, 'ncorners': 3} run_pylith() self.outputRoot = "sheardispnoslip" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault_info.h5" % self.outputRoot fields = ["normal_dir", "final_slip", "slip_time"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault.h5" % self.outputRoot fields = ["slip"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros( (ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress" or name == "cauchy_stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ normalDir = (+1.0, 0.0, 0.0) finalSlip = 0.0 slipTime = 0.0 nvertices = self.faultMesh['nvertices'] if name == "normal_dir": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = normalDir[0] field[0,:,1] = normalDir[1] field[0,:,2] = normalDir[2] elif name == "final_slip": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = finalSlip elif name == "slip_time": field = slipTime*numpy.zeros( (1, nvertices, 1), dtype=numpy.float64) elif name == "slip": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = finalSlip elif name == "traction_change": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = 0.0 else: raise ValueError("Unknown fault field '%s'." % name) # Mask clamped edges maskX = numpy.fabs(vertices[:,0]) <= 1.0 maskY = numpy.fabs(vertices[:,1]) <= 25.001e+3 maskZ = vertices[:,2] >= -20.001e+3 mask = numpy.bitwise_and(numpy.bitwise_and(maskX,maskY),maskZ) field[:,~mask,:] = 0.0 return field
class TestShearDispNoSlipRefine(TestHex8): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.mesh = {'ncells-elastic': 180*8, 'ncells-viscoelastic': 180*8, 'ncorners': 8, 'nvertices': 3591, 'spaceDim': 3, 'tensorSize': 6} self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 44 self.faultMesh = {'nvertices': 65, 'spaceDim': 3, 'ncells': 48, 'ncorners': 4} run_pylith() self.outputRoot = "sheardispnosliprefine" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault_info.h5" % self.outputRoot fields = ["normal_dir", "final_slip", "slip_time"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault.h5" % self.outputRoot fields = ["slip"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros( (ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ normalDir = (-1.0, 0.0, 0.0) finalSlip = 0.0 slipTime = 0.0 nvertices = self.faultMesh['nvertices'] if name == "normal_dir": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = normalDir[0] field[0,:,1] = normalDir[1] field[0,:,2] = normalDir[2] elif name == "final_slip": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = finalSlip elif name == "slip_time": field = slipTime*numpy.zeros( (1, nvertices, 1), dtype=numpy.float64) elif name == "slip": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = finalSlip elif name == "traction_change": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = 0.0 else: raise ValueError("Unknown fault field '%s'." % name) return field
class TestShearDispFriction(TestTri3): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestTri3.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 1 self.faultMesh = {'nvertices': 3, 'spaceDim': 2, 'ncells': 2, 'ncorners': 2} run_pylith() self.outputRoot = "sheardispfriction" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault_info.h5" % self.outputRoot fields = ["strike_dir", "normal_dir", "traction_initial","friction_coefficient","cohesion"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault.h5" % self.outputRoot fields = ["slip"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros( (ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ strikeDir = (-1.0, 0.0) normalDir = (0.0, 1.0) initialTraction = (0.0, -100.0e+6) frictionCoefficient = 1.0 nvertices = self.faultMesh['nvertices'] if name == "strike_dir": field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64) field[0,:,0] = strikeDir[0] field[0,:,1] = strikeDir[1] elif name == "normal_dir": field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64) field[0,:,0] = normalDir[0] field[0,:,1] = normalDir[1] elif name == "traction_initial": field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64) field[0,:,0] = initialTraction[0] field[0,:,1] = initialTraction[1] elif name == "friction_coefficient": field = numpy.zeros( (1, nvertices, 1), dtype=numpy.float64) field[0,:,0] = frictionCoefficient elif name == "cohesion": field = numpy.zeros( (1, nvertices, 1), dtype=numpy.float64) elif name == "slip": field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64) elif name == "traction": field = numpy.zeros( (1, nvertices, 2), dtype=numpy.float64) field[0,:,0] = 1.0e+6 field[0,:,1] = -1.0e+7 else: raise ValueError("Unknown fault field '%s'." % name) # Mask clamped vertices maskX = numpy.bitwise_and(vertices[:,0] >= -2.0001e+3, vertices[:,0] <= 1.0) maskY = numpy.fabs(vertices[:,1]) <= 0.01e+3 mask = numpy.bitwise_and(maskX,maskY) field[:,~mask,:] = 0 return field
class TestFrictionNoSlipHalo(TestHex8): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 21 self.faultMesh = {'nvertices': 34, 'spaceDim': 3, 'ncells': 23, 'ncorners': 4} run_pylith() self.outputRoot = "frictionnoslip_halo" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault_info.h5" % self.outputRoot fields = ["static_coefficient"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault.h5" % self.outputRoot fields = ["slip"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros( (ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ normalDir = (-1.0, 0.0, 0.0) strikeDir = (0.0, -1.0, 0.0) staticCoef = 0.6 initialTraction = (0.0,0.0,-100.0e+6) nvertices = self.faultMesh['nvertices'] if name == "static_coefficient": field = staticCoef*numpy.ones( (1, nvertices, 1), dtype=numpy.float64) elif name == "slip": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) else: raise ValueError("Unknown fault field '%s'." % name) return field
class TestFrictionNoSlip(TestHex8): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.nverticesO = self.mesh["nvertices"] self.mesh["nvertices"] += 10 self.faultMesh = {"nvertices": 21, "spaceDim": 3, "ncells": 12, "ncorners": 4} run_pylith() self.outputRoot = "frictionnoslip" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault_info.h5" % self.outputRoot fields = ["normal_dir", "strike_dir", "static_coefficient", "traction_initial"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault.h5" % self.outputRoot fields = ["slip"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh["ncells"] pts = numpy.zeros((ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ normalDir = (-1.0, 0.0, 0.0) strikeDir = (0.0, -1.0, 0.0) staticCoef = 0.6 initialTraction = (0.0, 0.0, -100.0e6) nvertices = self.faultMesh["nvertices"] if name == "normal_dir": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) field[0, :, 0] = normalDir[0] field[0, :, 1] = normalDir[1] field[0, :, 2] = normalDir[2] elif name == "strike_dir": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) field[0, :, 0] = strikeDir[0] field[0, :, 1] = strikeDir[1] field[0, :, 2] = strikeDir[2] elif name == "static_coefficient": field = staticCoef * numpy.ones((1, nvertices, 1), dtype=numpy.float64) elif name == "traction_initial": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) field[0, :, 0] = initialTraction[0] field[0, :, 1] = initialTraction[1] field[0, :, 2] = initialTraction[2] elif name == "slip": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) else: raise ValueError("Unknown fault field '%s'." % name) # Mask clamped vertices maskX = numpy.fabs(vertices[:, 0]) <= 1.0 maskY = numpy.fabs(vertices[:, 1]) <= 25.001e3 maskZ = vertices[:, 2] >= -20.001e3 mask = numpy.bitwise_and(numpy.bitwise_and(maskX, maskY), maskZ) field[:, ~mask, :] = 0.0 return field
class TestFaultsIntersectNoSlip(TestTet4): """ Test suite for testing pylith with shear slip on two faults. """ def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.nverticesO = self.mesh['nvertices'] # Fault x self.mesh['nvertices'] += 8 self.faultMeshX = {'nvertices': 19, 'spaceDim': 3, 'ncells': 20, 'ncorners': 3} # Fault y self.mesh['nvertices'] += 2 self.faultMeshY = {'nvertices': 9, 'spaceDim': 3, 'ncells': 8, 'ncorners': 3} run_pylith() self.outputRoot = "faultsintersectnoslip" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return from pylith.tests.Fault import check_vertex_fields fields = ["normal_dir", "final_slip", "slip_time"] self.fault = "x" filename = "%s-faultx_info.h5" % self.outputRoot check_vertex_fields(self, filename, self.faultMeshX, fields) self.fault = "y" filename = "%s-faulty_info.h5" % self.outputRoot check_vertex_fields(self, filename, self.faultMeshY, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return from pylith.tests.Fault import check_vertex_fields fields = ["slip"] filename = "%s-faultx.h5" % self.outputRoot self.fault = "x" check_vertex_fields(self, filename, self.faultMeshX, fields) filename = "%s-faulty.h5" % self.outputRoot self.fault = "y" check_vertex_fields(self, filename, self.faultMeshY, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros( (ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ if self.fault == "x": normalDir = (+1.0, 0.0, 0.0) finalSlip = 0.0 faultMesh = self.faultMeshX elif self.fault == "y": normalDir = (0.0,-1.0, 0.0) finalSlip = 0.0 faultMesh = self.faultMeshY slipTime = 0.0 dim = 3 nvertices = faultMesh['nvertices'] if name == "normal_dir": field = numpy.zeros( (1, nvertices, dim), dtype=numpy.float64) field[0,:,0] = normalDir[0] field[0,:,1] = normalDir[1] field[0,:,2] = normalDir[2] elif name == "final_slip": field = numpy.zeros( (1, nvertices, dim), dtype=numpy.float64) field[0,:,0] = finalSlip elif name == "slip_time": field = slipTime*numpy.zeros( (1, nvertices, 1), dtype=numpy.float64) elif name == "slip": field = numpy.zeros( (1, nvertices, dim), dtype=numpy.float64) field[0,:,0] = finalSlip elif name == "traction_change": field = numpy.zeros( (1, nvertices, dim), dtype=numpy.float64) field[0,:,0] = 0.0 else: raise ValueError("Unknown fault field '%s'." % name) return field
class TestFaultsIntersectNoSlip(TestTet4): """ Test suite for testing pylith with shear slip on two faults. """ def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.nverticesO = self.mesh['nvertices'] # Fault x self.mesh['nvertices'] += 8 self.faultMeshX = { 'nvertices': 19, 'spaceDim': 3, 'ncells': 20, 'ncorners': 3 } # Fault y self.mesh['nvertices'] += 2 self.faultMeshY = { 'nvertices': 9, 'spaceDim': 3, 'ncells': 8, 'ncorners': 3 } run_pylith(FaultsIntersectNoSlipApp, GenerateDB) self.outputRoot = "faultsintersectnoslip" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return from pylith.tests.Fault import check_vertex_fields fields = ["normal_dir", "final_slip", "slip_time"] self.fault = "x" filename = "%s-faultx_info.h5" % self.outputRoot check_vertex_fields(self, filename, self.faultMeshX, fields) self.fault = "y" filename = "%s-faulty_info.h5" % self.outputRoot check_vertex_fields(self, filename, self.faultMeshY, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return from pylith.tests.Fault import check_vertex_fields fields = ["slip"] filename = "%s-faultx.h5" % self.outputRoot self.fault = "x" check_vertex_fields(self, filename, self.faultMeshX, fields) filename = "%s-faulty.h5" % self.outputRoot self.fault = "y" check_vertex_fields(self, filename, self.faultMeshY, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros((ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress" or name == "cauchy_stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ if self.fault == "x": normalDir = (+1.0, 0.0, 0.0) finalSlip = 0.0 faultMesh = self.faultMeshX elif self.fault == "y": normalDir = (0.0, -1.0, 0.0) finalSlip = 0.0 faultMesh = self.faultMeshY slipTime = 0.0 dim = 3 nvertices = faultMesh['nvertices'] if name == "normal_dir": field = numpy.zeros((1, nvertices, dim), dtype=numpy.float64) field[0, :, 0] = normalDir[0] field[0, :, 1] = normalDir[1] field[0, :, 2] = normalDir[2] elif name == "final_slip": field = numpy.zeros((1, nvertices, dim), dtype=numpy.float64) field[0, :, 0] = finalSlip elif name == "slip_time": field = slipTime * numpy.zeros( (1, nvertices, 1), dtype=numpy.float64) elif name == "slip": field = numpy.zeros((1, nvertices, dim), dtype=numpy.float64) field[0, :, 0] = finalSlip elif name == "traction_change": field = numpy.zeros((1, nvertices, dim), dtype=numpy.float64) field[0, :, 0] = 0.0 else: raise ValueError("Unknown fault field '%s'." % name) return field
class TestFrictionNoSlipHalo(TestHex8): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 21 self.faultMesh = { 'nvertices': 34, 'spaceDim': 3, 'ncells': 23, 'ncorners': 4 } run_pylith(ShearApp, GenerateDB, nprocs=1) self.outputRoot = "frictionnoslip_halo" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault_info.h5" % self.outputRoot fields = ["static_coefficient"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault.h5" % self.outputRoot fields = ["slip"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros((ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ normalDir = (-1.0, 0.0, 0.0) strikeDir = (0.0, -1.0, 0.0) staticCoef = 0.6 initialTraction = (0.0, 0.0, -100.0e+6) nvertices = self.faultMesh['nvertices'] if name == "static_coefficient": field = staticCoef * numpy.ones( (1, nvertices, 1), dtype=numpy.float64) elif name == "slip": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) else: raise ValueError("Unknown fault field '%s'." % name) return field
class TestShearDispNoSlipRefine(TestTet4): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestTet4.setUp(self) self.mesh = { 'ncells-elastic': 1266 * 8, 'ncells-viscoelastic': 1276 * 8, 'ncorners': 4, 'nvertices': 4016, 'spaceDim': 3, 'tensorSize': 6 } self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 36 self.faultMesh = { 'nvertices': 57, 'spaceDim': 3, 'ncells': 80, 'ncorners': 3 } run_pylith(ShearApp, GenerateDB, nprocs=4) self.outputRoot = "sheardispnosliprefine" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault_info.h5" % self.outputRoot fields = ["normal_dir", "final_slip", "slip_time"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault.h5" % self.outputRoot fields = ["slip"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros((ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress" or name == "cauchy_stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ normalDir = (+1.0, 0.0, 0.0) finalSlip = 0.0 slipTime = 0.0 nvertices = self.faultMesh['nvertices'] if name == "normal_dir": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) field[0, :, 0] = normalDir[0] field[0, :, 1] = normalDir[1] field[0, :, 2] = normalDir[2] elif name == "final_slip": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) field[0, :, 0] = finalSlip elif name == "slip_time": field = slipTime * numpy.zeros( (1, nvertices, 1), dtype=numpy.float64) elif name == "slip": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) field[0, :, 0] = finalSlip elif name == "traction_change": field = numpy.zeros((1, nvertices, 3), dtype=numpy.float64) field[0, :, 0] = 0.0 else: raise ValueError("Unknown fault field '%s'." % name) # Mask clamped edges maskX = numpy.fabs(vertices[:, 0]) <= 1.0 maskY = numpy.fabs(vertices[:, 1]) <= 25.001e+3 maskZ = vertices[:, 2] >= -20.001e+3 mask = numpy.bitwise_and(numpy.bitwise_and(maskX, maskY), maskZ) field[:, ~mask, :] = 0.0 return field
class TestFrictionNoSlip(TestHex8): """ Test suite for testing pylith with 2-D shear extension. """ def setUp(self): """ Setup for test. """ TestHex8.setUp(self) self.nverticesO = self.mesh['nvertices'] self.mesh['nvertices'] += 10 self.faultMesh = {'nvertices': 21, 'spaceDim': 3, 'ncells': 12, 'ncorners': 4} run_pylith(ShearApp, GenerateDB, nprocs=3) self.outputRoot = "frictionnoslip" self.soln = AnalyticalSoln() return def test_fault_info(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault_info.h5" % self.outputRoot fields = ["normal_dir","strike_dir","static_coefficient", "traction_initial"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def test_fault_data(self): """ Check fault information. """ if not self.checkResults: return filename = "%s-fault.h5" % self.outputRoot fields = ["slip"] from pylith.tests.Fault import check_vertex_fields check_vertex_fields(self, filename, self.faultMesh, fields) return def calcDisplacements(self, vertices): """ Calculate displacement field given coordinates of vertices. """ return self.soln.displacement(vertices) def calcStateVar(self, name, vertices, cells): """ Calculate state variable. """ ncells = self.mesh['ncells'] pts = numpy.zeros( (ncells, 3), dtype=numpy.float64) if name == "total_strain": stateVar = self.soln.strain(pts) elif name == "stress": stateVar = self.soln.stress(pts) else: raise ValueError("Unknown state variable '%s'." % name) return stateVar def calcFaultField(self, name, vertices): """ Calculate fault info. """ normalDir = (-1.0, 0.0, 0.0) strikeDir = (0.0, -1.0, 0.0) staticCoef = 0.6 initialTraction = (0.0,0.0,-100.0e+6) nvertices = self.faultMesh['nvertices'] if name == "normal_dir": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = normalDir[0] field[0,:,1] = normalDir[1] field[0,:,2] = normalDir[2] elif name == "strike_dir": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = strikeDir[0] field[0,:,1] = strikeDir[1] field[0,:,2] = strikeDir[2] elif name == "static_coefficient": field = staticCoef*numpy.ones( (1, nvertices, 1), dtype=numpy.float64) elif name == "traction_initial": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) field[0,:,0] = initialTraction[0] field[0,:,1] = initialTraction[1] field[0,:,2] = initialTraction[2] elif name == "slip": field = numpy.zeros( (1, nvertices, 3), dtype=numpy.float64) else: raise ValueError("Unknown fault field '%s'." % name) # Mask clamped vertices maskX = numpy.fabs(vertices[:,0]) <= 1.0 maskY = numpy.fabs(vertices[:,1]) <= 25.001e+3 maskZ = vertices[:,2] >= -20.001e+3 mask = numpy.bitwise_and(numpy.bitwise_and(maskX,maskY),maskZ) field[:,~mask,:] = 0.0 return field