Skip to main content

Immersed Boundary Support

DevitoHorizon supports immersed-boundary conditions for topography-aware modelling using the Schism support in recipes.

Overview

Immersed boundaries allow you to model topographic free surfaces without the need for a staircased grid. Instead, a signed distance function (SDF) is used to represent the boundary geometry, which is then handled explicitly by the wave equation solver.

Requirements

  • Schism package: Immersed-boundary support requires the Schism-enabled recipes environment used by your DevitoPro installation
  • SDF data: A signed distance function discretized on the same grid as your velocity model

Usage

1. Prepare Your Data

You need two key inputs: - Velocity model: Standard SEGY file with velocity data (e.g., Model94-velocity_smooth_dx12_elev.sgy) - SDF: SEGY file containing the signed distance function (e.g., Model94-sdf_dx12_elev.sgy)

The SDF should be: - Discretized on the same grid as the velocity model - Negative values inside the domain (below the surface) - Positive values outside the domain (above the surface) - Zero at the topographic surface - Calculated to a radius of space_order * max(spacing) from the surface - Flood-filled in the interior region

2. Configure Your Parameters

Add the SDF to your model configuration:

param = {
    'f0': 0.015,                # Peak frequency in kHz
    'nbl': 40,                  # Absorbing boundary layer thickness
    'space_order': 8,           # Spatial discretization order
    'model': {
        'vp': '/path/to/velocity.sgy',
        'sdf': '/path/to/sdf.sgy'    # Add the SDF here
    }
}

3. Load the Model

The model loading process automatically detects and loads the SDF:

from devitohorizon.model import load_model

model = load_model(param)

# Check if SDF was loaded
if hasattr(model, 'sdf'):
    print(f"SDF loaded: {model.sdf.data.shape}")

4. Run Inversion/Migration

The SDF is automatically passed to the recipes solver, which handles the immersed boundary:

from devitohorizon.inversion import FWIObjective

objective = FWIObjective(param=param, options={'method': 'SPG', 'batch_size': 4})
model_opt, f_opt, result = objective.run(maxiter=1)

Implementation Details

Model Loading

The load_model_segy function in devitohorizon/model/io.py handles SDF loading:

  1. The SDF is loaded from the SEGY file using pysegy
  2. No unit conversions are applied to the SDF (it’s already in meters)
  3. The SDF is NOT squeezed to a scalar even if uniform (unlike velocity)
  4. The SDF is passed to WaveModel via **kwargs

Model Dumping

The SDF is saved with the model, as one more parameter file:

from devitohorizon.model import dump_model_segy

spec = dump_model_segy(param, 'output_model', model)
# {'vp': 'output_model_vp.segy', ..., 'sdf': 'output_model_sdf.segy'}

dump_model_segy writes every physical parameter as its own SEG-Y and adds the SDF when the model carries one, so the returned specification reads the whole model – immersed boundary included – back through load_model.

Gradient Computation

The immersed boundary is transparent to the gradient computation:

  1. The forward operator uses the SDF to impose free-surface conditions at the topography
  2. The adjoint operator respects the same boundary
  3. No special handling is needed in user code

Example: BP1994 Dataset

See demos/immersed_boundary_bp1994.ipynb for a complete BP1994 example:

import numpy as np
from devitohorizon.data import Dataset
from devitohorizon.model import dump_model_segy, load_model
from devitohorizon.physics import DevitoPhysics

# Configure with SDF
param = {
    'data_path': '/data/BP1994/allshots_noshift_hdrs_5s.sgy',
    'f0': 0.015,
    'nbl': 40,
    'space_order': 8,
    'model': {
        'vp': '/data/BP1994/Model94-velocity_smooth_dx12_elev.sgy',
        'sdf': '/data/BP1994/Model94-sdf_dx12_elev.sgy'
    }
}

# Load model with immersed boundary
model = load_model(param)

# Verify SDF is loaded
print(f"SDF range: [{np.min(model.sdf.data):.2f}, {np.max(model.sdf.data):.2f}]")

# Create dataset + physics and evaluate one shot
dataset = Dataset.from_segy(param['data_path'])
physics = DevitoPhysics(
    model=model,
    nbl=param['nbl'],
    space_order=param['space_order'],
    wavelet={'type': 'ricker', 'f0': param['f0']},
)

shot = dataset[0]
result = physics.compute_shot_gradient(shot)
print(f"Shot misfit: {result['misfit']:.6e}")

# Optional: persist the model including the SDF
dump_model_segy(param, 'model', model)

Notes and Limitations

  1. Material Properties: Continue material properties (velocity, etc.) through the surface. The immersed boundary imposes the free-surface condition explicitly, so there’s no need for a material contrast at the surface.

  2. Grid Orientation: The recipes immersed boundary assumes that the z-axis points downwards (increasing depth).

  3. SDF Padding: The SDF should be extruded into the padding region like any other material parameter.

  4. Performance: Immersed boundaries add some computational cost compared to flat free surfaces, but allow for accurate topography modeling without grid staircasing.

Troubleshooting

Error: “Immersed boundary functionality requires Schism to be installed” - Ensure you are using the Schism-enabled recipes installation required by your DevitoPro environment - Verify that the immersed-boundary operators are available in that environment before running production jobs

SDF not loaded - Check that the SDF file path is correct in your param dict - Verify the SDF file exists and is readable - Ensure the SDF is in SEGY format with the same grid as your velocity model

Boundary artifacts in results - Verify your SDF is correctly flood-filled in the interior - Check that the SDF calculation radius is sufficient (space_order * max(spacing)) - Ensure material properties are continuous through the surface

References

  • Immersed Boundary Method: Liu et al., 2019
  • Schism Documentation: See devitopro-woodside/schism/README.md
  • Example notebook: demos/immersed_boundary_bp1994.ipynb
Back to top