From 58756258a00f90449ac092dac7c36142f02358b6 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Mon, 25 Nov 2024 22:14:23 +0100 Subject: [PATCH 01/10] initial update --- SU2_CFD/include/drivers/CDriverBase.hpp | 19 ++++ SU2_CFD/include/solvers/CEulerSolver.hpp | 13 +++ SU2_CFD/include/solvers/CIncEulerSolver.hpp | 13 +++ SU2_CFD/include/solvers/CSolver.hpp | 14 +++ SU2_CFD/src/integration/CIntegration.cpp | 3 + SU2_CFD/src/solvers/CIncEulerSolver.cpp | 108 ++++++++++++++++++++ 6 files changed, 170 insertions(+) diff --git a/SU2_CFD/include/drivers/CDriverBase.hpp b/SU2_CFD/include/drivers/CDriverBase.hpp index eaa6857c911..ec15cf90a83 100644 --- a/SU2_CFD/include/drivers/CDriverBase.hpp +++ b/SU2_CFD/include/drivers/CDriverBase.hpp @@ -444,6 +444,8 @@ class CDriverBase { return CPyWrapperMatrixView(solver->GetNodes()->GetSolution(), "Solution of " + solver->GetSolverName(), false); } + + /*! * \brief Get a read/write view of the current solution on the mesh nodes of a marker. */ @@ -667,6 +669,23 @@ class CDriverBase { return sens; } + /*! + * \brief Get the gradients of a solver variable in a point. + * \returns Vector of gradients grad(iVar). + */ + inline vector GetGradient(unsigned short iSolver, unsigned long iPoint, unsigned short iVar) { + const auto nDim = GetNumberDimensions(); + auto* solver = GetSolverAndCheckMarker(iSolver); + auto* nodes = solver->GetNodes(); + + vector grad(nDim, 0.0); + for (auto iDim = 0u; iDim < nDim; ++iDim) { + grad[iDim] = nodes->GetGradient(iPoint, iVar, iDim); + } + return grad; + } + + /*! * \brief Set the adjoint of the structural displacements. * \note This can be the input of the FEA solver in an adjoint FSI setting. diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 83c4cbe18e6..ab5240bb588 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -409,6 +409,19 @@ class CEulerSolver : public CFVMFlowSolverBaseSource_Residual(geometry, solver_container, numerics, config, iMesh); + /*--- Compute custom (python wrapper) source term residuals ---*/ + solver_container[MainSolver]->Custom_Source_Residual(geometry, solver_container, numerics, config, iMesh); + /*--- Add viscous and convective residuals, and compute the Dual Time Source term ---*/ if (dual_time) diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 6aaf09a5183..1cbde7c5704 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1813,6 +1813,114 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont } +void CIncEulerSolver::Custom_Source_Residual(CGeometry *geometry, CSolver **solver_container, + CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + /*--- Pick one numerics object per thread. ---*/ + //CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; + + unsigned short iVar; + unsigned long iPoint; + + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + const bool rotating_frame = config->GetRotating_Frame(); + const bool axisymmetric = config->GetAxisymmetric(); + const bool body_force = config->GetBody_Force(); + const bool boussinesq = (config->GetKind_DensityModel() == INC_DENSITYMODEL::BOUSSINESQ); + const bool viscous = config->GetViscous(); + const bool radiation = config->AddRadiation(); + const bool vol_heat = config->GetHeatSource(); + const bool turbulent = (config->GetKind_Turb_Model() != TURB_MODEL::NONE); + const bool energy = config->GetEnergy_Equation(); + + // if (radiation) { + + // AD::StartNoSharedReading(); + + // CNumerics* second_numerics = numerics_container[SOURCE_SECOND_TERM + omp_get_thread_num()*MAX_TERMS]; + + // SU2_OMP_FOR_STAT(omp_chunk_size) + // for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + + // /*--- Store the radiation source term ---*/ + + // second_numerics->SetRadVarSource(solver_container[RAD_SOL]->GetNodes()->GetRadiative_SourceTerm(iPoint)); + + // /*--- Set control volume ---*/ + + // second_numerics->SetVolume(geometry->nodes->GetVolume(iPoint)); + + // /*--- Compute the residual ---*/ + + // auto residual = second_numerics->ComputeResidual(config); + + // /*--- Add Residual ---*/ + + // LinSysRes.AddBlock(iPoint, residual); + + // /*--- Implicit part ---*/ + + // if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); + + // if (vol_heat) { + + // if(solver_container[RAD_SOL]->GetNodes()->GetVol_HeatSource(iPoint)) { + + // auto Volume = geometry->nodes->GetVolume(iPoint); + + // /*--- Subtract integrated source from the residual. ---*/ + // LinSysRes(iPoint, nDim+1) -= config->GetHeatSource_Val()*Volume; + // } + + // } + + // } + // END_SU2_OMP_FOR + + // AD::EndNoSharedReading(); + // } + + + // /*--- Check if a verification solution is to be computed. ---*/ + + // if (VerificationSolution) { + // if ( VerificationSolution->IsManufacturedSolution() ) { + + // /*--- Get the physical time. ---*/ + // su2double time = 0.0; + // if (config->GetTime_Marching() != TIME_MARCHING::STEADY) time = config->GetPhysicalTime(); + + // AD::StartNoSharedReading(); + + // /*--- Loop over points ---*/ + // SU2_OMP_FOR_STAT(omp_chunk_size) + // for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + + // /*--- Get control volume size. ---*/ + // su2double Volume = geometry->nodes->GetVolume(iPoint); + + // /*--- Get the current point coordinates. ---*/ + // const su2double *coor = geometry->nodes->GetCoord(iPoint); + + // /*--- Get the MMS source term. ---*/ + // vector sourceMan(nVar,0.0); + // VerificationSolution->GetMMSSourceTerm(coor, time, sourceMan.data()); + + // /*--- Compute the residual for this control volume and subtract. ---*/ + // for (iVar = 0; iVar < nVar; iVar++) { + // LinSysRes[iPoint*nVar+iVar] -= sourceMan[iVar]*Volume; + // } + + // } + // END_SU2_OMP_FOR + + // AD::EndNoSharedReading(); + // } + // } + +} + + void CIncEulerSolver::Source_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { From cc3dfab47929bb94bad65072a397514dfa6046bf Mon Sep 17 00:00:00 2001 From: bigfooted Date: Tue, 3 Dec 2024 14:42:12 +0100 Subject: [PATCH 02/10] initial working version for buoyant flow --- Common/include/CConfig.hpp | 13 ++ Common/src/CConfig.cpp | 3 +- SU2_CFD/include/drivers/CDriver.hpp | 44 +++++ SU2_CFD/include/drivers/CDriverBase.hpp | 71 +++++++- SU2_CFD/include/numerics/CNumerics.hpp | 1 + .../include/numerics/flow/flow_sources.hpp | 24 +++ .../include/solvers/CFVMFlowSolverBase.hpp | 36 ++++ .../include/solvers/CFVMFlowSolverBase.inl | 3 + SU2_CFD/include/solvers/CSolver.hpp | 20 ++- SU2_CFD/src/drivers/CDriverBase.cpp | 4 + SU2_CFD/src/drivers/CSinglezoneDriver.cpp | 7 +- SU2_CFD/src/numerics/flow/flow_sources.cpp | 38 ++++ SU2_CFD/src/python_wrapper_structure.cpp | 13 ++ SU2_CFD/src/solvers/CIncEulerSolver.cpp | 109 ++--------- .../custom_source/lam_buoyancy_cavity.cfg | 120 +++++++++++++ TestCases/py_wrapper/custom_source/run.py | 169 ++++++++++++++++++ 16 files changed, 577 insertions(+), 98 deletions(-) create mode 100644 TestCases/py_wrapper/custom_source/lam_buoyancy_cavity.cfg create mode 100644 TestCases/py_wrapper/custom_source/run.py diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 0c32f044288..553b689023f 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -286,6 +286,7 @@ class CConfig { su2double **Giles_FlowDir; /*!< \brief Specified flow direction vector (unit vector) for Giles BC. */ su2double *Inlet_Ptotal; /*!< \brief Specified total pressures for inlet boundaries. */ su2double **Inlet_FlowDir; /*!< \brief Specified flow direction vector (unit vector) for inlet boundaries. */ + //su2double *PointSource; /*!< \brief Specified flow direction vector (unit vector) for inlet boundaries. */ su2double *Inlet_Temperature; /*!< \brief Specified temperatures for a supersonic inlet boundaries. */ su2double *Inlet_Pressure; /*!< \brief Specified static pressures for supersonic inlet boundaries. */ su2double **Inlet_Velocity; /*!< \brief Specified flow velocity vectors for supersonic inlet boundaries. */ @@ -9454,6 +9455,18 @@ class CConfig { */ unsigned long GetnOuter_Iter(void) const { return nOuterIter; } + /*! + * \brief Get the number of inner iterations + * \return Number of inner iterations on each multizone block + */ + void SetnInner_Iter(unsigned long val_iter) { nInnerIter = val_iter; } + + /*! + * \brief Get the number of outer iterations + * \return Number of outer iterations for the multizone problem + */ + void SetnOuter_Iter(unsigned long val_iter) { cout << "inner iter=" << val_iter << endl; nOuterIter = val_iter; } + /*! * \brief Get the number of time iterations * \return Number of time steps run diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 64be5736bca..b80fdedfc41 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -890,6 +890,7 @@ void CConfig::SetPointersNull() { Inlet_FlowDir = nullptr; Inlet_Temperature = nullptr; Inlet_Pressure = nullptr; Inlet_Velocity = nullptr; Outlet_Pressure = nullptr; Inlet_SpeciesVal = nullptr; Inlet_TurbVal = nullptr; + //PointSource = nullptr; /*--- Engine Boundary Condition settings ---*/ @@ -913,7 +914,7 @@ void CConfig::SetPointersNull() { Inlet_FlowDir = nullptr; Inlet_Temperature = nullptr; Inlet_Pressure = nullptr; Inlet_Velocity = nullptr; Inflow_Mach = nullptr; Inflow_Pressure = nullptr; Outlet_Pressure = nullptr; Isothermal_Temperature = nullptr; - + //PointSource = nullptr; ElasticityMod = nullptr; PoissonRatio = nullptr; MaterialDensity = nullptr; Load_Dir = nullptr; Load_Dir_Value = nullptr; Load_Dir_Multiplier = nullptr; diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 2f79be415b3..7c74ed40a85 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -475,6 +475,37 @@ class CDriver : public CDriverBase { */ unsigned long GetNumberTimeIter() const; + /*! + * \brief Get the number of inner iterations. + * \return Number of inner iterations. + */ + unsigned long GetNumberInnerIter() const; + + /*! + * \brief Get the number of outer iterations. + * \return Number of outer iterations. + */ + unsigned long GetNumberOuterIter() const; + + + /*! + * \brief Set the number of inner iterations. + * \return Number of inner iterations. + */ + void SetNumberInnerIter(unsigned long); + + /*! + * \brief Set the number of outer iterations. + * \return Number of outer iterations. + */ + void SetNumberOuterIter(unsigned long); + + /*! + * \brief Get the current solution + * \return Current solution + */ + unsigned long GetSolution(unsigned short iSolver, unsigned long iPoint, unsigned short iVar); + /*! * \brief Get the current time iteration. * \return Current time iteration. @@ -555,6 +586,19 @@ class CDriver : public CDriverBase { */ void SetMarkerTranslationRate(unsigned short iMarker, passivedouble vel_x, passivedouble vel_y, passivedouble vel_z); + /*! + * \brief Get the Freestream Density for nondimensionalization + * \return Freestream Density + */ + unsigned long GetDensity_FreeStreamND() const; + + /*! + * \brief Get the reference Body force for nondimensionalization + * \return reference Body Force + */ + unsigned long GetForce_Ref() const; + + /// \} }; diff --git a/SU2_CFD/include/drivers/CDriverBase.hpp b/SU2_CFD/include/drivers/CDriverBase.hpp index ec15cf90a83..699379ab444 100644 --- a/SU2_CFD/include/drivers/CDriverBase.hpp +++ b/SU2_CFD/include/drivers/CDriverBase.hpp @@ -179,6 +179,15 @@ class CDriverBase { */ unsigned long GetNumberElements() const; + /*! + * \brief Get the number of solution variables + * \return Number of solution variables. + */ + //unsigned long GetNumberSolverVars() const; + + unsigned short GetNumberSolverVars(const unsigned short iSol) const; + unsigned short GetNumberPrimitiveVars(const unsigned short iSol) const; + /*! * \brief Get the global index of a mesh element. * \param[in] iElem - Mesh element index. @@ -444,8 +453,6 @@ class CDriverBase { return CPyWrapperMatrixView(solver->GetNodes()->GetSolution(), "Solution of " + solver->GetSolverName(), false); } - - /*! * \brief Get a read/write view of the current solution on the mesh nodes of a marker. */ @@ -680,7 +687,7 @@ class CDriverBase { vector grad(nDim, 0.0); for (auto iDim = 0u; iDim < nDim; ++iDim) { - grad[iDim] = nodes->GetGradient(iPoint, iVar, iDim); + grad[iDim] = SU2_TYPE::GetValue(nodes->GetGradient(iPoint, iVar, iDim)); } return grad; } @@ -753,6 +760,49 @@ class CDriverBase { } } + /*! + * \brief Set the array of variables for the source in the point + * \param[in] iMarker - Marker index. + * \param[in] iVertex - Marker vertex index. + * \param[in] value - Value of the variable. + */ + void SetPointCustomSource(unsigned short iSOLVER, unsigned long iPoint, std::vector values) { + //for (auto iVar = 0ul; iVar < nVar; ++iDim) { + //GetSolverAndCheckField(FLOW_SOL, iPoint)->SetCustomPointSource (iPoint, value); + auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSOLVER]; + solver->SetCustomPointSource(iPoint, values); + } + +// return solution vector +inline vector GetSolutionVector(unsigned short iSOLVER, unsigned long iPoint) { + auto* solver = solver_container[iSOLVER][INST_0][MESH_0][iSOLVER]; + auto* nodes = solver->GetNodes(); + auto nVar = GetNumberSolverVars(iSOLVER); + //cout << "getting solution: "<GetSolution(iPoint,2); + //cout << "value : " << val << endl; + vector solutionvector(nVar, 0.0); + for (auto iVar = 0u; iVar < nVar; ++iVar) { + solutionvector[iVar] = SU2_TYPE::GetValue(nodes->GetSolution(iPoint,iVar)); + //cout << "vector = " << solutionvector[iVar] << endl; + } + return solutionvector; +} + +inline vector GetPrimitiveVector(unsigned short iSOLVER, unsigned long iPoint) { + auto* solver = solver_container[iSOLVER][INST_0][MESH_0][iSOLVER]; + auto* nodes = solver->GetNodes(); + auto nPrimvar = GetNumberPrimitiveVars(iSOLVER); + //cout << "getting solution: "<GetSolution(iPoint,2); + //cout << "value : " << val << endl; + vector solutionvector(nPrimvar, 0.0); + for (auto iVar = 0u; iVar < nPrimvar; ++iVar) { + solutionvector[iVar] = SU2_TYPE::GetValue(nodes->GetPrimitive(iPoint,iVar)); + //cout << "vector = " << solutionvector[iVar] << endl; + } + return solutionvector; +} /// \} protected: @@ -769,6 +819,21 @@ class CDriverBase { return solver; } + /*! + * \brief Automates some boilerplate of accessing solution fields for the python wrapper. + */ + inline CSolver* GetSolverAndCheckField(unsigned short iSolver, + unsigned long iPoint = std::numeric_limits::max()) const { + // 1. check for the solver the number of variables + // 2. check for the mesh the number of points + //if (iPoint < std::numeric_limits::max() && iPoint > GetNumberMarkers()) { + // SU2_MPI::Error("Marker index exceeds size.", CURRENT_FUNCTION); + //} + auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver]; + if (solver == nullptr) SU2_MPI::Error("The selected solver does not exist.", CURRENT_FUNCTION); + return solver; + } + /*! * \brief Initialize containers. */ diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 535335947ca..8d23b402bab 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -155,6 +155,7 @@ class CNumerics { su2double LocalGridLength_i; /*!< \brief Local grid length at point i. */ const su2double *RadVar_Source; /*!< \brief Source term from the radiative heat transfer equation. */ + const su2double *UserDefinedSource; /*!< \brief User Defined Source term. */ const su2double *Coord_i, /*!< \brief Cartesians coordinates of point i. */ *Coord_j; /*!< \brief Cartesians coordinates of point j. */ diff --git a/SU2_CFD/include/numerics/flow/flow_sources.hpp b/SU2_CFD/include/numerics/flow/flow_sources.hpp index e4cb64e4b54..e6a138ec901 100644 --- a/SU2_CFD/include/numerics/flow/flow_sources.hpp +++ b/SU2_CFD/include/numerics/flow/flow_sources.hpp @@ -467,3 +467,27 @@ class CSourceRadiation : public CSourceBase_Flow { ResidualType<> ComputeResidual(const CConfig* config) override; }; + + +/*! + * \class CSourceUserDefined + * \brief Class for a user defined source term using the python wrapper + * \ingroup SourceDiscr + * \author Nijso Beishuizen + */ +class CSourceUserDefined : public CSourceBase_Flow { +private: + bool implicit; + +public: + + CSourceUserDefined(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config); + + /*! + * \brief Source term integration for a user defined source. + * \param[in] config - Definition of the particular problem. + * \return Lightweight const-view of residual and Jacobian. + */ + ResidualType<> ComputeResidual(const CConfig* config) override; + +}; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 2aa31880bae..9aacffc9c2f 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -170,6 +170,7 @@ class CFVMFlowSolverBase : public CSolver { vector > Inlet_Ptotal; /*!< \brief Value of the Total P. */ vector > Inlet_Ttotal; /*!< \brief Value of the Total T. */ vector Inlet_FlowDir; /*!< \brief Value of the Flow Direction. */ + su2activematrix PointSource; /*!< \brief Value of the Flow Direction. */ vector > HeatFlux; /*!< \brief Heat transfer coefficient for each boundary and vertex. */ vector > HeatFluxTarget; /*!< \brief Heat transfer coefficient for each boundary and vertex. */ vector CharacPrimVar; /*!< \brief Value of the characteristic variables at each boundary. */ @@ -2148,6 +2149,18 @@ class CFVMFlowSolverBase : public CSolver { return Inlet_FlowDir[val_marker][val_vertex][val_dim]; } + /*! + * \brief A component of the unit vector representing the flow direction at an inlet boundary. + * \param[in] val_marker - Surface marker where the flow direction is evaluated + * \param[in] val_vertex - Vertex of the marker val_marker where the flow direction is evaluated + * \param[in] val_dim - The component of the flow direction unit vector to be evaluated + * \return Component of a unit vector representing the flow direction. + */ + inline su2double GetCustomPointSource(unsigned long val_point, + unsigned short val_var) const final { + return PointSource[val_point][val_var]; + } + /*! * \brief Set the value of the total temperature at an inlet boundary. * \param[in] val_marker - Surface marker where the total temperature is set. @@ -2201,6 +2214,29 @@ class CFVMFlowSolverBase : public CSolver { Inlet_FlowDir[val_marker][val_vertex][val_dim] = val_flowdir; } + /*! + * \brief Set a component of the unit vector representing the flow direction at an inlet boundary. + * \param[in] val_marker - Surface marker where the flow direction is set. + * \param[in] val_vertex - Vertex of the marker val_marker where the flow direction is set. + * \param[in] val_dim - The component of the flow direction unit vector to be set + * \param[in] val_flowdir - Component of a unit vector representing the flow direction. + */ + inline void SetCustomPointSource(unsigned long val_point, + vector val_source) final { + /*--- Since this call can be accessed indirectly using python, do some error + * checking to prevent segmentation faults ---*/ + //if (val_marker >= nMarker) + // SU2_MPI::Error("Out-of-bounds marker index used on inlet.", CURRENT_FUNCTION); + //else if (val_vertex >= nVertex[val_marker]) + // SU2_MPI::Error("Out-of-bounds vertex index used on inlet.", CURRENT_FUNCTION); + //else + //cout << "value list size=" << val_source.size() << endl; + //cout << "pointsource.size = " << nVar << endl; + //cout << "point,npoint=" << val_point << " " << nPointDomain << endl; + for (unsigned short iVar=0; iVar < val_source.size(); iVar++) + PointSource[val_point][iVar] = val_source[iVar]; + } + /*! * \brief Update the multi-grid structure for the customized boundary conditions. * \param geometry_container - Geometrical definition. diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 4797293529f..b9bcdc451f2 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -123,6 +123,9 @@ void CFVMFlowSolverBase::Allocate(const CConfig& config) { /*--- Store the value of the Flow direction at the inlet BC ---*/ AllocVectorOfMatrices(nVertex, nDim, Inlet_FlowDir); + + //AllocVectorOfVectors(nPointDomain, PointSource); + PointSource.resize(nPointDomain,nVar); /*--- Force definition and coefficient arrays for all of the markers ---*/ diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index bc913ed4348..10b1b6e38ec 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -2854,7 +2854,15 @@ class CSolver { inline virtual su2double GetInletFlowDir(unsigned short val_marker, unsigned long val_vertex, unsigned short val_dim) const { return 0; } - + /*! + * \brief A virtual member + * \param[in] val_marker - Surface marker where the flow direction is evaluated + * \param[in] val_vertex - Vertex of the marker val_marker where the flow direction is evaluated + * \param[in] val_dim - The component of the flow direction unit vector to be evaluated + * \return Component of a unit vector representing the flow direction. + */ + inline virtual su2double GetCustomPointSource(unsigned long val_point, + unsigned short val_var) const { return 0; } /*! * \brief A virtual member * \param[in] val_marker - Surface marker where the total temperature is set. @@ -2886,7 +2894,15 @@ class CSolver { unsigned long val_vertex, unsigned short val_dim, su2double val_flowdir) { } - + /*! + * \brief A virtual member + * \param[in] val_marker - Surface marker where the flow direction is set. + * \param[in] val_vertex - Vertex of the marker val_marker where the flow direction is set. + * \param[in] val_dim - The component of the flow direction unit vector to be set + * \param[in] val_flowdir - Component of a unit vector representing the flow direction. + */ + inline virtual void SetCustomPointSource(unsigned long val_Point, + vector val_source) { } /*! * \brief Updates the components of the farfield velocity vector. */ diff --git a/SU2_CFD/src/drivers/CDriverBase.cpp b/SU2_CFD/src/drivers/CDriverBase.cpp index 53483856b5d..7ea82380095 100644 --- a/SU2_CFD/src/drivers/CDriverBase.cpp +++ b/SU2_CFD/src/drivers/CDriverBase.cpp @@ -165,6 +165,10 @@ unsigned long CDriverBase::GetNumberDimensions() const { return main_geometry->G unsigned long CDriverBase::GetNumberElements() const { return main_geometry->GetnElem(); } +//unsigned long CDriverBase::GetNumberSolverVars() const { return main_geometry->GetnElem(); } +unsigned short CDriverBase::GetNumberSolverVars(const unsigned short iSol) const { return solver_container[selected_zone][INST_0][MESH_0][iSol]->GetnVar(); } +unsigned short CDriverBase::GetNumberPrimitiveVars(const unsigned short iSol) const { return solver_container[selected_zone][INST_0][MESH_0][iSol]->GetnPrimVar(); } + unsigned long CDriverBase::GetElementGlobalIndex(unsigned long iElem) const { if (iElem >= GetNumberElements()) { SU2_MPI::Error("Element index exceeds size.", CURRENT_FUNCTION); diff --git a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp index ed4d46f370e..8bec4611e58 100644 --- a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp @@ -106,6 +106,10 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) { /*--- Set the current time iteration in the config and also in the driver * because the python interface doesn't offer an explicit way of doing it. ---*/ + if (config_container[ZONE_0]->GetTime_Marching() == TIME_MARCHING::STEADY) { + cout << "steady simulation, iteration = " << TimeIter << endl; + config_container[ZONE_0]->SetInnerIter(TimeIter); + } this->TimeIter = TimeIter; config_container[ZONE_0]->SetTimeIter(TimeIter); @@ -113,8 +117,7 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) { /*--- Store the current physical time in the config container, as this can be used for verification / MMS. This should also be more general once the drivers are more stable. ---*/ - - if (config_container[ZONE_0]->GetTime_Marching() != TIME_MARCHING::STEADY) + if (config_container[ZONE_0]->GetTime_Marching() != TIME_MARCHING::STEADY) config_container[ZONE_0]->SetPhysicalTime(static_cast(TimeIter)*config_container[ZONE_0]->GetDelta_UnstTimeND()); else config_container[ZONE_0]->SetPhysicalTime(0.0); diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index 6f8359a5f58..b5c29a6325f 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -427,6 +427,8 @@ CNumerics::ResidualType<> CSourceIncBodyForce::ComputeResidual(const CConfig* co residual[nDim+1] = 0.0; + //cout << "residual = " << residual[0] << " " << residual[1] << " " << residual[2] << " " <(residual, jacobian, nullptr); } @@ -837,3 +839,39 @@ CNumerics::ResidualType<> CSourceRadiation::ComputeResidual(const CConfig *confi return ResidualType<>(residual, jacobian, nullptr); } + +CSourceUserDefined::CSourceUserDefined(unsigned short val_nDim, unsigned short val_nVar, const CConfig *config) : + CSourceBase_Flow(val_nDim, val_nVar, config) { + + implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); +} + +CNumerics::ResidualType<> CSourceUserDefined::ComputeResidual(const CConfig *config) { + + unsigned short iDim; + + /*--- Zero the continuity contribution. ---*/ + + residual[0] = 0.0; + + /*--- Zero the momentum contribution. ---*/ + + for (iDim = 0; iDim < nDim; iDim++) + residual[iDim+1] = 0.0; + + /*--- Set the energy contribution ---*/ + + residual[nDim+1] = -UserDefinedSource[0]*Volume; + + /*--- Set the energy contribution to the Jacobian. ---*/ + + if (implicit) { + + /*--- Jacobian is set to zero on initialization. ---*/ + + jacobian[nDim+1][nDim+1] = -UserDefinedSource[1]*Volume; + + } + + return ResidualType<>(residual, jacobian, nullptr); +} diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 2a148a346d9..2677eb21943 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -58,6 +58,14 @@ void CDriver::PreprocessPythonInterface(CConfig** config, CGeometry**** geometry unsigned long CDriver::GetNumberTimeIter() const { return config_container[selected_zone]->GetnTime_Iter(); } +unsigned long CDriver::GetNumberInnerIter() const { return config_container[selected_zone]->GetnInner_Iter(); } +unsigned long CDriver::GetNumberOuterIter() const { return config_container[selected_zone]->GetnOuter_Iter(); } +void CDriver::SetNumberInnerIter(unsigned long nInner) { config_container[selected_zone]->SetnInner_Iter(nInner); } +void CDriver::SetNumberOuterIter(unsigned long nOuter) { config_container[selected_zone]->SetnOuter_Iter(nOuter); } + +unsigned long CDriver::GetDensity_FreeStreamND() const { return config_container[selected_zone]->GetDensity_FreeStreamND(); } +unsigned long CDriver::GetForce_Ref() const { return config_container[selected_zone]->GetForce_Ref(); } + unsigned long CDriver::GetTimeIter() const { return TimeIter; } passivedouble CDriver::GetUnsteadyTimeStep() const { @@ -66,6 +74,11 @@ passivedouble CDriver::GetUnsteadyTimeStep() const { string CDriver::GetSurfaceFileName() const { return config_container[selected_zone]->GetSurfCoeff_FileName(); } +unsigned long CDriver::GetSolution(unsigned short iSOLVER, unsigned long iPoint, unsigned short iVar) { + auto solver = solver_container[iZone][INST_0][MESH_0][iSOLVER]; + return solver->GetNodes()->GetSolution(iPoint,iVar); +} + //////////////////////////////////////////////////////////////////////////////// /* Functions related to the management of markers */ //////////////////////////////////////////////////////////////////////////////// diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 1cbde7c5704..18f60dfbffa 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -1817,106 +1817,35 @@ void CIncEulerSolver::Custom_Source_Residual(CGeometry *geometry, CSolver **solv CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { /*--- Pick one numerics object per thread. ---*/ - //CNumerics* numerics = numerics_container[SOURCE_FIRST_TERM + omp_get_thread_num()*MAX_TERMS]; + CNumerics* numerics = numerics_container[SOURCE_SECOND_TERM + omp_get_thread_num()*MAX_TERMS]; unsigned short iVar; unsigned long iPoint; + AD::StartNoSharedReading(); - const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - const bool rotating_frame = config->GetRotating_Frame(); - const bool axisymmetric = config->GetAxisymmetric(); - const bool body_force = config->GetBody_Force(); - const bool boussinesq = (config->GetKind_DensityModel() == INC_DENSITYMODEL::BOUSSINESQ); - const bool viscous = config->GetViscous(); - const bool radiation = config->AddRadiation(); - const bool vol_heat = config->GetHeatSource(); - const bool turbulent = (config->GetKind_Turb_Model() != TURB_MODEL::NONE); - const bool energy = config->GetEnergy_Equation(); - - // if (radiation) { - - // AD::StartNoSharedReading(); - - // CNumerics* second_numerics = numerics_container[SOURCE_SECOND_TERM + omp_get_thread_num()*MAX_TERMS]; - - // SU2_OMP_FOR_STAT(omp_chunk_size) - // for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - - // /*--- Store the radiation source term ---*/ - - // second_numerics->SetRadVarSource(solver_container[RAD_SOL]->GetNodes()->GetRadiative_SourceTerm(iPoint)); - - // /*--- Set control volume ---*/ - - // second_numerics->SetVolume(geometry->nodes->GetVolume(iPoint)); - - // /*--- Compute the residual ---*/ - - // auto residual = second_numerics->ComputeResidual(config); - - // /*--- Add Residual ---*/ - - // LinSysRes.AddBlock(iPoint, residual); - - // /*--- Implicit part ---*/ - - // if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i); - - // if (vol_heat) { - - // if(solver_container[RAD_SOL]->GetNodes()->GetVol_HeatSource(iPoint)) { - - // auto Volume = geometry->nodes->GetVolume(iPoint); - - // /*--- Subtract integrated source from the residual. ---*/ - // LinSysRes(iPoint, nDim+1) -= config->GetHeatSource_Val()*Volume; - // } - - // } - - // } - // END_SU2_OMP_FOR - - // AD::EndNoSharedReading(); - // } - - - // /*--- Check if a verification solution is to be computed. ---*/ - - // if (VerificationSolution) { - // if ( VerificationSolution->IsManufacturedSolution() ) { - - // /*--- Get the physical time. ---*/ - // su2double time = 0.0; - // if (config->GetTime_Marching() != TIME_MARCHING::STEADY) time = config->GetPhysicalTime(); - - // AD::StartNoSharedReading(); - - // /*--- Loop over points ---*/ - // SU2_OMP_FOR_STAT(omp_chunk_size) - // for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - // /*--- Get control volume size. ---*/ - // su2double Volume = geometry->nodes->GetVolume(iPoint); + /*--- Load the volume of the dual mesh cell ---*/ - // /*--- Get the current point coordinates. ---*/ - // const su2double *coor = geometry->nodes->GetCoord(iPoint); + numerics->SetVolume(geometry->nodes->GetVolume(iPoint)); - // /*--- Get the MMS source term. ---*/ - // vector sourceMan(nVar,0.0); - // VerificationSolution->GetMMSSourceTerm(coor, time, sourceMan.data()); + /*--- Get control volume size. ---*/ + su2double Volume = geometry->nodes->GetVolume(iPoint); - // /*--- Compute the residual for this control volume and subtract. ---*/ - // for (iVar = 0; iVar < nVar; iVar++) { - // LinSysRes[iPoint*nVar+iVar] -= sourceMan[iVar]*Volume; - // } + /*--- Compute the residual for this control volume and subtract. ---*/ + for (iVar = 0; iVar < nVar; iVar++) { + LinSysRes[iPoint*nVar+iVar] += PointSource[iPoint][iVar] * Volume; + } + // cout << "source = " << iPoint << " " << PointSource[iPoint][0]*Volume + // << " " << PointSource[iPoint][1]*Volume + // << " " << PointSource[iPoint][2]*Volume + // << " " << PointSource[iPoint][3]*Volume << endl; - // } - // END_SU2_OMP_FOR + } + END_SU2_OMP_FOR - // AD::EndNoSharedReading(); - // } - // } + AD::EndNoSharedReading(); } diff --git a/TestCases/py_wrapper/custom_source/lam_buoyancy_cavity.cfg b/TestCases/py_wrapper/custom_source/lam_buoyancy_cavity.cfg new file mode 100644 index 00000000000..470a895b372 --- /dev/null +++ b/TestCases/py_wrapper/custom_source/lam_buoyancy_cavity.cfg @@ -0,0 +1,120 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Buoyancy-driven flow inside a cavity % +% Author: Thomas D. Economon % +% Date: 2018.06.10 % +% File Version 8.1.0 "Harrier" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +SOLVER= INC_NAVIER_STOKES +KIND_TURB_MODEL= NONE +MATH_PROBLEM= DIRECT +RESTART_SOL= NO + +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_DENSITY_MODEL= VARIABLE +INC_ENERGY_EQUATION = YES +% +% Uncomment a density below for a desired Rayleigh number +%INC_DENSITY_INIT= 0.00018903539834 % Ra ~ 1e3 +%INC_DENSITY_INIT= 0.00059778241716 % Ra ~ 1e4 +%INC_DENSITY_INIT= 0.00189035398341 % Ra ~ 1e5 +INC_DENSITY_INIT= 0.00597782417156 % Ra ~ 1e6 +% +INC_VELOCITY_INIT= ( 1.0, 0.0, 0.0 ) +INC_TEMPERATURE_INIT= 288.15 + +% ---- IDEAL GAS, POLYTROPIC, VAN DER WAALS AND PENG ROBINSON CONSTANTS -------% +% +FLUID_MODEL= INC_IDEAL_GAS +SPECIFIC_HEAT_CP= 1004.703 +MOLECULAR_WEIGHT= 28.96 + +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_CONSTANT= 1.716e-5 + +% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% +% +CONDUCTIVITY_MODEL= CONSTANT_CONDUCTIVITY +THERMAL_CONDUCTIVITY_CONSTANT= 0.0246295028571 + +% ----------------------- BODY FORCE DEFINITION -------------------------------% +% +BODY_FORCE= NO +BODY_FORCE_VECTOR= ( 0.0, -9.81, 0.0 ) + +% ---------------------- REFERENCE VALUE DEFINITION ---------------------------% +% +REF_ORIGIN_MOMENT_X = 0.25 +REF_ORIGIN_MOMENT_Y = 0.00 +REF_ORIGIN_MOMENT_Z = 0.00 +REF_AREA= 1.0 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( upper, 0.0, lower, 0.0 ) +MARKER_ISOTHERMAL= ( left, 461.04, right, 115.26 ) +MARKER_PLOTTING= ( upper, left, right, lower ) +MARKER_MONITORING= ( NONE ) + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER= 50 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 1.5, 0.5, 15.0, 1e10) +MAX_DELTA_TIME= 1E6 +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) +ITER=1 + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ILU_FILL_IN= 0 +LINEAR_SOLVER_ERROR= 1E-15 +LINEAR_SOLVER_ITER= 20 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT + + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_RESIDUAL_MINVAL= -12 +CONV_STARTITER= 10 +CONV_CAUCHY_ELEMS= 100 +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +MESH_FILENAME= mesh_cavity_65x65.su2 +MESH_FORMAT= SU2 +MESH_OUT_FILENAME= mesh_out.su2 +SOLUTION_FILENAME= solution_flow.dat +SOLUTION_ADJ_FILENAME= solution_adj.dat +TABULAR_FORMAT= CSV +CONV_FILENAME= history +RESTART_FILENAME= restart_flow.dat +RESTART_ADJ_FILENAME= restart_adj.dat +VOLUME_FILENAME= flow +VOLUME_ADJ_FILENAME= adjoint +GRAD_OBJFUNC_FILENAME= of_grad.dat +SURFACE_FILENAME= surface_flow +SURFACE_ADJ_FILENAME= surface_adjoint +OUTPUT_WRT_FREQ= 100 +SCREEN_OUTPUT= (OUTER_ITER, INNER_ITER, RMS_PRESSURE, RMS_TEMPERATURE, LIFT, DRAG) + +% ----------------------- GEOMETRY EVALUATION PARAMETERS ----------------------% +GEO_BOUNDS= ( 0.499, 0.501) diff --git a/TestCases/py_wrapper/custom_source/run.py b/TestCases/py_wrapper/custom_source/run.py new file mode 100644 index 00000000000..c9fcaf4e0ac --- /dev/null +++ b/TestCases/py_wrapper/custom_source/run.py @@ -0,0 +1,169 @@ +#!/usr/bin/env python + +## \file run.py +# \brief Unsteady inlet boundary conditions. +# \version 8.1.0 "Harrier" +# +# SU2 Project Website: https://su2code.github.io +# +# The SU2 Project is maintained by the SU2 Foundation +# (http://su2foundation.org) +# +# Copyright 2012-2024, SU2 Contributors (cf. AUTHORS.md) +# +# SU2 is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# SU2 is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with SU2. If not, see . + +import sys +import pysu2 +import math +import itertools +# from mpi4py import MPI + +def main(): + """ + Run the flow solver with a custom inlet (function of time and space). + """ + # comm = MPI.COMM_WORLD + comm = 0 + + # Initialize the primal driver of SU2, this includes solver preprocessing. + try: + driver = pysu2.CSinglezoneDriver('lam_buoyancy_cavity.cfg', 1, comm) + except TypeError as exception: + print('A TypeError occured in pysu2.CSinglezoneDriver : ', exception) + raise + + # Get the ID of the inlet marker. + all_marker_ids = driver.GetMarkerIndices() + marker_name = 'x_minus' + marker_id = all_marker_ids[marker_name] if marker_name in all_marker_ids else -1 + + # Run the time loop in python to vary the inlet conditions. + dt = driver.GetUnsteadyTimeStep() + + print("\n------------------------------ Begin Solver -----------------------------") + sys.stdout.flush() + + # we need to add a source term to the energy equation. For this, we need to get the solver, and the variable first. + # we then loop over all points and for these points, we add the source term + nDim = driver.GetNumberDimensions() + nNodes = driver.GetNumberNodes() + #solverindex = driver.GetSolverIndices() + #primindex = driver.GetPrimitiveIndices() + + # index to the flow solver + iSOLVER = driver.GetSolverIndices()['INC.FLOW'] + print("index of flow solver = ",iSOLVER) + coords = driver.Coordinates() + # all the indices and the map to the names of the primitives + primindex = driver.GetPrimitiveIndices() + print("indices of primitives=",primindex) + print("number of primitives:",len(primindex)) + + nElem = driver.GetNumberElements() + print("number of elements:",nElem) + + nVars = driver.GetNumberSolverVars(iSOLVER) + print("number of solver variables:",nVars) + varindex = primindex.copy() + for prim in varindex.copy(): + if varindex[prim] >=nVars: + del varindex[prim] + varindex = dict(sorted(varindex.items(), key=lambda item: item[1])) + + + + print("solver variable names:",varindex) + iDENSITY = primindex.get("DENSITY") + print("index of density = ",iDENSITY) + + index_Vel = varindex.get("VELOCITY_X") + print("index of velocity = ",index_Vel) + custom_source_vector = [0.0 for i in range(nVars)] + print("custom source vector = ", custom_source_vector) + + inner_iter = driver.GetNumberInnerIter(); + print("max. number of inner iterations: ",driver.GetNumberInnerIter()); + print("max nr of outer iterations: ",driver.GetNumberOuterIter()); + + # is in domain: isdomain = driver.GetNodeDomain(iPoint) + #for i_vertex in range(n_vertex) + #AllSolutions = driver.GetAllSolutions(iSOLVER) + Body_Force_Vector = [0.0, -9.81, 0.0] + DensityInc_0 = driver.GetDensity_FreeStreamND() + print("rho freestream = ",DensityInc_0) + Force_Ref = driver.GetForce_Ref() + print("reference force = ",Force_Ref) + # get the density from the solution + #residual[iDim+1] = -(DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; + + #for i_node in range(driver.GetNumberNodes() - driver.GetNumberHaloNodes()): + #print("(x,y) = ( ",coords.Get(i_node,0)," , ",coords.Get(i_node,1)," )") + #custom_source = -9.81 + # we need to set the custom source to the correct primitive equation, in this case let us add it to the y-momentum equation + #i_momy = 2 + #driver.SetCustomSource(iSOLVER, iVar, i_node,custom_source) + #DensityInc_i = driver.GetSolution(iSOLVER,iPoint,2) + #driver.SetPointCustomSource(iSOLVER, i_node,custom_source_vector) + + + + # we get the numer of iterations: + + DensityInc_i = 1 + # we set the actual inner iterations to 1 + #for time_iter in range(inner_iter): + for inner_iter in range(500): + + # set the source term, per point + print("loop over nodes and set the source term field") + for i_node in range(driver.GetNumberNodes() - driver.GetNumberHaloNodes()): + #print("node = ",i_node) + SolutionVector = driver.GetSolutionVector(iSOLVER,i_node) + #print("solutionvector=",SolutionVector) + PrimitiveVector = driver.GetPrimitiveVector(iSOLVER,i_node) + #print("primitivevector=",PrimitiveVector) + DensityInc_i = PrimitiveVector[iDENSITY] + #residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; + for iDim in range(nDim): + custom_source_vector[iDim+1] = -(DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref + #print("density=",DensityInc_i) + driver.SetPointCustomSource(iSOLVER, i_node,custom_source_vector) + print("end setting custom source term") + + # Change the total pressure. + #if marker_id >= 0: + # for i_vertex in range(driver.GetNumberMarkerNodes(marker_id)): + # y = driver.MarkerCoordinates(marker_id)(i_vertex, 1) + # t = time_iter * dt + # pt = 1e5 + 2e4 * y / 0.01 * (1 - math.cos(2 * math.pi * t / 0.1)) + # driver.SetMarkerCustomInletFlowVar1(marker_id, i_vertex, pt) + #driver.BoundaryConditionsUpdate() + print(" *** inner iteration:",inner_iter) + driver.Preprocess(inner_iter) + + # Run one time iteration. + driver.Run() + driver.Postprocess() + driver.Update() + + # Monitor the solver and output solution to file if required. + #driver.Monitor(inner_iter) + driver.Output(inner_iter) + + # Finalize the solver and exit cleanly. + driver.Finalize() + +if __name__ == '__main__': + main() From b407a273df875a0c69686153e296f82f6d7bd457 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Tue, 3 Dec 2024 14:53:03 +0100 Subject: [PATCH 03/10] small cleanup --- Common/include/CConfig.hpp | 13 ------------- Common/src/CConfig.cpp | 3 +-- SU2_CFD/include/drivers/CDriver.hpp | 13 ------------- SU2_CFD/src/drivers/CSinglezoneDriver.cpp | 7 ++----- SU2_CFD/src/python_wrapper_structure.cpp | 2 -- 5 files changed, 3 insertions(+), 35 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 553b689023f..0c32f044288 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -286,7 +286,6 @@ class CConfig { su2double **Giles_FlowDir; /*!< \brief Specified flow direction vector (unit vector) for Giles BC. */ su2double *Inlet_Ptotal; /*!< \brief Specified total pressures for inlet boundaries. */ su2double **Inlet_FlowDir; /*!< \brief Specified flow direction vector (unit vector) for inlet boundaries. */ - //su2double *PointSource; /*!< \brief Specified flow direction vector (unit vector) for inlet boundaries. */ su2double *Inlet_Temperature; /*!< \brief Specified temperatures for a supersonic inlet boundaries. */ su2double *Inlet_Pressure; /*!< \brief Specified static pressures for supersonic inlet boundaries. */ su2double **Inlet_Velocity; /*!< \brief Specified flow velocity vectors for supersonic inlet boundaries. */ @@ -9455,18 +9454,6 @@ class CConfig { */ unsigned long GetnOuter_Iter(void) const { return nOuterIter; } - /*! - * \brief Get the number of inner iterations - * \return Number of inner iterations on each multizone block - */ - void SetnInner_Iter(unsigned long val_iter) { nInnerIter = val_iter; } - - /*! - * \brief Get the number of outer iterations - * \return Number of outer iterations for the multizone problem - */ - void SetnOuter_Iter(unsigned long val_iter) { cout << "inner iter=" << val_iter << endl; nOuterIter = val_iter; } - /*! * \brief Get the number of time iterations * \return Number of time steps run diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index b80fdedfc41..64be5736bca 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -890,7 +890,6 @@ void CConfig::SetPointersNull() { Inlet_FlowDir = nullptr; Inlet_Temperature = nullptr; Inlet_Pressure = nullptr; Inlet_Velocity = nullptr; Outlet_Pressure = nullptr; Inlet_SpeciesVal = nullptr; Inlet_TurbVal = nullptr; - //PointSource = nullptr; /*--- Engine Boundary Condition settings ---*/ @@ -914,7 +913,7 @@ void CConfig::SetPointersNull() { Inlet_FlowDir = nullptr; Inlet_Temperature = nullptr; Inlet_Pressure = nullptr; Inlet_Velocity = nullptr; Inflow_Mach = nullptr; Inflow_Pressure = nullptr; Outlet_Pressure = nullptr; Isothermal_Temperature = nullptr; - //PointSource = nullptr; + ElasticityMod = nullptr; PoissonRatio = nullptr; MaterialDensity = nullptr; Load_Dir = nullptr; Load_Dir_Value = nullptr; Load_Dir_Multiplier = nullptr; diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 7c74ed40a85..cbb646e5def 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -487,19 +487,6 @@ class CDriver : public CDriverBase { */ unsigned long GetNumberOuterIter() const; - - /*! - * \brief Set the number of inner iterations. - * \return Number of inner iterations. - */ - void SetNumberInnerIter(unsigned long); - - /*! - * \brief Set the number of outer iterations. - * \return Number of outer iterations. - */ - void SetNumberOuterIter(unsigned long); - /*! * \brief Get the current solution * \return Current solution diff --git a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp index 8bec4611e58..ed4d46f370e 100644 --- a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp @@ -106,10 +106,6 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) { /*--- Set the current time iteration in the config and also in the driver * because the python interface doesn't offer an explicit way of doing it. ---*/ - if (config_container[ZONE_0]->GetTime_Marching() == TIME_MARCHING::STEADY) { - cout << "steady simulation, iteration = " << TimeIter << endl; - config_container[ZONE_0]->SetInnerIter(TimeIter); - } this->TimeIter = TimeIter; config_container[ZONE_0]->SetTimeIter(TimeIter); @@ -117,7 +113,8 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) { /*--- Store the current physical time in the config container, as this can be used for verification / MMS. This should also be more general once the drivers are more stable. ---*/ - if (config_container[ZONE_0]->GetTime_Marching() != TIME_MARCHING::STEADY) + + if (config_container[ZONE_0]->GetTime_Marching() != TIME_MARCHING::STEADY) config_container[ZONE_0]->SetPhysicalTime(static_cast(TimeIter)*config_container[ZONE_0]->GetDelta_UnstTimeND()); else config_container[ZONE_0]->SetPhysicalTime(0.0); diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 2677eb21943..1008af2d06a 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -60,8 +60,6 @@ unsigned long CDriver::GetNumberTimeIter() const { return config_container[selec unsigned long CDriver::GetNumberInnerIter() const { return config_container[selected_zone]->GetnInner_Iter(); } unsigned long CDriver::GetNumberOuterIter() const { return config_container[selected_zone]->GetnOuter_Iter(); } -void CDriver::SetNumberInnerIter(unsigned long nInner) { config_container[selected_zone]->SetnInner_Iter(nInner); } -void CDriver::SetNumberOuterIter(unsigned long nOuter) { config_container[selected_zone]->SetnOuter_Iter(nOuter); } unsigned long CDriver::GetDensity_FreeStreamND() const { return config_container[selected_zone]->GetDensity_FreeStreamND(); } unsigned long CDriver::GetForce_Ref() const { return config_container[selected_zone]->GetForce_Ref(); } From ce0b61e6bcf65912cf1724e72679523ad0dedd11 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Tue, 3 Dec 2024 15:08:08 +0100 Subject: [PATCH 04/10] small cleanup of python file --- TestCases/py_wrapper/custom_source/run.py | 53 +++-------------------- 1 file changed, 6 insertions(+), 47 deletions(-) diff --git a/TestCases/py_wrapper/custom_source/run.py b/TestCases/py_wrapper/custom_source/run.py index c9fcaf4e0ac..ea08aaf98bc 100644 --- a/TestCases/py_wrapper/custom_source/run.py +++ b/TestCases/py_wrapper/custom_source/run.py @@ -1,7 +1,7 @@ #!/usr/bin/env python ## \file run.py -# \brief Unsteady inlet boundary conditions. +# \brief Buoyancy force using user defines source term # \version 8.1.0 "Harrier" # # SU2 Project Website: https://su2code.github.io @@ -26,8 +26,6 @@ import sys import pysu2 -import math -import itertools # from mpi4py import MPI def main(): @@ -44,28 +42,17 @@ def main(): print('A TypeError occured in pysu2.CSinglezoneDriver : ', exception) raise - # Get the ID of the inlet marker. - all_marker_ids = driver.GetMarkerIndices() - marker_name = 'x_minus' - marker_id = all_marker_ids[marker_name] if marker_name in all_marker_ids else -1 - - # Run the time loop in python to vary the inlet conditions. - dt = driver.GetUnsteadyTimeStep() - print("\n------------------------------ Begin Solver -----------------------------") sys.stdout.flush() # we need to add a source term to the energy equation. For this, we need to get the solver, and the variable first. # we then loop over all points and for these points, we add the source term nDim = driver.GetNumberDimensions() - nNodes = driver.GetNumberNodes() - #solverindex = driver.GetSolverIndices() - #primindex = driver.GetPrimitiveIndices() # index to the flow solver iSOLVER = driver.GetSolverIndices()['INC.FLOW'] print("index of flow solver = ",iSOLVER) - coords = driver.Coordinates() + # all the indices and the map to the names of the primitives primindex = driver.GetPrimitiveIndices() print("indices of primitives=",primindex) @@ -93,7 +80,6 @@ def main(): custom_source_vector = [0.0 for i in range(nVars)] print("custom source vector = ", custom_source_vector) - inner_iter = driver.GetNumberInnerIter(); print("max. number of inner iterations: ",driver.GetNumberInnerIter()); print("max nr of outer iterations: ",driver.GetNumberOuterIter()); @@ -105,51 +91,24 @@ def main(): print("rho freestream = ",DensityInc_0) Force_Ref = driver.GetForce_Ref() print("reference force = ",Force_Ref) - # get the density from the solution - #residual[iDim+1] = -(DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; - - #for i_node in range(driver.GetNumberNodes() - driver.GetNumberHaloNodes()): - #print("(x,y) = ( ",coords.Get(i_node,0)," , ",coords.Get(i_node,1)," )") - #custom_source = -9.81 - # we need to set the custom source to the correct primitive equation, in this case let us add it to the y-momentum equation - #i_momy = 2 - #driver.SetCustomSource(iSOLVER, iVar, i_node,custom_source) - #DensityInc_i = driver.GetSolution(iSOLVER,iPoint,2) - #driver.SetPointCustomSource(iSOLVER, i_node,custom_source_vector) - - - # we get the numer of iterations: - - DensityInc_i = 1 - # we set the actual inner iterations to 1 - #for time_iter in range(inner_iter): for inner_iter in range(500): # set the source term, per point - print("loop over nodes and set the source term field") for i_node in range(driver.GetNumberNodes() - driver.GetNumberHaloNodes()): #print("node = ",i_node) - SolutionVector = driver.GetSolutionVector(iSOLVER,i_node) + #SolutionVector = driver.GetSolutionVector(iSOLVER,i_node) #print("solutionvector=",SolutionVector) PrimitiveVector = driver.GetPrimitiveVector(iSOLVER,i_node) #print("primitivevector=",PrimitiveVector) DensityInc_i = PrimitiveVector[iDENSITY] - #residual[iDim+1] = -Volume * (DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref; + for iDim in range(nDim): custom_source_vector[iDim+1] = -(DensityInc_i - DensityInc_0) * Body_Force_Vector[iDim] / Force_Ref + #print("density=",DensityInc_i) driver.SetPointCustomSource(iSOLVER, i_node,custom_source_vector) - print("end setting custom source term") - - # Change the total pressure. - #if marker_id >= 0: - # for i_vertex in range(driver.GetNumberMarkerNodes(marker_id)): - # y = driver.MarkerCoordinates(marker_id)(i_vertex, 1) - # t = time_iter * dt - # pt = 1e5 + 2e4 * y / 0.01 * (1 - math.cos(2 * math.pi * t / 0.1)) - # driver.SetMarkerCustomInletFlowVar1(marker_id, i_vertex, pt) - #driver.BoundaryConditionsUpdate() + print(" *** inner iteration:",inner_iter) driver.Preprocess(inner_iter) From d8d30a4c871ae219798e8618f65264070d3caeb8 Mon Sep 17 00:00:00 2001 From: bigfooted Date: Tue, 3 Dec 2024 15:25:36 +0100 Subject: [PATCH 05/10] small cleanup --- SU2_CFD/include/drivers/CDriverBase.hpp | 49 +++++++++---------- .../include/solvers/CFVMFlowSolverBase.hpp | 14 +++--- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/SU2_CFD/include/drivers/CDriverBase.hpp b/SU2_CFD/include/drivers/CDriverBase.hpp index 699379ab444..7a4988d76eb 100644 --- a/SU2_CFD/include/drivers/CDriverBase.hpp +++ b/SU2_CFD/include/drivers/CDriverBase.hpp @@ -762,47 +762,49 @@ class CDriverBase { /*! * \brief Set the array of variables for the source in the point - * \param[in] iMarker - Marker index. - * \param[in] iVertex - Marker vertex index. - * \param[in] value - Value of the variable. + * \param[in] iSolver - Solver index. + * \param[in] iPoint - Point index. + * \param[in] values - Vector values of the source term. */ - void SetPointCustomSource(unsigned short iSOLVER, unsigned long iPoint, std::vector values) { - //for (auto iVar = 0ul; iVar < nVar; ++iDim) { - //GetSolverAndCheckField(FLOW_SOL, iPoint)->SetCustomPointSource (iPoint, value); - auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSOLVER]; + void SetPointCustomSource(unsigned short iSolver, unsigned long iPoint, std::vector values) { + auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver]; solver->SetCustomPointSource(iPoint, values); } -// return solution vector -inline vector GetSolutionVector(unsigned short iSOLVER, unsigned long iPoint) { - auto* solver = solver_container[iSOLVER][INST_0][MESH_0][iSOLVER]; + /*! + * \brief Get the solution vector in a point for a specific solver + * \param[in] iSolver - Solver index. + * \param[in] iPoint - Point index. + * \param[out] solutionvector - Vector values of the solution. + */ +inline vector GetSolutionVector(unsigned short iSolver, unsigned long iPoint) { + auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver]; auto* nodes = solver->GetNodes(); - auto nVar = GetNumberSolverVars(iSOLVER); - //cout << "getting solution: "<GetSolution(iPoint,2); - //cout << "value : " << val << endl; + auto nVar = GetNumberSolverVars(iSolver); vector solutionvector(nVar, 0.0); for (auto iVar = 0u; iVar < nVar; ++iVar) { solutionvector[iVar] = SU2_TYPE::GetValue(nodes->GetSolution(iPoint,iVar)); - //cout << "vector = " << solutionvector[iVar] << endl; } return solutionvector; } -inline vector GetPrimitiveVector(unsigned short iSOLVER, unsigned long iPoint) { - auto* solver = solver_container[iSOLVER][INST_0][MESH_0][iSOLVER]; + /*! + * \brief Get the primitive variables vector in a point for a specific solver + * \param[in] iSolver - Solver index. + * \param[in] iPoint - Point index. + * \param[out] solutionvector - Vector values of the primitive variables. + */ +inline vector GetPrimitiveVector(unsigned short iSolver, unsigned long iPoint) { + auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver]; auto* nodes = solver->GetNodes(); - auto nPrimvar = GetNumberPrimitiveVars(iSOLVER); - //cout << "getting solution: "<GetSolution(iPoint,2); - //cout << "value : " << val << endl; + auto nPrimvar = GetNumberPrimitiveVars(iSolver); vector solutionvector(nPrimvar, 0.0); for (auto iVar = 0u; iVar < nPrimvar; ++iVar) { solutionvector[iVar] = SU2_TYPE::GetValue(nodes->GetPrimitive(iPoint,iVar)); - //cout << "vector = " << solutionvector[iVar] << endl; } return solutionvector; } + /// \} protected: @@ -826,9 +828,6 @@ inline vector GetPrimitiveVector(unsigned short iSOLVER, unsigned unsigned long iPoint = std::numeric_limits::max()) const { // 1. check for the solver the number of variables // 2. check for the mesh the number of points - //if (iPoint < std::numeric_limits::max() && iPoint > GetNumberMarkers()) { - // SU2_MPI::Error("Marker index exceeds size.", CURRENT_FUNCTION); - //} auto* solver = solver_container[selected_zone][INST_0][MESH_0][iSolver]; if (solver == nullptr) SU2_MPI::Error("The selected solver does not exist.", CURRENT_FUNCTION); return solver; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 9aacffc9c2f..3547d97376a 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -2225,16 +2225,14 @@ class CFVMFlowSolverBase : public CSolver { vector val_source) final { /*--- Since this call can be accessed indirectly using python, do some error * checking to prevent segmentation faults ---*/ - //if (val_marker >= nMarker) - // SU2_MPI::Error("Out-of-bounds marker index used on inlet.", CURRENT_FUNCTION); - //else if (val_vertex >= nVertex[val_marker]) - // SU2_MPI::Error("Out-of-bounds vertex index used on inlet.", CURRENT_FUNCTION); - //else - //cout << "value list size=" << val_source.size() << endl; - //cout << "pointsource.size = " << nVar << endl; - //cout << "point,npoint=" << val_point << " " << nPointDomain << endl; + if (val_point > nPointDomain) + SU2_MPI::Error("Out-of-bounds point index used on solver.", CURRENT_FUNCTION); + else if (val_source.size() > nVar) + SU2_MPI::Error("Out-of-bounds source size used on solver.", CURRENT_FUNCTION); + else { for (unsigned short iVar=0; iVar < val_source.size(); iVar++) PointSource[val_point][iVar] = val_source[iVar]; + } } /*! From 488efa066788ee0fbcbd24e73f4d6f5443a5d553 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 3 Dec 2024 16:18:57 +0100 Subject: [PATCH 06/10] Update SU2_CFD/include/drivers/CDriverBase.hpp --- SU2_CFD/include/drivers/CDriverBase.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/include/drivers/CDriverBase.hpp b/SU2_CFD/include/drivers/CDriverBase.hpp index 7a4988d76eb..fb7f73c46a1 100644 --- a/SU2_CFD/include/drivers/CDriverBase.hpp +++ b/SU2_CFD/include/drivers/CDriverBase.hpp @@ -183,7 +183,6 @@ class CDriverBase { * \brief Get the number of solution variables * \return Number of solution variables. */ - //unsigned long GetNumberSolverVars() const; unsigned short GetNumberSolverVars(const unsigned short iSol) const; unsigned short GetNumberPrimitiveVars(const unsigned short iSol) const; From 40e1d9761e1c514f3a6c84824b215f414408f005 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 3 Dec 2024 16:19:32 +0100 Subject: [PATCH 07/10] Fix code scanning alert no. 5107: Comparison of narrow type with wide type in loop condition Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp index 3547d97376a..c10ff9ea346 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp @@ -2230,7 +2230,7 @@ class CFVMFlowSolverBase : public CSolver { else if (val_source.size() > nVar) SU2_MPI::Error("Out-of-bounds source size used on solver.", CURRENT_FUNCTION); else { - for (unsigned short iVar=0; iVar < val_source.size(); iVar++) + for (size_t iVar=0; iVar < val_source.size(); iVar++) PointSource[val_point][iVar] = val_source[iVar]; } } From b77fd09582a2857f1c7010a35b962b76393f0364 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 3 Dec 2024 16:20:05 +0100 Subject: [PATCH 08/10] Update SU2_CFD/include/solvers/CFVMFlowSolverBase.inl --- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 2 -- 1 file changed, 2 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index b9bcdc451f2..3f10ef7885e 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -123,8 +123,6 @@ void CFVMFlowSolverBase::Allocate(const CConfig& config) { /*--- Store the value of the Flow direction at the inlet BC ---*/ AllocVectorOfMatrices(nVertex, nDim, Inlet_FlowDir); - - //AllocVectorOfVectors(nPointDomain, PointSource); PointSource.resize(nPointDomain,nVar); /*--- Force definition and coefficient arrays for all of the markers ---*/ From 4904b1992772dce28d65cba37cbc570049263f47 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 3 Dec 2024 16:20:27 +0100 Subject: [PATCH 09/10] Update SU2_CFD/src/numerics/flow/flow_sources.cpp --- SU2_CFD/src/numerics/flow/flow_sources.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index b5c29a6325f..93aab49d930 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -427,7 +427,6 @@ CNumerics::ResidualType<> CSourceIncBodyForce::ComputeResidual(const CConfig* co residual[nDim+1] = 0.0; - //cout << "residual = " << residual[0] << " " << residual[1] << " " << residual[2] << " " <(residual, jacobian, nullptr); } From d4ac82b0658a25fd7a075cee8196504f463bb7aa Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 3 Dec 2024 16:20:50 +0100 Subject: [PATCH 10/10] Update SU2_CFD/src/drivers/CDriverBase.cpp --- SU2_CFD/src/drivers/CDriverBase.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CDriverBase.cpp b/SU2_CFD/src/drivers/CDriverBase.cpp index 7ea82380095..2a6742fe600 100644 --- a/SU2_CFD/src/drivers/CDriverBase.cpp +++ b/SU2_CFD/src/drivers/CDriverBase.cpp @@ -165,7 +165,6 @@ unsigned long CDriverBase::GetNumberDimensions() const { return main_geometry->G unsigned long CDriverBase::GetNumberElements() const { return main_geometry->GetnElem(); } -//unsigned long CDriverBase::GetNumberSolverVars() const { return main_geometry->GetnElem(); } unsigned short CDriverBase::GetNumberSolverVars(const unsigned short iSol) const { return solver_container[selected_zone][INST_0][MESH_0][iSol]->GetnVar(); } unsigned short CDriverBase::GetNumberPrimitiveVars(const unsigned short iSol) const { return solver_container[selected_zone][INST_0][MESH_0][iSol]->GetnPrimVar(); }