def mesh_import(fname): """ Import a gmsh mesh and return mesh and sensors positions according to markers Returns ------- None. """ ## --------- Import mesh --------- ## mesh3d = readGmsh(fname, verbose=True) #mesh3d.exportVTK('mesh3d_Markers') #MR.PyMesh3d() # plot mesh3d_Markers marker in 3d sensors = [] for node in mesh3d.nodes(): if node.marker() == -99: sensors.append(node.pos()) elif node.marker() == -999: print('-999') sensors.append(node.pos()) elif node.marker() == -1000: print('-1000') sensors.append(node.pos()) return mesh3d, np.vstack(sensors)
import matplotlib.pyplot as plt import pygimli as pg from pygimli.meshtools import readGmsh subprocess.call(["wget", "http://www.pygimli.org/_downloads/mesh.geo"]) try: subprocess.call(["gmsh", "-2", "-o", "mesh.msh", "mesh.geo"]) gmsh = True except OSError: print("Gmsh needs to be installed for this example.") gmsh = False if gmsh: mesh = readGmsh("mesh.msh", verbose=True) pg.show(mesh, mesh.cellMarkers(), showLater=True, cmap="BrBG") plt.xlim(0, 50) plt.ylim(-50, 0) else: plt.figure() plt.title("Gmsh needs to be installed for this example") ############################################################################### # .. figure:: ../../_static/gmsh/mod_inv.png # :align: center # :width: 75 % # # Synthetic example. # # For the sake of illustration, the example presented was chosen to be simple
from pygimli.meshtools import readGmsh mesh = readGmsh('oblast.msh', verbose=True) mesh.save('oblast.bms')
from pygimli.meshtools import readGmsh mesh = readGmsh('bukov.msh', verbose=True) mesh.save('bukov.bms')
from pygimli.meshtools import readGmsh urlretrieve("https://www.pygimli.org/_downloads/mesh.geo", filename="mesh.geo") try: subprocess.call( ["gmsh", "-format", "msh2", "-2", "-o", "mesh.msh", "mesh.geo"]) gmsh = True except OSError: print("Gmsh needs to be installed for this example.") gmsh = False fig, ax = plt.subplots() if gmsh: mesh = readGmsh("mesh.msh", verbose=True) pg.show(mesh, ax=ax, markers=True, hold=True) ax.set_xlim(0, 50) ax.set_ylim(-50, 0) else: ax.set_title("Gmsh needs to be installed for this example") ############################################################################### # .. figure:: ../../_static/gmsh/mod_inv.png # :align: center # :width: 75 % # # Synthetic example. # # For the sake of illustration, the example presented was chosen to be simple # and two-dimensional, although Gmsh and the import function provided allow for