class TestRigidBody(TestQuad4): """ Test suite for testing pylith with 2-D rigid body motion. """ def setUp(self): """ Setup for test. """ TestQuad4.setUp(self) run_pylith(RigidBodyApp, GenerateDB) self.outputRoot = "lgdeformrigidbody" 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, 2), 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(RigidBodyApp, GenerateDB) self.outputRoot = "lgdeformrigidbody" 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) 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
def setUp(self): """ Setup for test. """ TestQuad4.setUp(self) run_pylith() self.outputRoot = "lgdeformrigidbody" self.soln = AnalyticalSoln() return
class TestRigidBody(TestHex8): """ Test suite for testing pylith with 2-D rigid body motion. """ def setUp(self): """ Setup for test. """ TestHex8.setUp(self) run_pylith() self.outputRoot = "lgdeformrigidbody" 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 rigidbody_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 = "rigidbody_disp.spatialdb" io._configure() io.write(data) return
def setUp(self): """ Setup for test. """ TestHex8.setUp(self) run_pylith() self.outputRoot = "lgdeformrigidbody" if has_vtk(): self.reader = VTKDataReader() self.soln = AnalyticalSoln() else: self.reader = None return