diff --git a/.github/workflows/performance-benchmarking.yml b/.github/workflows/performance-benchmarking.yml index b8c7eb9b..ff1ab5e7 100644 --- a/.github/workflows/performance-benchmarking.yml +++ b/.github/workflows/performance-benchmarking.yml @@ -69,16 +69,16 @@ jobs: run: | if [ "$RUNNER_OS" == "Linux" ]; then sudo apt-get update - sudo apt-get install -y valgrind linux-tools-common + sudo apt-get install -y valgrind linux-tools-common libfontconfig1-dev fi - name: Build benchmarks - run: cargo build --release --bench comprehensive_cfd_benchmarks + run: cargo build --release --bench performance_benchmarks - name: Run comprehensive benchmarks if: github.event.inputs.benchmark_type == 'comprehensive' || github.event_name != 'workflow_dispatch' run: | - cargo bench --bench comprehensive_cfd_benchmarks | tee benchmark_results.txt + cargo bench --bench performance_benchmarks | tee benchmark_results.txt - name: Run regression detection benchmarks if: github.event.inputs.benchmark_type == 'regression' || github.event_name == 'schedule' diff --git a/.gitignore b/.gitignore index 066d60e1..fab6f320 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,10 @@ report/ *.dll *.so *.dylib +.venv/ + +# Python compilation artifacts +__pycache__/ +*.pyc +*.pyo +*.pyd diff --git a/validation/__pycache__/__init__.cpython-313.pyc b/validation/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 5198d1c6..00000000 Binary files a/validation/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/validation/__pycache__/fenics_reference.cpython-313.pyc b/validation/__pycache__/fenics_reference.cpython-313.pyc deleted file mode 100644 index d4d28b3d..00000000 Binary files a/validation/__pycache__/fenics_reference.cpython-313.pyc and /dev/null differ diff --git a/validation/__pycache__/reference_cavity_mac.cpython-313.pyc b/validation/__pycache__/reference_cavity_mac.cpython-313.pyc deleted file mode 100644 index 105f3aba..00000000 Binary files a/validation/__pycache__/reference_cavity_mac.cpython-313.pyc and /dev/null differ diff --git a/validation/__pycache__/reference_cavity_psiomega.cpython-313.pyc b/validation/__pycache__/reference_cavity_psiomega.cpython-313.pyc deleted file mode 100644 index 5fd6010e..00000000 Binary files a/validation/__pycache__/reference_cavity_psiomega.cpython-313.pyc and /dev/null differ diff --git a/validation/__pycache__/validation_analytical.cpython-313.pyc b/validation/__pycache__/validation_analytical.cpython-313.pyc deleted file mode 100644 index 06c6784c..00000000 Binary files a/validation/__pycache__/validation_analytical.cpython-313.pyc and /dev/null differ diff --git a/validation/compare_cavity_external.py b/validation/compare_cavity_external.py index 2d0b092e..b585c4bd 100644 --- a/validation/compare_cavity_external.py +++ b/validation/compare_cavity_external.py @@ -104,8 +104,31 @@ def compare_solutions(cfd_python_result, external_result, Re: float): # Ensure same grid size if cfd_python_result["u"].shape != ext_sol["u"].shape: print(f"WARN: Grid size mismatch: cfd_python {cfd_python_result['u'].shape} vs external {ext_sol['u'].shape}") - # TODO: Interpolate if needed - return None + print("Interpolating cfd_python results to match external reference grid...") + from scipy.interpolate import RectBivariateSpline + + # cfd_python arrays are (ny, nx), RectBivariateSpline expects (x, y) + # So we transpose the CFD result fields (.T) for interpolation + interp_u = RectBivariateSpline(cfd_python_result["x"], cfd_python_result["y"], cfd_python_result["u"].T) + interp_v = RectBivariateSpline(cfd_python_result["x"], cfd_python_result["y"], cfd_python_result["v"].T) + interp_p = RectBivariateSpline(cfd_python_result["x"], cfd_python_result["y"], cfd_python_result["p"].T) + + # Evaluate on the external grid. Note that ext_solver.x and ext_solver.y are 1D arrays + new_u = interp_u(ext_solver.x, ext_solver.y).T + new_v = interp_v(ext_solver.x, ext_solver.y).T + new_p = interp_p(ext_solver.x, ext_solver.y).T + + cfd_python_result["u"] = new_u + cfd_python_result["v"] = new_v + cfd_python_result["p"] = new_p + + # Also interpolate centerlines using 1D interpolation + cfd_python_result["u_centerline"] = np.interp(ext_solver.y, cfd_python_result["y"], cfd_python_result["u_centerline"]) + cfd_python_result["v_centerline"] = np.interp(ext_solver.x, cfd_python_result["x"], cfd_python_result["v_centerline"]) + + # Update coordinates to match the external grid for proper plotting + cfd_python_result["x"] = ext_solver.x + cfd_python_result["y"] = ext_solver.y # Compute L2 errors u_diff = cfd_python_result["u"] - ext_sol["u"]