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

Mesh Laplacian computation #4187

Merged
merged 17 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions .pytest_cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
daniel-unyi-42 marked this conversation as resolved.
Show resolved Hide resolved
22 changes: 9 additions & 13 deletions torch_geometric/utils/get_mesh_laplacian.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def get_mesh_laplacian(pos: Tensor, face: Tensor) -> Tuple[Tensor, Tensor]:
:obj:`pos` and :obj:`face`. It is computed as

.. math::

\mathbf{L}_{ij} = \begin{cases}
\frac{\cot \angle_{ikj} + \cot \angle_{ilj}}{2 a_{ij}} &
\mbox{if } i, j \mbox{ is an edge,} \\
Expand Down Expand Up @@ -54,19 +53,16 @@ def add_angles(left, centre, right):
area_weight = torch.cat(
[area_201, area_201, area_012, area_012, area_120, area_120])
edge_index = torch.cat([
torch.stack([face[2], face[1]], dim=1),
torch.stack([face[1], face[2]], dim=1),
torch.stack([face[0], face[2]], dim=1),
torch.stack([face[2], face[0]], dim=1),
torch.stack([face[1], face[0]], dim=1),
torch.stack([face[0], face[1]], dim=1)
])

cot_edge_index, cot_weight = coalesce(edge_index.t(), cot_weight)
area_edge_index, area_weight = coalesce(edge_index.t(), area_weight)
torch.stack([face[2], face[1]], dim=0),
torch.stack([face[1], face[2]], dim=0),
torch.stack([face[0], face[2]], dim=0),
torch.stack([face[2], face[0]], dim=0),
torch.stack([face[1], face[0]], dim=0),
torch.stack([face[0], face[1]], dim=0)
], dim=1)

assert torch.all(cot_edge_index == area_edge_index)
edge_index = cot_edge_index
_, cot_weight = coalesce(edge_index, cot_weight)
edge_index, area_weight = coalesce(edge_index, area_weight)

# compute the diagonal part
row, col = edge_index
Expand Down