gimli-org / gimli

Geophysical Inversion and Modeling Library :earth_africa:

Home Page:https://www.pygimli.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

3d geometry with topography and fixed thin layer

mariosgeo opened this issue · comments

Problem description

I have 3d (xyz) electrodes on surface, where they define also a topography. What I want, is to make a layer (surface ?), just 10cm below each electrode. This is since all electrodes are placed on top brick layers within a city, and want to fix the resistivity to something high.

What I do,

  data=ert.load('ams_26_k_elev.pyg')

create a temporary array with the xy,elevations and subtract 10cm

 tmp=np.asarray(data.sensors())
 tmp[:,2]=tmp[:,2]-0.1

I will make a PLC for the 10cm

 plc2 = mt.createParaMeshPLC3D(tmp, paraDepth=0.1, paraMaxCellSize=0.01,
                         surfaceMeshQuality=34)

And a second PLC for the rest of the domain

 plc1 = mt.createParaMeshPLC3D(data, paraDepth=5, paraMaxCellSize=0.01,
                         surfaceMeshQuality=34)

Then add them

 plc=plc1+plc2

Add some nodes for accuracy

 for s in data.sensors():
       plc.createNode(s-[0.,0.,0.05], marker=-99)

And make a mesh

 mesh = mt.createMesh(plc, quality=1.3)

This returns the following error

  File ~\anaconda3\envs\pg\lib\site-packages\pygimli\meshtools\mesh.py:148 in createMesh
mesh = pg.meshtools.syscallTetgen(namePLC, quality, area,

  File ~\anaconda3\envs\pg\lib\site-packages\pygimli\meshtools\polytools.py:1902 in syscallTetgen
mesh = pg.meshtools.readTetgen(filebody + '-1')

  File ~\anaconda3\envs\pg\lib\site-packages\pygimli\meshtools\mesh.py:963 in readTetgen
with open(fName + '.node', 'r') as node_in:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\marios\\AppData\\Local\\Temp\\tmpd4jcuffp-1.node'
  1. There should be an example on 3D ERT, maybe with the slagdump 3D data (Günther et al., 2006) that I used in lack of your file. However, there is a notebook on https://github.com/gimli-org/notebooks/blob/main/ERT/3dtopo/slagdump3d.ipynb
  2. There should be a better error message if the mesh generation (tetgen is called in the background) fails, also hinting to look for intersections with tetgen -d, or an intersection check beforehand.
  3. In my case, surfaceMeshQuality=34 prevented building a correct mesh even from plc1, this is something to be looked at.
  4. Eventually, the mesh generation for plc2 being inside plc1 is never not sucessful as it creates (on the outside) plc2 faces that are subfaces of faces already created by plc1. So you should try to create only the upper surface with plc2 = createParaMeshSurface.

7th_iter.txt

The data file attached. And a demo script

data=ert.load('7th_iter.txt')
tmp=np.asarray(data.sensors())
tmp[:,2]=tmp[:,2]-0.2

plc1 = mt.createParaMeshPLC3D(data, paraDepth=5, paraMaxCellSize=0.1,
                         surfaceMeshQuality=34)

plc2=mt.createParaMeshSurface(tmp,surfaceMeshQuality=34,surfaceMeshArea=0.1)

plc=plc1+plc2

pg.show(plc)
mesh = mt.createMesh(plc, quality=1.3,switches='-d')
mesh.exportVTK('mesh3.vtk')

Edit. I am removing first and last electrodes, to avoid intersections.

ix=np.where((tmp[:,0]==0)
         |
         (tmp[:,0]==20)
         |
         (tmp[:,1]==0)
         |
         (tmp[:,1]==18)
         )[0]

tmp=np.delete(tmp,ix,axis=0)

And making sure that plc2 is not intersecting.

plc2=mt.createParaMeshSurface(tmp,surfaceMeshQuality=34,surfaceMeshArea=0.1,boundary=[0.1,0.1],paraBoundary=[0.01,0.01])

Still I get a different issue,

The input surface mesh contain self-intersections. Program stopped.

Edit 2:
If I place the surface bit deeper,

tmp[:,2]=tmp[:,2]-1.2

Then it creates the mesh. So I assume the intersection is on the "z-axis".

You can check intersections with tetgen -d polyfile (after exporting the plc with mt.exportPLC()).

I personally had problems already when using surfaceMeshQuality (there was a hole) but this might be due to my topo.