你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-07 23:14:03 +08:00
removed commented code
这个提交包含在:
@@ -4,6 +4,7 @@ from lxml import etree
|
|||||||
from gprMax.grid import Grid
|
from gprMax.grid import Grid
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
|
|
||||||
class Edges:
|
class Edges:
|
||||||
|
|
||||||
def __init__(self, grid):
|
def __init__(self, grid):
|
||||||
@@ -25,6 +26,7 @@ class Edges:
|
|||||||
self.edges[self.edge_count] = np.array([in_label, out_label])
|
self.edges[self.edge_count] = np.array([in_label, out_label])
|
||||||
self.edge_count += 1
|
self.edge_count += 1
|
||||||
|
|
||||||
|
|
||||||
class Coordinates:
|
class Coordinates:
|
||||||
|
|
||||||
def __init__(self, grid):
|
def __init__(self, grid):
|
||||||
@@ -36,6 +38,7 @@ class Coordinates:
|
|||||||
self.coordinates[self.coordinate_count] = np.array([x, y, z])
|
self.coordinates[self.coordinate_count] = np.array([x, y, z])
|
||||||
self.coordinate_count += 1
|
self.coordinate_count += 1
|
||||||
|
|
||||||
|
|
||||||
def hexCellPicker(grid, i, j, k):
|
def hexCellPicker(grid, i, j, k):
|
||||||
"""
|
"""
|
||||||
This is the ordering of nodes in the hexahedron cell.
|
This is the ordering of nodes in the hexahedron cell.
|
||||||
@@ -70,6 +73,7 @@ def hexCellPicker(grid, i, j, k):
|
|||||||
|
|
||||||
return cell
|
return cell
|
||||||
|
|
||||||
|
|
||||||
class Solids:
|
class Solids:
|
||||||
|
|
||||||
def __init__(self, fdtd_grid):
|
def __init__(self, fdtd_grid):
|
||||||
@@ -83,6 +87,7 @@ class Solids:
|
|||||||
self.solids[self.count] = self.fdtd_grid.solid[i][j][k]
|
self.solids[self.count] = self.fdtd_grid.solid[i][j][k]
|
||||||
self.count += 1
|
self.count += 1
|
||||||
|
|
||||||
|
|
||||||
class SolidLabels():
|
class SolidLabels():
|
||||||
|
|
||||||
def __init__(self, label_grid):
|
def __init__(self, label_grid):
|
||||||
@@ -114,6 +119,7 @@ class Materials:
|
|||||||
|
|
||||||
self.material_count += 1
|
self.material_count += 1
|
||||||
|
|
||||||
|
|
||||||
def process_grid(fdtd_grid):
|
def process_grid(fdtd_grid):
|
||||||
|
|
||||||
# Dimensions of the problem domain.
|
# Dimensions of the problem domain.
|
||||||
@@ -213,21 +219,15 @@ def process_grid(fdtd_grid):
|
|||||||
# Add the coordinates
|
# Add the coordinates
|
||||||
coordinates.add_coordinate(i, j, k)
|
coordinates.add_coordinate(i, j, k)
|
||||||
|
|
||||||
#x = np.arange(fdtd_grid.nx)
|
|
||||||
#y = np.arange(fdtd_grid.ny)
|
|
||||||
#z = np.arange(fdtd_grid.nz)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'coordinates': coordinates,
|
'coordinates': coordinates,
|
||||||
'solids': solids,
|
'solids': solids,
|
||||||
'solid_labels': solid_labels,
|
'solid_labels': solid_labels,
|
||||||
'edges': edges,
|
'edges': edges,
|
||||||
'edge_materials': edge_materials,
|
'edge_materials': edge_materials,
|
||||||
#'x': x,
|
|
||||||
#'y': y,
|
|
||||||
#'z': z
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def write_output_file(filename, grid):
|
def write_output_file(filename, grid):
|
||||||
|
|
||||||
data = process_grid(grid)
|
data = process_grid(grid)
|
||||||
@@ -237,11 +237,13 @@ def write_output_file(filename, grid):
|
|||||||
write_H5file(data)
|
write_H5file(data)
|
||||||
write_xml_doc(data)
|
write_xml_doc(data)
|
||||||
|
|
||||||
|
|
||||||
def write_xml_doc(options):
|
def write_xml_doc(options):
|
||||||
#write xml to file
|
#write xml to file
|
||||||
with open(options['filename'] + '.xdmf', 'wb') as xdmf_f:
|
with open(options['filename'] + '.xdmf', 'wb') as xdmf_f:
|
||||||
xdmf_f.write(options['xml_doc'])
|
xdmf_f.write(options['xml_doc'])
|
||||||
|
|
||||||
|
|
||||||
def write_H5file(options):
|
def write_H5file(options):
|
||||||
|
|
||||||
f = h5py.File(options['filename'] + '.h5', "w")
|
f = h5py.File(options['filename'] + '.h5', "w")
|
||||||
@@ -249,13 +251,11 @@ def write_H5file(options):
|
|||||||
coords.create_dataset('coordinates', data=options['coordinates'].coordinates)
|
coords.create_dataset('coordinates', data=options['coordinates'].coordinates)
|
||||||
coords.create_dataset('connectivity', data=options['edges'].edges)
|
coords.create_dataset('connectivity', data=options['edges'].edges)
|
||||||
coords.create_dataset('solid_connectivity', data=options['solid_labels'].solid_labels)
|
coords.create_dataset('solid_connectivity', data=options['solid_labels'].solid_labels)
|
||||||
#coords.create_dataset('x', data=options['x'])
|
|
||||||
#coords.create_dataset('y', data=options['y'])
|
|
||||||
#coords.create_dataset('z', data=options['z'])
|
|
||||||
data = f.create_group("data")
|
data = f.create_group("data")
|
||||||
data.create_dataset('materials', data=options['edge_materials'].materials)
|
data.create_dataset('materials', data=options['edge_materials'].materials)
|
||||||
data.create_dataset('solids', data=options['solids'].solids)
|
data.create_dataset('solids', data=options['solids'].solids)
|
||||||
|
|
||||||
|
|
||||||
def create_xdmf_markup(options):
|
def create_xdmf_markup(options):
|
||||||
|
|
||||||
# Write the XDMF markup for edge style grid
|
# Write the XDMF markup for edge style grid
|
||||||
@@ -295,39 +295,6 @@ def create_xdmf_markup(options):
|
|||||||
materials_el.text = "{}:/data/materials".format(options['filename'] + '.h5')
|
materials_el.text = "{}:/data/materials".format(options['filename'] + '.h5')
|
||||||
attr_el.append(materials_el)
|
attr_el.append(materials_el)
|
||||||
|
|
||||||
"""
|
|
||||||
# VOXEL style markup
|
|
||||||
v_grid_el = etree.Element("Grid", Name="Voxel", GridType="Uniform")
|
|
||||||
domain_el.append(v_grid_el)
|
|
||||||
|
|
||||||
noe = "{} {} {}".format(options['x'].size, options['y'].size, options['y'].size)
|
|
||||||
v_topology_el = etree.Element("Topology", TopologyType="3DRectMesh", NumberOfElements=noe)
|
|
||||||
v_grid_el.append(v_topology_el)
|
|
||||||
|
|
||||||
v_geometry = etree.Element("Geometry", GeometryType="VXVYVZ")
|
|
||||||
v_grid_el.append(v_geometry)
|
|
||||||
|
|
||||||
d1 = etree.Element("DataItem", Dimensions=str(options['x'].size), NumberType="Float", Precision="4", Format="HDF")
|
|
||||||
d1.text = "{}:/mesh/x".format(options['filename'] + '.h5')
|
|
||||||
v_geometry.append(d1)
|
|
||||||
|
|
||||||
d2 = etree.Element("DataItem", Dimensions=str(options['y'].size), NumberType="Float", Precision="4", Format="HDF")
|
|
||||||
d2.text = "{}:/mesh/y".format(options['filename'] + '.h5')
|
|
||||||
v_geometry.append(d2)
|
|
||||||
|
|
||||||
d3 = etree.Element("DataItem", Dimensions=str(options['z'].size), NumberType="Float", Precision="4", Format="HDF")
|
|
||||||
d3.text = "{}:/mesh/z".format(options['filename'] + '.h5')
|
|
||||||
v_geometry.append(d3)
|
|
||||||
|
|
||||||
v_attr = etree.Element("Attribute", Name="material-blocks", Center="Cell")
|
|
||||||
v_grid_el.append(v_attr)
|
|
||||||
|
|
||||||
d4 = etree.Element("DataItem", Format="HDF", NumberType="Float", Precision="4", Dimensions=str(options['solids'].solids.size))
|
|
||||||
d4.text = "{}:/data/solids".format(options['filename'] + '.h5')
|
|
||||||
v_attr.append(d4)
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
v_grid_el = etree.Element("Grid", Name="Voxel", GridType="Uniform")
|
v_grid_el = etree.Element("Grid", Name="Voxel", GridType="Uniform")
|
||||||
domain_el.append(v_grid_el)
|
domain_el.append(v_grid_el)
|
||||||
|
|
||||||
@@ -358,4 +325,3 @@ def create_xdmf_markup(options):
|
|||||||
encoding="utf-8", doctype=doc_type, pretty_print=True)
|
encoding="utf-8", doctype=doc_type, pretty_print=True)
|
||||||
|
|
||||||
return xml_doc
|
return xml_doc
|
||||||
|
|
||||||
|
在新工单中引用
屏蔽一个用户