Exemple #1
0
class TestReadDouble3D(TestCase):
    def setUp(self):
        import os
        from Danu import Output
        import random
        import numpy

        self.filename = 'test-Sequence.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Sequence')

        seq = self.sim.get_nextSequence(0, 0.0)
        n1 = random.randint(12, 50)
        n2 = random.randint(10, 60)
        n3 = random.randint(2, 40)
        self.data = numpy.random.random_sample((n1, n2, n3))

        self.data_name = 'Double Data'
        seq.data_write(self.data_name, self.data)

    def tearDown(self):
        import os
        if os.path.exists(self.filename):
            self.fh.close()
            os.remove(self.filename)

    def runTest(self):

        seq = self.sim.get_sequence('Series 1')
        read_data = seq.data_read(self.data_name)
        self.assertEqual(read_data.all(), self.data.all())
class TestUtils(TestCase):
    def setUp(self):
        import os
        from Danu import Output

        self.filename = 'test-Simulation.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Simulation')

    def tearDown(self):
        import os
        if os.path.exists(self.filename):
            self.fh.close()
            os.remove(self.filename)

    def test_data_count(self):
        cnt = self.sim.data_count()
        self.assertEqual(cnt, 0)

    def test_data_exists(self):
        data_name = 'Dataset'
        self.assertEqual(self.sim.data_exists(data_name), 0)

    def test_data_list(self):
        list = self.sim.data_list()
        self.assertEqual(len(list), 0)
Exemple #3
0
    def setUp(self):
        import os
        from Danu import Output
        import random
        import numpy

        self.filename = 'test-Sequence.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Sequence')

        seq = self.sim.get_nextSequence(0, 0.0)
        n1 = random.randint(10, 20)
        n2 = random.randint(10, 20)
        n3 = random.randint(10, 20)
        self.data = numpy.zeros((n1, n2, n3))
        i = 0
        while i < n1:
            j = 0
            while j < n2:
                k = 0
                while k < n3:
                    self.data[i][j] = random.randint(0, 10000)
                    k = k + 1
                j = j + 1
            i = i + 1

        self.data_name = 'Integer Data'
        seq.data_write(self.data_name, self.data)
class TestReadDouble3D(TestCase):

  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Sequence.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Sequence')

    seq=self.sim.get_nextSequence(0,0.0)
    n1=random.randint(12,50)
    n2=random.randint(10,60)
    n3=random.randint(2,40)
    self.data=numpy.random.random_sample((n1,n2,n3))

    self.data_name='Double Data'
    seq.data_write(self.data_name,self.data)

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def runTest(self):
  
    seq=self.sim.get_sequence('Series 1')
    read_data=seq.data_read(self.data_name)
    self.assertEqual(read_data.all(), self.data.all())
    def setUp(self):
        import os
        import numpy
        import random
        from Danu import Output

        self.filename = 'test-Simulation.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Simulation')

        self.data_name_1d = 'Double Data 1D'
        self.n = random.randint(1000, 10000)
        self.data_1d = numpy.random.random_sample((self.n))
        self.sim.data_write(self.data_name_1d, self.data_1d)

        self.data_name_2d = 'Double Data 2D'
        self.n1 = random.randint(100, 1000)
        self.n2 = random.randint(100, 1000)
        self.data_2d = numpy.random.random_sample((self.n1, self.n2))
        self.sim.data_write(self.data_name_2d, self.data_2d)

        self.data_name_3d = 'Double Data 3D'
        self.n1 = random.randint(10, 100)
        self.n2 = random.randint(10, 100)
        self.n3 = random.randint(10, 100)
        self.data_3d = numpy.random.random_sample((self.n1, self.n2, self.n3))
        self.sim.data_write(self.data_name_3d, self.data_3d)
Exemple #6
0
    def setUp(self):
        import os
        import numpy
        import random
        from Danu import Output
        from Danu import UNSTRUCTURED_MESH
        from Danu import HEX_ELEM, HEX_ELEM_ORDER

        self.filename = 'test-Mesh.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')

        self.mesh_name = 'Test Mesh 3D HEX'
        self.mesh = self.fh.add_unstruct_mesh(self.mesh_name, HEX_ELEM)

        self.n = random.randint(10, 2048)
        self.x = numpy.random.random_sample((self.n))
        self.y = numpy.random.random_sample((self.n))
        self.z = numpy.random.random_sample((self.n))
        self.coordinates = [self.x, self.y, self.z]
        self.mesh.write_coordinates(self.x, self.y, self.z)
        self.nelem = random.randint(1024, 2048)
        self.data = numpy.zeros((self.nelem, HEX_ELEM_ORDER),
                                dtype=numpy.int32)
        nc = 0
        while nc < self.nelem:
            i = 0
            while i < HEX_ELEM_ORDER:
                self.data[nc][i] = random.randint(0, 100000)
                i = i + 1
            nc = nc + 1
        self.mesh.write_connectivity(self.data)
Exemple #7
0
    def setUp(self):
        import random
        import string

        self.filename = 'test-Output.h5'

        self.fh = Output(self.filename, 'w')

        self.attributes = []

        self.int_attr_name = 'Dummy Int Attribute'
        self.attributes.append(self.int_attr_name)
        self.int_attr = random.randint(0, 1000000)
        self.fh.set_attribute(self.int_attr_name, self.int_attr)

        self.double_attr_name = 'Dummy Double Attribute'
        self.attributes.append(self.double_attr_name)
        self.double_attr = random.random()
        self.fh.set_attribute(self.double_attr_name, self.double_attr)

        self.str_attr_name = 'Dummy String Attribute'
        self.attributes.append(self.str_attr_name)
        str_len = random.randint(10, 1024)
        self.str_attr = ''.join(
            random.choice(string.letters) for i in xrange(str_len))
        self.fh.set_attribute(self.str_attr_name, self.str_attr)
Exemple #8
0
    def setUp(self):
        import os
        import numpy
        import random
        from Danu import Output
        from Danu import UNSTRUCTURED_MESH
        from Danu import HEX_ELEM, HEX_ELEM_ORDER

        self.filename = 'test-Mesh.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')

        self.mesh_name = 'Test Mesh 3D HEX'
        self.mesh = self.fh.add_unstruct_mesh(self.mesh_name, HEX_ELEM)

        self.data_name = 'Data to Read'
        self.nelem = random.randint(10, 2048)
        self.data = numpy.zeros((self.nelem, HEX_ELEM_ORDER),
                                dtype=numpy.int32)
        nc = 0
        while nc < self.nelem:
            i = 0
            while i < HEX_ELEM_ORDER:
                self.data[nc][i] = random.randint(0, 100000)
                i = i + 1
            nc = nc + 1
class TestUtils(TestCase):

  def setUp(self):
    import os
    from Danu import Output

    self.filename = 'test-Simulation.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Simulation')

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def test_data_count(self):
    cnt=self.sim.data_count()
    self.assertEqual(cnt,0)

  def test_data_exists(self):
    data_name='Dataset'
    self.assertEqual(self.sim.data_exists(data_name),0)

  def test_data_list(self):
    list=self.sim.data_list()
    self.assertEqual(len(list),0)
Exemple #10
0
    def setUp(self):
        import os
        from Danu import Output
        from Danu import UNSTRUCTURED_MESH, STRUCTURED_MESH
        from Danu import LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM

        self.filename = 'test-Mesh.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')

        self.valid_mesh_types = [UNSTRUCTURED_MESH, STRUCTURED_MESH]
        self.valid_mesh_elems1 = [LINE_ELEM]
        self.valid_mesh_elems2 = [TRI_ELEM, QUAD_ELEM]
        self.valid_mesh_elems3 = [TET_ELEM, HEX_ELEM]

        self.valid_mesh_1D = []
        self.valid_mesh_2D = []
        self.valid_mesh_3D = []

        for elem in self.valid_mesh_elems1:
            mesh_name = 'Mesh 1D' + str(elem)
            self._writeUnstructMesh(mesh_name, 1, elem)
            self.valid_mesh_1D.insert(0, mesh_name)

        for elem in self.valid_mesh_elems2:
            mesh_name = 'Mesh 2D' + str(elem)
            self._writeUnstructMesh(mesh_name, 2, elem)
            self.valid_mesh_2D.insert(0, mesh_name)

        for elem in self.valid_mesh_elems3:
            mesh_name = 'Mesh 3D' + str(elem)
            self._writeUnstructMesh(mesh_name, 3, elem)
            self.valid_mesh_3D.insert(0, mesh_name)
Exemple #11
0
class TestConnectivity(unittest.TestCase):
    def setUp(self):
        import os
        import numpy
        import random
        from Danu import Output
        from Danu import UNSTRUCTURED_MESH
        from Danu import HEX_ELEM, HEX_ELEM_ORDER

        self.filename = 'test-Mesh.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')

        self.mesh_name = 'Test Mesh 3D HEX'
        self.mesh = self.fh.add_unstruct_mesh(self.mesh_name, HEX_ELEM)

        self.data_name = 'Data to Read'
        self.nelem = random.randint(10, 2048)
        self.data = numpy.zeros((self.nelem, HEX_ELEM_ORDER),
                                dtype=numpy.int32)
        nc = 0
        while nc < self.nelem:
            i = 0
            while i < HEX_ELEM_ORDER:
                self.data[nc][i] = random.randint(0, 100000)
                i = i + 1
            nc = nc + 1

    def tearDown(self):
        import os
        if os.path.exists(self.filename):
            self.fh.close()
            #os.remove(self.filename)

    def test_basic(self):
        import numpy
        import random

        # try to read before a write
        try:
            r_data = self.mesh.read_connectivity()
        except:
            print 'Caught the read before write error'

        self.mesh.write_connectivity(self.data)
        read_data = self.mesh.read_connectivity()
        self.assertEqual(read_data.all(), self.data.all())

    def test_offset(self):
        import numpy
        import random

        self.mesh.write_connectivity(self.data)

        offset = self.mesh.connectivity_offset()
        self.assertEqual(offset, 0)
Exemple #12
0
class TestConnectivity(unittest.TestCase):

  def setUp(self):
    import os
    import numpy
    import random
    from Danu import Output
    from Danu import UNSTRUCTURED_MESH
    from Danu import HEX_ELEM, HEX_ELEM_ORDER 

    self.filename = 'test-Mesh.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')

    self.mesh_name='Test Mesh 3D HEX'
    self.mesh=self.fh.add_unstruct_mesh(self.mesh_name,HEX_ELEM)
    
    self.data_name='Data to Read'
    self.nelem=random.randint(10,2048)
    self.data=numpy.zeros((self.nelem,HEX_ELEM_ORDER),dtype=numpy.int32)
    nc=0
    while nc < self.nelem:
      i=0
      while i < HEX_ELEM_ORDER:
        self.data[nc][i]=random.randint(0,100000)
        i=i+1
      nc=nc+1	

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      #os.remove(self.filename)

  def test_basic(self):
    import numpy
    import random

    # try to read before a write
    try:
      r_data=self.mesh.read_connectivity()
    except:
      print 'Caught the read before write error'

    self.mesh.write_connectivity(self.data)  
    read_data=self.mesh.read_connectivity()
    self.assertEqual(read_data.all(),self.data.all())

  def test_offset(self):
    import numpy
    import random

    self.mesh.write_connectivity(self.data)  

    offset=self.mesh.connectivity_offset()
    self.assertEqual(offset,0)
    def setUp(self):
        import os
        from Danu import Output

        self.filename = 'test-Simulation.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
Exemple #14
0
class TestCreate(TestCase):

  def setUp(self):
    import os
    from Danu import Output

    self.filename = 'test-Probe.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Probe')

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def test_create_int(self):
    import numpy
    import random

    len=random.randint(1,7)
    num=random.randint(128,512)
    idata=numpy.zeros((num,len))
    i=0
    while i < num:
      l=0
      while l < len:
	idata[i][l]=random.randint(0,100000)
	l=l+1
      i=i+1

    probe=Probe(self.sim,'Int Data',idata)  

  def test_create_float(self):
    import numpy
    import random

    len=random.randint(1,7)
    num=random.randint(128,512)
    data=numpy.float32(numpy.random.random_sample((num,len)))

    probe=Probe(self.sim,'Float data',data)  


  def test_create_double(self):
    import numpy
    import random

    len=random.randint(1,7)
    num=random.randint(128,512)
    data=numpy.random.random_sample((num,len))

    probe=Probe(self.sim,'Double data',data)  
Exemple #15
0
    def setUp(self):
        from Danu import LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM

        self.filename = 'test-Output.h5'
        self.fh = Output(self.filename, 'w')

        self.mesh_count = 0
        self.mesh_names = []

        self.valid_elems = [LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM]
Exemple #16
0
  def setUp(self):
    import os
    from Danu import Output

    self.filename = 'test-Probe.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Probe')
Exemple #17
0
class TestBasic(TestCase):

  def setUp(self):
    import os
    from Danu import Output

    self.filename = 'test-Probe.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Probe')

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def runTest(self):
    import random
    import numpy

    print 'Begin basic test'
    try:
      probe=Probe()
    except:
      print 'Caught invalid number of arguments'

    try:
      probe=Probe(self.sim)
    except:
      print 'Caught invalid number of arguments'

    try:
      probe=Probe(self.sim,'Dummy Probe')
    except:
      print 'Caught invalid number of arguments'

    try:
      data=numpy.ones((10))
      probe=Probe(self.sim,'Dummy Probe',data)
    except:
      print 'Caught incorrect argument type'

    # Simple constructor and delete
    len=2
    num=20
    data=numpy.ones((num,len))
    probe= Probe(self.sim,'Dummy Probe',data)
    del probe

    probe=self.sim.probe_open('Dummy Probe')
    self.assertEqual(probe.length(),len)
    self.assertEqual(probe.number(),num)
Exemple #18
0
class TestAttributes(TestCase):
 
  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Probe.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Probe')
    self.probe_name='Dummy Probe'
    data=numpy.ones((3,10))
    Probe(self.sim,self.probe_name,data)

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def runTest(self):
    import random
    
    probe=self.sim.probe_open(self.probe_name)

    # integers
    int_name='Integer Attribute'
    try:
      probe.get_attribute(int_name)
    except:
      print 'Caught DNE attribute'
    else:
      raise RuntimeError, 'Failed to catch DNE error'
    int_attr=random.randint(1,102400)
    probe.set_attribute(int_name,int_attr)
    read_attr=probe.get_attribute(int_name)
    self.assertEqual(int_attr,read_attr)

    # double
    dbl_name='Double Attribute'
    dbl_attr=random.random()
    probe.set_attribute(dbl_name,dbl_attr)
    read_dbl=probe.get_attribute(dbl_name)
    self.assertEqual(read_dbl,dbl_attr)

    # string
    str_name='Chacracter Name Attribute'
    str_attr='ajksdweiouamnv 9iajemn  oiwiwe'
    probe.set_attribute(str_name,str_attr)
    string=probe.get_attribute(str_name)
    self.assertEqual(string,str_attr)
class TestAttributes(TestCase):
 
  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Sequence.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Sequence')
    self.seq=self.sim.get_nextSequence(0,0.0)

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def runTest(self):
    import random
    
    seq=self.seq

    # integers
    int_name='Integer Attribute'
    try:
      seq.get_attribute(int_name)
    except:
      print 'Caught DNE attribute'
    else:
      raise RuntimeError, 'Failed to catch DNE error'
    int_attr=random.randint(1,102400)
    seq.set_attribute(int_name,int_attr)
    read_attr=seq.get_attribute(int_name)
    self.assertEqual(int_attr,read_attr)

    # double
    dbl_name='Double Attribute'
    dbl_attr=random.random()
    seq.set_attribute(dbl_name,dbl_attr)
    read_dbl=seq.get_attribute(dbl_name)
    self.assertEqual(read_dbl,dbl_attr)

    # string
    str_name='Chacracter Name Attribute'
    str_attr='ajksdweiouamnv 9iajemn  oiwiwe'
    seq.set_attribute(str_name,str_attr)
    string=seq.get_attribute(str_name)
    self.assertEqual(string,str_attr)
    def setUp(self):
        import os
        import numpy
        import random
        from Danu import Output

        self.filename = 'test-Simulation.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Simulation')
class TestBasic(TestCase):

  def setUp(self):
    import os
    from Danu import Output

    self.filename = 'test-Sequence.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Sequence')

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def runTest(self):
    import random
    import numpy

    print 'Begin basic test'
    try:
      seq=Sequence()
    except:
      print 'Caught invalid number of arguments'

    try:
      seq=Sequence(self.sim)
    except:
      print 'Caught invalid name or id'

    try:
      seq=Sequence(self.sim,'Series DNE')
    except:
      print 'Caught id group that does not exist'

    try:
      seq=Sequence(self.sim,seriesname='Series 10')
    except:
      print 'Caught group name that does not exist'

    cycle=random.randint(0,10)
    time=numpy.float64(random.randint(0,1000))
    seq=self.sim.get_nextSequence(cycle,time)
    id=seq.id
    del seq
    seq_name=self.sim.get_sequence_name(id)
    new_seq=Sequence(self.sim,seq_name)
    del new_seq
Exemple #22
0
class TestAttributes(TestCase):
    def setUp(self):
        import os
        from Danu import Output
        import random
        import numpy

        self.filename = 'test-Sequence.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Sequence')
        self.seq = self.sim.get_nextSequence(0, 0.0)

    def tearDown(self):
        import os
        if os.path.exists(self.filename):
            self.fh.close()
            os.remove(self.filename)

    def runTest(self):
        import random

        seq = self.seq

        # integers
        int_name = 'Integer Attribute'
        try:
            seq.get_attribute(int_name)
        except:
            print 'Caught DNE attribute'
        else:
            raise RuntimeError, 'Failed to catch DNE error'
        int_attr = random.randint(1, 102400)
        seq.set_attribute(int_name, int_attr)
        read_attr = seq.get_attribute(int_name)
        self.assertEqual(int_attr, read_attr)

        # double
        dbl_name = 'Double Attribute'
        dbl_attr = random.random()
        seq.set_attribute(dbl_name, dbl_attr)
        read_dbl = seq.get_attribute(dbl_name)
        self.assertEqual(read_dbl, dbl_attr)

        # string
        str_name = 'Chacracter Name Attribute'
        str_attr = 'ajksdweiouamnv 9iajemn  oiwiwe'
        seq.set_attribute(str_name, str_attr)
        string = seq.get_attribute(str_name)
        self.assertEqual(string, str_attr)
Exemple #23
0
    def setUp(self):
        import os
        from Danu import Output
        import random
        import numpy

        self.filename = 'test-Sequence.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Sequence')
        self.seq = self.sim.get_nextSequence(0, 0.0)
    def setUp(self):
        import os
        import numpy
        import random
        from Danu import Output

        self.filename = 'test-Simulation.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Simulation')

        self.data_name_1d = 'Integer Data 1D'
        self.n = random.randint(1000, 10000)
        self.data_1d = numpy.zeros((self.n), numpy.int32)
        i = 0
        while i < self.n:
            self.data_1d[i] = random.randint(1, 100000)
            i = i + 1
        self.sim.data_write(self.data_name_1d, self.data_1d)

        self.data_name_2d = 'Integer Data 2D'
        self.n1 = random.randint(100, 1000)
        self.n2 = random.randint(100, 1000)
        self.data_2d = numpy.zeros((self.n1, self.n2), numpy.int32)
        i = 0
        while i < self.n1:
            j = 0
            while j < self.n2:
                self.data_2d[i][j] = random.randint(1, 100000)
                j = j + 1
            i = i + 1
        self.sim.data_write(self.data_name_2d, self.data_2d)

        self.data_name_3d = 'Integer Data 3D'
        self.n1 = random.randint(10, 100)
        self.n2 = random.randint(10, 100)
        self.n3 = random.randint(10, 100)
        self.data_3d = numpy.zeros((self.n1, self.n2, self.n3), numpy.int32)
        i = 0
        while i < self.n1:
            j = 0
            while j < self.n2:
                k = 0
                while k < self.n3:
                    self.data_3d[i][j][k] = random.randint(1, 100000)
                    k = k + 1
                j = j + 1
            i = i + 1
        self.sim.data_write(self.data_name_3d, self.data_3d)
Exemple #25
0
class TestBasic(TestCase):
    def setUp(self):
        import os
        from Danu import Output

        self.filename = 'test-Sequence.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Sequence')

    def tearDown(self):
        import os
        if os.path.exists(self.filename):
            self.fh.close()
            os.remove(self.filename)

    def runTest(self):
        import random
        import numpy

        print 'Begin basic test'
        try:
            seq = Sequence()
        except:
            print 'Caught invalid number of arguments'

        try:
            seq = Sequence(self.sim)
        except:
            print 'Caught invalid name or id'

        try:
            seq = Sequence(self.sim, 'Series DNE')
        except:
            print 'Caught id group that does not exist'

        try:
            seq = Sequence(self.sim, seriesname='Series 10')
        except:
            print 'Caught group name that does not exist'

        cycle = random.randint(0, 10)
        time = numpy.float64(random.randint(0, 1000))
        seq = self.sim.get_nextSequence(cycle, time)
        id = seq.id
        del seq
        seq_name = self.sim.get_sequence_name(id)
        new_seq = Sequence(self.sim, seq_name)
        del new_seq
Exemple #26
0
 def test_open_rdonly(self):
     from Danu import FILE_ACC_RDONLY
     bad_file = 'does-not-exist-' + self.filename
     try:
         file = Output(bad_file, 'r')
     except:
         print 'Caught the bad file error'
     else:
         print 'Failed to catch the error'
         raise
     file = Output(self.filename, 'r')
     access = file.access
     self.assertEqual(access, FILE_ACC_RDONLY)
     del file
Exemple #27
0
class TestOutputWriteAttribute(unittest.TestCase):

  def setUp(self):
    self.filename         = 'test-Output.h5'
    self.int_attr_name    = 'Dummy Int Attribute'
    self.double_attr_name = 'Dummy Double Attribute'
    self.str_attr_name    = 'Dummy String Attribute'
    self.fh               = Output(self.filename,'a')

  def tearDown(self):
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def test_string_attribute(self):
    import random
    str_len = random.randint(16,1024)
    self.fh.set_attribute(self.str_attr_name,os.urandom(str_len))
  
  def test_double_attribute(self):
    import random
    self.fh.set_attribute(self.double_attr_name,random.random())
  
  def test_int_attribute(self):
    import random
    self.fh.set_attribute(self.int_attr_name,random.randint(0,100000))
Exemple #28
0
class TestOutputWriteAttribute(unittest.TestCase):
    def setUp(self):
        self.filename = 'test-Output.h5'
        self.int_attr_name = 'Dummy Int Attribute'
        self.double_attr_name = 'Dummy Double Attribute'
        self.str_attr_name = 'Dummy String Attribute'
        self.fh = Output(self.filename, 'a')

    def tearDown(self):
        if os.path.exists(self.filename):
            self.fh.close()
            os.remove(self.filename)

    def test_string_attribute(self):
        import random
        str_len = random.randint(16, 1024)
        self.fh.set_attribute(self.str_attr_name, os.urandom(str_len))

    def test_double_attribute(self):
        import random
        self.fh.set_attribute(self.double_attr_name, random.random())

    def test_int_attribute(self):
        import random
        self.fh.set_attribute(self.int_attr_name, random.randint(0, 100000))
Exemple #29
0
  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Probe.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Probe')
    self.probe_name='Dummy Probe'
    data=numpy.ones((3,10))
    Probe(self.sim,self.probe_name,data)
class TestDataReadFloat(TestCase):
    def setUp(self):
        import os
        import numpy
        import random
        from Danu import Output

        self.filename = 'test-Simulation.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Simulation')

        self.data_name_1d = 'Float Data 1D'
        self.n = random.randint(1000, 10000)
        self.data_1d = numpy.float32(numpy.random.random_sample((self.n)))
        self.sim.data_write(self.data_name_1d, self.data_1d)

        self.data_name_2d = 'Float Data 2D'
        self.n1 = random.randint(100, 1000)
        self.n2 = random.randint(100, 1000)
        self.data_2d = numpy.float32(
            numpy.random.random_sample((self.n1, self.n2)))
        self.sim.data_write(self.data_name_2d, self.data_2d)

        self.data_name_3d = 'Float Data 3D'
        self.n1 = random.randint(10, 100)
        self.n2 = random.randint(10, 100)
        self.n3 = random.randint(10, 100)
        self.data_3d = numpy.float32(
            numpy.random.random_sample((self.n1, self.n2, self.n3)))
        self.sim.data_write(self.data_name_3d, self.data_3d)

    def tearDown(self):
        import os
        if os.path.exists(self.filename):
            self.fh.close()

    def runTest(self):
        data1 = self.sim.data_read(self.data_name_1d)
        self.assertEqual(data1.all(), self.data_1d.all())

        data2 = self.sim.data_read(self.data_name_2d)
        self.assertEqual(data2.all(), self.data_2d.all())

        data3 = self.sim.data_read(self.data_name_3d)
        self.assertEqual(data3.all(), self.data_3d.all())
Exemple #31
0
  def setUp(self):
    import os
    import numpy
    import random
    from Danu import Output
    from Danu import UNSTRUCTURED_MESH
    from Danu import HEX_ELEM, HEX_ELEM_ORDER 

    self.filename = 'test-Mesh.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')

    self.mesh_name='Test Mesh 3D HEX'
    self.mesh=self.fh.add_unstruct_mesh(self.mesh_name,HEX_ELEM)
    
    self.n=random.randint(10,2048)
    self.x=numpy.random.random_sample((self.n))
    self.y=numpy.random.random_sample((self.n))
    self.z=numpy.random.random_sample((self.n))
    self.coordinates=[self.x,self.y,self.z]
    self.mesh.write_coordinates(self.x,self.y,self.z)
    self.nelem=random.randint(1024,2048)
    self.data=numpy.zeros((self.nelem,HEX_ELEM_ORDER),dtype=numpy.int32)
    nc=0
    while nc < self.nelem:
      i=0
      while i < HEX_ELEM_ORDER:
        self.data[nc][i]=random.randint(0,100000)
        i=i+1
      nc=nc+1	
    self.mesh.write_connectivity(self.data)
  def setUp(self):
    import os
    import numpy
    import random
    from Danu import Output

    self.filename = 'test-Simulation.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Simulation')

    self.data_name_1d='Double Data 1D'
    self.n=random.randint(1000,10000)
    self.data_1d=numpy.random.random_sample((self.n))
    self.sim.data_write(self.data_name_1d,self.data_1d) 

    self.data_name_2d='Double Data 2D'
    self.n1=random.randint(100,1000)
    self.n2=random.randint(100,1000)
    self.data_2d=numpy.random.random_sample((self.n1,self.n2))
    self.sim.data_write(self.data_name_2d,self.data_2d) 
    
    self.data_name_3d='Double Data 3D'
    self.n1=random.randint(10,100)
    self.n2=random.randint(10,100)
    self.n3=random.randint(10,100)
    self.data_3d=numpy.random.random_sample((self.n1,self.n2,self.n3))
    self.sim.data_write(self.data_name_3d,self.data_3d) 
Exemple #33
0
  def setUp(self):
    import os
    import numpy
    import random
    from Danu import Output
    from Danu import UNSTRUCTURED_MESH
    from Danu import HEX_ELEM, HEX_ELEM_ORDER 

    self.filename = 'test-Mesh.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')

    self.mesh_name='Test Mesh 3D HEX'
    self.mesh=self.fh.add_unstruct_mesh(self.mesh_name,HEX_ELEM)
    
    self.data_name='Data to Read'
    self.nelem=random.randint(10,2048)
    self.data=numpy.zeros((self.nelem,HEX_ELEM_ORDER),dtype=numpy.int32)
    nc=0
    while nc < self.nelem:
      i=0
      while i < HEX_ELEM_ORDER:
        self.data[nc][i]=random.randint(0,100000)
        i=i+1
      nc=nc+1	
  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Sequence.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Sequence')

    seq=self.sim.get_nextSequence(0,0.0)
    n1=random.randint(10,20)
    n2=random.randint(10,20)
    n3=random.randint(10,20)
    self.data=numpy.zeros((n1,n2,n3))
    i=0
    while i < n1:
      j=0
      while j < n2:
        k=0
        while k < n3:
          self.data[i][j]=random.randint(0,10000)
          k=k+1
        j=j+1
      i=i+1

    self.data_name='Integer Data'
    seq.data_write(self.data_name,self.data)
Exemple #35
0
    def setUp(self):
        import os
        from Danu import Output
        from Danu import UNSTRUCTURED_MESH, STRUCTURED_MESH
        from Danu import LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM

        self.filename = 'test-Mesh.h5'
        self.fh = Output(self.filename, 'w')

        self.mesh_count = 0
        self.mesh_names = []

        self.valid_mesh_types = [UNSTRUCTURED_MESH, STRUCTURED_MESH]
        self.valid_mesh_elems1 = [LINE_ELEM]
        self.valid_mesh_elems2 = [TRI_ELEM, QUAD_ELEM]
        self.valid_mesh_elems3 = [TET_ELEM, HEX_ELEM]
Exemple #36
0
  def setUp(self):
    import os
    from Danu import Output
    from Danu import UNSTRUCTURED_MESH, STRUCTURED_MESH
    from Danu import LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM 

    self.filename = 'test-Mesh.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh       = Output(self.filename,'w')

    self.valid_mesh_types = [UNSTRUCTURED_MESH, STRUCTURED_MESH]
    self.valid_mesh_elems1 = [LINE_ELEM]
    self.valid_mesh_elems2 = [TRI_ELEM, QUAD_ELEM]
    self.valid_mesh_elems3 = [TET_ELEM, HEX_ELEM]

    self.valid_mesh_1D = []
    self.valid_mesh_2D = []
    self.valid_mesh_3D = []
     
    for elem in self.valid_mesh_elems1:
      mesh_name='Mesh 1D' + str(elem)
      self._writeUnstructMesh(mesh_name,1,elem)
      self.valid_mesh_1D.insert(0,mesh_name)

    for elem in self.valid_mesh_elems2:
      mesh_name='Mesh 2D' + str(elem)
      self._writeUnstructMesh(mesh_name,2,elem)
      self.valid_mesh_2D.insert(0,mesh_name)

    for elem in self.valid_mesh_elems3:
      mesh_name='Mesh 3D' + str(elem)
      self._writeUnstructMesh(mesh_name,3,elem)
      self.valid_mesh_3D.insert(0,mesh_name)
Exemple #37
0
  def setUp(self):
    import random
    import string

    self.filename         = 'test-Output.h5'

    self.fh               = Output(self.filename,'w')

    self.attributes       = []

    self.int_attr_name    = 'Dummy Int Attribute'
    self.attributes.append(self.int_attr_name)
    self.int_attr         = random.randint(0,1000000)
    self.fh.set_attribute(self.int_attr_name,self.int_attr)

    self.double_attr_name = 'Dummy Double Attribute'
    self.attributes.append(self.double_attr_name)
    self.double_attr      = random.random()
    self.fh.set_attribute(self.double_attr_name,self.double_attr)

    self.str_attr_name    = 'Dummy String Attribute'
    self.attributes.append(self.str_attr_name)
    str_len = random.randint(10,1024)
    self.str_attr         = ''.join(random.choice(string.letters) for i in xrange(str_len))
    self.fh.set_attribute(self.str_attr_name,self.str_attr)
Exemple #38
0
class TestAttributes(unittest.TestCase):
    def setUp(self):
        import os
        import numpy
        import random
        from Danu import Output
        from Danu import UNSTRUCTURED_MESH
        from Danu import HEX_ELEM, HEX_ELEM_ORDER

        self.filename = 'test-Mesh.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')

        self.mesh_name = 'Test Mesh 3D HEX'
        self.mesh = self.fh.add_unstruct_mesh(self.mesh_name, HEX_ELEM)

        self.n = random.randint(10, 2048)
        self.x = numpy.random.random_sample((self.n))
        self.y = numpy.random.random_sample((self.n))
        self.z = numpy.random.random_sample((self.n))
        self.coordinates = [self.x, self.y, self.z]
        self.mesh.write_coordinates(self.x, self.y, self.z)
        self.nelem = random.randint(1024, 2048)
        self.data = numpy.zeros((self.nelem, HEX_ELEM_ORDER),
                                dtype=numpy.int32)
        nc = 0
        while nc < self.nelem:
            i = 0
            while i < HEX_ELEM_ORDER:
                self.data[nc][i] = random.randint(0, 100000)
                i = i + 1
            nc = nc + 1
        self.mesh.write_connectivity(self.data)

    def tearDown(self):
        import os
        if os.path.exists(self.filename):
            self.fh.close()
            os.remove(self.filename)

    def runTest(self):
        import Danu
        self.assertEqual(self.x.size, self.mesh.nnodes())
        self.assertEqual(Danu.HEX_ELEM_ORDER, self.mesh.elem_order())
        print self.mesh.nelem()
class TestDataReadDouble(TestCase):

  def setUp(self):
    import os
    import numpy
    import random
    from Danu import Output

    self.filename = 'test-Simulation.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Simulation')

    self.data_name_1d='Double Data 1D'
    self.n=random.randint(1000,10000)
    self.data_1d=numpy.random.random_sample((self.n))
    self.sim.data_write(self.data_name_1d,self.data_1d) 

    self.data_name_2d='Double Data 2D'
    self.n1=random.randint(100,1000)
    self.n2=random.randint(100,1000)
    self.data_2d=numpy.random.random_sample((self.n1,self.n2))
    self.sim.data_write(self.data_name_2d,self.data_2d) 
    
    self.data_name_3d='Double Data 3D'
    self.n1=random.randint(10,100)
    self.n2=random.randint(10,100)
    self.n3=random.randint(10,100)
    self.data_3d=numpy.random.random_sample((self.n1,self.n2,self.n3))
    self.sim.data_write(self.data_name_3d,self.data_3d) 

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()

  def runTest(self):
    data1=self.sim.data_read(self.data_name_1d)
    self.assertEqual(data1.all(),self.data_1d.all())

    data2=self.sim.data_read(self.data_name_2d)
    self.assertEqual(data2.all(),self.data_2d.all())

    data3=self.sim.data_read(self.data_name_3d)
    self.assertEqual(data3.all(),self.data_3d.all())
Exemple #40
0
class TestAttributes(unittest.TestCase):

  def setUp(self):
    import os
    import numpy
    import random
    from Danu import Output
    from Danu import UNSTRUCTURED_MESH
    from Danu import HEX_ELEM, HEX_ELEM_ORDER 

    self.filename = 'test-Mesh.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')

    self.mesh_name='Test Mesh 3D HEX'
    self.mesh=self.fh.add_unstruct_mesh(self.mesh_name,HEX_ELEM)
    
    self.n=random.randint(10,2048)
    self.x=numpy.random.random_sample((self.n))
    self.y=numpy.random.random_sample((self.n))
    self.z=numpy.random.random_sample((self.n))
    self.coordinates=[self.x,self.y,self.z]
    self.mesh.write_coordinates(self.x,self.y,self.z)
    self.nelem=random.randint(1024,2048)
    self.data=numpy.zeros((self.nelem,HEX_ELEM_ORDER),dtype=numpy.int32)
    nc=0
    while nc < self.nelem:
      i=0
      while i < HEX_ELEM_ORDER:
        self.data[nc][i]=random.randint(0,100000)
        i=i+1
      nc=nc+1	
    self.mesh.write_connectivity(self.data)

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def runTest(self):
    import Danu
    self.assertEqual(self.x.size,self.mesh.nnodes())
    self.assertEqual(Danu.HEX_ELEM_ORDER,self.mesh.elem_order())
    print self.mesh.nelem()
class TestReadInteger3D(TestCase):

  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Sequence.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Sequence')

    seq=self.sim.get_nextSequence(0,0.0)
    n1=random.randint(10,20)
    n2=random.randint(10,20)
    n3=random.randint(10,20)
    self.data=numpy.zeros((n1,n2,n3))
    i=0
    while i < n1:
      j=0
      while j < n2:
        k=0
        while k < n3:
          self.data[i][j]=random.randint(0,10000)
          k=k+1
        j=j+1
      i=i+1

    self.data_name='Integer Data'
    seq.data_write(self.data_name,self.data)

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def runTest(self):
  
    seq=self.sim.get_sequence('Series 1')
    read_data=seq.data_read(self.data_name)

    self.assertEqual(read_data.all(), self.data.all())
Exemple #42
0
class TestMeshWriteCoordinates(unittest.TestCase):

  def setUp(self):
    import os
    from Danu import Output
    from Danu import UNSTRUCTURED_MESH, STRUCTURED_MESH
    from Danu import LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM 

    self.filename = 'test-Mesh.h5'
    self.fh       = Output(self.filename,'w')

    self.mesh_count = 0
    self.mesh_names = []

    self.valid_mesh_types = [UNSTRUCTURED_MESH, STRUCTURED_MESH]
    self.valid_mesh_elems1 = [LINE_ELEM]
    self.valid_mesh_elems2 = [TRI_ELEM, QUAD_ELEM]
    self.valid_mesh_elems3 = [TET_ELEM, HEX_ELEM]

  def tearDown(self):
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def test_write_coordinates_1D(self):
    import numpy
    import random
    from Danu import LINE_ELEM

    mesh_name = '1D Mesh'
    nnodes=random.randint(128,1024)
    mesh = self.fh.add_unstruct_mesh(mesh_name,LINE_ELEM)
    xcoordinates = numpy.random.random_sample((nnodes))
    try:
      mesh.write_coordinates()
      raise RuntimeError, "Failed to raise exception"
    except:
      print "Caught null argument exception"

    try:
      mesh.write_coordinates(1)
      raise RuntimeError, "Failed to raise exception"
    except:
      print "Caught invalid data type"

    mesh.write_coordinates(xcoordinates)
Exemple #43
0
class TestMeshWriteCoordinates(unittest.TestCase):
    def setUp(self):
        import os
        from Danu import Output
        from Danu import UNSTRUCTURED_MESH, STRUCTURED_MESH
        from Danu import LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM

        self.filename = 'test-Mesh.h5'
        self.fh = Output(self.filename, 'w')

        self.mesh_count = 0
        self.mesh_names = []

        self.valid_mesh_types = [UNSTRUCTURED_MESH, STRUCTURED_MESH]
        self.valid_mesh_elems1 = [LINE_ELEM]
        self.valid_mesh_elems2 = [TRI_ELEM, QUAD_ELEM]
        self.valid_mesh_elems3 = [TET_ELEM, HEX_ELEM]

    def tearDown(self):
        if os.path.exists(self.filename):
            self.fh.close()
            os.remove(self.filename)

    def test_write_coordinates_1D(self):
        import numpy
        import random
        from Danu import LINE_ELEM

        mesh_name = '1D Mesh'
        nnodes = random.randint(128, 1024)
        mesh = self.fh.add_unstruct_mesh(mesh_name, LINE_ELEM)
        xcoordinates = numpy.random.random_sample((nnodes))
        try:
            mesh.write_coordinates()
            raise RuntimeError, "Failed to raise exception"
        except:
            print "Caught null argument exception"

        try:
            mesh.write_coordinates(1)
            raise RuntimeError, "Failed to raise exception"
        except:
            print "Caught invalid data type"

        mesh.write_coordinates(xcoordinates)
Exemple #44
0
class TestReadInteger3D(TestCase):
    def setUp(self):
        import os
        from Danu import Output
        import random
        import numpy

        self.filename = 'test-Sequence.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Sequence')

        seq = self.sim.get_nextSequence(0, 0.0)
        n1 = random.randint(10, 20)
        n2 = random.randint(10, 20)
        n3 = random.randint(10, 20)
        self.data = numpy.zeros((n1, n2, n3))
        i = 0
        while i < n1:
            j = 0
            while j < n2:
                k = 0
                while k < n3:
                    self.data[i][j] = random.randint(0, 10000)
                    k = k + 1
                j = j + 1
            i = i + 1

        self.data_name = 'Integer Data'
        seq.data_write(self.data_name, self.data)

    def tearDown(self):
        import os
        if os.path.exists(self.filename):
            self.fh.close()
            os.remove(self.filename)

    def runTest(self):

        seq = self.sim.get_sequence('Series 1')
        read_data = seq.data_read(self.data_name)

        self.assertEqual(read_data.all(), self.data.all())
  def setUp(self):
    import os
    from Danu import Output

    self.filename = 'test-Simulation.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
Exemple #46
0
  def setUp(self):
    from Danu import LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM

    self.filename = 'test-Output.h5'
    self.fh       = Output(self.filename,'w')

    self.mesh_count = 0
    self.mesh_names = []

    self.valid_elems = [LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM]
class TestReadInteger1D(TestCase):

  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Sequence.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Sequence')

    seq=self.sim.get_nextSequence(0,0.0)
    n=random.randint(128,512)
    self.data=numpy.zeros((n))
    i=0
    while i < n:
      self.data[i]=random.randint(0,10000)
      i=i+1

    self.data_name='Integer Data'
    seq.data_write(self.data_name,self.data)

  def tearDown(self):
    import os
    if os.path.exists(self.filename):
      self.fh.close()
      os.remove(self.filename)

  def runTest(self):
  
    seq=self.sim.get_sequence('Series 1')
    try:
      read_data=seq.data_read('Data DNE')
    except:
      print 'Caught Data set that did not exist'

    read_data=seq.data_read(self.data_name)

    self.assertEqual(read_data.all(), self.data.all())
Exemple #48
0
  def setUp(self):
    import os
    import random
    import numpy
    from Danu import Output

    self.filename = 'test-Probe.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Probe')

    # Int data
    self.idata_name='Int data'
    len=random.randint(1,7)
    num=random.randint(128,512)
    self.idata=numpy.zeros((num,len))
    self.idata_len=len
    i=0
    while i < num:
      l=0
      while l < len:
	self.idata[i][l]=random.randint(0,100000)
	l=l+1
      i=i+1
    probe=Probe(self.sim,self.idata_name,self.idata)  

    # Float data
    self.fdata_name='Float data'
    len=random.randint(1,7)
    num=random.randint(128,512)
    self.fdata=numpy.float32(numpy.random.random_sample((num,len)))
    self.fdata_len=len
    probe=Probe(self.sim,self.fdata_name,self.fdata)  

    # Double data
    self.rdata_name='Double data'
    len=random.randint(1,7)
    num=random.randint(128,512)
    self.rdata=numpy.random.random_sample((num,len))
    self.rdata_len=len
    probe=Probe(self.sim,self.rdata_name,self.rdata)  
Exemple #49
0
    def setUp(self):
        import os
        from Danu import Output
        import random
        import numpy

        self.filename = 'test-Sequence.h5'
        if os.path.exists(self.filename):
            os.remove(self.filename)

        self.fh = Output(self.filename, 'w')
        self.sim = self.fh.add_simulation('Test Sequence')

        seq = self.sim.get_nextSequence(0, 0.0)
        n = random.randint(128, 512)
        self.data = numpy.random.random_sample((n))

        self.data_name = 'Double Data'
        seq.data_write(self.data_name, self.data)
  def setUp(self):
    import os
    import numpy
    import random
    from Danu import Output

    self.filename = 'test-Simulation.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Simulation')
  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Sequence.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Sequence')
    self.seq=self.sim.get_nextSequence(0,0.0)
  def setUp(self):
    import os
    import numpy
    import random
    from Danu import Output

    self.filename = 'test-Simulation.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Simulation')

    self.data_name_1d='Integer Data 1D'
    self.n=random.randint(1000,10000)
    self.data_1d=numpy.zeros((self.n),numpy.int32)
    i=0
    while i < self.n:
      self.data_1d[i]=random.randint(1,100000)
      i=i+1
    self.sim.data_write(self.data_name_1d,self.data_1d) 

    self.data_name_2d='Integer Data 2D'
    self.n1=random.randint(100,1000)
    self.n2=random.randint(100,1000)
    self.data_2d=numpy.zeros((self.n1,self.n2),numpy.int32)
    i=0
    while i < self.n1:
      j=0
      while j < self.n2:
	self.data_2d[i][j]=random.randint(1,100000)
	j=j+1
      i=i+1
    self.sim.data_write(self.data_name_2d,self.data_2d) 
    
    self.data_name_3d='Integer Data 3D'
    self.n1=random.randint(10,100)
    self.n2=random.randint(10,100)
    self.n3=random.randint(10,100)
    self.data_3d=numpy.zeros((self.n1,self.n2,self.n3),numpy.int32)
    i=0
    while i < self.n1:
      j=0
      while j < self.n2:
        k=0
	while k < self.n3:
	  self.data_3d[i][j][k]=random.randint(1,100000)
	  k=k+1
	j=j+1
      i=i+1
    self.sim.data_write(self.data_name_3d,self.data_3d) 
Exemple #53
0
  def setUp(self):
    import os
    from Danu import Output
    from Danu import UNSTRUCTURED_MESH, STRUCTURED_MESH
    from Danu import LINE_ELEM, TRI_ELEM, QUAD_ELEM, TET_ELEM, HEX_ELEM 

    self.filename = 'test-Mesh.h5'
    self.fh       = Output(self.filename,'w')

    self.mesh_count = 0
    self.mesh_names = []

    self.valid_mesh_types = [UNSTRUCTURED_MESH, STRUCTURED_MESH]
    self.valid_mesh_elems1 = [LINE_ELEM]
    self.valid_mesh_elems2 = [TRI_ELEM, QUAD_ELEM]
    self.valid_mesh_elems3 = [TET_ELEM, HEX_ELEM]
  def setUp(self):
    import os
    from Danu import Output
    import random
    import numpy

    self.filename = 'test-Sequence.h5'
    if  os.path.exists(self.filename):
      os.remove(self.filename)

    self.fh=Output(self.filename,'w')
    self.sim=self.fh.add_simulation('Test Sequence')

    seq=self.sim.get_nextSequence(0,0.0)
    n=random.randint(128,512)
    self.data=numpy.random.random_sample((n))

    self.data_name='Double Data'
    seq.data_write(self.data_name,self.data)