Read Tensor Mesh

Read a UBC tensor mesh file

# sphinx_gallery_thumbnail_number = 1
import PVGeo
import pyvista
from pyvista import examples

Download sample data files and keep track of names:

url = 'https://github.com/OpenGeoVis/PVGeo/raw/master/tests/data/Craig-Chile/craig_chile.msh'
mesh_file, _ = examples.downloads._retrieve_file(url, 'craig_chile.msh')
url = 'https://github.com/OpenGeoVis/PVGeo/raw/master/tests/data/Craig-Chile/Lpout.mod'
model_file, _ = examples.downloads._retrieve_file(url, 'Lpout.mod')

Read the mesh and model

reader = PVGeo.ubc.TensorMeshReader()
reader.set_mesh_filename(mesh_file)
reader.add_model_file_name(model_file)
mesh = reader.apply()
print(mesh)

Out:

RectilinearGrid (0x7f15dc0fc2e8)
  N Cells:      190440
  N Points:     200900
  X Bounds:     3.550e+05, 3.722e+05
  Y Bounds:     5.999e+06, 6.016e+06
  Z Bounds:     -5.250e+03, 3.000e+03
  Dimensions:   70, 70, 41
  N Arrays:     1

Use a PyVista threshold filter to remove NaN data values

mesh.threshold().plot()
read tensor mesh

Out:

[(392348.1001399256, 6036348.100139925, 27598.10013992562),
 (363625.0, 6007625.0, -1125.0),
 (0.0, 0.0, 1.0)]

Or inspect slices of the model

mesh.slice_orthogonal().plot()
read tensor mesh

Out:

[(392348.1001399256, 6036348.100139925, 27598.10013992562),
 (363625.0, 6007625.0, -1125.0),
 (0.0, 0.0, 1.0)]

Or threshold a data range

mesh.threshold([-0.6, -0.3]).plot(clim=[-0.6, 0.3])
read tensor mesh

Out:

[(384737.1076481045, 6027487.107648104, 19892.107648104513),
 (363875.0, 6006625.0, -970.0),
 (0.0, 0.0, 1.0)]

Total running time of the script: ( 0 minutes 4.176 seconds)

Gallery generated by Sphinx-Gallery