diff --git a/gprMax/geometry_views.py b/gprMax/geometry_views.py index eade70b9..3f46237e 100644 --- a/gprMax/geometry_views.py +++ b/gprMax/geometry_views.py @@ -86,14 +86,18 @@ class GeometryView: self.vtk_nycells = self.vtk_yfcells - self.vtk_yscells self.vtk_nzcells = self.vtk_zfcells - self.vtk_zscells - # Create an array and add numeric IDs for PML, sources and receivers - self.srcs_rxs_pml = np.zeros((G.nx + 1, G.ny + 1, G.nz + 1), dtype=np.int8) + # Create arrays and add numeric IDs for PML, sources and receivers (0 is not set, 1 is PML, srcs and rxs numbered thereafter) + self.srcs_pml = np.zeros((G.nx + 1, G.ny + 1, G.nz + 1), dtype=np.int8) + self.rxs = np.zeros((G.nx + 1, G.ny + 1, G.nz + 1), dtype=np.int8) for pml in G.pmls: - self.srcs_rxs_pml[pml.xs:pml.xf, pml.ys:pml.yf, pml.zs:pml.zf] = 1 - for index, srcrx in enumerate(G.rxs + G.hertziandipoles + G.magneticdipoles + G.voltagesources + G.transmissionlines): - self.srcs_rxs_pml[srcrx.xcoord, srcrx.ycoord, srcrx.zcoord] = index + 2 + self.srcs_pml[pml.xs:pml.xf, pml.ys:pml.yf, pml.zs:pml.zf] = 1 + for index, src in enumerate(G.hertziandipoles + G.magneticdipoles + G.voltagesources + G.transmissionlines): + self.srcs_pml[src.xcoord, src.ycoord, src.zcoord] = index + 2 + for index, rx in enumerate(G.rxs): + self.rxs[rx.xcoord, rx.ycoord, rx.zcoord] = index + 1 - vtk_srcs_rxs_pml_offset = round_value((np.dtype(np.uint32).itemsize * self.vtk_nxcells * self.vtk_nycells * self.vtk_nzcells) + np.dtype(np.uint32).itemsize) + vtk_srcs_pml_offset = round_value((np.dtype(np.uint32).itemsize * self.vtk_nxcells * self.vtk_nycells * self.vtk_nzcells) + np.dtype(np.uint32).itemsize) + vtk_rxs_offset = round_value((np.dtype(np.uint32).itemsize * self.vtk_nxcells * self.vtk_nycells * self.vtk_nzcells) + np.dtype(np.uint32).itemsize + (np.dtype(np.int8).itemsize * self.vtk_nxcells * self.vtk_nycells * self.vtk_nzcells) + np.dtype(np.uint32).itemsize) with open(self.filename, 'wb') as f: f.write('\n'.encode('utf-8')) @@ -102,7 +106,8 @@ class GeometryView: f.write('\n'.format(self.vtk_xscells, self.vtk_xfcells, self.vtk_yscells, self.vtk_yfcells, self.vtk_zscells, self.vtk_zfcells).encode('utf-8')) f.write('\n'.encode('utf-8')) f.write('\n'.encode('utf-8')) - f.write('\n'.format(vtk_srcs_rxs_pml_offset).encode('utf-8')) + f.write('\n'.format(vtk_srcs_pml_offset).encode('utf-8')) + f.write('\n'.format(vtk_rxs_offset).encode('utf-8')) f.write('\n'.encode('utf-8')) f.write('\n\n\n_'.encode('utf-8')) @@ -115,13 +120,21 @@ class GeometryView: for i in range(self.xs, self.xf, self.dx): f.write(pack('I', G.solid[i, j, k])) - # Write source/receiver IDs + # Write source/PML IDs datasize = int(np.dtype(np.int8).itemsize * self.vtk_nxcells * self.vtk_nycells * self.vtk_nzcells) f.write(pack('I', datasize)) for k in range(self.zs, self.zf, self.dz): for j in range(self.ys, self.yf, self.dy): for i in range(self.xs, self.xf, self.dx): - f.write(pack('b', self.srcs_rxs_pml[i, j, k])) + f.write(pack('b', self.srcs_pml[i, j, k])) + + # Write receiver IDs + datasize = int(np.dtype(np.int8).itemsize * self.vtk_nxcells * self.vtk_nycells * self.vtk_nzcells) + f.write(pack('I', datasize)) + for k in range(self.zs, self.zf, self.dz): + for j in range(self.ys, self.yf, self.dy): + for i in range(self.xs, self.xf, self.dx): + f.write(pack('b', self.rxs[i, j, k])) f.write('\n\n'.encode('utf-8')) @@ -239,8 +252,10 @@ class GeometryView: f.write('{}\n'.format(material.ID, material.numID).encode('utf-8')) if not materialsonly: f.write('1\n'.encode('utf-8')) - for index, srcrx in enumerate(G.rxs + G.hertziandipoles + G.magneticdipoles + G.voltagesources + G.transmissionlines): - f.write('{}\n'.format(srcrx.ID, index + 2).encode('utf-8')) + for index, src in enumerate(G.hertziandipoles + G.magneticdipoles + G.voltagesources + G.transmissionlines): + f.write('{}\n'.format(src.ID, index + 2).encode('utf-8')) + for index, rx in enumerate(G.rxs): + f.write('{}\n'.format(rx.ID, index + 1).encode('utf-8')) f.write('\n'.encode('utf-8')) diff --git a/tools/Paraview macros/gprMax_info.py b/tools/Paraview macros/gprMax_info.py index 94adf85c..063de0fa 100644 --- a/tools/Paraview macros/gprMax_info.py +++ b/tools/Paraview macros/gprMax_info.py @@ -36,7 +36,8 @@ renderview.ResetCamera() # Lists to hold material and sources/receiver identifiers written in VTK file in tags and materials = [] -srcs_rxs_pml = [] +srcs_pml = [] +rxs = [] with open(model.FileName[0], 'r') as f: for line in f: if line.startswith('