@author: CHEN Yongxin
@organization: University of Southampton
@contact: [email protected]
"""

from writeParaview.legacy_structured import vts
from grid.MakeGrid import MakeGrid
import numpy as np
import os

# make output folder
if not os.path.isdir("output"): os.mkdir("output")

# 2D grid
x, y = MakeGrid()
SliceShape = x.shape

# 3rd dimension
nz = 20
dz = .25

# convert 2D to 3D: extrude a slice in 3rd direction
x = np.stack([x for _ in range(nz)], axis=-1)
y = np.stack([y for _ in range(nz)], axis=-1)
z = np.stack([np.zeros(SliceShape) + i * dz for i in range(nz)], axis=-1)
# make scalar field p, 2-component field, 3-component field
p = np.zeros((1, ) + x.shape)
v2 = np.zeros((2, ) + x.shape)
v3 = np.zeros((3, ) + x.shape)
@author: CHEN Yongxin
@organization: University of Southampton
@contact: [email protected]
"""

from writeParaview.xml_unstructured import vtu
from grid.MakeGrid import MakeGrid
import numpy as np
import os

# make output folder
if not os.path.isdir("output"): os.mkdir("output")

# get 2D grid
x, y = MakeGrid()
# get dimension info
nx, ny = x.shape

# make grid: convert structured grid to unstructured grid
xyz = np.zeros((x.size, 3))
xflat = x.flatten(order='F')
yflat = y.flatten(order='F')
xyz[:, 0] = xflat
xyz[:, 1] = yflat

# make cell connectivity array, 4-point cell
cells = np.zeros(((nx - 1) * (ny - 1), 1 + 4), dtype=int)
cells[:, 0] = 4
for j in range(ny - 1):
    for i in range(nx - 1):
예제 #3
0
@author: CHEN Yongxin
@organization: University of Southampton
@contact: [email protected]
"""

from writeParaview.xml_structured import vts
from grid.MakeGrid import MakeGrid
import numpy as np
import os

# make output folder
if not os.path.isdir("output"): os.mkdir("output")

# 2D grid
x, y = MakeGrid()

# convert 2D to 3D
x = x.reshape(x.shape + (1, ))
y = y.reshape(y.shape + (1, ))
z = np.zeros_like(x)

# make scalar field p, 2-component field, 3-component field
p = np.zeros((1, ) + x.shape)
v2 = np.zeros((2, ) + x.shape)
v3 = np.zeros((3, ) + x.shape)

for j in range(p.shape[2]):
    p[:, :, j, :] = j

for i in range(v3.shape[1]):
relativeDir = "data/"  # relative path from .pvts to .vts
pvtsName = pvtsDir + "Parallel_XML_structured"
pieceName = "Seial_XML_structured_Piece"
vtsName = vtsDir + pieceName
relativePath = relativeDir + pieceName

# make output folder
if master:
    if not os.path.isdir(pvtsDir): os.mkdir(pvtsDir)
    if not os.path.isdir(vtsDir): os.mkdir(vtsDir)

# Make global grid
# 2D grid
nx = 120
ny = 60
x, y = MakeGrid(nx + 1, ny + 1)

# 3rd dimension
nz = 20
dz = .25

# extrude
x = np.stack([x for _ in range(nz + 1)], axis=-1)
y = np.stack([y for _ in range(nz + 1)], axis=-1)
z = np.stack([np.zeros((nx + 1, ny + 1)) + i * dz for i in range(nz + 1)],
             axis=-1)

# global quantities
nprocs = [size, 1, 1]  # number of processors in 3 dimensions
wise = np.array([1, nx + 1]) - 1  # WholeExtent, with 0 start
wjse = np.array([1, ny + 1]) - 1
예제 #5
0
relativeDir = "data/"  # relative path from .pvts to .vts
pvtuName = pvtuDir + "Parallel_XML_unstructured"
pieceName = "Seial_XML_unstructured_Piece"
vtuName = vtuDir + pieceName
relativePath = relativeDir + pieceName

# make output folder
if master:
    if not os.path.isdir(pvtuDir): os.mkdir(pvtuDir)
    if not os.path.isdir(vtuDir): os.mkdir(vtuDir)

# Make global grid
# 2D grid
nx = 120 + 1
ny = 60 + 1
x, y = MakeGrid(nx, ny)

# 3rd dimension
nz = 20 + 1
dz = .25

# extrude
x = np.stack([x for _ in range(nz)], axis=-1)
y = np.stack([y for _ in range(nz)], axis=-1)
z = np.stack([np.zeros((nx, ny)) + i * dz for i in range(nz)], axis=-1)

# number of cells in partition
pcx = (nx - 1) // size
pcy = ny - 1
pcz = nz - 1