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

Add support for planar periodic meshes #23

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

andrewdnolan
Copy link
Collaborator

@andrewdnolan andrewdnolan commented Dec 19, 2024

This PR adds support for planar periodic meshes, by streamlining and abstracting the spherical wrapping functionality so that it works to both planar and spherical meshes. For this to work, I've added getter/setter methods for the period attributes that handle the planar periodic / spherical meshes details appropriately. This has also dramatically simplified the spherical wrapping procedure, which was unduly complicated (and insufficient) previously. Testing of new the spherical wrapping for vertex patches has revealed a bug in #12, which produces invalid geometries for vertices along culled boundaries. When these invalid geometries intersect the map projection boundary, cartopy struggles with them resulting in the patches spanning the entire plot area. This bug is fixed as part of this PR. Finally, for testing purposes this PR also adds a small planar periodic mesh to the datasets database.

Fixes #15.

@andrewdnolan andrewdnolan added the enhancement New feature or request label Dec 19, 2024
@andrewdnolan andrewdnolan self-assigned this Dec 19, 2024
@andrewdnolan
Copy link
Collaborator Author

andrewdnolan commented Dec 19, 2024

Planar Periodic Testing

import mosaic
import matplotlib.pyplot as plt

def test_periodic(descriptor, ds, loc):
    fig, ax = plt.subplots()

    mosaic.polypcolor(ax, descriptor, ds.indexToCellID * 0.0, ec='k', cmap='binary')
    mosaic.polypcolor(ax, descriptor, ds[f"indexTo{loc}ID"], alpha=0.5, ec='tab:orange')

    ax.scatter(ds[f"x{loc}"], ds[f"y{loc}"], color="tab:blue")

    ax.set_title(f"{loc} Patches")


ds = mosaic.datasets.open_dataset("doubly_periodic_4x4")

descriptor = mosaic.Descriptor(ds)

for loc in ["Cell", "Edge", "Vertex"]:
    test_periodic(descriptor, ds, loc)

plt.show()

Cell patches:

Cell_periodic

Edges patches:

Edge_periodic

Vertex patches

Vertex_periodic

@andrewdnolan andrewdnolan force-pushed the periodic_planar branch 2 times, most recently from 9de3628 to b5bba02 Compare December 20, 2024 23:37
Further testing is need to move the spherical wrapping into the
new method used by planar periodic meshes.
WIP: There's debugging that's needed for vertex patches
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Planar periodic meshes are not supported
1 participant