Exemplo n.º 1
0
def test_multi_mesh():
    coordsMulti = np.array([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]],
                           dtype=np.float64)

    connect1 = np.array([
        [0, 1, 3],
    ], dtype=np.int64)
    connect2 = np.array([
        [1, 2, 3],
    ], dtype=np.int64)

    data1 = {}
    data2 = {}
    data1["connect1", "test"] = np.array([
        [0.0, 1.0, 3.0],
    ], dtype=np.float64)
    data2["connect2", "test"] = np.array([
        [1.0, 2.0, 3.0],
    ], dtype=np.float64)

    connectList = [connect1, connect2]
    dataList = [data1, data2]

    ds = load_unstructured_mesh(connectList, coordsMulti, dataList)

    sl = SlicePlot(ds, "z", ("connect1", "test"))
    assert sl.data_source.field_data["connect1", "test"].shape == (1, 3)
    sl = SlicePlot(ds, "z", ("connect2", "test"))
    assert sl.data_source.field_data["connect2", "test"].shape == (1, 3)
    sl = SlicePlot(ds, "z", ("all", "test"))
    assert sl.data_source.field_data["all", "test"].shape == (2, 3)
    sl.annotate_mesh_lines()
Exemplo n.º 2
0
def test_multi_mesh():
    coordsMulti = np.array([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]],
                           dtype=np.float64)

    connect1 = np.array([
        [0, 1, 3],
    ], dtype=np.int64)
    connect2 = np.array([
        [1, 2, 3],
    ], dtype=np.int64)

    data1 = {}
    data2 = {}
    data1['connect1', 'test'] = np.array([
        [0.0, 1.0, 3.0],
    ], dtype=np.float64)
    data2['connect2', 'test'] = np.array([
        [1.0, 2.0, 3.0],
    ], dtype=np.float64)

    connectList = [connect1, connect2]
    dataList = [data1, data2]

    ds = load_unstructured_mesh(connectList, coordsMulti, dataList)

    sl = SlicePlot(ds, 'z', ('connect1', 'test'))
    sl = SlicePlot(ds, 'z', ('connect2', 'test'))
    sl = SlicePlot(ds, 'z', ('all', 'test'))
    sl.annotate_mesh_lines()
Exemplo n.º 3
0
def test_multi_field():
    coords = np.array([[0.0, 0.0], [1.0, 0.0], [1.0, 1.0], [0.0, 1.0]],
                      dtype=np.float64)

    connect = np.array([[0, 1, 3], [1, 2, 3]], dtype=np.int64)

    data = {}
    data["connect1", "test"] = np.array([[0.0, 1.0, 3.0], [1.0, 2.0, 3.0]],
                                        dtype=np.float64)
    data["connect1",
         "testAgain"] = np.array([[0.0, 1.0, 3.0], [1.0, 2.0, 3.0]],
                                 dtype=np.float64)

    ds = load_unstructured_mesh(connect, coords, data)

    sl = SlicePlot(ds, "z", "test")
    sl.annotate_mesh_lines()

    sl = SlicePlot(ds, "z", "testAgain")
    sl.annotate_mesh_lines()
Exemplo n.º 4
0
# y = np.array(y)
# z = np.array(z)
# cvar =np.sqrt(x**2+y**2+z**2)

ax.scatter(x, y, z, c=cvar, marker='.')
ax.set_xlim([min(x), 0])
ax.set_ylim([min(y), 0])
ax.set_zlim([max(z), 0])
plt.show()

# https://yt-project.org/doc/examining/loading_data.html#unstructured-grid-data
# model.unstructured['data']['connect1', 'dvs']=np.float64(model.unstructured['data']['connect1', 'dvs'])
# model.unstructured['cnnct']=np.float64(model.unstructured['cnnct'])

ds = yt.load_unstructured_mesh(model.unstructured['cnnct'],
                               model.unstructured['vertices'],
                               node_data=model.unstructured['data'])

sc = yt.create_scene(ds, ('connect1', 'depth'))
# # override the default colormap
# ms = sc.get_source()
# ms.cmap = 'Eos A'
#
# # adjust the camera position and orientation
# cam = sc.camera
# cam.focus = ds.arr([0.0, 0.0, 0.0], 'code_length')
# cam_pos = ds.arr([-3.0, 3.0, -3.0], 'code_length')
# north_vector = ds.arr([0.0, -1.0, -1.0], 'dimensionless')
# cam.set_position(cam_pos, north_vector)
#
# # increase the default resolution