def test_evaluate_gradient(): grid = StructuredGrid() grid.update_property('Y', grid.nodes[:, 1]) vector = np.mean(grid.evaluate_gradient(grid.barycentre(), 'Y'), axis=0) # vector/=np.linalg.norm(vector) assert np.sum(vector - np.array([0, grid.step_vector[1], 0])) == 0
def test_get_element(): grid = StructuredGrid() point = grid.barycentre()[[0], :] idc, inside = grid.position_to_cell_corners(point) bary = np.mean(grid.nodes[idc, :], axis=0) assert np.sum(point - bary) == 0
def test_evaluate_value(): grid = StructuredGrid() grid.update_property('X', grid.nodes[:, 0]) assert np.sum(grid.barycentre()[:, 0] - grid.evaluate_value(grid.barycentre(), 'X')) == 0