Working on geometry views for subgrids

这个提交包含在:
Craig Warren
2022-11-09 18:14:35 +00:00
父节点 929403f111
当前提交 4e2079db59
共有 2 个文件被更改,包括 14 次插入32 次删除

查看文件

@@ -1439,15 +1439,12 @@ class GeometryView(UserObjectMulti):
self.hash = '#geometry_view'
def geometry_view_constructor(self, grid, output_type):
"""Selects appropriate class for geometry view dependent on grid type
and geometry view type, i.e. normal or fine.
"""Selects appropriate class for geometry view dependent on geometry
view type, i.e. normal or fine.
"""
if output_type == 'n':
if isinstance(grid, SubGridBaseGrid):
from .geometry_outputs import GeometryViewSubgridVoxels as GeometryViewUser
else:
from .geometry_outputs import GeometryViewVoxels as GeometryViewUser
from .geometry_outputs import GeometryViewVoxels as GeometryViewUser
else:
from .geometry_outputs import GeometryViewLines as GeometryViewUser

查看文件

@@ -38,6 +38,7 @@ import gprMax.config as config
from ._version import __version__
from .cython.geometry_outputs import write_lines
from .subgrids.grid import SubGridBaseGrid
from .utilities.utilities import (get_terminal_width,
numeric_list_to_float_list,
numeric_list_to_int_list)
@@ -239,11 +240,18 @@ class GeometryViewVoxels(GeometryView):
vtk_data: dict of data and comments for VTK file.
"""
if isinstance(self.grid, SubGridBaseGrid):
origin = ((self.grid.i0 * self.grid.dx * self.grid.ratio),
(self.grid.j0 * self.grid.dy * self.grid.ratio),
(self.grid.k0 * self.grid.dz * self.grid.ratio))
else:
origin = ((self.xs * self.grid.dx),
(self.ys * self.grid.dy),
(self.zs * self.grid.dz))
# Write the VTK file .vti
imageToVTK(str(self.filename),
origin=((self.xs * self.grid.dx),
(self.ys * self.grid.dy),
(self.zs * self.grid.dz)),
origin=origin,
spacing=((self.dx * self.grid.dx),
(self.dy * self.grid.dy),
(self.dz * self.grid.dz)),
@@ -251,29 +259,6 @@ class GeometryViewVoxels(GeometryView):
comments=[vtk_data['comments']])
class GeometryViewSubgridVoxels(GeometryViewVoxels):
"""Imagedata (.vti) for a per-cell geometry view for sub-grids."""
def __init__(self, *args):
# For sub-grid we are only going to export the entire grid. temporary fix.
xs, ys, zs, xf, yf, zf, dx, dy, dz, filename, grid = args
xs, ys, zs = 0, 0, 0
xf, yf, zf = grid.nx, grid.ny, grid.nz
dx, dy, dz = 1, 1, 1
args = xs, ys, zs, xf, yf, zf, dx, dy, dz, filename, grid
super().__init__(*args)
"""
def get_coordinates(self, solid):
# (length is number of vertices in each direction) * (size of each block [m]) + (starting offset) + grid offset
x = np.arange(
0, solid.shape[0] + 1) * (self.grid.dx * self.dx) + ((self.xs - self.grid.n_boundary_cells_x) * self.grid.dx)# + self.grid.x1
y = np.arange(
0, solid.shape[1] + 1) * (self.grid.dy * self.dy) + ((self.ys - self.grid.n_boundary_cells_y) * self.grid.dy)# + self.grid.y1
z = np.arange(
0, solid.shape[2] + 1) * (self.grid.dz * self.dz) + ((self.zs - self.grid.n_boundary_cells_z) * self.grid.dz)# + self.grid.z1
return x, y, z
"""
class Comments():
"""Comments can be strings included in the header of XML VTK file, and are
used to hold extra (gprMax) information about the VTK data.