Skip to content

Commit

Permalink
fix node/element indexing to work with latest esmpy
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenworsley committed Apr 23, 2024
1 parent 922669e commit b4c2184
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions esmf_regrid/experimental/unstructured_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,17 @@ def __init__(
if location == "face":
field_kwargs = {"meshloc": esmpy.MeshLoc.ELEMENT}
shape = (len(face_node_connectivity),)
index_offset = self.esi
elif location == "node":
field_kwargs = {"meshloc": esmpy.MeshLoc.NODE}
shape = (len(node_coords),)
index_offset = self.nsi
else:
raise ValueError(
f"The mesh location '{location}' is not supported, only "
f"'face' and 'node' are supported."
)
super().__init__(
shape=shape,
index_offset=index_offset,
index_offset=1,
field_kwargs=field_kwargs,
mask=mask,
)
Expand All @@ -97,10 +95,10 @@ def _as_esmf_info(self):
# the data must be translated into a form ESMF understands
num_node = self.node_coords.shape[0]
num_elem = self.fnc.shape[0]
nodeId = np.array(range(self.nsi, self.nsi + num_node))
nodeId = np.arange(1, num_node + 1)
nodeCoord = self.node_coords.flatten()
nodeOwner = np.zeros([num_node]) # regridding currently serial
elemId = np.array(range(self.esi, self.esi + num_elem))
elemId = np.arange(1, num_elem + 1)
elemType = self.fnc.count(axis=1)
# Experiments seem to indicate that ESMF is using 0 indexing here
elemConn = self.fnc.compressed() - self.nsi
Expand Down

0 comments on commit b4c2184

Please sign in to comment.