Quickstart

This page gets a first PETGEM forward simulation running in a few commands, using the canonical csem_model case. For the concepts behind each step see Overview; for the full walkthrough see Forward modeling examples.

Prerequisites

A working build environment with PETSc (complex scalars) and the Python helpers - see Installation. The quickest route is the provided Docker image, which ships every dependency.

Build

make

This builds build/fm.csem (forward), build/im.csem (inverse), and the unified build/petgem dispatcher.

Run the canonical forward example

# Case directory and polynomial order
export CSEM_TEST_DIR=tests/cases/csem_model
export NORD=1

# 1. Mesh
gmsh ${CSEM_TEST_DIR}/mesh_p${NORD}.geo -3 -o ${CSEM_TEST_DIR}/mesh_p${NORD}.msh

# 2. Assemble the input bundle + parameter file (forward mode)
python3 utils/preprocess.py \
   -mode forward \
   -nord ${NORD} \
   -case_dir ${CSEM_TEST_DIR} \
   -mesh_filename mesh_p${NORD}.msh \
   -receiver_filename receivers.txt \
   -source_filename sources.txt \
   -sigma_file sigmas.txt \
   -input_filename input_p${NORD}.h5 \
   -params_filename params_p${NORD}.txt

# 3. Forward modeling
mpirun -n 4 build/fm.csem \
   -options_file ${CSEM_TEST_DIR}/params_p${NORD}.txt

# 4. Validate against the reference (prints NRMSD)
python3 ${CSEM_TEST_DIR}/postprocess.py \
   -responses_filename responses_p${NORD}.h5

Step 4 prints the normalized root-mean-square deviation (NRMSD) of |Ex| against the shipped reference; values below the default tolerance (0.03) indicate a successful run.

Using the unified dispatcher

The single-purpose binaries and the petgem dispatcher run identical code paths. The forward run above is equivalent to:

mpirun -n 4 build/petgem modeling \
   -options_file ${CSEM_TEST_DIR}/params_p${NORD}.txt

For an inversion run, use -mode inverse in preprocessing and build/im.csem (or build/petgem inverse) - see Inverse modeling examples.

Next steps