NOAA-ORR-ERD / gridded

A single API for accessing / working with gridded model results on multiple grid types
https://noaa-orr-erd.github.io/gridded/index.html
The Unlicense
64 stars 14 forks source link

Dual node mesh #62

Open Chilipp opened 3 years ago

Chilipp commented 3 years ago

This PR is a follow-up of #61 and adds the algorithm to compute the dual mesh for the nodes. It uses the functionalities from #61 (which is why it's a draft PR so far) such that we create the dual mesh for the nodes from the dual mesh for the edges. Roughly spoken, it works like this:

  1. create the dual edge mesh
  2. create a node_edge_connectivity (similarly to the algorithm proposed by @Huite for the edge_face_connectivity in https://github.com/NOAA-ORR-ERD/gridded/pull/61#issuecomment-762313944)
  3. for each edge in this node_edge_connectivity: if the cell in the corresponding dual edge mesh is triangular, add the center of the edge as another node.
  4. sort the edges in the dual cells such that they build a chain

The anti-clockwise ordering results from the anti-clockwise ordering of the dual edge mesh.

I head to use cython for step 3 and 4 as I did not know how to best vectorize this.