This repository contains post-processing tools for CFD simulation data from xcompact3d. The tools process ADIOS2 BP files for divergence/curl calculations, streamline visualization, contour plotting, data compression, and RMSE analysis.
- Setup
- Scripts Overview
- Usage Examples
- Output Files
- Configuration
- Known Issues
- Troubleshooting
- Contributing
You'll need to install the following system-level dependencies:
-
MPI - Required for parallel execution
-
ADIOS2 - For reading and writing .bp simulation files
- ADIOS2 Installation Guide
- Important: Make sure ADIOS2 is compiled with Python bindings and MPI support enabled
- Update your
PYTHONPATHto include ADIOS2 Python bindings
-
MGARD - For compression functionality
- MGARD Installation Guide
- Required for compression operations in
compression.py
Install the required Python packages:
pip install numpy matplotlib numpyFor a clean setup with virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install numpy matplotlib mpi4py adios2Calculate divergence and curl from velocity field data. Supports both 2D and 3D velocity fields.
Status:
Generate streamline visualizations from velocity field data.
Status:
- ✅ Works for 2D and 3D data
⚠️ Parallel processing implementation is in development
Generate contour plots for specified variables from simulation data.
Status:
- ✅ Works for both 2D and 3D modes
- ✅ Supports multiple variables
⚠️ Parallel processing implementation is in development⚠️ Probly can make it better
Compress ADIOS2 BP files using MGARD compression.
Status:
- ✅ Works with XML configuration files
⚠️ Standalone operation (without XML) is in development⚠️ Only takes in MGARD
Calculate Root Mean Square Error between two datasets (e.g., high-res vs low-res simulations).
Status:
- ✅ Functional for comparing simulation results
⚠️ Parallel processing implementation is in development
# Basic usage
mpirun -np 4 python3 divCurl.py input_file.bp 50
# With custom output file
mpirun -np 4 python3 divCurl.py input_file.bp 50 --output results.bp
# With XML configuration file
mpirun -np 4 python3 divCurl.py input_file.bp 50 --xml config.xml
# Complete example with all options
mpirun -np 4 python3 divCurl.py input_file.bp 50 --xml config.xml --output my_results.bpArguments:
input_file(required): Path to input ADIOS2 BP filemax_steps(required): Maximum number of time steps to process--xml, -x(optional): Path to ADIOS2 XML configuration file--output, -o(optional): Output file name (default:div_curl.bp)
# Basic 2D usage
python3 streamlines.py input_file.bp 20
# With XML configuration
python3 streamlines.py input_file.bp 20 --xml config.xml
python3 streamlines.py input_file.bp 20 --mode 3d --var1 ux --var2 uy --slice 16Arguments:
path(required): Path to BP file to processmax_steps(required): Maximum number of time steps to process--xml, -x(optional): ADIOS2 XML config file--mode, -m(optional): Processing mode -2d(default) or3d(experimental)--var1(optional): First velocity component for 3D mode (default:ux)--var2(optional): Second velocity component for 3D mode (default:uy)--slice, -s(optional): Slice index for 3D mode (default: 16)
# 2D contour plots for multiple variables
python3 contour.py input_file.bp --vars ux,uy,pp --max_steps 10 --mode 2d
# 3D contour plots with specific slice
python3 contour.py input_file.bp --vars ux,uy --max_steps 10 --mode 3d --slice 20
# With XML configuration
python3 contour.py input_file.bp --vars ux,uy,pp --max_steps 10 --xml config.xmlArguments:
input_file(required): Path to input ADIOS2 BP file--vars, -v(required): Variables to plot, separated by commas--max_steps, -n(required): Maximum number of timesteps to process--xml, -x(optional): Path to ADIOS2 XML configuration file--mode, -m(optional): Processing mode -2d(default) or3d--slice, -s(optional): Slice index for 3D mode (default: 16)
# With XML configuration (recommended)
python3 compression.py input_file.bp 50 --xml config.xml --output compressed.bp
# With specific error bound
python3 compression.py input_file.bp 50 --xml config.xml --errorBound 0.001 --output compressed.bpArguments:
path(required): Path to BP file to processmax_steps(required): Maximum number of time steps to process--xml, -x(optional): Path to ADIOS2 XML configuration file--errorBound, -eb(optional): Error bound for compression (default: 0 - no compression)--output, -o(optional): Output file name (default:compressed.bp)
# Compare high-res and low-res simulations
python3 RMSE.py --highres ground_truth.bp --lowres compressed.bp --var ux --max_steps 10
# Compare different variables
python3 RMSE.py --highres reference.bp --lowres test.bp --var pp --max_steps 25Arguments:
--highres(required): Path to the ground truth (high resolution) ADIOS2 file--lowres(required): Path to the lower resolution ADIOS2 file--var(required): Variable name to compare--max_steps(required): Maximum number of steps to process
Creates a new BP file (default: div_curl.bp) containing:
div: Divergence fieldcurl_x,curl_y,curl_z: Curl components (3D) orcurl_zonly (2D)
Generates PNG images in ../RESULTS/ directory:
- 2D Mode:
[base_name]_2d_streamlines_step####.png - 3D Mode:
[base_name]_3d_[var1][var2]_slice[N]_step####.png
All images use a consistent color scale based on global velocity magnitude.
Generates PNG images in ../RESULTS/ directory:
- 2D Mode:
[variable]_step_[N].png - 3D Mode:
[variable]_3d_slice_[mode]_idx[N].png
Creates a compressed BP file with MGARD compression applied to all variables.
Prints RMSE values to console for each time step processed.
If using ADIOS2 XML configuration files, ensure they include:
- Variable definitions
- Transport methods
- Compression settings (for compression.py)
- MPI settings for parallel processing
Example XML structure:
<?xml version="1.0"?>
<adios-config>
<io name="ReadIO">
<transport type="File"/>
</io>
<io name="WriteIO">
<transport type="File"/>
</io>
</adios-config>- Parallel Processing: Currently being developed for all scripts
- Compression: Standalone operation (without XML) is being implemented
- Error Handling: Improved error handling and validation being added
- MPI Integration: Some scripts need better MPI error handling
-
"Module not found" errors
- Ensure all dependencies are installed
- Verify ADIOS2 Python bindings are accessible
- Check your
PYTHONPATHincludes ADIOS2 installation
-
MPI errors
- Verify MPI installation
- Ensure mpi4py is compatible with your MPI version
- Make sure ADIOS2 was compiled with MPI support (
-DADIOS2_USE_MPI=ON)
-
File access errors
- Check file paths and permissions
- Ensure input files exist and are readable
- Verify output directories are writable
-
Memory issues
- Reduce the number of time steps (
max_steps) - Use more MPI processes to distribute memory load
- Check available system memory
- Reduce the number of time steps (
-
Compression errors
- Ensure MGARD is properly installed
- Use XML configuration files for compression
- Check error bound values are reasonable
- Use appropriate number of MPI processes for your system
- Process data in chunks if memory is limited
- Use XML configuration files for better performance
- Monitor system resources during processing
This project is under active development. Current development priorities:
-
High Priority:
- Parallel processing implementation across all scripts
- Standalone compression functionality
-
Medium Priority:
- Enhanced error handling and validation
- Performance optimizations
- Better documentation and examples
-
Low Priority:
- commets in code
- Follow existing code style and structure
- Add appropriate error handling
- Include documentation for new features
- Test with various data sizes and MPI configurations
- Update README when adding new functionality
For bug reports or feature requests, please create an issue with detailed information about your system configuration and the specific problem encountered.