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

DRAFT: Add face_edge_signs #938

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions uxarray/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,18 @@ def face_areas(self) -> xr.DataArray:
)
return self._ds["face_areas"]

@property
def face_edge_signs(self) -> xr.DataArray:
"""The sign of the edges for each face.

TODO:
"""

if "face_edge_signs" not in self._ds:
self._ds["face_edge_signs"] = ...

return self._ds["face_edge_signs"]

@property
def bounds(self):
"""Latitude Longitude Bounds for each Face in degrees.
Expand Down
29 changes: 29 additions & 0 deletions uxarray/grid/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,3 +912,32 @@ def _construct_edge_face_distances(node_lon, node_lat, edge_faces):
)

return edge_face_distances


def _populate_face_edge_signs(grid):
face_edge_signs = _construct_face_edge_signs(
grid.face_edge_connectivity.values,
grid.edge_face_connectivity.valuies,
)

return face_edge_signs


@njit
def _construct_face_edge_signs(
face_edge_connectivity, edge_face_connectivity, n_face, n_edge, n_max_face_edges
):
# construct empty array to store face edge signs
face_edge_signs = np.zeros_like(face_edge_connectivity)

for edge_idx in range(n_edge):
edges_0 = face_edge_connectivity[edge_face_connectivity[edge_idx, 0]]
edges_1 = face_edge_connectivity[edge_face_connectivity[edge_idx, 1]]

index_j0 = np.where(edges_0 == edge_idx)[0][0]
index_j1 = np.where(edges_1 == edge_idx)[0][0]

face_edge_signs[edge_face_connectivity[edge_idx, index_j0]] = 1
face_edge_signs[edge_face_connectivity[edge_idx, index_j1]] = 1

pass
Loading