Example #1
0
def test_vtk_structured_grid():
    angle_mesh = np.mgrid[1:2:10j, 0:2 * np.pi:20j, 0:np.pi:30j]

    r = angle_mesh[0, np.newaxis]
    phi = angle_mesh[1, np.newaxis]
    theta = angle_mesh[2, np.newaxis]
    mesh = np.vstack((
        r * np.sin(theta) * np.cos(phi),
        r * np.sin(theta) * np.sin(phi),
        r * np.cos(theta),
    ))

    from pytools.obj_array import make_obj_array
    vec = make_obj_array([
        np.sin(theta) * np.cos(phi),
        np.sin(theta) * np.sin(phi),
        np.cos(theta),
    ])

    write_structured_grid("yo.vts",
                          mesh,
                          point_data=[("phi", phi), ("vec", vec)])
# contributed by Luke Olson

from __future__ import absolute_import
import numpy as np

n = 50
x, y = np.meshgrid(np.linspace(-1, 1, n), np.linspace(-1, 1, n))

u = np.exp(-50 * (x**2 + y**2))

from pyvisfile.vtk import write_structured_grid
mesh = np.rollaxis(np.dstack((x, y)), 2)
write_structured_grid('test.vts',
                      mesh,
                      point_data=[('u', u[np.newaxis, :, :])])
Example #3
0
 def write_vtk_file(self, file_name, data, real_only=False):
     from pyvisfile.vtk import write_structured_grid
     write_structured_grid(file_name,
                           self.nd_points,
                           point_data=list(
                               separate_by_real_and_imag(data, real_only)))
# contributed by Luke Olson

import numpy as np

n = 50
x, y = np.meshgrid(np.linspace(-1, 1, n),
np.linspace(-1, 1, n))

u = np.exp(-50 * (x**2 + y**2))

from pyvisfile.vtk import write_structured_grid
mesh = np.rollaxis(np.dstack((x, y)), 2)
write_structured_grid('test.vts', mesh,
        point_data=[('u', u[np.newaxis, :, :])])
Example #5
0
from __future__ import absolute_import
from pyvisfile.vtk import write_structured_grid

import numpy as np

angle_mesh = np.mgrid[1:2:10j, 0:2 * np.pi:20j, 0:np.pi:30j]

r = angle_mesh[0, np.newaxis]
phi = angle_mesh[1, np.newaxis]
theta = angle_mesh[2, np.newaxis]
mesh = np.vstack((
    r * np.sin(theta) * np.cos(phi),
    r * np.sin(theta) * np.sin(phi),
    r * np.cos(theta),
))

from pytools.obj_array import make_obj_array

vec = make_obj_array([
    np.sin(theta) * np.cos(phi),
    np.sin(theta) * np.sin(phi),
    np.cos(theta),
])

write_structured_grid("yo.vts", mesh, point_data=[("phi", phi), ("vec", vec)])
from __future__ import absolute_import
from pyvisfile.vtk import write_structured_grid

import numpy as np

angle_mesh = np.mgrid[1:2:10j, 0:2*np.pi:20j]

r = angle_mesh[0, np.newaxis]
phi = angle_mesh[1, np.newaxis]
mesh = np.vstack((
    r*np.cos(phi),
    r*np.sin(phi),
    ))

from pytools.obj_array import make_obj_array
vec = make_obj_array([
    np.cos(phi),
    np.sin(phi),
    ])

write_structured_grid("yo-2d.vts", mesh,
        point_data=[("phi", phi), ("vec", vec)])
Example #7
0
 def write_vtk_file(self, file_name, data, real_only=False):
     from pyvisfile.vtk import write_structured_grid
     write_structured_grid(file_name, self.nd_points,
             point_data=list(separate_by_real_and_imag(data, real_only)))
Example #8
0
# contributed by Luke Olson

import numpy as np

n = 50
x, y = np.meshgrid(np.linspace(-1, 1, n),
np.linspace(-1, 1, n))

u = np.exp(-50 * (x**2 + y**2))

from pyvisfile.vtk import write_structured_grid
mesh = np.rollaxis(np.dstack((x, y)), 2)
write_structured_grid("test.vts", mesh,
        point_data=[("u", u[np.newaxis, :, :])])