diff --git a/SimPEG/Utils/meshutils.py b/SimPEG/Utils/meshutils.py index 85316869..e30bcfaf 100644 --- a/SimPEG/Utils/meshutils.py +++ b/SimPEG/Utils/meshutils.py @@ -319,6 +319,83 @@ def writeVTRFile(fileName,mesh,model=None): vtrWriteFilter.Update() +def ExtractCoremesh(xyzlim, mesh, meshType='tensor'): + """ + Extracts Core Mesh from Global mesh + xyzlim: 2D array [ndim x 2] + mesh: SimPEG mesh + This function ouputs: + - actind: corresponding boolean index from global to core + - meshcore: core SimPEG mesh + Warning: 1D and 2D has not been tested + """ + from SimPEG import Mesh + if mesh.dim ==1: + xyzlim = xyzlim.flatten() + xmin, xmax = xyzlim[0], xyzlim[1] + + xind = np.logical_and(mesh.vectorCCx>xmin, mesh.vectorCCxxmin) & (mesh.gridCC[:,0]ymin, mesh.vectorCCyzmin, mesh.vectorCCzxmin) & (mesh.gridCC[:,0]ymin) & (mesh.gridCC[:,1]xmin, mesh.vectorCCxymin, mesh.vectorCCyzmin, mesh.vectorCCzxmin) & (mesh.gridCC[:,0]ymin) & (mesh.gridCC[:,1]zmin) & (mesh.gridCC[:,2]