Ejemplo n.º 1
0
def test_load_grid():
    gr = Grid()
    filename = str(DATA_DIR / Path('test_create_grid.vtk'))
    gr.load(filename)
    ncells = gr.getNumberOfCells()
    print(f'ncells = {ncells}')
    assert (ncells == 2)
    num_bad_cells = gr.check()
    assert (num_bad_cells == 0)
    points = gr.getPoints()
    assert (points.shape[0] == ncells)
    assert (points.shape[1] == 4)
    assert (points.shape[2] == 3)
Ejemplo n.º 2
0
def test_create_grid():
    # create the grid
    gr = Grid()
    # 2 cells
    points = numpy.array([(0., 0., 0.), (1., 0., 0.), (1., 1., 0.),
                          (0., 1., 0.), (1., 0., 0.), (2., 0., 0.),
                          (2., 1., 0.), (1., 1., 0.)]).reshape((2, 4, 3))
    gr.setPoints(points)

    # get a pointer to the points of the cell-by-cell mesh
    pts = gr.getPoints()
    print(pts)

    with TemporaryDirectory() as d:
        fname = str(Path(d) / Path('grid.vtk'))
        gr.dump(fname)