class TestAxialDisp(TestHex8): """ Test suite for testing pylith with 2-D axial extension. """ def setUp(self): """ Setup for test. """ TestHex8.setUp(self) run_pylith(AxialApp, GenerateDB) self.outputRoot = "axialdisp" 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. """ TestQuad4.setUp(self) run_pylith(AxialApp, GenerateDB) self.outputRoot = "axialdisp" self.soln = AnalyticalSoln() return
def run(self): """ Generate the database. """ from axialdisp_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 == "x": xyz = numpy.array([[-40.0e+3, 0.0, 0.0], [+40.0e+3, 0.0, 0.0]], dtype=numpy.float64) ic = 0 elif component == "y": xyz = numpy.array([[0.0, -40.0e+3, 0.0], [0.0, +40.0e+3, 0.0]], dtype=numpy.float64) ic = 1 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 = "axial_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 axialdisp_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': "initial_amplitude_x", 'units': "m", 'data': numpy.ravel(disp[0, :, 0]) }, { 'name': "initial_amplitude_y", 'units': "m", 'data': numpy.ravel(disp[0, :, 1]) }] } from spatialdata.spatialdb.SimpleIOAscii import createWriter io = createWriter("axialdisp_bc.spatialdb") io.write(data) data["values"][0]["name"] = "displacement_x" data["values"][1]["name"] = "displacement_y" io = createWriter("axialdisp_ic.spatialdb") io.write(data) return
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
def setUp(self): """ Setup for test. """ TestQuad4.setUp(self) run_pylith() self.outputRoot = "axialdisp" self.soln = AnalyticalSoln() return
def setUp(self): """ Setup for test. """ TestTri3.setUp(self) run_pylith(AxialApp, GenerateDB) self.outputRoot = "axialdisp" self.soln = AnalyticalSoln() return
def run(self): """ Generate the database. """ from axialdisp_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 == "x": xyz = numpy.array([[-40.0e+3, 0.0, 0.0], [+40.0e+3, 0.0, 0.0]], dtype=numpy.float64) ic = 0 elif component == "y": xyz = numpy.array([[0.0, -40.0e+3, 0.0], [0.0, +40.0e+3, 0.0]], dtype=numpy.float64) ic = 1 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 = "axial_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
class TestAxialDisp(TestQuad4): """ Test suite for testing pylith with 2-D axial extension. """ def setUp(self): """ Setup for test. """ TestQuad4.setUp(self) run_pylith() self.outputRoot = "axialdisp" if has_vtk(): self.reader = VTKDataReader() self.soln = AnalyticalSoln() else: self.reader = None 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 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 axialdisp_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 = "axial_disp.spatialdb" io._configure() io.write(data) return
def setUp(self): """ Setup for test. """ TestQuad4.setUp(self) run_pylith() self.outputRoot = "axialdisp" if has_vtk(): self.reader = VTKDataReader() self.soln = AnalyticalSoln() else: self.reader = None return
def run(self): """Generate the database. """ # Domain x = numpy.arange(-4.0e+3, 4.01e+3, 1.0e+3) y = numpy.arange(-4.0e+3, 4.01e+3, 1.0e+3) z = numpy.arange(-8.0e+3, 0.01e+3, 1.0e+3) x3, y3, z3 = numpy.meshgrid(x, y, z) nptsX = x.shape[0] nptsY = y.shape[0] nptsZ = z.shape[0] xyz = numpy.zeros((nptsX * nptsY * nptsZ, 3), dtype=numpy.float64) xyz[:, 0] = x3.ravel() xyz[:, 1] = y3.ravel() xyz[:, 2] = z3.ravel() 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 = { "x": x, "y": y, "z": z, "points": xyz, "coordsys": cs, "data_dim": 3, "values": [ { "name": "initial_amplitude_x", "units": "m", "data": numpy.ravel(disp[0, :, 0]) }, { "name": "initial_amplitude_y", "units": "m", "data": numpy.ravel(disp[0, :, 1]) }, { "name": "initial_amplitude_z", "units": "m", "data": numpy.ravel(disp[0, :, 2]) }, ] } from spatialdata.spatialdb.SimpleGridAscii import SimpleGridAscii io = SimpleGridAscii() io.inventory.filename = "axialdisp_bc.spatialdb" io._configure() io.write(data) return
def setUp(self): """Setup for test. """ FullTestCase.setUp(self) self.exactsoln = AnalyticalSoln() return