Skip to content

lmengel422/FVCOM-Grid-Generation

Repository files navigation

FVCOM Grid Generation

Utilities and examples for generating 2D Gmsh meshes, including adaptive coastal meshes suitable for FVCOM-style workflows.

What is in this repo

  • basic_mesh_example.py: builds a simple rectangular mesh and writes rectangle_mesh.msh.
  • adaptive_mesh_example.py: builds a rectangle with spatially varying target element size and writes adaptive_mesh.msh.
  • coastal_bathy_adaptive_mesh.py: builds a coastal ocean mesh with refinement near shoreline and shallow bathymetry.
  • load_mesh.py: loads a .msh file, reconstructs coordinates, and plots the mesh over a basemap.

Requirements

  • Python 3.10+
  • Internet access for first-time coastal data downloads
  • Gmsh desktop application (https://gmsh.info/) if you want to open meshes in the Gmsh GUI interface

Install Python dependencies:

python -m pip install -r requirements.txt

Quick start

Run the simple examples:

python basic_mesh_example.py
python adaptive_mesh_example.py

These produce:

  • rectangle_mesh.msh
  • adaptive_mesh.msh

Coastal adaptive mesh generation

Run interactively and enter coordinates at prompts (press Enter after each value):

python coastal_bathy_adaptive_mesh.py

Prompt sequence:

  • Enter lat-min:
  • Enter lat-max:
  • Enter lon-min:
  • Enter lon-max:

You can also pass coordinates directly with flags:

python coastal_bathy_adaptive_mesh.py --lat-min 44.8 --lat-max 52.0 --lon-min -129.0 --lon-max -121.0

Optional arguments:

  • --output-mesh: output mesh filename (default: coastal_adaptive_mesh.msh)
  • --cache-dir: cache directory for downloaded data (default: mesh_cache)
  • --show-gui: open the Gmsh GUI after mesh generation

Outputs:

  • coastal_adaptive_mesh.msh
  • coastal_adaptive_mesh.json (projection sidecar used for back-projection in plotting)
  • Download/cache files under mesh_cache/

Visualize a generated mesh

By default, load_mesh.py reads coastal_adaptive_mesh.msh and saves a map image:

python load_mesh.py

Output:

  • mesh_map.png

Notes

  • The first coastal run downloads global bathymetry and Natural Earth land polygons; later runs reuse cached files.
  • If plotting a projected coastal mesh, keep the .json sidecar next to the .msh file so coordinates can be converted back to lon/lat.

Attribution

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages