This tutorial is presented as Python code running inside a Jupyter Notebook, the recommended way to use Salvus. To run it yourself you can copy/type each individual cell or directly download the full notebook, including all required files.

Layered Meshing 03: Meshing complex geophysical domains

The new "layered meshing" interface in Salvus allows us to declaratively build meshes for complex multi-layered domains. In this example we'll give an overview of how it can be used to create a mesh for a chunk of Monterey bay which includes topography, bathymetry, thin near-surface layers, and the ocean itself. We'll also use this opportunity to give a refresher on the different "policy" types, and how they interact to form our final mesh. Let's get started!
As always, the first step is to import the Salvus Python environment. Here we'll add an extra import to the canonical Salvus namespace to bring the layered meshing API into scope.
import pathlib

import numpy as np
import sympy
import xarray as xr

import salvus.namespace as sn
import salvus.mesh.layered_meshing as lm

Selecting our domain

As outlined in the 3D Surface Topography tutorial, the first thing we want to do when working with areas of Earth's surface is to define our domain. We'll be working in UTM coordinates, and a convenient way to handle coordinate conversions is to use the specialized UtmDomain.from_spherical_chunk constructor that takes WGS84 coordinates and converts them to an appropriate UTM domain. The UTM zone and coordinates could of course also be specified directly.
We choose a small box around Monterey, California, as below.
# Define our domain.
d = sn.domain.dim3.UtmDomain.from_spherical_chunk(

# Have a look at the domain to make sure it is correct.