Skip to content

Commit 5d5b190

Browse files
authored
Merge pull request #359 from xylar/add-so-rrs-meshes
Add SO and RRS meshes
2 parents 4f1231f + c817bed commit 5d5b190

File tree

27 files changed

+711
-312
lines changed

27 files changed

+711
-312
lines changed

docs/developers_guide/api.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,16 +268,20 @@ seaice/api
268268
IcosahedralMeshStep.get_cell_width
269269
```
270270

271-
### Uniform Spherical Base Mesh Step
271+
### Spherical Base Meshes
272272

273273
```{eval-rst}
274274
.. currentmodule:: polaris.mesh.base
275275
276276
.. autosummary::
277277
:toctree: generated/
278278
279-
add_uniform_spherical_base_mesh_step
279+
add_spherical_base_mesh_step
280280
get_base_mesh_steps
281+
rrs.RRSBaseMesh
282+
rrs.RRSBaseMesh.build_cell_width_lat_lon
283+
so.SOBaseMesh
284+
so.SOBaseMesh.build_cell_width_lat_lon
281285
```
282286

283287
### model_step
@@ -371,6 +375,7 @@ seaice/api
371375
:toctree: generated/
372376
373377
resolution_to_string
378+
resolution_to_string_and_units
374379
```
375380

376381
### streams

docs/developers_guide/mesh/framework.md

Lines changed: 0 additions & 147 deletions
This file was deleted.
99.4 KB
Loading
102 KB
Loading
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(dev-mesh-framework)=
2+
3+
# Mesh Framework
4+
5+
The framework for the `mesh` component provides classes and functions for
6+
creating spherical and planar mesh steps.
7+
8+
```{toctree}
9+
:titlesonly: true
10+
11+
spherical
12+
planar
13+
```
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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

Comments
 (0)