Io module (io.h)

Functions

PetscErrorCode loadCsemInputs(fmParams *fm_params, DM *dm, Vec *conductivity, Vec *materialsID, CsemSourceSet *sources, Vec *receivers)

Loads all CSEM inputs from the unified PETGEM HDF5 bundle.

Opens fm_params->inputFile on PETSC_COMM_WORLD to load the DMPlex topology, sections, and the combined model-data vector (split into the per-cell conductivity and materials_id local Vecs). Opens the same file again on PETSC_COMM_SELF (each rank reads independently) to load:

  • /nord single-element Vec, written into fm_params->nord

  • /receivers Vec of 3·N_recv reals

  • /sources/frequency single-frequency scalar

  • /sources/position Vec of 3·N_src reals

  • /sources/current Vec of N_src reals

  • /sources/length Vec of N_src reals

  • /sources/dipAngle Vec of N_src reals

  • /sources/azimuthAngle Vec of N_src reals

Replaces the legacy importGrid + setupCsemSource + per-call receivers-file open path with a single open of the bundle produced by the Python preprocessor (utils/functions.py::writeBundle).

Loads all CSEM inputs from the unified PETGEM HDF5 bundle.

This routine reads the full simulation input file (mesh, model fields, sources, receivers, and auxiliary parameters) and reconstructs the runtime PETSc objects required by the solver.

Loading is split into two stages:

  • Phase 1 (parallel I/O): builds the DMPlex mesh, loads topology, distributes it across ranks, and reconstructs the combined per-cell model vector. This vector is then split into conductivity and material-ID fields using local sections.

  • Phase 2 (serial I/O on PETSC_COMM_SELF): reads scalar or small datasets such as /nord, receivers, and source definitions.

The function enforces consistency between the bundled data layout and the internal DM structure, and applies CLI overrides when present (e.g., -nord).

Parameters:
  • fm_params[inout] Parameters; inputFile is read, nord is written from the bundle’s /nord dataset.

  • dm[out] Loaded DMPlex mesh.

  • conductivity[out] Per-cell conductivity Vec.

  • materialsID[out] Per-cell material-id Vec.

  • sources[out] Forward transmitter set; pass NULL to skip (im.csem pulls multi-frequency sources via setupInversionSources instead).

  • receivers[out] Serial Vec of 3·N_recv receiver reals; pass NULL to skip.

  • fm_Params[inout] Runtime parameters (input file, nord, etc.).

  • odm[out] Output distributed mesh (DMPlex).

  • conductivity_output[out] Cell-wise conductivity field.

  • materials_id_output[out] Cell-wise material ID field.

  • sources[out] Source set (optional, allocated if non-NULL).

  • receivers_output[out] Receiver vector (optional, allocated if non-NULL).

Returns:

PetscErrorCode PETSC_SUCCESS on success, or a PETSc error code otherwise.

Returns:

PetscErrorCode PETSC_SUCCESS on success, or a PETSc error code otherwise.