你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
Removed .pvd wrapper creation and reading
这个提交包含在:
@@ -39,27 +39,6 @@ from .utilities.utilities import (get_terminal_width,
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def write_vtk_pvd(gvs):
|
|
||||||
"""Writes Paraview data file (.pvd) - provides pointers to a collection of
|
|
||||||
data files, i.e. GeometryViews.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
gvs: list of all GeometryViews.
|
|
||||||
"""
|
|
||||||
|
|
||||||
filename = config.get_model_config().output_file_path
|
|
||||||
pvd = VtkGroup(str(filename))
|
|
||||||
|
|
||||||
# Add filenames of all GeometryViews to group
|
|
||||||
for gv in gvs:
|
|
||||||
sim_time = 0
|
|
||||||
pvd.addFile(str(gv.filename) + gv.vtkfiletype.ext, sim_time,
|
|
||||||
group = "", part = "0")
|
|
||||||
pvd.save()
|
|
||||||
|
|
||||||
logger.info(f'Written wrapper for geometry files: {filename.name}.pvd')
|
|
||||||
|
|
||||||
|
|
||||||
def save_geometry_views(gvs):
|
def save_geometry_views(gvs):
|
||||||
"""Creates and saves geometryviews.
|
"""Creates and saves geometryviews.
|
||||||
|
|
||||||
@@ -80,10 +59,6 @@ def save_geometry_views(gvs):
|
|||||||
pbar.update(gv.nbytes)
|
pbar.update(gv.nbytes)
|
||||||
pbar.close()
|
pbar.close()
|
||||||
|
|
||||||
# Write a Paraview data file (.pvd) if there is more than one GeometryView
|
|
||||||
if len(gvs) > 1:
|
|
||||||
write_vtk_pvd(gvs)
|
|
||||||
|
|
||||||
logger.info('')
|
logger.info('')
|
||||||
|
|
||||||
|
|
||||||
|
@@ -17,11 +17,9 @@
|
|||||||
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import mmap
|
|
||||||
import os
|
import os
|
||||||
from xml.etree import ElementTree as ET
|
|
||||||
|
|
||||||
from paraview.simple import (AppendDatasets, Box, ColorBy, GetActiveSource,
|
from paraview.simple import (AppendDatasets, Box, GetActiveSource,
|
||||||
GetActiveView, GetParaViewVersion, Hide,
|
GetActiveView, GetParaViewVersion, Hide,
|
||||||
OpenDataFile, RenameSource, RenderAllViews,
|
OpenDataFile, RenameSource, RenderAllViews,
|
||||||
SetActiveSource, Show, Threshold)
|
SetActiveSource, Show, Threshold)
|
||||||
@@ -145,34 +143,12 @@ data = GetActiveSource()
|
|||||||
Hide(data)
|
Hide(data)
|
||||||
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
# Get filename or list of filenames #
|
|
||||||
#####################################
|
|
||||||
|
|
||||||
# Single .vti or .vtu file
|
# Single .vti or .vtu file
|
||||||
if len(data.FileName) == 1:
|
file = data.FileName
|
||||||
files = data.FileName
|
dirname = os.path.dirname(file[0])
|
||||||
dirname = os.path.dirname(files[0])
|
|
||||||
|
|
||||||
# Multiple .vti or .vtu files referenced in a .pvd file
|
# Read and display data from file, i.e. materials, sources, receivers, and PMLs
|
||||||
else:
|
with open(file, 'rb') as f:
|
||||||
files = []
|
|
||||||
dirname = os.path.dirname(data.FileName)
|
|
||||||
tree = ET.parse(data.FileName)
|
|
||||||
root = tree.getroot()
|
|
||||||
for elem in root:
|
|
||||||
for subelem in elem.findall('DataSet'):
|
|
||||||
tmp = os.path.join(dirname, subelem.get('file'))
|
|
||||||
files.append(tmp)
|
|
||||||
|
|
||||||
|
|
||||||
#################################################################
|
|
||||||
# Read and display data from file(s), i.e. materials, sources, #
|
|
||||||
# receivers, and PMLs #
|
|
||||||
#################################################################
|
|
||||||
|
|
||||||
for file in files:
|
|
||||||
with open(file, 'rb') as f:
|
|
||||||
# Comments () embedded in line 3 of file
|
# Comments () embedded in line 3 of file
|
||||||
f.readline()
|
f.readline()
|
||||||
f.readline()
|
f.readline()
|
||||||
@@ -184,25 +160,25 @@ for file in files:
|
|||||||
print('\ngprMax version: ' + c['gprMax_version'])
|
print('\ngprMax version: ' + c['gprMax_version'])
|
||||||
print(file)
|
print(file)
|
||||||
|
|
||||||
################
|
################
|
||||||
# Display data #
|
# Display data #
|
||||||
################
|
################
|
||||||
pv_view = GetActiveView()
|
pv_view = GetActiveView()
|
||||||
pv_view.AxesGrid.Visibility = 1 # Show Data Axes Grid
|
pv_view.AxesGrid.Visibility = 1 # Show Data Axes Grid
|
||||||
pv_data = OpenDataFile(file)
|
pv_data = OpenDataFile(file)
|
||||||
pv_disp = Show(pv_data, pv_view)
|
pv_disp = Show(pv_data, pv_view)
|
||||||
pv_src = GetActiveSource()
|
pv_src = GetActiveSource()
|
||||||
Hide(pv_src)
|
Hide(pv_src)
|
||||||
src_name = os.path.split(file)
|
src_name = os.path.split(file)
|
||||||
RenameSource(src_name[1])
|
RenameSource(src_name[1])
|
||||||
|
|
||||||
# Discretisation
|
# Discretisation
|
||||||
dl = c['dx_dy_dz']
|
dl = c['dx_dy_dz']
|
||||||
# Number of voxels
|
# Number of voxels
|
||||||
nl = c['nx_ny_nz']
|
nl = c['nx_ny_nz']
|
||||||
|
|
||||||
# Materials
|
# Materials
|
||||||
try:
|
try:
|
||||||
for i, mat in enumerate(c['Materials']):
|
for i, mat in enumerate(c['Materials']):
|
||||||
threshold = threshold_filt(pv_src, i, i, ['CELLS', 'Material'])
|
threshold = threshold_filt(pv_src, i, i, ['CELLS', 'Material'])
|
||||||
RenameSource(mat, threshold)
|
RenameSource(mat, threshold)
|
||||||
@@ -212,11 +188,11 @@ for file in files:
|
|||||||
thresholddisplay = Show(threshold, pv_view)
|
thresholddisplay = Show(threshold, pv_view)
|
||||||
thresholddisplay.ColorArrayName = ['CELLS', 'Material']
|
thresholddisplay.ColorArrayName = ['CELLS', 'Material']
|
||||||
threshold.UpdatePipeline()
|
threshold.UpdatePipeline()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print('No materials to load')
|
print('No materials to load')
|
||||||
|
|
||||||
# Display any sources
|
# Display any sources
|
||||||
try:
|
try:
|
||||||
for item in c['Sources']:
|
for item in c['Sources']:
|
||||||
pos = item['position']
|
pos = item['position']
|
||||||
name = item['name']
|
name = item['name']
|
||||||
@@ -226,11 +202,11 @@ for file in files:
|
|||||||
XLength=dl[0], YLength=dl[1], ZLength=dl[2])
|
XLength=dl[0], YLength=dl[1], ZLength=dl[2])
|
||||||
RenameSource(name, src)
|
RenameSource(name, src)
|
||||||
Show(src)
|
Show(src)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print('No sources to load')
|
print('No sources to load')
|
||||||
|
|
||||||
# Display any receivers
|
# Display any receivers
|
||||||
try:
|
try:
|
||||||
for item in c['Receivers']:
|
for item in c['Receivers']:
|
||||||
pos = item['position']
|
pos = item['position']
|
||||||
name = item['name']
|
name = item['name']
|
||||||
@@ -240,14 +216,14 @@ for file in files:
|
|||||||
XLength=dl[0], YLength=dl[1], ZLength=dl[2])
|
XLength=dl[0], YLength=dl[1], ZLength=dl[2])
|
||||||
RenameSource(name, rx)
|
RenameSource(name, rx)
|
||||||
Show(rx)
|
Show(rx)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print('No receivers to load')
|
print('No receivers to load')
|
||||||
|
|
||||||
# Display any PMLs
|
# Display any PMLs
|
||||||
try:
|
try:
|
||||||
pt = c['PMLthickness']
|
pt = c['PMLthickness']
|
||||||
display_pmls(pt, dl, nl)
|
display_pmls(pt, dl, nl)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print('No PMLs to load')
|
print('No PMLs to load')
|
||||||
|
|
||||||
|
|
||||||
@@ -255,6 +231,3 @@ RenderAllViews()
|
|||||||
|
|
||||||
# Reset view to fit data
|
# Reset view to fit data
|
||||||
pv_view.ResetCamera()
|
pv_view.ResetCamera()
|
||||||
|
|
||||||
# Show color bar/color legend
|
|
||||||
# thresholdDisplay.SetScalarBarVisibility(renderview, False)
|
|
||||||
|
在新工单中引用
屏蔽一个用户