你已经派生过 gprMax
镜像自地址
https://gitee.com/sunhf/gprMax.git
已同步 2025-08-08 07:24:19 +08:00
materials macro for evtk
这个提交包含在:
@@ -205,8 +205,10 @@ class GeometryView:
|
|||||||
pml = np.ones((G.nx, G.ny, G.nz))
|
pml = np.ones((G.nx, G.ny, G.nz))
|
||||||
pml[10:-10, 10:-10, 10:-10] = 0
|
pml[10:-10, 10:-10, 10:-10] = 0
|
||||||
|
|
||||||
|
material_ids = ','.join([m.ID for m in G.materials if '+' not in m.ID])
|
||||||
|
|
||||||
fp = './test-evtk-hl'
|
fp = './test-evtk-hl'
|
||||||
rectilinearToVTK(fp, x, y, z, cellData = {"materials" : G.solid, "pml": pml}, comments = ['hi', 'world'])
|
rectilinearToVTK(fp, x, y, z, cellData = {"Material" : G.solid, "pml": pml}, comments = [material_ids, 'world'])
|
||||||
|
|
||||||
def write_vtk(self, G, pbar):
|
def write_vtk(self, G, pbar):
|
||||||
"""Writes the geometry information to a VTK file.
|
"""Writes the geometry information to a VTK file.
|
||||||
|
@@ -48,7 +48,6 @@ scene.add(title_gpr)
|
|||||||
scene.add(dxdydz)
|
scene.add(dxdydz)
|
||||||
scene.add(time_window)
|
scene.add(time_window)
|
||||||
|
|
||||||
|
|
||||||
# plastic box in sub grid
|
# plastic box in sub grid
|
||||||
material = gprMax.Material(er=3, mr=1, se=0, sm=0, id='plastic')
|
material = gprMax.Material(er=3, mr=1, se=0, sm=0, id='plastic')
|
||||||
scene.add(material)
|
scene.add(material)
|
||||||
|
78
tools/Paraview macros/etvk.py
普通文件
78
tools/Paraview macros/etvk.py
普通文件
@@ -0,0 +1,78 @@
|
|||||||
|
# Copyright (C) 2015-2021: The University of Edinburgh
|
||||||
|
# Authors: Craig Warren, Antonis Giannopoulos, and John Hartley
|
||||||
|
#
|
||||||
|
# This file is part of gprMax.
|
||||||
|
#
|
||||||
|
# gprMax is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# gprMax is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with gprMax. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import mmap
|
||||||
|
import os
|
||||||
|
from xml.etree import ElementTree as ET
|
||||||
|
|
||||||
|
from paraview.simple import *
|
||||||
|
|
||||||
|
# Get whatever source is loaded (should be model)
|
||||||
|
model = GetActiveSource()
|
||||||
|
|
||||||
|
# Get active view
|
||||||
|
renderview = GetActiveView()
|
||||||
|
|
||||||
|
# Show Data Axes Grid
|
||||||
|
renderview.AxesGrid.Visibility = 1
|
||||||
|
|
||||||
|
# Hide display of root data
|
||||||
|
Hide(model)
|
||||||
|
|
||||||
|
# one file only for now
|
||||||
|
|
||||||
|
# Get max numID of materials
|
||||||
|
fp = model.FileName[0]
|
||||||
|
|
||||||
|
# materials string
|
||||||
|
ms = None
|
||||||
|
|
||||||
|
# read the material list comment from the file
|
||||||
|
b = True
|
||||||
|
with open(fp, 'rb') as f:
|
||||||
|
while(b):
|
||||||
|
line = f.readline().decode()
|
||||||
|
if 'pec,free_space' in line:
|
||||||
|
# materials string
|
||||||
|
ms = line
|
||||||
|
b = False
|
||||||
|
|
||||||
|
if ms:
|
||||||
|
# materials list
|
||||||
|
ml = ms[5:-5].split(',')
|
||||||
|
|
||||||
|
# create a threshold filter for each material type
|
||||||
|
for i, m in enumerate(ml):
|
||||||
|
threshold = Threshold(Input=model)
|
||||||
|
threshold.ThresholdRange = [i, i]
|
||||||
|
threshold.Scalars = ['CELLS', 'Material']
|
||||||
|
RenameSource(m, threshold)
|
||||||
|
|
||||||
|
# Show data in view, except for free_space
|
||||||
|
if i != 1:
|
||||||
|
thresholddisplay = Show(threshold, renderview)
|
||||||
|
thresholddisplay.ColorArrayName = ['CELLS', 'Material']
|
||||||
|
threshold.UpdatePipeline()
|
||||||
|
|
||||||
|
RenderAllViews()
|
||||||
|
|
||||||
|
# Reset view to fit data
|
||||||
|
renderview.ResetCamera()
|
||||||
|
|
||||||
|
# Show color bar/color legend
|
||||||
|
# thresholdDisplay.SetScalarBarVisibility(renderview, False)
|
在新工单中引用
屏蔽一个用户