예제 #1
0
    def __init__(self):
        """
    Constructor.
    """
        self.availableFields = \
            {'vertex': \
               {'info': ["vertex info"],
                'data': ["vertex data 1",
                         "vertex data 2"]},
             'cell': \
               {'info': ["cell info"],
                'data': ["cell data"]}}

        filename = "data/twohex8.txt"

        from pylith.meshio.MeshIOAscii import MeshIOAscii
        iohandler = MeshIOAscii()
        iohandler.inventory.filename = filename
        from spatialdata.geocoords.CSCart import CSCart
        iohandler.inventory.coordsys = CSCart()
        iohandler._configure()

        from spatialdata.units.Nondimensional import Nondimensional
        normalizer = Nondimensional()
        normalizer._configure()
        mesh = iohandler.read(debug=False, interpolate=False)

        from pylith.topology.Fields import Fields
        fields = Fields(mesh)

        self.mesh = mesh
        self.fields = fields
        return
예제 #2
0
  def setUp(self):
    """
    Setup mesh and associated field.
    """
    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/tri3.mesh"
    importer.inventory.coordsys = cs
    importer._configure()
    self.mesh = importer.read(debug=False, interpolate=False)
    
    self.fields = Fields(self.mesh)
    return
예제 #3
0
  def setUp(self):
    """
    Setup mesh and associated field.
    """
    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/tri3.mesh"
    importer.inventory.coordsys = cs
    importer._configure()
    self.mesh = importer.read(debug=False, interpolate=False)
    
    self.fields = Fields(self.mesh)
    return
예제 #4
0
class TestMeshFields(unittest.TestCase):
  """
  Unit testing of Fields object.
  """

  def setUp(self):
    """
    Setup mesh and associated field.
    """
    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/tri3.mesh"
    importer.inventory.coordsys = cs
    importer._configure()
    self.mesh = importer.read(debug=False, interpolate=False)
    
    self.fields = Fields(self.mesh)
    return


  def test_constructorA(self):
    """
    Test constructor.
    """
    return


  def test_mesh(self):
    """
    Test mesh().
    """
    mesh = self.fields.mesh()
    
    self.assertEqual(2, mesh.dimension())
    return


  def test_add(self):
    self.fields.add("field", "displacement")
    field = self.fields.get("field")
    field.newSection()

    self.assertEqual(2, field.spaceDim())
    return


  def test_addFiberDim(self):
    from pylith.topology.topology import FieldBase
    self.fields.add("field", "displacement")
    field = self.fields.get("field")
    field.newSection(FieldBase.VERTICES_FIELD, 4)

    self.assertEqual(2, field.spaceDim())
    return


  def test_del(self):
    self.fields.add("field A", "A")
    self.fields.add("field B", "B")
    self.fields.delField("field A")
    field = self.fields.get("field B")
    return


  def test_copyLayout(self):
    from pylith.topology.topology import FieldBase
    self.fields.add("field A", "A")
    field = self.fields.get("field A")
    field.newSection(FieldBase.VERTICES_FIELD, 4)

    self.fields.add("field B", "B")
    self.fields.copyLayout("field A")

    # No test of result
    return
예제 #5
0
class TestMeshFields(unittest.TestCase):
  """
  Unit testing of Fields object.
  """

  def setUp(self):
    """
    Setup mesh and associated field.
    """
    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/tri3.mesh"
    importer.inventory.coordsys = cs
    importer._configure()
    self.mesh = importer.read(debug=False, interpolate=False)
    
    self.fields = Fields(self.mesh)
    return


  def test_constructorA(self):
    """
    Test constructor.
    """
    return


  def test_mesh(self):
    """
    Test mesh().
    """
    mesh = self.fields.mesh()
    
    self.assertEqual(2, mesh.dimension())
    return


  def test_add(self):
    self.fields.add("field", "displacement")
    field = self.fields.get("field")

    self.assertEqual(2, field.spaceDim())
    return


  def test_addFiberDim(self):
    from pylith.topology.topology import FieldBase
    self.fields.add("field", "displacement")
    field = self.fields.get("field")
    field.newSection(FieldBase.VERTICES_FIELD, 4)

    self.assertEqual(2, field.spaceDim())
    return


  def test_del(self):
    self.fields.add("field A", "A")
    self.fields.add("field B", "B")
    self.fields.delField("field A")
    field = self.fields.get("field B")
    return


  def test_copyLayout(self):
    from pylith.topology.topology import FieldBase
    self.fields.add("field A", "A")
    field = self.fields.get("field A")
    field.newSection(FieldBase.VERTICES_FIELD, 4)

    self.fields.add("field B", "B")
    self.fields.copyLayout("field A")

    # No test of result
    return