Skip to content

Commit

Permalink
MPAS face_face_connectivity parsing (#832)
Browse files Browse the repository at this point in the history
* Added face_face parsing

* Added padding with fill values

* Update uxarray/io/_mpas.py

Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>

* Update uxarray/io/_mpas.py

Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>

* Update uxarray/io/_mpas.py

Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>

---------

Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
  • Loading branch information
aaronzedwick and philipc2 authored Jul 3, 2024
1 parent 07813fa commit b0e0651
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions uxarray/io/_mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def _primal_to_ugrid(in_ds, out_ds):
if "dcEdge" in in_ds:
_parse_edge_face_distances(in_ds, out_ds)

if "cellsOnCell" in in_ds:
_parse_face_faces(in_ds, out_ds)

# set global attributes
_parse_global_attrs(in_ds, out_ds)

Expand Down Expand Up @@ -463,6 +466,29 @@ def _parse_global_attrs(in_ds, out_ds):
out_ds.attrs = in_ds.attrs


def _parse_face_faces(in_ds, out_ds):
"""Parses face-face connectivity for Primal Mesh."""
cellsOnCell = np.array(in_ds["cellsOnCell"].values, dtype=INT_DTYPE)
nEdgesOnCell = np.array(in_ds["nEdgesOnCell"].values, dtype=INT_DTYPE)

# replace padded values with fill values
cellsOnCell = _replace_padding(cellsOnCell, nEdgesOnCell)

# replace missing/zero values with fill values
cellsOnCell = _replace_zeros(cellsOnCell)

# make zero-indexed
cellsOnCell = _to_zero_index(cellsOnCell)

face_face_connectivity = cellsOnCell

out_ds["face_face_connectivity"] = xr.DataArray(
data=face_face_connectivity,
dims=ugrid.FACE_FACE_CONNECTIVITY_DIMS,
attrs=ugrid.FACE_FACE_CONNECTIVITY_ATTRS,
)


def _replace_padding(verticesOnCell, nEdgesOnCell):
"""Replaces the padded values in verticesOnCell defined by nEdgesOnCell
with a fill-value.
Expand Down

0 comments on commit b0e0651

Please sign in to comment.