From 0d09263b186c8829f8a9376bb7a82df5a1b2f76e Mon Sep 17 00:00:00 2001 From: bigfooted Date: Thu, 20 Nov 2025 08:47:42 +0100 Subject: [PATCH 1/2] python source term for heat solver --- SU2_CFD/include/solvers/CHeatSolver.hpp | 11 +++++++++++ SU2_CFD/src/solvers/CHeatSolver.cpp | 16 ++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/SU2_CFD/include/solvers/CHeatSolver.hpp b/SU2_CFD/include/solvers/CHeatSolver.hpp index a286f9be7717..df2d99149b7f 100644 --- a/SU2_CFD/include/solvers/CHeatSolver.hpp +++ b/SU2_CFD/include/solvers/CHeatSolver.hpp @@ -196,6 +196,17 @@ class CHeatSolver final : public CScalarSolver { unsigned short iMesh, unsigned short iRKStep) override; + /*! + * \brief Source term computation. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] numerics_container - Description of the numerical method. + * \param[in] config - Definition of the particular problem. + * \param[in] iMesh - Index of the mesh in multigrid computations. + */ + void Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, + CConfig *config, unsigned short iMesh) override ; + void Set_Heatflux_Areas(CGeometry *geometry, CConfig *config) override; diff --git a/SU2_CFD/src/solvers/CHeatSolver.cpp b/SU2_CFD/src/solvers/CHeatSolver.cpp index 547697690027..d7f8fb2e0507 100644 --- a/SU2_CFD/src/solvers/CHeatSolver.cpp +++ b/SU2_CFD/src/solvers/CHeatSolver.cpp @@ -311,6 +311,22 @@ void CHeatSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contain } } +void CHeatSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, + CConfig *config, unsigned short iMesh) { + + CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; + + /*--- Regular source terms go here. ---*/ + /*--- ... ---*/ + + /*--- Custom user defined source term (from the python wrapper) ---*/ + if (config->GetPyCustomSource()) { + CustomSourceResidual(geometry, solver_container, numerics_container, config, iMesh); + } + +} + + void CHeatSolver::Set_Heatflux_Areas(CGeometry *geometry, CConfig *config) { BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS { From 4a036f6e1567e0428464ac5d243463c1642753bd Mon Sep 17 00:00:00 2001 From: bigfooted Date: Thu, 20 Nov 2025 09:26:23 +0100 Subject: [PATCH 2/2] remove unused variable --- SU2_CFD/src/solvers/CHeatSolver.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CHeatSolver.cpp b/SU2_CFD/src/solvers/CHeatSolver.cpp index d7f8fb2e0507..479e81e42b41 100644 --- a/SU2_CFD/src/solvers/CHeatSolver.cpp +++ b/SU2_CFD/src/solvers/CHeatSolver.cpp @@ -314,8 +314,6 @@ void CHeatSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contain void CHeatSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { - CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM]; - /*--- Regular source terms go here. ---*/ /*--- ... ---*/