Skip to content

Commit 20a7087

Browse files
authored
Merge pull request #305 from xylar/add-mesh-component
Add a `mesh` component
2 parents 12bd3dc + 6c44e99 commit 20a7087

File tree

72 files changed

+569
-405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+569
-405
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
]
4949

5050
autosummary_generate = ['developers_guide/api.md',
51-
# 'developers_guide/landice/api.md',
51+
'developers_guide/mesh/api.md',
5252
'developers_guide/ocean/api.md',
5353
'developers_guide/seaice/api.md']
5454

docs/developers_guide/api.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ documentation.
1212
:maxdepth: 1
1313
:titlesonly: true
1414
15+
mesh/api
1516
ocean/api
1617
seaice/api
1718
```
@@ -187,18 +188,6 @@ seaice/api
187188
ModelStep.partition
188189
```
189190

190-
### components
191-
192-
```{eval-rst}
193-
.. currentmodule:: polaris.tasks
194-
195-
.. autosummary::
196-
:toctree: generated/
197-
198-
get_components
199-
```
200-
201-
202191
### config
203192

204193
```{eval-rst}
@@ -277,6 +266,17 @@ seaice/api
277266
IcosahedralMeshStep.get_cell_width
278267
```
279268

269+
### Uniform Spherical Base Mesh Step
270+
271+
```{eval-rst}
272+
.. currentmodule:: polaris.mesh.add_step
273+
274+
.. autosummary::
275+
:toctree: generated/
276+
277+
add_uniform_spherical_base_mesh_step
278+
```
279+
280280
### model_step
281281

282282
```{eval-rst}
@@ -353,6 +353,16 @@ seaice/api
353353
MappingFileStep.run
354354
```
355355

356+
### resolution
357+
358+
```{eval-rst}
359+
.. currentmodule:: polaris.resolution
360+
361+
.. autosummary::
362+
:toctree: generated/
363+
364+
resolution_to_string
365+
```
356366

357367
### streams
358368

docs/developers_guide/framework/config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ resolution's work directory:
101101

102102
```python
103103
from polaris.config import PolarisConfigParser
104-
from polaris.ocean.resolution import resolution_to_subdir
104+
from polaris.resolution import resolution_to_string
105105
from polaris.tasks.ocean.baroclinic_channel.default import Default
106106
from polaris.tasks.ocean.baroclinic_channel.init import Init
107107
from polaris.tasks.ocean.baroclinic_channel.rpe import Rpe
108108

109109

110110
def add_baroclinic_channel_tasks(component):
111111
for resolution in [10., 4., 1.]:
112-
resdir = resolution_to_subdir(resolution)
112+
resdir = resolution_to_string(resolution)
113113
resdir = f'planar/baroclinic_channel/{resdir}'
114114

115115
config_filename = 'baroclinic_channel.cfg'

docs/developers_guide/framework/index.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@
22

33
# Framework
44

5-
All of the {ref}`dev-packages` that are not in the two components (`ocean`
5+
All of the {ref}`dev-packages` that are not in the components (`mesh`, `ocean`
66
and `seaice`) belong to the polaris framework. Some of these
77
modules and packages are used by the {ref}`dev-command-line`, while others are
88
meant to be called within tasks and steps to simplify tasks like adding
99
input and output files, downloading data sets, building up config files,
10-
yaml files, namelists and streams files, setting up and running the E3SM
11-
component, and verifying the output by comparing steps with one another or
10+
yaml files, namelists and streams files, setting up and running the E3SM
11+
component, and verifying the output by comparing steps with one another or
1212
against a baseline.
1313

14+
The framework is organized to separate tasks and shared framework code. Tasks
15+
for each component are located in `polaris.tasks.<component>`, while shared
16+
framework code (e.g., config files, YAML files, utilities) is located in
17+
`polaris.<component>`. This separation ensures clarity and avoids circular
18+
dependencies.
19+
1420
```{toctree}
1521
:titlesonly: true
1622
1723
commands
1824
config
1925
logging
2026
io
21-
mesh
2227
mpas
2328
model
2429
provenance

docs/developers_guide/mesh/api.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# mesh
2+
3+
```{eval-rst}
4+
.. currentmodule:: polaris.tasks.mesh.add_tasks
5+
6+
.. autosummary::
7+
:toctree: generated/
8+
9+
add_mesh_tasks
10+
```
11+
12+
## Tasks
13+
14+
### Base Mesh Tasks
15+
16+
```{eval-rst}
17+
.. currentmodule:: polaris.tasks.mesh.base
18+
19+
.. autosummary::
20+
:toctree: generated/
21+
22+
add_base_mesh_tasks
23+
24+
BaseMeshTask
25+
```

docs/developers_guide/framework/mesh.md renamed to docs/developers_guide/mesh/framework.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
(dev-mesh)=
1+
(dev-mesh-framework)=
22

3-
# Mesh
3+
# Mesh Framework
44

55
(dev-spherical-meshes)=
66

@@ -81,7 +81,7 @@ vtk_lat_lon = False
8181
## Planar Meshes
8282

8383
So far, there is not support for creating planar meshes in the polaris
84-
framework. But there are helpful functions for creating both
84+
framework. But there are helpful functions for creating both
8585
[uniform hexagonal meshes](http://mpas-dev.github.io/MPAS-Tools/stable/mesh_creation.html#uniform-planar-meshes)
8686
and [more general planar meshes](http://mpas-dev.github.io/MPAS-Tools/stable/mesh_creation.html#planar-meshes)
8787
using the [mpas_tools](http://mpas-dev.github.io/MPAS-Tools/stable/index.html)
@@ -91,12 +91,12 @@ package.
9191

9292
You can build a uniform planar mesh in a step by calling
9393
{py:func}`mpas_tools.planar_hex.make_planar_hex_mesh()`. The mesh is defined
94-
by the number of cells in the x and y directions (`nx` and `ny`), the
94+
by the number of cells in the x and y directions (`nx` and `ny`), the
9595
resolution `dc` in km (`dc` is the distance between adjacent cell centers),
9696
and some (admittedly oddly named) parameters for determining which directions
9797
(if any) are periodic, `nonperiodic_x` and `nonperiodic_y`.
9898

99-
There are a few considerations for determining `nx` and `ny`. There is a
99+
There are a few considerations for determining `nx` and `ny`. There is a
100100
framework level function {py:func}`polaris.mesh.planar.compute_planar_hex_nx_ny()`
101101
to take care of this for you:
102102

@@ -108,16 +108,16 @@ nx, ny = compute_planar_hex_nx_ny(lx, ly, resolution)
108108
```
109109

110110
What follows is an explanation of the subtleties that are accounted for in that
111-
function. Typically, we need at least 4 grid cells in each direction for
112-
MPAS-Ocean to be well behaved, and similar restrictions may apply to other
113-
components. Second, `ny` needs to be an even number because of the staggering
114-
of the hexagons used to create the mesh. (We typically also use even numbers
111+
function. Typically, we need at least 4 grid cells in each direction for
112+
MPAS-Ocean to be well behaved, and similar restrictions may apply to other
113+
components. Second, `ny` needs to be an even number because of the staggering
114+
of the hexagons used to create the mesh. (We typically also use even numbers
115115
for `nx` but that is not strictly necessary.)
116116

117117
Another important consideration is that the physical size of the mesh in the x
118-
direction is `lx = nx * dc`. However, the physical extent in the y direction
118+
direction is `lx = nx * dc`. However, the physical extent in the y direction
119119
is `ly = (np.sqrt(3) / 2) * ny * dc` because of the staggering of the hexagons
120-
in that direction. As a result, if you know the desired domain size `ly`,
120+
in that direction. As a result, if you know the desired domain size `ly`,
121121
you need to compute the number of cells in that direction including an extra
122122
factor of `2. / np.sqrt(3)`, as in this example:
123123
```python
@@ -139,9 +139,9 @@ ds_mesh = make_planar_hex_mesh(nx=nx, ny=ny, dc=dc, nonperiodic_x=False,
139139
### General planar meshes
140140

141141
One way to create a more general planar mesh is by calling
142-
{py:func}`mpas_tools.mesh.creation.build_mesh.build_planar_mesh()`, which uses
142+
{py:func}`mpas_tools.mesh.creation.build_mesh.build_planar_mesh()`, which uses
143143
JIGSAW to build a mesh with variable resolution. See
144144
[Planar Meshes](http://mpas-dev.github.io/MPAS-Tools/stable/mesh_creation.html#planar-meshes)
145-
for more details. We plan to create framework-level steps for planar meshes
145+
for more details. We plan to create framework-level steps for planar meshes
146146
similar to {py:class}`polaris.mesh.QuasiUniformSphericalMeshStep` and
147147
{py:class}`polaris.mesh.IcosahedralMeshStep` in the not too distant future.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(dev-mesh)=
2+
3+
# Mesh component
4+
5+
The `mesh` component defines tasks and steps related to generating and
6+
manipulating MPAS meshes. There are currently no component-level config
7+
options.
8+
9+
```{toctree}
10+
:titlesonly: true
11+
12+
tasks/index
13+
framework
14+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
(dev-mesh-base)=
2+
3+
# Base Mesh Task
4+
5+
The the base mesh tasks defined by {py:class}`polaris.tasks.mesh.base.BaseMeshTask`
6+
can be used to generate quasi-uniform (`qu`) and subdivided icosahedral
7+
(`icos`) spherical meshes at quasi-uniform resolutions ranging from 30 to 480
8+
km. These "base" meshes cover the full sphere (include both continents and
9+
ocean regions).
10+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(dev-mesh-tasks)=
2+
3+
# Tasks
4+
5+
```{toctree}
6+
:titlesonly: true
7+
8+
base
9+
```

docs/developers_guide/ocean/api.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
:toctree: generated/
88
99
Ocean
10+
11+
add_tasks.add_ocean_tasks
1012
```
1113

1214
## Tasks
@@ -394,16 +396,6 @@
394396
get_time_interval_string
395397
```
396398

397-
### Spherical Base Mesh Step
398-
399-
```{eval-rst}
400-
.. currentmodule:: polaris.ocean.mesh.spherical
401-
402-
.. autosummary::
403-
:toctree: generated/
404-
405-
add_spherical_base_mesh_step
406-
```
407399

408400
### Reference Potential Energy (RPE)
409401

0 commit comments

Comments
 (0)