Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing delaunay and voronoi generators #2664

Merged
merged 16 commits into from
Jan 19, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updating Delauny to use skgraphs delaunay
  • Loading branch information
jgostick committed Dec 20, 2022
commit c3dc2c0e5462e094f6471a6674e6982ce3ac3597
15 changes: 8 additions & 7 deletions openpnm/network/_delaunay.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from openpnm.network import Network
from openpnm.utils import Docorator
from openpnm._skgraph.generators import voronoi_delaunay_dual, tools
from openpnm._skgraph.generators import voronoi_delaunay_dual, delaunay, tools
from openpnm._skgraph.tools import isoutside
from openpnm._skgraph.operations import trim_nodes

Expand Down Expand Up @@ -52,16 +52,17 @@ class Delaunay(Network):
def __init__(self, shape, points, reflect=True, trim=True, **kwargs):
super().__init__(**kwargs)
points = tools.parse_points(shape=shape, points=points, reflect=reflect)
net, vor, tri = voronoi_delaunay_dual(points=points,
shape=shape,
trim=trim,
node_prefix='pore',
edge_prefix='throat')
net = trim_nodes(network=net, inds=np.where(net['pore.voronoi'])[0])
net, tri = delaunay(points=points,
shape=shape,
node_prefix='pore',
edge_prefix='throat')
self.update(net)


if __name__ == "__main__":
import openpnm as op
dn = Delaunay(shape=[2, 0], points=1000, reflect=True, trim=True)
op.visualization.plot_connections(dn)
pts = np.random.rand(500, 2)
dn = Delaunay(points=pts, shape=[1, 1, 0])
op.visualization.plot_connections(dn)