Skip to content

Commit

Permalink
Lang (AE) renamed neighbour to neighbor
Browse files Browse the repository at this point in the history
  • Loading branch information
carsten-forty2 committed Nov 20, 2019
1 parent 505ccbf commit 10b0644
Show file tree
Hide file tree
Showing 30 changed files with 497 additions and 492 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -84,3 +84,4 @@ python/pygimli/core/*.dll
.vscode/settings.json

python/pygimli/testing/synth.ves
.vscode/launch.json
10 changes: 7 additions & 3 deletions cmake/Findpygccxml.cmake
Expand Up @@ -5,7 +5,6 @@
# PYGCCXML_FOUND, If false, do not try to use pygccxml
# PYPLUSPLUS_FOUND, If false, do not try to use pyplusplus


find_python_module(pygccxml)

if (pygccxml_FOUND)
Expand All @@ -25,7 +24,12 @@ else()
message( STATUS "NOT Found pygccxml: we try to get a copy or cannot build pygimli.")
find_package(Subversion REQUIRED)
endif(PYGCCXML_PATH)


endif()

if (PYGCCXML_PATH)
message(STATUS "Found pygccxml path: ${PYGCCXML_PATH}")
STRING(REGEX REPLACE "\\\\" "/" PYGCCXML_PATH ${PYGCCXML_PATH})
message(STATUS "Found pygccxml path: ${PYGCCXML_PATH}")
endif()

mark_as_advanced(PYGCCXML)
10 changes: 5 additions & 5 deletions doc/examples/seismics/plot_4_rays_layered_and_gradient_models.py
Expand Up @@ -117,7 +117,7 @@ def analyticalSolutionGradient(x, a=1000, b=100):
boundary.setMarker(0)

xmin, xmax = mesh.xmin(), mesh.xmax()
mesh.createNeighbourInfos()
mesh.createNeighborInfos()

# In order to use the Dijkstra, we extract the surface positions >0
mx = pg.x(mesh)
Expand All @@ -144,7 +144,7 @@ def analyticalSolutionGradient(x, a=1000, b=100):
pg.show(mesh, vel, ax=ax[0, j], label="Velocity (m/s)", hold=True,
logScale=False, cMap="summer_r", coverage=0.7)
drawMesh(ax[0, j], mesh, color="white", lw=0.21)

# We compare the accuracy for 0-5 secondary nodes
sec_nodes = [0, 1, 5]
t_all = []
Expand All @@ -161,7 +161,7 @@ def analyticalSolutionGradient(x, a=1000, b=100):
# Perform traveltime calculations and log time with pg.tic() & pg.toc()
pg.tic()
res = mgr.simulate(vel=vel, scheme=data, mesh=mesh, secNodes=n)
# We need to copy res['t'] here because res['t'] is a reference to
# We need to copy res['t'] here because res['t'] is a reference to
# an array in res, and res will be removed in the next iteration.
# Unfortunately, we don't have any reverence counting for core objects yet.
t_all.append(res['t'].array())
Expand All @@ -173,7 +173,7 @@ def analyticalSolutionGradient(x, a=1000, b=100):
lab = "Raypath with %d sec nodes" % n
else:
lab = None

recNode = mgr.fop.mesh().findNearestNode([sensors[p], 0.0])
sourceNode = mgr.fop.mesh().findNearestNode([0.0, 0.0])

Expand All @@ -196,7 +196,7 @@ def analyticalSolutionGradient(x, a=1000, b=100):
ax[2, j].plot(px, np.abs(t_all[i] - t_ana) * 1000)

ax[1, j].legend()

# Draw sensor positions for the selected receivers
for p in recs:
ax[0, j].plot(sensors[p], 0.0, "kv", ms=10)
Expand Down
2 changes: 1 addition & 1 deletion doc/paper/cg17/example-2_visualization.py
Expand Up @@ -145,7 +145,7 @@ def showModel(outPath):
pg.wait()
pg.show(fopMesh, ax=ax, linewidth=0.2)

paraMesh.createNeighbourInfos()
paraMesh.createNeighborInfos()
bs = []
for b in paraMesh.boundaries():
if b.leftCell() and b.rightCell():
Expand Down
5 changes: 5 additions & 0 deletions python/generate_pygimli_code.py
Expand Up @@ -18,6 +18,11 @@

(options, args) = optionParser.parse_args()

print('##############')
print(options)
print(args)
print('##############')

if options.caster:
settings.caster_path = options.caster

Expand Down
2 changes: 2 additions & 0 deletions python/pygimli/core/__init__.py
Expand Up @@ -861,6 +861,8 @@ def abs(v):
"""
if isinstance(v, _pygimli_.CVector):
return _pygimli_.mag(v)
elif isinstance(v, list):
return _pygimli_.absR3(np.array(v).T)
elif isinstance(v, _pygimli_.R3Vector):
return _pygimli_.absR3(v)
elif isinstance(v, np.ndarray):
Expand Down
36 changes: 14 additions & 22 deletions python/pygimli/core/mesh.py
Expand Up @@ -16,8 +16,6 @@ def __Mesh_str(self):
st += " secNodes: " + str(self.secondaryNodeCount())

return st


Mesh.__str__ = __Mesh_str


Expand All @@ -26,8 +24,6 @@ def __addPLCs__(self, other):
return mergePLC([self, other])
else:
error("Addition is only supported for PLCs, i.e. meshs without cells.")


Mesh.__add__ = __addPLCs__


Expand All @@ -44,8 +40,6 @@ def __MeshEntity_str(self):
for n in self.nodes():
s += '\t' + str(n.id()) + " " + str(n.pos()) + "\n"
return s


MeshEntity.__str__ = __MeshEntity_str


Expand All @@ -56,11 +50,9 @@ def __Node_str(self):
', Marker: ' + str(self.marker())
s += '\t' + str(self.pos()) + '\n'
return s


Node.__str__ = __Node_str

# For Jupyer Notebook use.. checkme
# For Jupyer Notebook use.. check me
# Node.__repr__ = Node_str
# Mesh.__repr__ = Mesh_str
# MeshEntity.__repr__ = MeshEntity_str
Expand All @@ -69,8 +61,6 @@ def __Node_str(self):
def __Mesh_setVal(self, key, val):
"""Index access to the mesh data"""
self.addData(key, val)


Mesh.__setitem__ = __Mesh_setVal


Expand All @@ -80,8 +70,6 @@ def __Mesh_getVal(self, key):
return self.data(key)
else:
error('The mesh does not have the requested data:', key)


Mesh.__getitem__ = __Mesh_getVal


Expand All @@ -90,8 +78,6 @@ def __MeshBoundingBox__(self):
mi = [bb.min()[i] for i in range(self.dim())]
ma = [bb.max()[i] for i in range(self.dim())]
return [mi, ma]


Mesh.bb = __MeshBoundingBox__


Expand All @@ -108,7 +94,6 @@ def __MeshSetCellMarker__(self, m):
def __MeshHoleMarkers__(self):
return self.holeMarker()


Mesh.cellMarker = __MeshGetCellMarker__
Mesh.setCellMarker = __MeshSetCellMarker__
Mesh.holeMarkers = __MeshHoleMarkers__
Expand All @@ -130,7 +115,7 @@ def __createSecondaryNodes__(self, n=3, verbose=False):
pg.Mesh
Copy of the given mesh with secondary nodes.
"""
self.createNeighbourInfos()
self.createNeighborInfos()

if self.boundary(0).nodeCount() != self.boundary(0).allNodeCount():
warn("Mesh already contains secondary nodes. Not adding any more.")
Expand All @@ -148,10 +133,10 @@ def __createSecondaryNodes__(self, n=3, verbose=False):
for b in self.boundaries():
bs = b.shape()
for sx in range(n):
nmax = n
nMax = n
if isinstance(b, TriangleFace):
nmax = n - sx
for sy in range(nmax):
nMax = n - sx
for sy in range(nMax):
if isinstance(b, TriangleFace):
pos = bs.xyz([(sx + 1) / (n + 2),
(sy + 1) / (n + 2)])
Expand Down Expand Up @@ -216,9 +201,16 @@ def __createMeshWithSecondaryNodes__(self, n=3, verbose=False):
m = Mesh(self)
m.createSecondaryNodes(n, verbose)
return m


Mesh.createSecondaryNodes = __createSecondaryNodes__
Mesh.createMeshWithSecondaryNodes = __createMeshWithSecondaryNodes__

Mesh.exportPLC = exportPLC

# just to keep backward compatibility 20191120
Mesh.createNeighbourInfos = Mesh.createNeighborInfos
Mesh.xmin = Mesh.xMin
Mesh.ymin = Mesh.yMin
Mesh.zmin = Mesh.zMin
Mesh.xmax = Mesh.xMax
Mesh.ymax = Mesh.yMax
Mesh.zmax = Mesh.zMax
2 changes: 1 addition & 1 deletion python/pygimli/meshtools/grid.py
Expand Up @@ -283,7 +283,7 @@ def appendTriangleBoundary(mesh, xbound=10, ybound=10, marker=1, quality=34.0,
mesh2.copyCell(cell)

# old neighbor infos need to be cleaned since the new cells are added
mesh2.createNeighbourInfos(force=True)
mesh2.createNeighborInfos(force=True)

for b in mesh2.boundaries():
if b.leftCell() is None or b.rightCell() is None:
Expand Down
12 changes: 6 additions & 6 deletions python/pygimli/meshtools/mapping.py
Expand Up @@ -215,17 +215,17 @@ def fillEmptyToCellArray(mesh, vals, slope=True):
# atts = pg.Vector(mesh.cellCount(), 0.0) # not used
# oldAtts = mesh.cellAttributes() # not used
mesh.setCellAttributes(vals)
mesh.createNeighbourInfos()
mesh.createNeighborInfos()
# std::vector< Cell * >
# empties = []

if slope:
# search all cells with empty neighbours
# search all cells with empty neighbors
ids = pg.find(mesh.cellAttributes() != 0.0)

for c in mesh.cells(ids):
for i in range(c.neighbourCellCount()):
nc = c.neighbourCell(i)
for i in range(c.neighborCellCount()):
nc = c.neighborCell(i)

if nc:
if nc.attribute() == 0.0:
Expand All @@ -240,7 +240,7 @@ def fillEmptyToCellArray(mesh, vals, slope=True):
while startCell:

startCell.shape().isInside(pos, sf, False)
nextC = startCell.neighbourCell(sf)
nextC = startCell.neighborCell(sf)
if nextC:
if nextC.attribute() == 0.0:
nextC.setAttribute(c.attribute())
Expand Down Expand Up @@ -495,7 +495,7 @@ def interpolate(*args, **kwargs):
* 2D parametric to points (method=['linear, 'spline', 'harmonic'])
* 2D/3D point cloud to points/grids
('Delauney', 'linear, 'spline', 'harmonic')
* Mesh to points based on nearest neighbour values (pg.core)
* Mesh to points based on nearest neighbor values (pg.core)
Examples
--------
Expand Down
14 changes: 7 additions & 7 deletions python/pygimli/meshtools/mesh.py
Expand Up @@ -196,7 +196,7 @@ def refineQuad2Tri(mesh, style=1):
out.createBoundary([b.node(0).id(), b.node(1).id()],
b.marker())

out.createNeighbourInfos()
out.createNeighborInfos()

return out

Expand Down Expand Up @@ -520,7 +520,7 @@ def readGmsh(fname, verbose=False):
mesh.node(int(cell[2] - 1)), mesh.node(int(cell[3] - 1)),
marker=int(cell[4]))

mesh.createNeighbourInfos()
mesh.createNeighborInfos()

# Set Neumann on outer edges by default (can be overriden by Gmsh info)
for b in mesh.boundaries():
Expand Down Expand Up @@ -605,7 +605,7 @@ def readTetgen(fname, comment='#', verbose=False, defaultCellMarker=0,
are loaded or not. Note that without the -f in during the tetgen call,
the faces in the .face file will only contain the faces of the original
input poly file and not all faces. If only a part of the faces are
imported, a createNeighbourInfos call of the mesh will fail.
imported, a createNeighborInfos call of the mesh will fail.
quadratic: boolean (False)
Returns a P2 (quadratic) refined mesh when True (to be removed, as soon
Expand Down Expand Up @@ -754,7 +754,7 @@ def readHydrus2dMesh(fileName='MESHTRIA.TXT'):
mesh.node(int(line[3]) - 1), mesh.node(int(line[4]) - 1), 1)

fid.close()
mesh.createNeighbourInfos()
mesh.createNeighborInfos()
return mesh


Expand Down Expand Up @@ -808,7 +808,7 @@ def readHydrus3dMesh(fileName='MESHTRIA.TXT'):
cells.append(c)

f.close()
mesh.createNeighbourInfos()
mesh.createNeighborInfos()
return mesh


Expand Down Expand Up @@ -969,7 +969,7 @@ def readGambitNeutral(fileName, verbose=False):
if verbose:
print("Gambit neutral file imported: ", mesh)

mesh.createNeighbourInfos()
mesh.createNeighborInfos()
return mesh


Expand Down Expand Up @@ -1023,7 +1023,7 @@ def convertHDF5Mesh(h5Mesh, group='mesh', indices='cell_indices',
for i, cell in enumerate(mesh_cells):
mesh.createCell(pg.core.IndexArray(cell), marker=int(mesh_marker[i]))

mesh.createNeighbourInfos()
mesh.createNeighborInfos()

if verbose:
print('converted mesh:', mesh)
Expand Down
12 changes: 6 additions & 6 deletions python/pygimli/mplviewer/meshview.py
Expand Up @@ -22,7 +22,7 @@ def __new__(cls):
if CellBrowserCacheSingleton.__instance is None:
CellBrowserCacheSingleton.__instance = object.__new__(cls)
return CellBrowserCacheSingleton.__instance
#
#
def add(self, c):
self.cbCache_.append(c)

Expand Down Expand Up @@ -545,7 +545,7 @@ def drawMeshBoundaries(ax, mesh, hideMesh=False, useColorMap=False,

# drawAA = True
# swatch = pg.core.Stopwatch(True)
mesh.createNeighbourInfos()
mesh.createNeighborInfos()

if not hideMesh:
drawSelectedMeshBoundaries(ax,
Expand Down Expand Up @@ -875,7 +875,7 @@ def drawField(ax, mesh, data=None, levels=[], nLevs=5,
gci = None

if len(levels) == 0:
levels = autolevel(data, nLevs,
levels = autolevel(data, nLevs,
zmin=cMin, zmax=cMax, logScale=logScale)

if len(z) == len(triangles):
Expand Down Expand Up @@ -913,7 +913,7 @@ def drawField(ax, mesh, data=None, levels=[], nLevs=5,

gci = ax.tricontourf(x, y, triangles, z, levels=levs,
**kwargs)

if contourLines:
ax.tricontour(x, y, triangles, z, levels=levels,
colors=kwargs.pop('colors', ['0.5']), **kwargs)
Expand Down Expand Up @@ -1167,11 +1167,11 @@ def drawStreams(ax, mesh, data, startStream=3, coarseMesh=None, quiver=False,
if coarseMesh is not None:
viewMesh = coarseMesh
dataMesh = mesh
dataMesh.createNeighbourInfos()
dataMesh.createNeighborInfos()
else:
viewMesh = mesh

viewMesh.createNeighbourInfos()
viewMesh.createNeighborInfos()

for c in viewMesh.cells():
c.setValid(True)
Expand Down
2 changes: 1 addition & 1 deletion python/pygimli/physics/gravimetry/gravMagModelling.py
Expand Up @@ -663,7 +663,7 @@ def solveGravimetry(mesh, dDensity=None, pnts=None, complete=False):
if pnts is None:
pnts = [[0.0, 0.0]]

mesh.createNeighbourInfos()
mesh.createNeighborInfos()

Gdg = None
Gdgz = None
Expand Down
2 changes: 1 addition & 1 deletion python/pygimli/physics/traveltime/refraction.py
Expand Up @@ -298,7 +298,7 @@
# solution.
# """
# self.mesh = mesh
# self.mesh.createNeighbourInfos()
# self.mesh.createNeighborInfos()
# self.fop.setMesh(self.mesh)
# self.fop.regionManager().setConstraintType(1)

Expand Down

0 comments on commit 10b0644

Please sign in to comment.