This repository contains a C-based implementation of a Meshless Method for solving the Navier-Stokes equations. The solver utilizes a radial basis function (RBF) based meshless approach with optional multicore CPU acceleration using OpenACC.
- Implementing various boundary conditions
- Extending OpenACC pragmas to implement GPU acceleration.
- A multigrid (multi-level) accelerated Navier Stokes solver to achieve steady state using TIMPLE in meshless framework
- A compressible flow solver
- The meshless (first and second derivative matrices) Dx, Dy, Dz, and Laplacian matrices for a Gmsh ASCII (version 2) .msh file implemented.
- Poly Harmonic Spline Radial Basis Function with appended polynomials implemented. ( MULTIQUADRICS AND GAUSSIAN IN-WORK )
- Local Interpolation with point clouds identified through a kd-tree algorithm
- Heat conduction problem added with multigrid implementation and for Dirchlet boundary conditions
- SOR solver used for Pressure Poisson and Heat conduction equations
- Heat conduction equations solved for Neumann boundary condition
- Navier Stokes Solver implemented with Fractional Step
- Navier Stokes Solver implemented with Time Implicit solver
- Multigrided Poisson solver
Make necessary changes in the grid_filenames.csv and flow_parameters.csv grid_filenames.csv has the mesh filenames in the order from finest grid to coarse grid flow_parameters.csv has the details like polynomial degree, phs degree, cloud_size_multiplier and others
To compile the code for different hardware architectures:
Single-core CPU:
gcc @sources.txt -lmMulti-core CPU:
nvc -acc -ta=multicore @sources.txtGPU (NVIDIA):
nvc -acc -gpu=managed @sources.txtAfter compiling:
./a.outSince we are in the developing stage, we are using a conda environment. If you don't have conda installed in the system, please do the following:
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
source ~/.bashrc
rm ./Miniconda3-latest-Linux-x86_64.shcurl -o Miniconda3-latest-Windows-x86_64.exe `
https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe
Start-Process -Wait .\Miniconda3-latest-Windows-x86_64.exe `
-ArgumentList "/InstallationType=JustMe",
"/AddToPath=0",
"/RegisterPython=0",
"/S",
"/D=$env:USERPROFILE\Miniconda3"
$env:USERPROFILE\Miniconda3\Scripts\conda.exe init powershell
Remove-Item Miniconda3-latest-Windows-x86_64.exe
conda install -c conda-forge m2w64-gccAfter installing conda environment run this (for both Linux and Windows system):
conda env create -f environment.yml
conda activate memphys_guiTo start the GUI:
python gui.pyheader_files/: Contains all the custom C header files used in the solver.init/: Holds sample initialization scripts.flow_parameters.csv: Contains simulation parameters. Can be edited by the user.grid_filenames.csv: Lists available mesh files for use in the simulation.
This file defines the core physical and numerical parameters for the simulation. Each line is of the format parameter_name,value. Here are some key parameters:
domain_dimensions: Dimensionality of the domain (2 or 3).poly_deg: Degree of the appended polynomial (recommended: [2–15]).phs_deg: Degree of the polyharmonic spline (odd integers: 3, 5, 7, 9...).cloud_size_multiplier: Controls the local stencil size; typically between 1.5 and 2.5 for 2d cases and between 3 to 4 for 3d cases.courant_number: CFL condition; controls the time step size.steady_tolerance: Tolerance for steady-state convergence.poisson_solver_tolerance: Tolerance for pressure Poisson solver.num_vcycles: Number of V-cycles in multigrid.num_relax: Number of relaxation steps.num_time_steps: Total simulation time steps.write_interval: How often to write output.Re: Reynolds number.restart_filename: Ifrestartis 1, this file will be loaded.
You can customize these settings to suit your problem configuration.
- First line:
num_levels– Number of mesh refinement levels or hierarchies. - Following lines: Paths to
.mshmesh files generated using Gmsh from fine grid to coarse grid.
To use your own mesh:
- Create a mesh in Gmsh.
- Export it in ASCII format (version 2).
- Add its path to
grid_filenames.csv. - Ensure the mesh is consistent with expected domain dimensions.
- Modify
flow_parameters.csvas needed before compilation.
Several 2d and 3d mesh cases are included under the paths:
mesh/2d/TC/mesh/2d/SQ/mesh/3d/CUBE/mesh/3d/SP_in_SP/
- [o] Test full solver workflow (compile → run → plot)
- [o] Verify mesh file validation
- Test all callbacks thoroughly
- Remove debug print statements from main.py
- Enable custom fonts (set
ENABLE_CUSTOM_FONTS = True) - Implement config save/load functionality
- Add unit tests for modules
- Add more validation rules
- Advanced plot settings dialog
- Keyboard shortcuts
- Drag-and-drop mesh files
- Recent files menu
- Font Changes: Require application restart (DearPyGUI limitation)
- Screenshot Feature: External plotter window only
- Config Save/Load: Not yet implemented (placeholders exist)
MeMPhyS/
├── main.py # New entry point (replaces old gui.py)
├── src/
│ ├── config/ # Configuration and constants
│ │ ├── __init__.py
│ │ ├── constants.py # All constants and parameters
│ │ └── themes.py # DearPyGUI themes
│ │
│ ├── core/ # Core functionality
│ │ ├── __init__.py
│ │ ├── state.py # Application state management
│ │ └── logger.py # Logging system
│ │
│ ├── utils/ # Utility functions
│ │ ├── __init__.py
│ │ ├── fonts.py # Font management
│ │ ├── file_io.py # File operations
│ │ └── platform_utils.py # OS-specific utilities
│ │
│ ├── solver/ # Solver management
│ │ ├── __init__.py
│ │ ├── runner.py # Compilation and execution
│ │ └── monitoring.py # Convergence monitoring
│ │
│ ├── callbacks/ # Callback functions
│ │ ├── __init__.py
│ │ ├── solver_callbacks.py # Solver operations
│ │ ├── mesh_callbacks.py # Mesh management
│ │ ├── plot_callbacks.py # Visualization
│ │ └── menu_callbacks.py # Menu actions
│ │
│ ├── ui/ # User interface
│ │ ├── __init__.py
│ │ ├── main_window.py # Main window assembly
│ │ ├── menu_bar.py # Menu bar
│ │ ├── parameters_panel.py # Left panel
│ │ ├── visualization_panel.py # Right panel
│ │ └── dialogs.py # Modal dialogs
│ │
│ └── plotting/
│ └── plotter.py # External plotting (existing)
│
├── header_files/ # C header files (unchanged)
├── logs/ # Log files
└── requirements.txt # Python dependencies
python gui.pyContains all application constants:
- Solver parameters (BASE_PARAMETERS, IMPLICIT_PARAMETERS, MULTIGRID_PARAMETERS)
- GUI dimensions and settings
- File paths and names
- Colors and styling
- Validation rules (PARAMETER_CONSTRAINTS)
All DearPyGUI themes:
- Button themes (primary, secondary, success, error)
- Input themes
- Plot themes
- Modal themes
initialize_all_themes()- Create all themesapply_global_theme()- Apply app-wide styling
Application state management via AppState class:
- Process management (plotter, solver)
- File handle management
- Font registry
- UI state (multigrid enabled, mesh levels, etc.)
app_state- Global instance
Key Methods:
app_state.solver_running = True
app_state.set_mesh_file(1, "mesh.msh")
app_state.cleanup() # Call on exitStructured logging system via Logger class:
- Multiple outputs (file, GUI, console)
- Log levels (INFO, WARNING, ERROR, SUCCESS, DEBUG)
- Colored console output
- Auto-scrolling GUI log
logger- Global instance
Key Methods:
logger.info("Information message")
logger.error("Error message")
logger.success("Success message")
logger.log_exception(e, "Context")
logger.separator()Font management:
find_system_font()- Cross-platform font discoveryinitialize_fonts()- Load all fonts at startupchange_font()- Change current font- Platform-specific font paths
File operations:
write_parameters_csv()- Write parameters to CSVwrite_grid_csv()- Write grid configurationvalidate_mesh_file()- Validate mesh filesread_csv_file()/write_csv_file()- CSV utilities
OS-specific utilities:
open_folder()- Open in file exploreropen_url()- Open in browserget_platform()- Get OS namebuild_compile_command()- Build compilation command
Solver compilation and execution via SolverRunner class:
compile_and_run()- Main entry pointstop_solver()- Terminate running solvercheck_dependencies()- Verify compiler, files exist- Asynchronous execution with live output
solver_runner- Global instance
Usage:
from src.solver import solver_runner
success = solver_runner.compile_and_run(
init_file="init_cavity.c",
button_tag="run_button",
on_complete=my_callback
)Convergence monitoring via ConvergenceMonitor class:
- Real-time CSV file monitoring
- Automatic plot updates
- Smart axis scaling
- Convergence status tracking
convergence_monitor- Global instance
Usage:
from src.solver import convergence_monitor
convergence_monitor.start()
status = convergence_monitor.get_convergence_status()
convergence_monitor.stop()All callback functions organized by function:
run_solver_callback()- Run solvervalidate_numeric_input()- Parameter validationshow_implicit_callback()- Show/hide implicit paramsstop_solver_callback()- Stop solver
show_multigrid_callback()- Enable/disable multigridupdate_mesh_inputs_callback()- Update mesh input visibilityselect_mesh_file_callback()- File selectionvalidate_all_mesh_files_callback()- Validate all meshesauto_fill_mesh_levels_callback()- Auto-generate mesh names
update_plot_callback()- Launch plotterreset_convergence_plot_callback()- Reset plotexport_convergence_data_callback()- Export data to CSV
open_logs_callback()- Open logs foldershow_about_callback()- Show About dialogshow_preferences_callback()- Show Preferencesexit_application_callback()- Clean exit
create_main_window()- Assemble main window
create_parameters_panel()- Left panel with parameters
create_visualization_panel()- Right panel with plots
create_about_dialog()- About dialogcreate_preferences_dialog()- Preferences dialogshow_error_dialog()- Error messageshow_confirmation_dialog()- Yes/No confirmation
In main.py, line ~47:
ENABLE_CUSTOM_FONTS = True # Change to TrueIn src/config/constants.py:
CONVERGENCE_UPDATE_INTERVAL = 2.0 # secondsIn your code:
logger.set_enable_console(True) # Console output
logger.set_enable_file(True) # File output
logger.set_enable_gui(True) # GUI outputfrom src.core import logger
logger.info("Information message")
logger.success("Success message")
logger.error("Error message")
logger.warning("Warning message")
logger.separator()from src.core import app_state
app_state.solver_running = True
app_state.set_mesh_file(1, "mesh.msh")
app_state.cleanup() # On exitfrom src.solver import solver_runner
solver_runner.compile_and_run(
init_file="init_cavity.c",
button_tag="run_button"
)- Check if
Convergence.csvexists - Verify convergence monitor started (check logs)
- Run solver to generate data
- Check available fonts for your OS
- See
src/utils/fonts.pyfor font paths - Try different font from Preferences
- Verify gcc is installed:
gcc --version - Check init file path is correct
- Check mesh files exist
- Review logs for compilation errors
- Check logs:
logs/log_YYYY-MM-DD.txt - Check GitHub issues
- Enable debug logging
Dr. Akash Unnikrishnan developed this code as part of his PhD work with the guidance of Prof. Surya Pratap Vanka from University of Illinois at Urbana Champaign and Prof. Vinod Narayanan at Indian Institute of Technology Gandhinagar. Special mention has to go for Dr. Shantanu Shahane, who developed the first version of memphys which is available here: github.com/shahaneshantanu/memphys
Version: 2.2 Restructured
Date: December 2025
Maintainer: Akash Unnikrishnan