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)
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)
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)
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
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