|
| 1 | +(dev-planar-meshes)= |
| 2 | + |
| 3 | +# Planar Meshes |
| 4 | + |
| 5 | +So far, there is not support for creating planar meshes in the polaris |
| 6 | +framework. But there are helpful functions for creating both |
| 7 | +[uniform hexagonal meshes](https://mpas-dev.github.io/MPAS-Tools/stable/mesh_creation.html#uniform-planar-meshes) |
| 8 | +and [more general planar meshes](https://mpas-dev.github.io/MPAS-Tools/stable/mesh_creation.html#planar-meshes) |
| 9 | +using the [mpas_tools](https://mpas-dev.github.io/MPAS-Tools/stable/index.html) |
| 10 | +package. |
| 11 | + |
| 12 | +## Uniform planar meshes |
| 13 | + |
| 14 | +You can build a uniform planar mesh in a step by calling |
| 15 | +{py:func}`mpas_tools.planar_hex.make_planar_hex_mesh()`. The mesh is defined |
| 16 | +by the number of cells in the x and y directions (`nx` and `ny`), the |
| 17 | +resolution `dc` in km (`dc` is the distance between adjacent cell centers), |
| 18 | +and some (admittedly oddly named) parameters for determining which directions |
| 19 | +(if any) are periodic, `nonperiodic_x` and `nonperiodic_y`. |
| 20 | + |
| 21 | +There are a few considerations for determining `nx` and `ny`. There is a |
| 22 | +framework level function {py:func}`polaris.mesh.planar.compute_planar_hex_nx_ny()` |
| 23 | +to take care of this for you: |
| 24 | + |
| 25 | +```python |
| 26 | +from polaris.mesh.planar import compute_planar_hex_nx_ny |
| 27 | + |
| 28 | + |
| 29 | +nx, ny = compute_planar_hex_nx_ny(lx, ly, resolution) |
| 30 | +``` |
| 31 | + |
| 32 | +What follows is an explanation of the subtleties that are accounted for in that |
| 33 | +function. Typically, we need at least 4 grid cells in each direction for |
| 34 | +MPAS-Ocean to be well behaved, and similar restrictions may apply to other |
| 35 | +components. Second, `ny` needs to be an even number because of the staggering |
| 36 | +of the hexagons used to create the mesh. (We typically also use even numbers |
| 37 | +for `nx` but that is not strictly necessary.) |
| 38 | + |
| 39 | +Another important consideration is that the physical size of the mesh in the x |
| 40 | +direction is `lx = nx * dc`. However, the physical extent in the y direction |
| 41 | +is `ly = (np.sqrt(3) / 2) * ny * dc` because of the staggering of the hexagons |
| 42 | +in that direction. As a result, if you know the desired domain size `ly`, |
| 43 | +you need to compute the number of cells in that direction including an extra |
| 44 | +factor of `2. / np.sqrt(3)`, as in this example: |
| 45 | +```python |
| 46 | +import numpy as np |
| 47 | +from mpas_tools.planar_hex import make_planar_hex_mesh |
| 48 | + |
| 49 | +lx = 500e3 |
| 50 | +ly = 160e3 |
| 51 | +dc = 1e3 |
| 52 | + |
| 53 | +nx = max(2 * int(0.5 * lx / dc + 0.5), 4) |
| 54 | +# factor of 2/sqrt(3) because of hexagonal mesh |
| 55 | +ny = max(2 * int(0.5 * ly * (2. / np.sqrt(3)) / dc + 0.5), 4) |
| 56 | + |
| 57 | +ds_mesh = make_planar_hex_mesh(nx=nx, ny=ny, dc=dc, nonperiodic_x=False, |
| 58 | + nonperiodic_y=True) |
| 59 | +``` |
| 60 | + |
| 61 | +## General planar meshes |
| 62 | + |
| 63 | +One way to create a more general planar mesh is by calling |
| 64 | +{py:func}`mpas_tools.mesh.creation.build_mesh.build_planar_mesh()`, which uses |
| 65 | +JIGSAW to build a mesh with variable resolution. See |
| 66 | +[Planar Meshes](https://mpas-dev.github.io/MPAS-Tools/stable/mesh_creation.html#planar-meshes) |
| 67 | +for more details. We plan to create framework-level steps for planar meshes |
| 68 | +similar to {py:class}`polaris.mesh.QuasiUniformSphericalMeshStep` and |
| 69 | +{py:class}`polaris.mesh.IcosahedralMeshStep` in the not too distant future. |
0 commit comments