Example #1
0
 def setUp(self):
     """
 Setup test subject.
 """
     from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
     self.material = ElasticPlaneStrain()
     return
  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)
Example #3
0
  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
    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)
Example #5
0
 def setUp(self):
   """
   Setup test subject.
   """
   from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
   self.material = ElasticPlaneStrain()
   return
Example #6
0
    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
Example #7
0
class TestMaterial(unittest.TestCase):
  """
  Unit testing of Material object.
  """

  def setUp(self):
    """
    Setup test subject.
    """
    from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
    self.material = ElasticPlaneStrain()
    return
    

  def testId(self):
    """
    Test id().
    """
    id = 1234
    self.material.id(id)
    self.assertEqual(id, self.material.id())
    return


  def testLabel(self):
    """
    Test label().
    """
    label = "material abc"
    self.material.label(label)
    self.assertEqual(label, self.material.label())
    return


  def testTimeStep(self):
    """
    Test timeStep().
    """
    dt = 0.5
    self.material.timeStep(dt)
    self.assertEqual(dt, self.material.timeStep())
    return


  def testDBProperties(self):
    """
    Test dbProperties().
    """
    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.dbProperties(db)

    # No test of result.
    return


  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


  def testNormalizer(self):
    """
    Test normalizer().
    """
    from spatialdata.units.Nondimensional import Nondimensional
    normalizer = Nondimensional()
    normalizer._configure()


    self.material.normalizer(normalizer)

    # No test of result.
    return


  def testIsJacobianSymmetric(self):
    """
    Test isJacobianSymmetric().
    """
    # Default should be True.
    self.failUnless(self.material.isJacobianSymmetric())

    return
  

  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
Example #8
0
 def setUp(self):
   """
   Setup test subject.
   """
   self.material = ElasticPlaneStrain()
   return
Example #9
0
class TestElasticPlaneStrain(unittest.TestCase):
  """
  Unit testing of ElasticPlaneStrain object.
  """

  def setUp(self):
    """
    Setup test subject.
    """
    self.material = ElasticPlaneStrain()
    return
  

  def test_constructor(self):
    """
    Test constructor.
    """
    self.assertEqual(2, self.material.dimension())
    return


  def test_useElasticBehavior(self):
    """
    Test useElasticBehavior().
    """
    self.material.useElasticBehavior(False)
    return


  def testHasStateVars(self):
    self.failIf(self.material.hasStateVars())
    return


  def testTensorSize(self):
    self.assertEqual(3, self.material.tensorSize())
    return


  def testNeedNewJacobian(self):
    """
    Test needNewJacobian().
    """
    # Default should be False.
    self.failIf(self.material.needNewJacobian())

    # Changing time step should not require new Jacobian.
    self.material.timeStep(1.0)
    self.material.timeStep(2.0)
    self.failIf(self.material.needNewJacobian())
    return
  

  def testStableTimeStepImplicit(self):
    """
    Test stableTimeStepImplicit().
    """
    from pylith.topology.Mesh import Mesh
    mesh = Mesh()
    dt = self.material.stableTimeStepImplicit(mesh)
    from pylith.utils.utils import maxdouble
    self.assertAlmostEqual(1.0, dt/maxdouble())
  

  def test_factory(self):
    """
    Test factory method.
    """
    from pylith.materials.ElasticPlaneStrain import material
    m = material()
    return
Example #10
0
class TestMaterial(unittest.TestCase):
    """
  Unit testing of Material object.
  """
    def setUp(self):
        """
    Setup test subject.
    """
        from pylith.materials.ElasticPlaneStrain import ElasticPlaneStrain
        self.material = ElasticPlaneStrain()
        return

    def testId(self):
        """
    Test id().
    """
        id = 1234
        self.material.id(id)
        self.assertEqual(id, self.material.id())
        return

    def testLabel(self):
        """
    Test label().
    """
        label = "material abc"
        self.material.label(label)
        self.assertEqual(label, self.material.label())
        return

    def testTimeStep(self):
        """
    Test timeStep().
    """
        dt = 0.5
        self.material.timeStep(dt)
        self.assertEqual(dt, self.material.timeStep())
        return

    def testDBProperties(self):
        """
    Test dbProperties().
    """
        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.dbProperties(db)

        # No test of result.
        return

    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

    def testNormalizer(self):
        """
    Test normalizer().
    """
        from spatialdata.units.Nondimensional import Nondimensional
        normalizer = Nondimensional()
        normalizer._configure()

        self.material.normalizer(normalizer)

        # No test of result.
        return

    def testIsJacobianSymmetric(self):
        """
    Test isJacobianSymmetric().
    """
        # Default should be True.
        self.failUnless(self.material.isJacobianSymmetric())

        return

    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
Example #11
0
 def setUp(self):
     """
 Setup test subject.
 """
     self.material = ElasticPlaneStrain()
     return
Example #12
0
class TestElasticPlaneStrain(unittest.TestCase):
    """
  Unit testing of ElasticPlaneStrain object.
  """
    def setUp(self):
        """
    Setup test subject.
    """
        self.material = ElasticPlaneStrain()
        return

    def test_constructor(self):
        """
    Test constructor.
    """
        self.assertEqual(2, self.material.dimension())
        return

    def test_useElasticBehavior(self):
        """
    Test useElasticBehavior().
    """
        self.material.useElasticBehavior(False)
        return

    def testHasStateVars(self):
        self.failIf(self.material.hasStateVars())
        return

    def testTensorSize(self):
        self.assertEqual(3, self.material.tensorSize())
        return

    def testNeedNewJacobian(self):
        """
    Test needNewJacobian().
    """
        # Default should be False.
        self.failIf(self.material.needNewJacobian())

        # Changing time step should not require new Jacobian.
        self.material.timeStep(1.0)
        self.material.timeStep(2.0)
        self.failIf(self.material.needNewJacobian())
        return

    def testStableTimeStepImplicit(self):
        """
    Test stableTimeStepImplicit().
    """
        from pylith.topology.Mesh import Mesh
        mesh = Mesh()
        dt = self.material.stableTimeStepImplicit(mesh)
        from pylith.utils.utils import maxdouble
        self.assertAlmostEqual(1.0, dt / maxdouble())

    def test_factory(self):
        """
    Test factory method.
    """
        from pylith.materials.ElasticPlaneStrain import material
        m = material()
        return