Exemplo n.º 1
0
    def test_iter_edges(self):
        """Test _iter_edges method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        self.assertEqual(foam_mesh.iter(item_type=CUBA.EDGE), [])
Exemplo n.º 2
0
    def test_generate_uuidmapping(self):
        """Test generate_uuidmapping method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        foam_mesh.generate_uuidmapping(8, 0, 6, 1)
Exemplo n.º 3
0
    def test_has_cells(self):
        """Test _has_cells method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        self.assertTrue(foam_mesh.has_type(CUBA.CELL))
Exemplo n.º 4
0
    def test_has_faces(self):
        """Test _has_faces method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        self.assertTrue(foam_mesh.has_type(CUBA.FACE))
Exemplo n.º 5
0
    def test_has_cells(self):
        """Test _has_cells method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        self.assertTrue(foam_mesh.has_type(CUBA.CELL))
Exemplo n.º 6
0
    def test_has_faces(self):
        """Test _has_faces method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        self.assertTrue(foam_mesh.has_type(CUBA.FACE))
Exemplo n.º 7
0
    def test_iter_edges(self):
        """Test _iter_edges method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        self.assertEqual(foam_mesh.iter(item_type=CUBA.EDGE), [])
Exemplo n.º 8
0
    def test_generate_uuidmapping(self):
        """Test generate_uuidmapping method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        foam_mesh.generate_uuidmapping(8, 0, 6, 1)
Exemplo n.º 9
0
    def test_update_cells(self):
        """Test _update_cells method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        label = 0
        cuid = foam_mesh._foamCellLabelToUuid[label]
        cell_f = foam_mesh.get(cuid)
        self.assertIsInstance(cell_f.data, DataContainer)
        cell = list(self.mesh.iter(item_type=CUBA.CELL))[label]
        self.assertEqual(cell.data, cell_f.data)

        updated_cells = []
        for cell in foam_mesh.iter(item_type=CUBA.CELL):
            cell.data[CUBA.VELOCITY] = [2, 1, 3]
            updated_cells.append(cell)
        foam_mesh.update(updated_cells)

        label = 0
        cuid = foam_mesh._foamCellLabelToUuid[label]
        cell_f = foam_mesh.get(cuid)
        self.assertIsInstance(cell_f.data, DataContainer)
        cell = list(self.mesh.iter(item_type=CUBA.CELL))[label]
        self.assertNotEqual(cell.data, cell_f.data)

        updated_cells = []
        for cell in foam_mesh.iter(item_type=CUBA.CELL):
            cell.points = [
                self.points[1].uid, self.points[2].uid, self.points[3].uid
            ]
            updated_cells.append(cell)
        with self.assertRaises(Warning):
            foam_mesh.update(updated_cells)
Exemplo n.º 10
0
    def test_iter_faces(self):
        """Test _iter_faces method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        for face_f in foam_mesh.iter(item_type=CUBA.FACE):
            self.assertEqual(len(face_f.points), 4)
Exemplo n.º 11
0
    def test_update_faces(self):
        """Test _update_faces method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        with self.assertRaises(NotImplementedError):
            foam_mesh.update(self.faces)
Exemplo n.º 12
0
    def test_add_cells(self):
        """Test _add_cells method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        with self.assertRaises(NotImplementedError):
            foam_mesh.add(self.cells)
Exemplo n.º 13
0
    def test_get_edge(self):
        """Test _get_edge method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        with self.assertRaises(KeyError):
            foam_mesh.get(self.edges[0].uid)
Exemplo n.º 14
0
    def test_get_edge(self):
        """Test _get_edge method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        with self.assertRaises(KeyError):
            foam_mesh.get(self.edges[0].uid)
Exemplo n.º 15
0
    def test_iter_faces(self):
        """Test _iter_faces method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        for face_f in foam_mesh.iter(item_type=CUBA.FACE):
            self.assertEqual(len(face_f.points), 4)
Exemplo n.º 16
0
    def test_update_faces(self):
        """Test _update_faces method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        with self.assertRaises(NotImplementedError):
            foam_mesh.update(self.faces)
Exemplo n.º 17
0
    def test_add_cells(self):
        """Test _add_cells method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        with self.assertRaises(NotImplementedError):
            foam_mesh.add(self.cells)
Exemplo n.º 18
0
    def test_update_cells(self):
        """Test _update_cells method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        label = 0
        cuid = foam_mesh._foamCellLabelToUuid[label]
        cell_f = foam_mesh.get(cuid)
        self.assertIsInstance(cell_f.data, DataContainer)
        cell = list(self.mesh.iter(item_type=CUBA.CELL))[label]
        self.assertEqual(cell.data, cell_f.data)

        updated_cells = []
        for cell in foam_mesh.iter(item_type=CUBA.CELL):
            cell.data[CUBA.VELOCITY] = [2, 1, 3]
            updated_cells.append(cell)
        foam_mesh.update(updated_cells)

        label = 0
        cuid = foam_mesh._foamCellLabelToUuid[label]
        cell_f = foam_mesh.get(cuid)
        self.assertIsInstance(cell_f.data, DataContainer)
        cell = list(self.mesh.iter(item_type=CUBA.CELL))[label]
        self.assertNotEqual(cell.data, cell_f.data)

        updated_cells = []
        for cell in foam_mesh.iter(item_type=CUBA.CELL):
            cell.points = [self.points[1].uid, self.points[2].uid,
                           self.points[3].uid]
            updated_cells.append(cell)
        with self.assertRaises(Warning):
            foam_mesh.update(updated_cells)
Exemplo n.º 19
0
    def test_iter_cells(self):
        """Test _iter_cells method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        for cell_f in foam_mesh.iter(item_type=CUBA.CELL):
            label = foam_mesh._uuidToFoamLabelAndType[cell_f.uid][0]
            cell = self.cells[label]
            self.assertEqual(cell.data[CUBA.VELOCITY],
                             cell_f.data[CUBA.VELOCITY])
Exemplo n.º 20
0
    def test_iter_cells(self):
        """Test _iter_cells method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        for cell_f in foam_mesh.iter(item_type=CUBA.CELL):
            label = foam_mesh._uuidToFoamLabelAndType[cell_f.uid][0]
            cell = self.cells[label]
            self.assertEqual(cell.data[CUBA.VELOCITY],
                             cell_f.data[CUBA.VELOCITY])
Exemplo n.º 21
0
    def test_get_point(self):
        """Test _get_point method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        label = 0
        for point in self.mesh.iter(item_type=CUBA.POINT):
            puid = foam_mesh._foamPointLabelToUuid[label]
            point_f = foam_mesh.get(puid)
            self.assertEqual(point.coordinates, point_f.coordinates)
            label += 1
Exemplo n.º 22
0
    def test_get_point(self):
        """Test _get_point method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        label = 0
        for point in self.mesh.iter(item_type=CUBA.POINT):
            puid = foam_mesh._foamPointLabelToUuid[label]
            point_f = foam_mesh.get(puid)
            self.assertEqual(point.coordinates, point_f.coordinates)
            label += 1
Exemplo n.º 23
0
    def test_write(self):
        """Test write method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        foam_mesh.write()
        meshpath = os.path.join(foam_mesh.path, 'constant', 'polyMesh')
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'points')))
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'owner')))
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'neighbour')))
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'boundary')))
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'faces')))
Exemplo n.º 24
0
    def test_write(self):
        """Test write method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        foam_mesh.write()
        meshpath = os.path.join(foam_mesh.path, 'constant', 'polyMesh')
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'points')))
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'owner')))
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'neighbour')))
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'boundary')))
        self.assertTrue(os.path.exists(os.path.join(meshpath, 'faces')))
Exemplo n.º 25
0
    def test_get_cell(self):
        """Test get_cell method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        label = 0
        for cell in self.mesh.iter(item_type=CUBA.CELL):
            cuid = foam_mesh._foamCellLabelToUuid[label]
            cell_f = foam_mesh.get(cuid)
            self.assertEqual(cell.data[CUBA.PRESSURE],
                             cell_f.data[CUBA.PRESSURE])
            self.assertEqual(cell.data[CUBA.VELOCITY],
                             cell_f.data[CUBA.VELOCITY])
            label += 1
Exemplo n.º 26
0
    def test_get_cell(self):
        """Test get_cell method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)
        label = 0
        for cell in self.mesh.iter(item_type=CUBA.CELL):
            cuid = foam_mesh._foamCellLabelToUuid[label]
            cell_f = foam_mesh.get(cuid)
            self.assertEqual(cell.data[CUBA.PRESSURE],
                             cell_f.data[CUBA.PRESSURE])
            self.assertEqual(cell.data[CUBA.VELOCITY],
                             cell_f.data[CUBA.VELOCITY])
            label += 1
Exemplo n.º 27
0
    def test_count_of(self):
        """Test count_of method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)

        item_type = CUBA.POINT
        self.assertEqual(foam_mesh.count_of(item_type),
                         self.mesh.count_of(item_type))

        item_type = CUBA.EDGE
        self.assertEqual(foam_mesh.count_of(item_type),
                         self.mesh.count_of(item_type))

        item_type = CUBA.FACE
        self.assertEqual(foam_mesh.count_of(item_type),
                         self.mesh.count_of(item_type))

        item_type = CUBA.CELL
        self.assertEqual(foam_mesh.count_of(item_type),
                         self.mesh.count_of(item_type))
Exemplo n.º 28
0
    def test_count_of(self):
        """Test count_of method

        """

        foam_mesh = FoamMesh('test_mesh', {}, self.solver, self.mesh)

        item_type = CUBA.POINT
        self.assertEqual(foam_mesh.count_of(item_type),
                         self.mesh.count_of(item_type))

        item_type = CUBA.EDGE
        self.assertEqual(foam_mesh.count_of(item_type),
                         self.mesh.count_of(item_type))

        item_type = CUBA.FACE
        self.assertEqual(foam_mesh.count_of(item_type),
                         self.mesh.count_of(item_type))

        item_type = CUBA.CELL
        self.assertEqual(foam_mesh.count_of(item_type),
                         self.mesh.count_of(item_type))