Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/gimli-org/gimli into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Günther committed Mar 18, 2024
2 parents 77f5ba4 + bc33982 commit c924854
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
15 changes: 8 additions & 7 deletions core/src/inversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ bool RInversion::oneStep() {
if (verbose_) std::cout << "solve CGLSCDWWtrans with lambda = " << lambda_ << std::endl;

try{
solveCGLSCDWWhtrans(*forward_->jacobian(), *forward_->constraints(),
solveCGLSCDWWhtrans(*forward_->jacobian(), *forward_->constraints(),
dataWeight_,
deltaDataIter_,
deltaModelIter_,
Expand All @@ -319,18 +319,19 @@ bool RInversion::oneStep() {
lambda_, roughness, maxCGLSIter_, CGLStol_,
dosave_);
} catch(...){
__MS("Debug halt! 1700")
forward_->mesh()->save("S1700.bms");
forward_->regionManager().mesh().save("R1700.bms");
// __MS("Debug halt! 1700")
// forward_->mesh()->save("S1700.bms");
// forward_->regionManager().mesh().save("R1700.bms");

// __MS("Debug halt! 17708")
// forward_->mesh()->save("S17708.bms");
// forward_->regionManager().mesh().save("R17708.bms");

std::cout<<forward_->mesh()->boundary(2121).marker() << std::endl;
std::cout<<forward_->mesh()->boundary(2122).marker() << std::endl;
// std::cout<<forward_->mesh()->boundary(2121).marker() << std::endl;
// std::cout<<forward_->mesh()->boundary(2122).marker() << std::endl;

exit(1);
// exit(1);
log(Error, "solveCGLSCDWWhtrans throws unknown exception.");
}
} // else no optimization

Expand Down
7 changes: 4 additions & 3 deletions pygimli/meshtools/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def appendTriangleBoundary(mesh, xbound=10, ybound=10, marker=1,
mesh: :gimliapi:`GIMLI::Mesh`
Mesh to which the triangle boundary should be appended.
xbound: float, optional
Absolute horizontal prolongation distance.
Absolute horizontal prolongation distance. Need to be greater 2.
ybound: float, optional
Absolute vertical prolongation distance.
marker: int, optional
Expand Down Expand Up @@ -358,8 +358,9 @@ def appendTriangleBoundary(mesh, xbound=10, ybound=10, marker=1,
poly.copyBoundary(b)

preserveSwitch = 'Y'
# pg.show(poly, boundaryMarkers=True, showNodes=True)
# pg.wait()
#pg.show(poly, fillRegion=False)
#pg.show(poly, boundaryMarkers=True, showNodes=True)
#pg.wait()

mesh2 = pg.meshtools.createMesh(poly, preserveBoundary=preserveSwitch,
**kwargs)
Expand Down
6 changes: 3 additions & 3 deletions pygimli/meshtools/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2021,8 +2021,7 @@ def createParaMesh2DGrid(sensors, paraDX=1, paraDZ=1, paraDepth=0, nLayers=11,

# print(xMin, xMax, dx)
x = pg.utils.grange(xMin, xMax, dx=dx)

y = -pg.utils.grange(dz, paraDepth, n=nLayers, log=True)
y = -pg.cat([0], pg.utils.grange(dz, paraDepth, n=nLayers, log=True))

mesh.createGrid(x, y[::-1])
mesh.setCellMarkers([2] * mesh.cellCount())
Expand All @@ -2034,7 +2033,8 @@ def createParaMesh2DGrid(sensors, paraDX=1, paraDZ=1, paraDepth=0, nLayers=11,
boundary = abs((paraXLimits[1] - paraXLimits[0]) * 4.0)

mesh = pg.meshtools.appendTriangleBoundary( # circular import?
mesh, xbound=boundary, ybound=boundary, marker=1, addNodes=5, **kwargs)
mesh, xbound=boundary, ybound=boundary,
marker=1, addNodes=5, **kwargs)

return mesh

Expand Down
25 changes: 20 additions & 5 deletions pygimli/viewer/mpl/meshview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,9 @@ def drawSensors(ax, sensors, diam=None, coords=None, **kwargs):
**kwargs
Additional kwargs forwarded to mpl.PatchCollection, mpl.Circle
sensorMarker:
Also 'sm'. Set marker style: 'o' Circle, 'v' Triangle pointing down.
Examples
--------
>>> import numpy as np
Expand All @@ -1355,21 +1358,33 @@ def drawSensors(ax, sensors, diam=None, coords=None, **kwargs):
not pg.core.zVari(sensors) and sensors[0][2] == 0.0:
coords = [0, 1]

eCircles = []

if diam is None:
eSpacing = pg.Pos(sensors[0]).distance(sensors[1])
diam = eSpacing / 2.5

eSensors = []
sm = kwargs.pop('sm', kwargs.pop('sensorMarker', 'o'))
for e in sensors:
eCircles.append(mpl.patches.Circle((e[coords[0]],
e[coords[1]]), diam/2, **kwargs))

p = mpl.collections.PatchCollection(eCircles, **kwargs)
x = e[coords[0]]
y = e[coords[1]]
if sm == 'o':
eSensors.append(mpl.patches.Circle((x,y), diam/2,
**kwargs))
else:
eSensors.append(mpl.patches.Polygon(([x, y],
[x+diam/1.5/1.4, y+diam/1.5],
[x-diam/1.5/1.4, y+diam/1.5]
),
closed=True,
**kwargs))

p = mpl.collections.PatchCollection(eSensors, clip_on=False, **kwargs)
p.set_zorder(100)
ax.add_collection(p)

updateAxes_(ax)
#ax.set(ylim=[None, y+diam])


def _createParameterContraintsLines(mesh, cMat, cWeights=None):
Expand Down

0 comments on commit c924854

Please sign in to comment.