Mesh transformation utilities for FEMTIC-based magnetotelluric inverse modeling.
MeshTran is an open-source preprocessing toolkit designed to prepare spatial data and computational domains for the Finite Element Magnetotelluric Inversion Code, FEMTIC (Y. Usui, 2015). The objective of this project is not to replace FEMTIC utilities, but to provide a structured preprocessing layer that simplifies coordinate transformations, domain definition, and mesh preparation steps commonly required before running large-scale MT inversions.
The toolkit focuses on reproducible preparation of FEMTIC input files from observational data and geospatial datasets. In particular, MeshTran aims to reduce the complexity of preparing the FEMTIC preprocessing input data by allowing most mesh preparation steps to be controlled from a single configuration file.
MeshTran is also designed as a component of the broader MTIF (Magnetotelluric Inversion Framework) ecosystem, where it acts as the geometry and preprocessing layer prior to running the inversion workflow.
Current utilities support the following preprocessing tasks:
- Reading MT station information from EDI files
- Coordinate transformation (latitude/longitude → UTM → mesh coordinates)
- Domain centering and coordinate normalization
- DEM and bathymetry integration
- Automated generation of FEMTIC input files
- Preparation of geometry and inputs for
makeTetraMeshandTetGen - Simplified configuration of FEMTIC meshing parameters
- Basic validation utilities for domain consistency
A key goal of MeshTran is to simplify FEMTIC mesh configuration. Instead of manually editing multiple preprocessing files, users can define the required parameters in a single configuration input, from which MeshTran generates the corresponding FEMTIC input files.
The typical preprocessing pipeline implemented in MeshTran follows these steps:
- Reading configuration file
- Read DEM and EDI files, extracting latitude, longitude, and elevation
- 1.1 For the stydy cases involves sea, extracting coast line
- 1.2 Performing the ray casting algorithm to land-sea classification
- Convert geographic coordinates from DEM and EDI files to kilometers UTM coordinates
- Transform coordinates into the local mesh reference system
- Read from EDI files, impedance tensor data and choose the error floor or assigned error must be applied to the data
- Write observe data file.
- Validate domain coverage with DEM and asign padding constraints to land only cases.
- Define the computational analysis domain in local mesh coordinates
- Writing topography, bathymetry and coast line files.
- Writing files for surface refinement at site zones and two-dimensional surface mesh
- Generating volumetric refinement file below site zones and file for volumetric iterative refinement.
- Writing files for model parameter mesh getting resistivity_attr file.
- Running a wrapper of makeTetraMesh
- Run wrapped
TetGento get volumetric mesh in*.ele,*.edge,*.node,*.faceand.neighfiles. - Running iterative refinement
- Running wrapped
TetGen2Femtic - Generating input files ready for FEMTIC inversion
observe.dat
control.dat→ (surface mesh)topography.datbathymetry.datcoastline.datobserving_site.datanalysis_domain.dat
makeMtr.paramobs_site.dat
output.X.nodeoutput.X.eleoutput.X.faceoutput.X.neighresistivity_attr.dat
resistivity_block_iter0.datmesh.datoutput.*.femtic.vtk
The control.dat file (not generated by MeshTran), which defines the inversion parameters, should be created manually according to the desired configuration.
The repository is organized as follows:
MeshTran/
├─ Makefile
├── readme.md
├── computing
├── meshTran (executable must be compiled)
├── mod
├── set_meshtran.io
│
├── preprocessing
│ ├── buildMesh
│ ├── DEM
│ ├── edi_files
│ └── geometry
│
└── src
├── mesh_config.f90
├── mesh_entities.f90
└── meshTranFemtic.f90
The structure may evolve as the project matures.
A minimal preprocessing workflow using MeshTran follows these steps:
-
Put the
DEM.xyzandEDI filesinpreprocessing/folder -
Provide a configuration file (
*.io) setting the dataset and meshing parameters. -
Compile MeshTran by running:
make
-
Run the MeshTran preprocessing workflow by:
./meshTran
-
Generate FEMTIC input files in
computing/after meshtran execution.
By these simple steps it processes station data, prepares the computational domain, and generates the required FEMTIC preprocessing files.
See the MeshTran Wiki for a detailed example configuration file and guides on mesh quality, coastline extraction, and advanced workflow configuration.
MeshTran is designed to function as a preprocessing component within the MTIF (Magnetotelluric Inversion Framework).
Within MTIF, configuration is typically handled using structured configuration files (e.g. TOML), which are more expressive and easier to maintain than the traditional FEMTIC plaintext input files. MeshTran acts as the intermediate layer that translates these higher-level configuration parameters into the FEMTIC input format required by the meshing and inversion pipeline.
MeshTran is a Linux tool. At build time it only links against the Intel
toolchain below; all geometry/topography processing is delegated to external
CLI tools invoked as subprocesses via Fortran's execute_command_line, which
must be available on $PATH.
- Intel OneAPI HPC Toolkit 2024.0
- Intel ifort 2021.11.1 20231117 (included in the OneAPI described above)
- Intel MKL 2024.0
| Tool | Version Tested | Used For |
|---|---|---|
gdal_contour |
GDAL 3.9.3 (2024-10-07) | Coastline contour extraction from DEM (GeoJSON) |
jq |
1.7.1 | Parse coastline GeoJSON into coordinate CSV |
ogr2ogr |
GDAL 3.9.3 (2024-10-07) | Convert line geometry to Shapefile |
ogrinfo |
GDAL 3.9.3 (2024-10-07) | Inspect Shapefile attributes and IDs |
gnuplot |
6.0 patchlevel 1 | Diagnostic visualization of DEM and coastline |
TetGen |
1.5 (2013-11-04) | Tetrahedral mesh generation |
- tetGen2Femtic v1.0
- makeTetraMesh v1.3
- makeMtr v1.0
The TetGen execution parameters can be modified and MeshTran must be recompiled if different meshing behavior is desired.
This project is currently under active development. And it already covers the necessary preprocessing steps required to generate the input files needed to run land-only and land-sea magnetotelluric inversion models with FEMTIC.
Interfaces and utilities may evolve as the preprocessing workflow matures. The code is primarily developed to support FEMTIC-based magnetotelluric inversion model research.
Due to the nature of its underlying system calls, MeshTran is a tool focused
primarily on Linux and macOS (Unix-like systems). For Windows users, a Docker
container is planned to be implemented in the future.
If you use MeshTran, please cite the software using the GitHub "Cite this repository" button or the DOI assigned by Zenodo.