From 5e79c2acbfe7de54ab040762a4c1fd8a4bf79e5f Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 4 Sep 2019 15:19:19 -0700 Subject: [PATCH 01/57] First implementation of nonlinear controller. Needs cleanup. Not stable for RANS. --- SU2_CFD/include/solver_structure.hpp | 12 +++ SU2_CFD/include/solver_structure.inl | 2 + SU2_CFD/include/variables/CVariable.hpp | 40 +++++++ SU2_CFD/src/drivers/CDriver.cpp | 48 ++++----- SU2_CFD/src/iteration_structure.cpp | 16 +-- SU2_CFD/src/output_structure.cpp | 5 + SU2_CFD/src/solver_direct_mean.cpp | 136 ++++++++++++++++++++++-- SU2_CFD/src/solver_direct_turbulent.cpp | 4 +- SU2_CFD/src/variables/CVariable.cpp | 4 + 9 files changed, 227 insertions(+), 40 deletions(-) diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index bb19df436c76..419a221fa830 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -1290,6 +1290,12 @@ class CSolver { */ virtual void ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config); + /*! + * \brief A virtual member. + * \param[in] config - Definition of the particular problem. + */ + virtual su2double ComputeUnderRelaxationFactor(CConfig *config); + /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. @@ -5426,6 +5432,12 @@ class CEulerSolver : public CSolver { */ void ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config); + /*! + * \brief Compute a suitable under-relaxation parameter to limit the change in the solution variables over a nonlinear iteration for stability. + * \param[in] config - Definition of the particular problem. + */ + su2double ComputeUnderRelaxationFactor(CConfig *config); + /*! * \brief Compute the pressure forces and all the adimensional coefficients. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index aad715e371ba..b7933dbb8c49 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -855,6 +855,8 @@ inline void CSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solv inline void CSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { } +inline su2double CSolver::ComputeUnderRelaxationFactor(CConfig *config) { return 0.0; } + inline void CSolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { } inline void CSolver::ImplicitNewmark_Update(CGeometry *geometry, CSolver **solver_container, CConfig *config) { } diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 74a8a5fcc5f6..41ef7727ebd0 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -81,6 +81,10 @@ class CVariable { su2double *Res_TruncError, /*!< \brief Truncation error for multigrid cycle. */ *Residual_Old, /*!< \brief Auxiliar structure for residual smoothing. */ *Residual_Sum; /*!< \brief Auxiliar structure for residual smoothing. */ + su2double UnderRelaxation; /*!< \brief Value of the under-relxation parameter local to the control volume. */ + su2double LocalCFL; /*!< \brief Value of the CFL number local to the control volume. */ + su2double LocalCFLFactor; /*!< \brief Value of the factor to increase/decrease the CFL number local to the control volume. */ + static unsigned short nDim; /*!< \brief Number of dimension of the problem. */ unsigned short nVar; /*!< \brief Number of variables of the problem, note that this variable cannnot be static, it is possible to @@ -472,6 +476,42 @@ class CVariable { val_residual[iVar] = Residual_Sum[iVar]; } + /*! + * \brief Set the value of the under-relaxation parameter for the current control volume (CV). + * \param[in] val_under_relaxation - the input value of the under-relaxation parameter for this CV. + */ + inline void SetUnderRelaxation(su2double val_under_relaxation) { UnderRelaxation = val_under_relaxation; } + + /*! + * \brief Get the value of the under-relaxation parameter for the current control volume (CV). + * \return Value of the under-relaxation parameter for this CV. + */ + inline su2double GetUnderRelaxation(void) { return UnderRelaxation; } + + /*! + * \brief Set the value of the local CFL number for the current control volume (CV). + * \param[in] val_cfl - the input value of the local CFL number for this CV. + */ + inline void SetLocalCFL(su2double val_cfl) { LocalCFL = val_cfl; } + + /*! + * \brief Get the value of the local CFL number for the current control volume (CV). + * \return Value of the local CFL number for this CV. + */ + inline su2double GetLocalCFL(void) { return LocalCFL; } + + /*! + * \brief Set the value of the factor to increase/decrease the local CFL number for the current control volume (CV). + * \param[in] val_cfl_factor - the input value of the factor to increase/decrease the local CFL number for this CV. + */ + inline void SetLocalCFLFactor(su2double val_cfl_factor) { LocalCFLFactor = val_cfl_factor; } + + /*! + * \brief Get the value of the factor to increase/decrease the local CFL number for the current control volume (CV). + * \return Value of the factor to increase/decrease the local CFL number for this CV. + */ + inline su2double GetLocalCFLFactor(void) { return LocalCFLFactor; } + /*! * \brief Set auxiliar variables, we are looking for the gradient of that variable. * \param[in] val_auxvar - Value of the auxiliar variable. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 232834ecaaa7..bb1dac36505b 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -3922,13 +3922,13 @@ bool CDriver::Monitor(unsigned long ExtIter) { } } - /*--- Evaluate the new CFL number (adaptive). ---*/ - if (config_container[ZONE_0]->GetCFL_Adapt() == YES) { - for (iZone = 0; iZone < nZone; iZone++){ - if (!(config_container[iZone]->GetMultizone_Problem())) // This needs to be changed everywhere in the code, in a future PR - output->SetCFL_Number(solver_container, config_container, iZone); - } - } +// /*--- Evaluate the new CFL number (adaptive). ---*/ +// if (config_container[ZONE_0]->GetCFL_Adapt() == YES) { +// for (iZone = 0; iZone < nZone; iZone++){ +// if (!(config_container[iZone]->GetMultizone_Problem())) // This needs to be changed everywhere in the code, in a future PR +// output->SetCFL_Number(solver_container, config_container, iZone); +// } +// } /*--- Check whether the current simulation has reached the specified convergence criteria, and set StopCalc to true, if so. ---*/ @@ -4291,23 +4291,23 @@ bool CTurbomachineryDriver::Monitor(unsigned long ExtIter) { } - /*--- Evaluate the new CFL number (adaptive). ---*/ - if (config_container[ZONE_0]->GetCFL_Adapt() == YES) { - if(mixingplane){ - CFL = 0; - for (iZone = 0; iZone < nZone; iZone++){ - output->SetCFL_Number(solver_container, config_container, iZone); - CFL += config_container[iZone]->GetCFL(MESH_0); - } - /*--- For fluid-multizone the new CFL number is the same for all the zones and it is equal to the zones' minimum value. ---*/ - for (iZone = 0; iZone < nZone; iZone++){ - config_container[iZone]->SetCFL(MESH_0, CFL/nZone); - } - } - else{ - output->SetCFL_Number(solver_container, config_container, ZONE_0); - } - } +// /*--- Evaluate the new CFL number (adaptive). ---*/ +// if (config_container[ZONE_0]->GetCFL_Adapt() == YES) { +// if(mixingplane){ +// CFL = 0; +// for (iZone = 0; iZone < nZone; iZone++){ +// output->SetCFL_Number(solver_container, config_container, iZone); +// CFL += config_container[iZone]->GetCFL(MESH_0); +// } +// /*--- For fluid-multizone the new CFL number is the same for all the zones and it is equal to the zones' minimum value. ---*/ +// for (iZone = 0; iZone < nZone; iZone++){ +// config_container[iZone]->SetCFL(MESH_0, CFL/nZone); +// } +// } +// else{ +// output->SetCFL_Number(solver_container, config_container, ZONE_0); +// } +// } /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ diff --git a/SU2_CFD/src/iteration_structure.cpp b/SU2_CFD/src/iteration_structure.cpp index 137cbed4b78a..a1ca3e54b747 100644 --- a/SU2_CFD/src/iteration_structure.cpp +++ b/SU2_CFD/src/iteration_structure.cpp @@ -568,10 +568,10 @@ void CFluidIteration::Preprocess(COutput *output, SetWind_GustField(config[val_iZone], geometry[val_iZone][val_iInst], solver[val_iZone][val_iInst]); } - /*--- Evaluate the new CFL number (adaptive). ---*/ - if ((config[val_iZone]->GetCFL_Adapt() == YES) && ( OuterIter != 0 ) ) { - output->SetCFL_Number(solver, config, val_iZone); - } +// /*--- Evaluate the new CFL number (adaptive). ---*/ +// if ((config[val_iZone]->GetCFL_Adapt() == YES) && ( OuterIter != 0 ) ) { +// output->SetCFL_Number(solver, config, val_iZone); +// } } @@ -1286,10 +1286,10 @@ void CHeatIteration::Preprocess(COutput *output, unsigned long OuterIter = config[val_iZone]->GetOuterIter(); - /*--- Evaluate the new CFL number (adaptive). ---*/ - if ((config[val_iZone]->GetCFL_Adapt() == YES) && ( OuterIter != 0 ) ) { - output->SetCFL_Number(solver, config, val_iZone); - } +// /*--- Evaluate the new CFL number (adaptive). ---*/ +// if ((config[val_iZone]->GetCFL_Adapt() == YES) && ( OuterIter != 0 ) ) { +// output->SetCFL_Number(solver, config, val_iZone); +// } } diff --git a/SU2_CFD/src/output_structure.cpp b/SU2_CFD/src/output_structure.cpp index 137e8c65b1b2..de8396c58c41 100644 --- a/SU2_CFD/src/output_structure.cpp +++ b/SU2_CFD/src/output_structure.cpp @@ -12995,6 +12995,9 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * } } + nVar_Par +=1; + Variable_Names.push_back("Local_CFL"); + } /*--- Auxiliary vectors for variables defined on surfaces only. ---*/ @@ -13305,6 +13308,8 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * } } + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetLocalCFL(); iVar++; + } /*--- Increment the point counter, as there may have been halos we diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 71729acf56ca..ec324c128270 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -903,6 +903,13 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short InitiateComms(geometry, config, SOLUTION); CompleteComms(geometry, config, SOLUTION); + /* Store the initial CFL number for all grid points. */ + + for (iPoint = 0; iPoint < nPoint; iPoint++) { + const su2double CFL = config->GetCFL(MGLevel); + node[iPoint]->SetLocalCFL(CFL); + } + } CEulerSolver::~CEulerSolver(void) { @@ -3125,7 +3132,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, bool dual_time = ((config->GetUnsteady_Simulation() == DT_STEPPING_1ST) || (config->GetUnsteady_Simulation() == DT_STEPPING_2ND)); - Min_Delta_Time = 1.E6; Max_Delta_Time = 0.0; + Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ @@ -3213,7 +3220,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Vol = geometry->node[iPoint]->GetVolume(); if (Vol != 0.0) { - Local_Delta_Time = config->GetCFL(iMesh)*Vol / node[iPoint]->GetMax_Lambda_Inv(); + Local_Delta_Time = node[iPoint]->GetLocalCFL()*Vol / node[iPoint]->GetMax_Lambda_Inv(); Global_Delta_Time = min(Global_Delta_Time, Local_Delta_Time); Min_Delta_Time = min(Min_Delta_Time, Local_Delta_Time); Max_Delta_Time = max(Max_Delta_Time, Local_Delta_Time); @@ -5191,12 +5198,15 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver SetIterLinSolver(IterLinSol); + su2double underRelaxation = ComputeUnderRelaxationFactor(config); + /*--- Update solution (system written in terms of increments) ---*/ if (!adjoint) { for (iPoint = 0; iPoint < nPointDomain; iPoint++) { + underRelaxation = node[iPoint]->GetUnderRelaxation(); for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddSolution(iVar, config->GetRelaxation_Factor_Flow()*LinSysSol[iPoint*nVar+iVar]); + node[iPoint]->AddSolution(iVar, underRelaxation*LinSysSol[iPoint*nVar+iVar]); } } } @@ -5221,6 +5231,113 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver } +su2double CEulerSolver::ComputeUnderRelaxationFactor(CConfig *config) { + + /* Loop over the solution update given by relaxing the linear + system for this nonlinear iteration. */ + + su2double underRelaxation = 1.0; + su2double localUnderRelaxation = 1.0; + const su2double percentChange = 0.30;// config->GetUnderRelaxationPercentChange(); + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { + + localUnderRelaxation = 1.0; + + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + + /* We impose a limit on the maximum percentage that the + density and energy can change over a nonlinear iteration. */ + + + if ((iVar == 0) || (iVar == nVar-1)) { + + const unsigned long index = iPoint*nVar + iVar; + + + su2double ratio = fabs(LinSysSol[index])/node[iPoint]->GetSolution(iVar); + + if (ratio > percentChange) { + underRelaxation = min(percentChange/ratio, underRelaxation); + localUnderRelaxation = min(percentChange/ratio, localUnderRelaxation); + } + + } + + } + + node[iPoint]->SetUnderRelaxation(localUnderRelaxation); + + } + + /* Reduce to obtain the global minimum relaxation factor. */ + + localUnderRelaxation = underRelaxation; + SU2_MPI::Allreduce(&localUnderRelaxation, &underRelaxation, + 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + + /* Adapt the CFL number based on the under-relaxation parameter. */ + + if (config->GetCFL_Adapt()) { + + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { + + su2double CFLFactor = 1.0, CFL = 0.0, CFLMin = 0.0, CFLMax = 0.0, MGFactor[100]; + unsigned short iMesh; + + /*--- Compute MG factor ---*/ + + for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; + else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); + } + + /*--- If we use a small under-relaxation parameter for stability, + then we should reduce the CFL before the next iteration. If we + are able to add the entire nonlinear update (under-relaxation = 1) + then we can increase the CFL number for the next iteration. ---*/ + + underRelaxation = node[iPoint]->GetUnderRelaxation(); + + if (underRelaxation < 0.1) { + CFLFactor = config->GetCFL_AdaptParam(0); + node[iPoint]->SetUnderRelaxation(0.0); + } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { + CFLFactor = 1.0; + } else { + CFLFactor = config->GetCFL_AdaptParam(1); + } + + CFLMin = config->GetCFL_AdaptParam(2); + CFLMax = config->GetCFL_AdaptParam(3); + + //CFL = config->GetCFL(MGLevel); + CFL = node[iPoint]->GetLocalCFL(); + + if ((CFL <= CFLMin)) { + CFL = CFLMin; + CFLFactor = 1.001*MGFactor[MGLevel]; + } + else if ((CFL >= CFLMax)) { + CFL = CFLMax; + CFLFactor = 0.999*MGFactor[MGLevel]; + } + + CFL *= CFLFactor; + + node[iPoint]->SetLocalCFL(CFL); + node[iPoint]->SetLocalCFLFactor(CFL); + + //config->SetCFL(MGLevel, CFL); + //if (rank==MASTER_NODE) cout << " CFL: " << CFL << " omega: " << underRelaxation << endl; + + } + + } + + return underRelaxation; + +} + void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config) { unsigned long iPoint, jPoint, iEdge, iVertex; unsigned short iDim, iVar, iMarker; @@ -14974,6 +15091,13 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) InitiateComms(geometry, config, SOLUTION); CompleteComms(geometry, config, SOLUTION); + /* Store the initial CFL number for all grid points. */ + + for (iPoint = 0; iPoint < nPoint; iPoint++) { + const su2double CFL = config->GetCFL(MGLevel); + node[iPoint]->SetLocalCFL(CFL); + } + } CNSSolver::~CNSSolver(void) { @@ -15238,7 +15362,7 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC bool dual_time = ((config->GetUnsteady_Simulation() == DT_STEPPING_1ST) || (config->GetUnsteady_Simulation() == DT_STEPPING_2ND)); - Min_Delta_Time = 1.E6; Max_Delta_Time = 0.0; + Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed and viscosity ---*/ @@ -15358,8 +15482,8 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC Vol = geometry->node[iPoint]->GetVolume(); if (Vol != 0.0) { - Local_Delta_Time = config->GetCFL(iMesh)*Vol / node[iPoint]->GetMax_Lambda_Inv(); - Local_Delta_Time_Visc = config->GetCFL(iMesh)*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); + Local_Delta_Time = node[iPoint]->GetLocalCFL()*Vol / node[iPoint]->GetMax_Lambda_Inv(); + Local_Delta_Time_Visc = node[iPoint]->GetLocalCFL()*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); Local_Delta_Time = min(Local_Delta_Time, Local_Delta_Time_Visc); Global_Delta_Time = min(Global_Delta_Time, Local_Delta_Time); Min_Delta_Time = min(Min_Delta_Time, Local_Delta_Time); diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index 122be49736cb..3fa916def7b2 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -369,7 +369,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - Delta = Vol / (config->GetCFLRedCoeff_Turb()*solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time()); + Delta = Vol / (solver_container[FLOW_SOL]->node[iPoint]->GetLocalCFLFactor()*solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time()); Jacobian.AddVal2Diag(iPoint, Delta); /*--- Right hand side of the system (-Residual) and initial guess (x = 0) ---*/ @@ -408,7 +408,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ case SA: case SA_E: case SA_COMP: case SA_E_COMP: for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->AddClippedSolution(0, config->GetRelaxation_Factor_Turb()*LinSysSol[iPoint], lowerlimit[0], upperlimit[0]); + node[iPoint]->AddClippedSolution(0, solver_container[FLOW_SOL]->node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint], lowerlimit[0], upperlimit[0]); } break; diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index b948adfc98e3..f9a90d2de675 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -57,6 +57,10 @@ CVariable::CVariable(void) { Residual_Sum = NULL; Solution_Adj_Old = NULL; + /* Under-relaxation parameters. */ + UnderRelaxation = 1.0; + LocalCFLFactor = 1.0; + } CVariable::CVariable(unsigned short val_nvar, CConfig *config) { From 76d22c964474a52b9208701cfb6ad4d1e14260aa Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 9 Sep 2019 12:06:39 -0700 Subject: [PATCH 02/57] Check point. Still needs more testing. --- SU2_CFD/include/solver_structure.hpp | 13 +- SU2_CFD/include/solver_structure.inl | 2 +- SU2_CFD/include/variables/CVariable.hpp | 15 +- SU2_CFD/src/output_structure.cpp | 57 ++++- SU2_CFD/src/solver_direct_mean.cpp | 231 ++++++++++-------- SU2_CFD/src/solver_direct_turbulent.cpp | 114 ++++++++- SU2_CFD/src/variables/CVariable.cpp | 22 +- .../Xcode/SU2_CFD.xcodeproj/project.pbxproj | 129 +++++----- 8 files changed, 410 insertions(+), 173 deletions(-) diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 419a221fa830..ecd096683062 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -155,6 +155,9 @@ class CSolver { su2double ***VertexTractionAdjoint; /*- Also temporary -*/ public: + vector isNonRealizable; + vector nonRealizableCounter; + vector isNonRealizablePoint; CSysVector LinSysSol; /*!< \brief vector to store iterative solution of implicit linear system. */ CSysVector LinSysRes; /*!< \brief vector to store iterative residual of implicit linear system. */ @@ -1294,7 +1297,7 @@ class CSolver { * \brief A virtual member. * \param[in] config - Definition of the particular problem. */ - virtual su2double ComputeUnderRelaxationFactor(CConfig *config); + virtual void ComputeUnderRelaxationFactor(CConfig *config); /*! * \brief A virtual member. @@ -5436,7 +5439,7 @@ class CEulerSolver : public CSolver { * \brief Compute a suitable under-relaxation parameter to limit the change in the solution variables over a nonlinear iteration for stability. * \param[in] config - Definition of the particular problem. */ - su2double ComputeUnderRelaxationFactor(CConfig *config); + void ComputeUnderRelaxationFactor(CConfig *config); /*! * \brief Compute the pressure forces and all the adimensional coefficients. @@ -9423,6 +9426,12 @@ class CTurbSolver : public CSolver { void SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, unsigned short iMesh, unsigned short RunTime_EqSystem); + /*! + * \brief Compute a suitable under-relaxation parameter to limit the change in the solution variables over a nonlinear iteration for stability. + * \param[in] config - Definition of the particular problem. + */ + void ComputeUnderRelaxationFactor(CConfig *config); + /*! * \brief Load a solution from a restart file. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index b7933dbb8c49..620f3b38fac4 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -855,7 +855,7 @@ inline void CSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solv inline void CSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { } -inline su2double CSolver::ComputeUnderRelaxationFactor(CConfig *config) { return 0.0; } +inline void CSolver::ComputeUnderRelaxationFactor(CConfig *config) { } inline void CSolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { } diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 41ef7727ebd0..379d19bb0bcc 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -62,6 +62,7 @@ class CVariable { su2double *Solution, /*!< \brief Solution of the problem. */ *Solution_Old; /*!< \brief Old solution of the problem R-K. */ bool Non_Physical; /*!< \brief Non-physical points in the solution (force first order). */ + unsigned short Non_Physical_Counter; /*!< \brief Number of consecutive iterations that a point has been treated first-order. After a specified number of successful reconstructions, the point can be returned to second-order. */ su2double *Solution_time_n, /*!< \brief Solution of the problem at time n for dual-time stepping technique. */ *Solution_time_n1; /*!< \brief Solution of the problem at time n-1 for dual-time stepping technique. */ su2double **Gradient; /*!< \brief Gradient of the solution of the problem. */ @@ -151,13 +152,23 @@ class CVariable { * \brief Set the value of the non-physical point. * \param[in] val_value - identification of the non-physical point. */ - inline void SetNon_Physical(bool val_value) { Non_Physical = !val_value; } + inline void SetNon_Physical(bool val_value) { + if (val_value) { + Non_Physical = val_value; + Non_Physical_Counter = 0; + } else { + Non_Physical_Counter++; + if (Non_Physical_Counter > 20) { + Non_Physical = val_value; + } + } + } /*! * \brief Get the value of the non-physical point. * \return Value of the Non-physical point. */ - inline su2double GetNon_Physical(void) { return su2double(Non_Physical); } + inline bool GetNon_Physical(void) { return Non_Physical; } /*! * \brief Get the solution. diff --git a/SU2_CFD/src/output_structure.cpp b/SU2_CFD/src/output_structure.cpp index c13b2ff04787..8171a7c0eeee 100644 --- a/SU2_CFD/src/output_structure.cpp +++ b/SU2_CFD/src/output_structure.cpp @@ -12761,6 +12761,18 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * if (SecondIndex != NONE) nVar_Second = solver[SecondIndex]->GetnVar(); nVar_Consv_Par = nVar_First + nVar_Second; + vector First_Order(geometry->GetnPoint(),0.0); + for (unsigned long iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { + if (solver[FLOW_SOL]->isNonRealizable[iEdge]) { + iPoint = geometry->edge[iEdge]->GetNode(0); + jPoint = geometry->edge[iEdge]->GetNode(1); + + First_Order[iPoint] = 1.0; + First_Order[jPoint] = 1.0; + + } + } + /*--------------------------------------------------------------------------*/ /*--- Step 1: Register the variables that will be output. To register a ---*/ /*--- variable, two things are required. First, increment the ---*/ @@ -13006,7 +13018,35 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * nVar_Par +=1; Variable_Names.push_back("Local_CFL"); - + nVar_Par +=1; + Variable_Names.push_back("Local_CFL_Factor"); + nVar_Par +=1; + Variable_Names.push_back("Under_Relaxation"); + + nVar_Par +=1; + Variable_Names.push_back("First_Order"); + + nVar_Par += 5*nDim; + Variable_Names.push_back("GradT_x"); + Variable_Names.push_back("GradT_y"); + if (geometry->GetnDim() == 3) Variable_Names.push_back("GradT_z"); + + Variable_Names.push_back("GradVelx_x"); + Variable_Names.push_back("GradVelx_y"); + if (geometry->GetnDim() == 3) Variable_Names.push_back("GradVelx_z"); + + Variable_Names.push_back("GradVely_x"); + Variable_Names.push_back("GradVely_y"); + if (geometry->GetnDim() == 3) Variable_Names.push_back("GradVely_z"); + + Variable_Names.push_back("GradP_x"); + Variable_Names.push_back("GradP_y"); + if (geometry->GetnDim() == 3) Variable_Names.push_back("GradP_z"); + + Variable_Names.push_back("GradDensity_x"); + Variable_Names.push_back("GradDensity_y"); + if (geometry->GetnDim() == 3) Variable_Names.push_back("GradDensity_z"); + } /*--- Auxiliary vectors for variables defined on surfaces only. ---*/ @@ -13326,7 +13366,20 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * } Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetLocalCFL(); iVar++; - + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetLocalCFLFactor(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetUnderRelaxation(); iVar++; + Local_Data[jPoint][iVar] = First_Order[iPoint]; iVar++; + + su2double **gradient = solver[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); + + /* First, write the primitive gradients from the solution. */ + for (jVar = 0; jVar < 5; jVar++) { + for (iDim = 0; iDim < nDim; iDim ++){ + Local_Data[jPoint][iVar] = gradient[jVar][iDim]; + iVar++; + } + } + } /*--- Increment the point counter, as there may have been halos we diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index ec324c128270..a3c51a511fd1 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -908,8 +908,13 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short for (iPoint = 0; iPoint < nPoint; iPoint++) { const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); + node[iPoint]->SetLocalCFLFactor(1.0); } + /* Create helper vector to track non-physical faces. */ + isNonRealizable.resize(geometry->GetnEdge(),false); + nonRealizableCounter.resize(geometry->GetnEdge(),0); + } CEulerSolver::~CEulerSolver(void) { @@ -3100,16 +3105,21 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, C for (iPoint = 0; iPoint < nPoint; iPoint ++) { - /*--- Initialize the non-physical points vector ---*/ - - node[iPoint]->SetNon_Physical(false); - /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ RightSol = node[iPoint]->SetPrimVar(FluidModel); node[iPoint]->SetSecondaryVar(FluidModel); - if (!RightSol) { node[iPoint]->SetNon_Physical(true); ErrorCounter++; } + if (!RightSol) { node[iPoint]->SetNon_Physical(true); } + else { + /*--- Initialize the non-physical points vector ---*/ + + node[iPoint]->SetNon_Physical(false); + + } + + if (node[iPoint]->GetNon_Physical() == true) ErrorCounter++; + /*--- Initialize the convective, source and viscous residual vector ---*/ @@ -3430,10 +3440,9 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain for (iVar = 0; iVar < nPrimVarGrad; iVar++) { Project_Grad_i = 0.0; Project_Grad_j = 0.0; - Non_Physical = node[iPoint]->GetNon_Physical()*node[jPoint]->GetNon_Physical(); for (iDim = 0; iDim < nDim; iDim++) { - Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]*Non_Physical; - Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]*Non_Physical; + Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]; + Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]; } if (limiter) { if (van_albada){ @@ -3509,28 +3518,68 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain } RoeEnthalpy = (R*Primitive_j[nDim+3]+Primitive_i[nDim+3])/(R+1); neg_sound_speed = ((Gamma-1)*(RoeEnthalpy-0.5*sq_vel) < 0.0); - + if (neg_sound_speed) { for (iVar = 0; iVar < nPrimVar; iVar++) { Primitive_i[iVar] = V_i[iVar]; Primitive_j[iVar] = V_j[iVar]; } + //node[iPoint]->SetNon_Physical(true); + //node[jPoint]->SetNon_Physical(true); + isNonRealizable[iEdge] = true; + nonRealizableCounter[iEdge] = 0; Secondary_i[0] = S_i[0]; Secondary_i[1] = S_i[1]; Secondary_j[0] = S_i[0]; Secondary_j[1] = S_i[1]; counter_local++; } - + if (neg_density_i || neg_pressure_i) { for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; + //node[iPoint]->SetNon_Physical(true); + isNonRealizable[iEdge] = true; + nonRealizableCounter[iEdge] = 0; Secondary_i[0] = S_i[0]; Secondary_i[1] = S_i[1]; counter_local++; } - + if (neg_density_j || neg_pressure_j) { for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; + //node[jPoint]->SetNon_Physical(true); + isNonRealizable[iEdge] = true; + nonRealizableCounter[iEdge] = 0; Secondary_j[0] = S_j[0]; Secondary_j[1] = S_j[1]; counter_local++; } - + + /* Lastly, check for existing first-order points still active + from previous iterations. */ + + if (isNonRealizable[iEdge]) { + for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; + for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; + + } + + + if ((!neg_sound_speed && !neg_density_i && !neg_pressure_i) && + (!neg_sound_speed && !neg_density_j && !neg_pressure_j)) { + nonRealizableCounter[iEdge]++; +// if (nonRealizableCounter[iEdge] > 20) +// isNonRealizable[iEdge] = false; + } + +// if (node[iPoint]->GetNon_Physical()) { +// for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; +// } +// if (node[jPoint]->GetNon_Physical()) { +// for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; +// } +// +// if (!neg_sound_speed && !neg_density_i && !neg_pressure_i) +// node[iPoint]->SetNon_Physical(false); +// +// if (!neg_sound_speed && !neg_density_j && !neg_pressure_j) +// node[jPoint]->SetNon_Physical(false); +// numerics->SetPrimitive(Primitive_i, Primitive_j); numerics->SetSecondary(Secondary_i, Secondary_j); @@ -5198,15 +5247,14 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver SetIterLinSolver(IterLinSol); - su2double underRelaxation = ComputeUnderRelaxationFactor(config); + ComputeUnderRelaxationFactor(config); /*--- Update solution (system written in terms of increments) ---*/ if (!adjoint) { for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - underRelaxation = node[iPoint]->GetUnderRelaxation(); for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddSolution(iVar, underRelaxation*LinSysSol[iPoint*nVar+iVar]); + node[iPoint]->AddSolution(iVar, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint*nVar+iVar]); } } } @@ -5231,111 +5279,92 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver } -su2double CEulerSolver::ComputeUnderRelaxationFactor(CConfig *config) { +void CEulerSolver::ComputeUnderRelaxationFactor(CConfig *config) { /* Loop over the solution update given by relaxing the linear system for this nonlinear iteration. */ - su2double underRelaxation = 1.0; su2double localUnderRelaxation = 1.0; - const su2double percentChange = 0.30;// config->GetUnderRelaxationPercentChange(); + const su2double allowableRatio = 0.20; for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { localUnderRelaxation = 1.0; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - + /* We impose a limit on the maximum percentage that the density and energy can change over a nonlinear iteration. */ - - + if ((iVar == 0) || (iVar == nVar-1)) { - const unsigned long index = iPoint*nVar + iVar; - - - su2double ratio = fabs(LinSysSol[index])/node[iPoint]->GetSolution(iVar); - - if (ratio > percentChange) { - underRelaxation = min(percentChange/ratio, underRelaxation); - localUnderRelaxation = min(percentChange/ratio, localUnderRelaxation); + su2double ratio = fabs(LinSysSol[index])/(node[iPoint]->GetSolution(iVar)+EPS); + if (ratio > allowableRatio) { + localUnderRelaxation = min(allowableRatio/ratio, localUnderRelaxation); } - } - } - node[iPoint]->SetUnderRelaxation(localUnderRelaxation); + /* Store the under-relaxation factor for this point. */ - } - - /* Reduce to obtain the global minimum relaxation factor. */ + node[iPoint]->SetUnderRelaxation(localUnderRelaxation); - localUnderRelaxation = underRelaxation; - SU2_MPI::Allreduce(&localUnderRelaxation, &underRelaxation, - 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + } /* Adapt the CFL number based on the under-relaxation parameter. */ if (config->GetCFL_Adapt()) { for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - - su2double CFLFactor = 1.0, CFL = 0.0, CFLMin = 0.0, CFLMax = 0.0, MGFactor[100]; - unsigned short iMesh; - - /*--- Compute MG factor ---*/ - - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; - else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); - } - - /*--- If we use a small under-relaxation parameter for stability, - then we should reduce the CFL before the next iteration. If we - are able to add the entire nonlinear update (under-relaxation = 1) - then we can increase the CFL number for the next iteration. ---*/ - - underRelaxation = node[iPoint]->GetUnderRelaxation(); - - if (underRelaxation < 0.1) { - CFLFactor = config->GetCFL_AdaptParam(0); - node[iPoint]->SetUnderRelaxation(0.0); - } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { - CFLFactor = 1.0; - } else { - CFLFactor = config->GetCFL_AdaptParam(1); - } - - CFLMin = config->GetCFL_AdaptParam(2); - CFLMax = config->GetCFL_AdaptParam(3); - - //CFL = config->GetCFL(MGLevel); - CFL = node[iPoint]->GetLocalCFL(); - - if ((CFL <= CFLMin)) { - CFL = CFLMin; - CFLFactor = 1.001*MGFactor[MGLevel]; - } - else if ((CFL >= CFLMax)) { - CFL = CFLMax; - CFLFactor = 0.999*MGFactor[MGLevel]; - } - CFL *= CFLFactor; + su2double CFLFactor = 1.0, MGFactor[100]; + + const su2double CFLMin = config->GetCFL_AdaptParam(2); + const su2double CFLMax = config->GetCFL_AdaptParam(3); + + /*--- Compute MG factor ---*/ + + for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; + else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); + } + + /* Get the current local CFL number at this point. */ + + su2double CFL = node[iPoint]->GetLocalCFL(); + + /* If we apply a small under-relaxation parameter for stability, + then we should reduce the CFL before the next iteration. If we + are able to add the entire nonlinear update (under-relaxation = 1) + then we can increase the CFL number for the next iteration. */ + + const su2double underRelaxation = node[iPoint]->GetUnderRelaxation(); + + if (underRelaxation < 0.1) { + CFLFactor = config->GetCFL_AdaptParam(0); + } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { + CFLFactor = 1.0; + } else { + CFLFactor = config->GetCFL_AdaptParam(1); + } + + /* Check if we are hitting the min or max and adjust. */ + if (CFL <= CFLMin) { + CFL = CFLMin; + CFLFactor = 1.001*MGFactor[MGLevel]; + } else if (CFL >= CFLMax) { + CFL = CFLMax; + CFLFactor = 0.999*MGFactor[MGLevel]; + } + + /* Apply the adjustment to the CFL and store local values. */ + CFL *= CFLFactor; node[iPoint]->SetLocalCFL(CFL); - node[iPoint]->SetLocalCFLFactor(CFL); - - //config->SetCFL(MGLevel, CFL); - //if (rank==MASTER_NODE) cout << " CFL: " << CFL << " omega: " << underRelaxation << endl; - - } - + node[iPoint]->SetLocalCFLFactor(CFLFactor); + + } + } - return underRelaxation; - } void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config) { @@ -15096,8 +15125,13 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) for (iPoint = 0; iPoint < nPoint; iPoint++) { const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); + node[iPoint]->SetLocalCFLFactor(1.0); } + /* Create helper vector to track non-physical faces. */ + isNonRealizable.resize(geometry->GetnEdge(),false); + nonRealizableCounter.resize(geometry->GetnEdge(),0); + } CNSSolver::~CNSSolver(void) { @@ -15326,17 +15360,22 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon } } - /*--- Initialize the non-physical points vector ---*/ - - node[iPoint]->SetNon_Physical(false); - /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ RightSol = node[iPoint]->SetPrimVar(eddy_visc, turb_ke, FluidModel); node[iPoint]->SetSecondaryVar(FluidModel); - if (!RightSol) { node[iPoint]->SetNon_Physical(true); ErrorCounter++; } - + if (!RightSol) { node[iPoint]->SetNon_Physical(true); + } + else { + /*--- Initialize the non-physical points vector ---*/ + + node[iPoint]->SetNon_Physical(false); + + } + + if (node[iPoint]->GetNon_Physical() == true) ErrorCounter++; + /*--- Set the DES length scale ---*/ node[iPoint]->SetDES_LengthScale(DES_LengthScale); diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index 3fa916def7b2..9cde964ed088 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -369,7 +369,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - Delta = Vol / (solver_container[FLOW_SOL]->node[iPoint]->GetLocalCFLFactor()*solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time()); + Delta = Vol / ((node[iPoint]->GetLocalCFL()/solver_container[FLOW_SOL]->node[iPoint]->GetLocalCFL())*solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time()); Jacobian.AddVal2Diag(iPoint, Delta); /*--- Right hand side of the system (-Residual) and initial guess (x = 0) ---*/ @@ -397,6 +397,8 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + ComputeUnderRelaxationFactor(config); + /*--- Update solution (system written in terms of increments) ---*/ if (!adjoint) { @@ -408,7 +410,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ case SA: case SA_E: case SA_COMP: case SA_E_COMP: for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->AddClippedSolution(0, solver_container[FLOW_SOL]->node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint], lowerlimit[0], upperlimit[0]); + node[iPoint]->AddClippedSolution(0, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint], lowerlimit[0], upperlimit[0]); } break; @@ -461,6 +463,98 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ } +void CTurbSolver::ComputeUnderRelaxationFactor(CConfig *config) { + + /* Loop over the solution update given by relaxing the linear + system for this nonlinear iteration. */ + + su2double localUnderRelaxation = 1.0; + const su2double allowableDecrease = -1.00; + const su2double allowableIncrease = 1.0; + + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { + + localUnderRelaxation = 1.0; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + + /* We impose a limit on the maximum percentage that the + turbulence variables can change over a nonlinear iteration. */ + + const unsigned long index = iPoint*nVar + iVar; + su2double ratio = LinSysSol[index]/(node[iPoint]->GetSolution(iVar)+EPS); + if (ratio > allowableIncrease && (fabs(LinSysSol[index]) > 1.0e-3)) { + localUnderRelaxation = min(allowableIncrease/ratio, localUnderRelaxation); + } else if (ratio < allowableDecrease && (fabs(LinSysSol[index]) > 1.0e-3)) { + localUnderRelaxation = min(fabs(allowableDecrease)/ratio, localUnderRelaxation); + } + + } + + /* Store the under-relaxation factor for this point. */ + + node[iPoint]->SetUnderRelaxation(localUnderRelaxation); + + } + + /* Adapt the CFL number based on the under-relaxation parameter. */ + + if (config->GetCFL_Adapt()) { + + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { + + su2double CFLFactor = 1.0, MGFactor[100]; + + const su2double CFLMin = config->GetCFL_AdaptParam(2); + const su2double CFLMax = config->GetCFL_AdaptParam(3); + + /*--- Compute MG factor ---*/ + + for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; + else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); + } + + + /* Get the current local CFL number at this point. */ + + su2double CFL = node[iPoint]->GetLocalCFL(); + + /* If we apply a small under-relaxation parameter for stability, + then we should reduce the CFL before the next iteration. If we + are able to add the entire nonlinear update (under-relaxation = 1) + then we can increase the CFL number for the next iteration. */ + + const su2double underRelaxation = node[iPoint]->GetUnderRelaxation(); + + if (underRelaxation < 0.1) { + CFLFactor = config->GetCFL_AdaptParam(0); + } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { + CFLFactor = 1.0; + } else { + CFLFactor = config->GetCFL_AdaptParam(1); + } + + /* Check if we are hitting the min or max and adjust. */ + + if (CFL <= CFLMin) { + CFL = CFLMin; + CFLFactor = 1.001*MGFactor[MGLevel]; + } else if (CFL >= CFLMax) { + CFL = CFLMax; + CFLFactor = 0.999*MGFactor[MGLevel]; + } + + /* Apply the adjustment to the CFL and store local values. */ + CFL *= CFLFactor; + node[iPoint]->SetLocalCFL(CFL); + node[iPoint]->SetLocalCFLFactor(CFLFactor); + + } + + } + +} + void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, unsigned short iMesh, unsigned short RunTime_EqSystem) { @@ -1115,6 +1209,14 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor SetImplicitPeriodic(true); + /* Store the initial CFL number for all grid points. */ + + for (iPoint = 0; iPoint < nPoint; iPoint++) { + const su2double CFL = config->GetCFL(MGLevel); + node[iPoint]->SetLocalCFL(CFL); + node[iPoint]->SetLocalCFLFactor(1.0); + } + } CTurbSASolver::~CTurbSASolver(void) { @@ -3434,6 +3536,14 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh SetImplicitPeriodic(true); + /* Store the initial CFL number for all grid points. */ + + for (iPoint = 0; iPoint < nPoint; iPoint++) { + const su2double CFL = config->GetCFL(MGLevel); + node[iPoint]->SetLocalCFL(CFL); + node[iPoint]->SetLocalCFLFactor(1.0); + } + } CTurbSSTSolver::~CTurbSSTSolver(void) { diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index f9a90d2de675..70fdcdb44a55 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -60,7 +60,11 @@ CVariable::CVariable(void) { /* Under-relaxation parameters. */ UnderRelaxation = 1.0; LocalCFLFactor = 1.0; - + + /* Non-physical point (first-order) initialization. */ + Non_Physical = false; + Non_Physical_Counter = 0; + } CVariable::CVariable(unsigned short val_nvar, CConfig *config) { @@ -94,6 +98,14 @@ CVariable::CVariable(unsigned short val_nvar, CConfig *config) { for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; + /* Under-relaxation parameters. */ + UnderRelaxation = 1.0; + LocalCFLFactor = 1.0; + + /* Non-physical point (first-order) initialization. */ + Non_Physical = false; + Non_Physical_Counter = 0; + } CVariable::CVariable(unsigned short val_nDim, unsigned short val_nvar, CConfig *config) { @@ -161,6 +173,14 @@ CVariable::CVariable(unsigned short val_nDim, unsigned short val_nvar, CConfig * } } + /* Under-relaxation parameters. */ + UnderRelaxation = 1.0; + LocalCFLFactor = 1.0; + + /* Non-physical point (first-order) initialization. */ + Non_Physical = false; + Non_Physical_Counter = 0; + } CVariable::~CVariable(void) { diff --git a/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj b/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj index b719b312f9df..cca8f7517cbf 100644 --- a/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj +++ b/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj @@ -97,18 +97,16 @@ E96FAF142189FECA0046BF5D /* graph_coloring_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E96FAF112189FECA0046BF5D /* graph_coloring_structure.cpp */; }; E96FAF152189FECA0046BF5D /* fem_gauss_jacobi_quadrature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E96FAF122189FECA0046BF5D /* fem_gauss_jacobi_quadrature.cpp */; }; E96FAF162189FECA0046BF5D /* fem_cgns_elements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E96FAF132189FECA0046BF5D /* fem_cgns_elements.cpp */; }; - E97429A9231F122A006DA2D3 /* CTransfer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429A8231F122A006DA2D3 /* CTransfer.cpp */; }; - E97429AB231F123A006DA2D3 /* CTransfer_BoundaryDisplacements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429AA231F123A006DA2D3 /* CTransfer_BoundaryDisplacements.cpp */; }; - E97429B0231F1577006DA2D3 /* CMeshSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429AE231F1576006DA2D3 /* CMeshSolver.cpp */; }; - E97429B1231F1577006DA2D3 /* CDiscAdjMeshSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429AF231F1577006DA2D3 /* CDiscAdjMeshSolver.cpp */; }; - E97429BB231F1614006DA2D3 /* CDiscAdjMeshBoundVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429B4231F1612006DA2D3 /* CDiscAdjMeshBoundVariable.cpp */; }; - E97429BC231F1614006DA2D3 /* CFEAFSIBoundVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429B5231F1613006DA2D3 /* CFEAFSIBoundVariable.cpp */; }; - E97429BD231F1614006DA2D3 /* CDiscAdjMeshVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429B6231F1613006DA2D3 /* CDiscAdjMeshVariable.cpp */; }; - E97429BE231F1614006DA2D3 /* CDiscAdjFEABoundVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429B7231F1613006DA2D3 /* CDiscAdjFEABoundVariable.cpp */; }; - E97429BF231F1614006DA2D3 /* CMeshElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429B8231F1613006DA2D3 /* CMeshElement.cpp */; }; - E97429C0231F1614006DA2D3 /* CMeshBoundVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429B9231F1613006DA2D3 /* CMeshBoundVariable.cpp */; }; - E97429C1231F1614006DA2D3 /* CMeshVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429BA231F1613006DA2D3 /* CMeshVariable.cpp */; }; - E97429CA231F16A2006DA2D3 /* CFEAMeshElasticity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429C9231F16A2006DA2D3 /* CFEAMeshElasticity.cpp */; }; + E97429CF232358E3006DA2D3 /* CInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429CE232358E3006DA2D3 /* CInterface.cpp */; }; + E97429D323235901006DA2D3 /* CSlidingInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429D0232358FF006DA2D3 /* CSlidingInterface.cpp */; }; + E97429D423235901006DA2D3 /* CMixingPlaneInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429D123235900006DA2D3 /* CMixingPlaneInterface.cpp */; }; + E97429D523235901006DA2D3 /* CConservativeVarsInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429D223235901006DA2D3 /* CConservativeVarsInterface.cpp */; }; + E97429D723235911006DA2D3 /* CConjugateHeatInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429D623235910006DA2D3 /* CConjugateHeatInterface.cpp */; }; + E97429DD23235921006DA2D3 /* CDisplacementsInterfaceLegacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429D823235921006DA2D3 /* CDisplacementsInterfaceLegacy.cpp */; }; + E97429DE23235921006DA2D3 /* CFlowTractionInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429D923235921006DA2D3 /* CFlowTractionInterface.cpp */; }; + E97429DF23235921006DA2D3 /* CDisplacementsInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429DA23235921006DA2D3 /* CDisplacementsInterface.cpp */; }; + E97429E023235921006DA2D3 /* CDiscAdjDisplacementsInterfaceLegacy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429DB23235921006DA2D3 /* CDiscAdjDisplacementsInterfaceLegacy.cpp */; }; + E97429E123235921006DA2D3 /* CDiscAdjFlowTractionInterface.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E97429DC23235921006DA2D3 /* CDiscAdjFlowTractionInterface.cpp */; }; E9C8307F2061E60E004417A9 /* fem_geometry_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C830752061E60E004417A9 /* fem_geometry_structure.cpp */; }; E9C830802061E60E004417A9 /* fem_integration_rules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C830762061E60E004417A9 /* fem_integration_rules.cpp */; }; E9C830812061E60E004417A9 /* fem_standard_element.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C830772061E60E004417A9 /* fem_standard_element.cpp */; }; @@ -116,11 +114,9 @@ E9C830832061E60E004417A9 /* fem_work_estimate_metis.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C830792061E60E004417A9 /* fem_work_estimate_metis.cpp */; }; E9C830852061E60E004417A9 /* geometry_structure_fem_part.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C8307B2061E60E004417A9 /* geometry_structure_fem_part.cpp */; }; E9C830932061E799004417A9 /* solver_direct_mean_fem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C830922061E799004417A9 /* solver_direct_mean_fem.cpp */; }; - E9D6EE572316522800618E36 /* CDummyDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE562316522700618E36 /* CDummyDriver.cpp */; }; + E9D6EE572316522800618E36 /* (null) in Sources */ = {isa = PBXBuildFile; }; E9D6EE5A23165FD300618E36 /* CDummyDriver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE5923165FD300618E36 /* CDummyDriver.cpp */; }; E9D6EE5D2316653200618E36 /* CSU2ASCIIMeshReaderFVM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE5C2316653100618E36 /* CSU2ASCIIMeshReaderFVM.cpp */; }; - E9D6EE602317B4C000618E36 /* CTransfer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE5F2317B4C000618E36 /* CTransfer.cpp */; }; - E9D6EE622317B4CE00618E36 /* CTransfer_BoundaryDisplacements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE612317B4CE00618E36 /* CTransfer_BoundaryDisplacements.cpp */; }; E9D6EE672317B80600618E36 /* CMeshSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE652317B80500618E36 /* CMeshSolver.cpp */; }; E9D6EE682317B80600618E36 /* CDiscAdjMeshSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE662317B80600618E36 /* CDiscAdjMeshSolver.cpp */; }; E9D6EE6A2317B86300618E36 /* CFEAMeshElasticity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE692317B86300618E36 /* CFEAMeshElasticity.cpp */; }; @@ -134,7 +130,6 @@ E9D85B4C1C3F1B9E0077122F /* ad_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D85B4B1C3F1B9E0077122F /* ad_structure.cpp */; }; E9D885A92303F8E400917362 /* CBoxMeshReaderFVM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D885A82303F8E400917362 /* CBoxMeshReaderFVM.cpp */; }; E9D9CE861C62A1A7004119E9 /* interpolation_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D9CE851C62A1A7004119E9 /* interpolation_structure.cpp */; }; - E9D9CE891C62A1C8004119E9 /* transfer_physics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D9CE871C62A1C8004119E9 /* transfer_physics.cpp */; }; E9E51AD622FA313900773E0C /* CLinearPartitioner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9E51AD522FA313800773E0C /* CLinearPartitioner.cpp */; }; E9E51AD922FA603800773E0C /* CMeshReaderFVM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9E51AD822FA603700773E0C /* CMeshReaderFVM.cpp */; }; E9E51ADD22FAB11800773E0C /* CCGNSMeshReaderFVM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9E51ADC22FAB11700773E0C /* CCGNSMeshReaderFVM.cpp */; }; @@ -332,30 +327,26 @@ E96FAF1B2189FF620046BF5D /* fem_gauss_jacobi_quadrature.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = fem_gauss_jacobi_quadrature.inl; path = ../../Common/include/fem_gauss_jacobi_quadrature.inl; sourceTree = ""; }; E96FAF1C2189FF620046BF5D /* fem_cgns_elements.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = fem_cgns_elements.hpp; path = ../../Common/include/fem_cgns_elements.hpp; sourceTree = ""; }; E96FAF1D2189FF620046BF5D /* fem_gauss_jacobi_quadrature.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = fem_gauss_jacobi_quadrature.hpp; path = ../../Common/include/fem_gauss_jacobi_quadrature.hpp; sourceTree = ""; }; - E97429A8231F122A006DA2D3 /* CTransfer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CTransfer.cpp; path = ../../SU2_CFD/src/transfer/CTransfer.cpp; sourceTree = ""; }; - E97429AA231F123A006DA2D3 /* CTransfer_BoundaryDisplacements.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CTransfer_BoundaryDisplacements.cpp; path = ../../SU2_CFD/src/transfer/physics/CTransfer_BoundaryDisplacements.cpp; sourceTree = ""; }; - E97429AC231F12E5006DA2D3 /* CTransfer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CTransfer.hpp; path = ../../SU2_CFD/include/transfer/CTransfer.hpp; sourceTree = ""; }; - E97429AD231F12F7006DA2D3 /* CTransfer_BoundaryDisplacements.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CTransfer_BoundaryDisplacements.hpp; path = ../../SU2_CFD/include/transfer/physics/CTransfer_BoundaryDisplacements.hpp; sourceTree = ""; }; - E97429AE231F1576006DA2D3 /* CMeshSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMeshSolver.cpp; path = ../../SU2_CFD/src/solvers/CMeshSolver.cpp; sourceTree = ""; }; - E97429AF231F1577006DA2D3 /* CDiscAdjMeshSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjMeshSolver.cpp; path = ../../SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp; sourceTree = ""; }; - E97429B2231F158B006DA2D3 /* CDiscAdjMeshSolver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjMeshSolver.hpp; path = ../../SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp; sourceTree = ""; }; - E97429B3231F158B006DA2D3 /* CMeshSolver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMeshSolver.hpp; path = ../../SU2_CFD/include/solvers/CMeshSolver.hpp; sourceTree = ""; }; - E97429B4231F1612006DA2D3 /* CDiscAdjMeshBoundVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjMeshBoundVariable.cpp; path = ../../SU2_CFD/src/variables/CDiscAdjMeshBoundVariable.cpp; sourceTree = ""; }; - E97429B5231F1613006DA2D3 /* CFEAFSIBoundVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFEAFSIBoundVariable.cpp; path = ../../SU2_CFD/src/variables/CFEAFSIBoundVariable.cpp; sourceTree = ""; }; - E97429B6231F1613006DA2D3 /* CDiscAdjMeshVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjMeshVariable.cpp; path = ../../SU2_CFD/src/variables/CDiscAdjMeshVariable.cpp; sourceTree = ""; }; - E97429B7231F1613006DA2D3 /* CDiscAdjFEABoundVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjFEABoundVariable.cpp; path = ../../SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp; sourceTree = ""; }; - E97429B8231F1613006DA2D3 /* CMeshElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMeshElement.cpp; path = ../../SU2_CFD/src/variables/CMeshElement.cpp; sourceTree = ""; }; - E97429B9231F1613006DA2D3 /* CMeshBoundVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMeshBoundVariable.cpp; path = ../../SU2_CFD/src/variables/CMeshBoundVariable.cpp; sourceTree = ""; }; - E97429BA231F1613006DA2D3 /* CMeshVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMeshVariable.cpp; path = ../../SU2_CFD/src/variables/CMeshVariable.cpp; sourceTree = ""; }; - E97429C2231F1661006DA2D3 /* CMeshElement.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMeshElement.hpp; path = ../../SU2_CFD/include/variables/CMeshElement.hpp; sourceTree = ""; }; - E97429C3231F1661006DA2D3 /* CDiscAdjMeshVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjMeshVariable.hpp; path = ../../SU2_CFD/include/variables/CDiscAdjMeshVariable.hpp; sourceTree = ""; }; - E97429C4231F1661006DA2D3 /* CDiscAdjFEABoundVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjFEABoundVariable.hpp; path = ../../SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp; sourceTree = ""; }; - E97429C5231F1661006DA2D3 /* CMeshVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMeshVariable.hpp; path = ../../SU2_CFD/include/variables/CMeshVariable.hpp; sourceTree = ""; }; - E97429C6231F1661006DA2D3 /* CDiscAdjMeshBoundVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjMeshBoundVariable.hpp; path = ../../SU2_CFD/include/variables/CDiscAdjMeshBoundVariable.hpp; sourceTree = ""; }; - E97429C7231F1661006DA2D3 /* CFEAFSIBoundVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CFEAFSIBoundVariable.hpp; path = ../../SU2_CFD/include/variables/CFEAFSIBoundVariable.hpp; sourceTree = ""; }; - E97429C8231F1661006DA2D3 /* CMeshBoundVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMeshBoundVariable.hpp; path = ../../SU2_CFD/include/variables/CMeshBoundVariable.hpp; sourceTree = ""; }; - E97429C9231F16A2006DA2D3 /* CFEAMeshElasticity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFEAMeshElasticity.cpp; path = ../../SU2_CFD/src/numerics/CFEAMeshElasticity.cpp; sourceTree = ""; }; - E97429CB231F1760006DA2D3 /* CFEAMeshElasticity.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CFEAMeshElasticity.hpp; path = ../../SU2_CFD/include/numerics/CFEAMeshElasticity.hpp; sourceTree = ""; }; + E97429CE232358E3006DA2D3 /* CInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CInterface.cpp; path = ../../SU2_CFD/src/interfaces/CInterface.cpp; sourceTree = ""; }; + E97429D0232358FF006DA2D3 /* CSlidingInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CSlidingInterface.cpp; path = ../../SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp; sourceTree = ""; }; + E97429D123235900006DA2D3 /* CMixingPlaneInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMixingPlaneInterface.cpp; path = ../../SU2_CFD/src/interfaces/cfd/CMixingPlaneInterface.cpp; sourceTree = ""; }; + E97429D223235901006DA2D3 /* CConservativeVarsInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CConservativeVarsInterface.cpp; path = ../../SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp; sourceTree = ""; }; + E97429D623235910006DA2D3 /* CConjugateHeatInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CConjugateHeatInterface.cpp; path = ../../SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp; sourceTree = ""; }; + E97429D823235921006DA2D3 /* CDisplacementsInterfaceLegacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDisplacementsInterfaceLegacy.cpp; path = ../../SU2_CFD/src/interfaces/fsi/CDisplacementsInterfaceLegacy.cpp; sourceTree = ""; }; + E97429D923235921006DA2D3 /* CFlowTractionInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFlowTractionInterface.cpp; path = ../../SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp; sourceTree = ""; }; + E97429DA23235921006DA2D3 /* CDisplacementsInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDisplacementsInterface.cpp; path = ../../SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp; sourceTree = ""; }; + E97429DB23235921006DA2D3 /* CDiscAdjDisplacementsInterfaceLegacy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjDisplacementsInterfaceLegacy.cpp; path = ../../SU2_CFD/src/interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.cpp; sourceTree = ""; }; + E97429DC23235921006DA2D3 /* CDiscAdjFlowTractionInterface.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjFlowTractionInterface.cpp; path = ../../SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp; sourceTree = ""; }; + E97429E223235937006DA2D3 /* CInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CInterface.hpp; path = ../../SU2_CFD/include/interfaces/CInterface.hpp; sourceTree = ""; }; + E97429E323235951006DA2D3 /* CSlidingInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CSlidingInterface.hpp; path = ../../SU2_CFD/include/interfaces/cfd/CSlidingInterface.hpp; sourceTree = ""; }; + E97429E423235951006DA2D3 /* CConservativeVarsInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CConservativeVarsInterface.hpp; path = ../../SU2_CFD/include/interfaces/cfd/CConservativeVarsInterface.hpp; sourceTree = ""; }; + E97429E523235951006DA2D3 /* CMixingPlaneInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMixingPlaneInterface.hpp; path = ../../SU2_CFD/include/interfaces/cfd/CMixingPlaneInterface.hpp; sourceTree = ""; }; + E97429E62323595D006DA2D3 /* CConjugateHeatInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CConjugateHeatInterface.hpp; path = ../../SU2_CFD/include/interfaces/cht/CConjugateHeatInterface.hpp; sourceTree = ""; }; + E97429E72323596C006DA2D3 /* CDiscAdjFlowTractionInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjFlowTractionInterface.hpp; path = ../../SU2_CFD/include/interfaces/fsi/CDiscAdjFlowTractionInterface.hpp; sourceTree = ""; }; + E97429E82323596C006DA2D3 /* CDiscAdjDisplacementsInterfaceLegacy.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjDisplacementsInterfaceLegacy.hpp; path = ../../SU2_CFD/include/interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.hpp; sourceTree = ""; }; + E97429E92323596D006DA2D3 /* CDisplacementsInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDisplacementsInterface.hpp; path = ../../SU2_CFD/include/interfaces/fsi/CDisplacementsInterface.hpp; sourceTree = ""; }; + E97429EA2323596D006DA2D3 /* CDisplacementsInterfaceLegacy.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDisplacementsInterfaceLegacy.hpp; path = ../../SU2_CFD/include/interfaces/fsi/CDisplacementsInterfaceLegacy.hpp; sourceTree = ""; }; + E97429EB2323596D006DA2D3 /* CFlowTractionInterface.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CFlowTractionInterface.hpp; path = ../../SU2_CFD/include/interfaces/fsi/CFlowTractionInterface.hpp; sourceTree = ""; }; E97B6C8117F941800008255B /* config_template.cfg */ = {isa = PBXFileReference; lastKnownFileType = text; name = config_template.cfg; path = ../../config_template.cfg; sourceTree = ""; }; E9C2835022A701B5007B4E59 /* CMMSNSTwoHalfSpheresSolution.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMMSNSTwoHalfSpheresSolution.hpp; path = ../../Common/include/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.hpp; sourceTree = ""; }; E9C2835122A701B5007B4E59 /* CMMSNSTwoHalfCirclesSolution.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMMSNSTwoHalfCirclesSolution.hpp; path = ../../Common/include/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.hpp; sourceTree = ""; }; @@ -386,10 +377,6 @@ E9D6EE5B23165FE400618E36 /* CDummyDriver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDummyDriver.hpp; path = ../../SU2_CFD/include/drivers/CDummyDriver.hpp; sourceTree = ""; }; E9D6EE5C2316653100618E36 /* CSU2ASCIIMeshReaderFVM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CSU2ASCIIMeshReaderFVM.cpp; path = ../../Common/src/CSU2ASCIIMeshReaderFVM.cpp; sourceTree = ""; }; E9D6EE5E2316655400618E36 /* CSU2ASCIIMeshReaderFVM.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CSU2ASCIIMeshReaderFVM.hpp; path = ../../Common/include/CSU2ASCIIMeshReaderFVM.hpp; sourceTree = ""; }; - E9D6EE5F2317B4C000618E36 /* CTransfer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CTransfer.cpp; path = ../../SU2_CFD/src/transfer/CTransfer.cpp; sourceTree = ""; }; - E9D6EE612317B4CE00618E36 /* CTransfer_BoundaryDisplacements.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CTransfer_BoundaryDisplacements.cpp; path = ../../SU2_CFD/src/transfer/physics/CTransfer_BoundaryDisplacements.cpp; sourceTree = ""; }; - E9D6EE632317B4E100618E36 /* CTransfer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CTransfer.hpp; path = ../../SU2_CFD/include/transfer/CTransfer.hpp; sourceTree = ""; }; - E9D6EE642317B4F500618E36 /* CTransfer_BoundaryDisplacements.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CTransfer_BoundaryDisplacements.hpp; path = ../../SU2_CFD/include/transfer/physics/CTransfer_BoundaryDisplacements.hpp; sourceTree = ""; }; E9D6EE652317B80500618E36 /* CMeshSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMeshSolver.cpp; path = ../../SU2_CFD/src/solvers/CMeshSolver.cpp; sourceTree = ""; }; E9D6EE662317B80600618E36 /* CDiscAdjMeshSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjMeshSolver.cpp; path = ../../SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp; sourceTree = ""; }; E9D6EE692317B86300618E36 /* CFEAMeshElasticity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFEAMeshElasticity.cpp; path = ../../SU2_CFD/src/numerics/CFEAMeshElasticity.cpp; sourceTree = ""; }; @@ -420,8 +407,6 @@ E9D885A72303F8D000917362 /* CBoxMeshReaderFVM.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CBoxMeshReaderFVM.hpp; path = ../../Common/include/CBoxMeshReaderFVM.hpp; sourceTree = ""; }; E9D885A82303F8E400917362 /* CBoxMeshReaderFVM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CBoxMeshReaderFVM.cpp; path = ../../Common/src/CBoxMeshReaderFVM.cpp; sourceTree = ""; }; E9D9CE851C62A1A7004119E9 /* interpolation_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = interpolation_structure.cpp; path = ../../Common/src/interpolation_structure.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; - E9D9CE871C62A1C8004119E9 /* transfer_physics.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = transfer_physics.cpp; path = ../../SU2_CFD/src/transfer_physics.cpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; - E9D9CE961C62A272004119E9 /* transfer_structure.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; lineEnding = 0; name = transfer_structure.inl; path = ../../SU2_CFD/include/transfer_structure.inl; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; E9D9CE971C62A2A7004119E9 /* interpolation_structure.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = interpolation_structure.hpp; path = ../../Common/include/interpolation_structure.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; E9E51AD522FA313800773E0C /* CLinearPartitioner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CLinearPartitioner.cpp; path = ../../Common/src/toolboxes/CLinearPartitioner.cpp; sourceTree = ""; }; E9E51AD722FA314F00773E0C /* CLinearPartitioner.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CLinearPartitioner.hpp; path = ../../Common/include/toolboxes/CLinearPartitioner.hpp; sourceTree = ""; }; @@ -560,7 +545,6 @@ 355D2C9D2172BDE100C10535 /* sgs_model.inl */, 05E6DBB217EB624700FA1F7E /* solver_structure.inl */, E90B501522DFE0CC000ED392 /* task_definition.inl */, - E9D9CE961C62A272004119E9 /* transfer_structure.inl */, 05F108A11978D2D700F2F288 /* transport_model.inl */, 3599C5D62121FAF4003AAF05 /* wall_model.inl */, ); @@ -575,16 +559,24 @@ E96FAF1A2189FF620046BF5D /* blas_structure.hpp */, E9D885A72303F8D000917362 /* CBoxMeshReaderFVM.hpp */, E9E51ADB22FAB10D00773E0C /* CCGNSMeshReaderFVM.hpp */, + E97429E62323595D006DA2D3 /* CConjugateHeatInterface.hpp */, + E97429E423235951006DA2D3 /* CConservativeVarsInterface.hpp */, + E97429E82323596C006DA2D3 /* CDiscAdjDisplacementsInterfaceLegacy.hpp */, E9D6EE7E2317B8CC00618E36 /* CDiscAdjFEABoundVariable.hpp */, + E97429E72323596C006DA2D3 /* CDiscAdjFlowTractionInterface.hpp */, E9D6EE802317B8CC00618E36 /* CDiscAdjMeshBoundVariable.hpp */, E9D6EE7A2317B8B000618E36 /* CDiscAdjMeshSolver.hpp */, E9D6EE7D2317B8CC00618E36 /* CDiscAdjMeshVariable.hpp */, EB14FF9C22F790720045FB27 /* CDiscAdjSinglezoneDriver.hpp */, + E97429E92323596D006DA2D3 /* CDisplacementsInterface.hpp */, + E97429EA2323596D006DA2D3 /* CDisplacementsInterfaceLegacy.hpp */, EB14FF9D22F790720045FB27 /* CDriver.hpp */, E9D6EE5B23165FE400618E36 /* CDummyDriver.hpp */, E9D6EE812317B8CC00618E36 /* CFEAFSIBoundVariable.hpp */, E9D6EE792317B8A100618E36 /* CFEAMeshElasticity.hpp */, + E97429EB2323596D006DA2D3 /* CFlowTractionInterface.hpp */, E9C2835A22A701B6007B4E59 /* CIncTGVSolution.hpp */, + E97429E223235937006DA2D3 /* CInterface.hpp */, E9C2835722A701B5007B4E59 /* CInviscidVortexSolution.hpp */, E9E51AD722FA314F00773E0C /* CLinearPartitioner.hpp */, E9D6EE822317B8CC00618E36 /* CMeshBoundVariable.hpp */, @@ -592,6 +584,7 @@ E9E51ADA22FA604600773E0C /* CMeshReaderFVM.hpp */, E9D6EE7B2317B8B000618E36 /* CMeshSolver.hpp */, E9D6EE7F2317B8CC00618E36 /* CMeshVariable.hpp */, + E97429E523235951006DA2D3 /* CMixingPlaneInterface.hpp */, E9C2835222A701B5007B4E59 /* CMMSIncEulerSolution.hpp */, E9C2835C22A701B6007B4E59 /* CMMSIncNSSolution.hpp */, E9C2835122A701B5007B4E59 /* CMMSNSTwoHalfCirclesSolution.hpp */, @@ -605,10 +598,9 @@ E9E674382302A942009B6A25 /* CRectangularMeshReaderFVM.hpp */, E9C2835822A701B5007B4E59 /* CRinglebSolution.hpp */, EB14FF9E22F790720045FB27 /* CSinglezoneDriver.hpp */, + E97429E323235951006DA2D3 /* CSlidingInterface.hpp */, E9D6EE5E2316655400618E36 /* CSU2ASCIIMeshReaderFVM.hpp */, E9C2835922A701B5007B4E59 /* CTGVSolution.hpp */, - E9D6EE642317B4F500618E36 /* CTransfer_BoundaryDisplacements.hpp */, - E9D6EE632317B4E100618E36 /* CTransfer.hpp */, E9C2835422A701B5007B4E59 /* CUserDefinedSolution.hpp */, E9C2835522A701B5007B4E59 /* CVerificationSolution.hpp */, E941BB951B71D1AB005C6C06 /* datatype_structure.hpp */, @@ -886,10 +878,17 @@ E9D9CE841C62A16D004119E9 /* MultiZone */ = { isa = PBXGroup; children = ( - E9D6EE612317B4CE00618E36 /* CTransfer_BoundaryDisplacements.cpp */, - E9D6EE5F2317B4C000618E36 /* CTransfer.cpp */, + E97429D623235910006DA2D3 /* CConjugateHeatInterface.cpp */, + E97429D223235901006DA2D3 /* CConservativeVarsInterface.cpp */, + E97429DB23235921006DA2D3 /* CDiscAdjDisplacementsInterfaceLegacy.cpp */, + E97429DC23235921006DA2D3 /* CDiscAdjFlowTractionInterface.cpp */, + E97429DA23235921006DA2D3 /* CDisplacementsInterface.cpp */, + E97429D823235921006DA2D3 /* CDisplacementsInterfaceLegacy.cpp */, + E97429D923235921006DA2D3 /* CFlowTractionInterface.cpp */, + E97429CE232358E3006DA2D3 /* CInterface.cpp */, + E97429D123235900006DA2D3 /* CMixingPlaneInterface.cpp */, + E97429D0232358FF006DA2D3 /* CSlidingInterface.cpp */, E9D9CE851C62A1A7004119E9 /* interpolation_structure.cpp */, - E9D9CE871C62A1C8004119E9 /* transfer_physics.cpp */, ); name = MultiZone; sourceTree = ""; @@ -981,10 +980,9 @@ E90B4FDF22DFDF94000ED392 /* CInviscidVortexSolution.cpp in Sources */, 05E6DB9917EB61E600FA1F7E /* primal_grid_structure.cpp in Sources */, E90B4FDC22DFDF94000ED392 /* CIncTGVSolution.cpp in Sources */, - E97429BE231F1614006DA2D3 /* CDiscAdjFEABoundVariable.cpp in Sources */, 05AF9F201BE1E1830062E1F1 /* element_linear.cpp in Sources */, + E97429D723235911006DA2D3 /* CConjugateHeatInterface.cpp in Sources */, E90B500622DFDFE4000ED392 /* CFEAVariable.cpp in Sources */, - E97429BD231F1614006DA2D3 /* CDiscAdjMeshVariable.cpp in Sources */, 05F8F2682008A1C8000FEA01 /* python_wrapper_structure.cpp in Sources */, E90B4FE422DFDF94000ED392 /* CVerificationSolution.cpp in Sources */, E90B4FE022DFDF94000ED392 /* CMMSNSUnitQuadSolution.cpp in Sources */, @@ -1000,21 +998,18 @@ E9F512C81CB2FD6B004D5089 /* numerics_direct_elasticity_linear.cpp in Sources */, E90B4FE322DFDF94000ED392 /* CRinglebSolution.cpp in Sources */, 05E6DC0417EB62A100FA1F7E /* integration_time.cpp in Sources */, - E9D6EE572316522800618E36 /* CDummyDriver.cpp in Sources */, + E9D6EE572316522800618E36 /* (null) in Sources */, 05F1089B1978D2AE00F2F288 /* fluid_model_ppr.cpp in Sources */, - E97429B0231F1577006DA2D3 /* CMeshSolver.cpp in Sources */, - E97429C0231F1614006DA2D3 /* CMeshBoundVariable.cpp in Sources */, + E97429D423235901006DA2D3 /* CMixingPlaneInterface.cpp in Sources */, 05812D7B1F2787540086FCB0 /* output_physics.cpp in Sources */, E941BB8E1B71D0D0005C6C06 /* solver_adjoint_discrete.cpp in Sources */, 05E6DC0517EB62A100FA1F7E /* iteration_structure.cpp in Sources */, + E97429D323235901006DA2D3 /* CSlidingInterface.cpp in Sources */, 05E6DC0817EB62A100FA1F7E /* numerics_adjoint_mean.cpp in Sources */, 05AF9F211BE1E1830062E1F1 /* element_structure.cpp in Sources */, E90B500022DFDFE4000ED392 /* CHeatFVMVariable.cpp in Sources */, - E97429A9231F122A006DA2D3 /* CTransfer.cpp in Sources */, E90B500922DFDFE4000ED392 /* CTurbSAVariable.cpp in Sources */, 05E6DC0B17EB62A100FA1F7E /* numerics_adjoint_turbulent.cpp in Sources */, - E97429BB231F1614006DA2D3 /* CDiscAdjMeshBoundVariable.cpp in Sources */, - E9D6EE602317B4C000618E36 /* CTransfer.cpp in Sources */, 05F108A41978D2F200F2F288 /* transport_model.cpp in Sources */, E9D6EE682317B80600618E36 /* CDiscAdjMeshSolver.cpp in Sources */, E9FDF6EA1D2DD0560066E49C /* adt_structure.cpp in Sources */, @@ -1024,6 +1019,7 @@ 05F1089A1978D2AE00F2F288 /* fluid_model_pig.cpp in Sources */, 05E6DC1017EB62A100FA1F7E /* numerics_direct_mean.cpp in Sources */, E9D85B4C1C3F1B9E0077122F /* ad_structure.cpp in Sources */, + E97429E023235921006DA2D3 /* CDiscAdjDisplacementsInterfaceLegacy.cpp in Sources */, E90B4FDD22DFDF94000ED392 /* CUserDefinedSolution.cpp in Sources */, 05F1089D1978D2AE00F2F288 /* fluid_model.cpp in Sources */, E90B4FD922DFDF94000ED392 /* CMMSNSUnitQuadSolutionWallBC.cpp in Sources */, @@ -1034,7 +1030,6 @@ E9D885A92303F8E400917362 /* CBoxMeshReaderFVM.cpp in Sources */, E9C830812061E60E004417A9 /* fem_standard_element.cpp in Sources */, 05E6DC1317EB62A100FA1F7E /* numerics_direct_transition.cpp in Sources */, - E97429BC231F1614006DA2D3 /* CFEAFSIBoundVariable.cpp in Sources */, 0506980A1AA6179100FF4F07 /* output_fieldview.cpp in Sources */, 05E6DC1417EB62A100FA1F7E /* numerics_direct_turbulent.cpp in Sources */, E9D6EE6A2317B86300618E36 /* CFEAMeshElasticity.cpp in Sources */, @@ -1042,6 +1037,7 @@ E90B4FFC22DFDFE4000ED392 /* CDiscAdjVariable.cpp in Sources */, 05E6DC1817EB62A100FA1F7E /* numerics_structure.cpp in Sources */, 05E6DC1917EB62A100FA1F7E /* numerics_template.cpp in Sources */, + E97429DD23235921006DA2D3 /* CDisplacementsInterfaceLegacy.cpp in Sources */, E9C830822061E60E004417A9 /* fem_wall_distance.cpp in Sources */, E90B4FF922DFDFE4000ED392 /* CIncEulerVariable.cpp in Sources */, E90B500122DFDFE4000ED392 /* CEulerVariable.cpp in Sources */, @@ -1056,35 +1052,36 @@ 3599C5D32121FAC9003AAF05 /* wall_model.cpp in Sources */, 05E6DC1D17EB62A100FA1F7E /* output_tecplot.cpp in Sources */, E9D9CE861C62A1A7004119E9 /* interpolation_structure.cpp in Sources */, - E9D6EE622317B4CE00618E36 /* CTransfer_BoundaryDisplacements.cpp in Sources */, 05F1089C1978D2AE00F2F288 /* fluid_model_pvdw.cpp in Sources */, 05E6DC1F17EB62A100FA1F7E /* solver_adjoint_mean.cpp in Sources */, 05E6DC2217EB62A100FA1F7E /* solver_adjoint_turbulent.cpp in Sources */, E90B4FDB22DFDF94000ED392 /* CTGVSolution.cpp in Sources */, 05E6DC2517EB62A100FA1F7E /* solver_direct_heat.cpp in Sources */, E90B500822DFDFE4000ED392 /* CFEABoundVariable.cpp in Sources */, - E97429AB231F123A006DA2D3 /* CTransfer_BoundaryDisplacements.cpp in Sources */, + E97429DE23235921006DA2D3 /* CFlowTractionInterface.cpp in Sources */, 05E6DC2717EB62A100FA1F7E /* solver_direct_mean.cpp in Sources */, E9F512C91CB2FD6B004D5089 /* numerics_direct_elasticity_nonlinear.cpp in Sources */, E90B4FDE22DFDF94000ED392 /* CMMSNSTwoHalfSpheresSolution.cpp in Sources */, E90B4FFD22DFDFE4000ED392 /* CDiscAdjFEAVariable.cpp in Sources */, + E97429DF23235921006DA2D3 /* CDisplacementsInterface.cpp in Sources */, 05E6DC2A17EB62A100FA1F7E /* solver_direct_transition.cpp in Sources */, + E97429D523235901006DA2D3 /* CConservativeVarsInterface.cpp in Sources */, E90B4FF822DFDFE4000ED392 /* CVariable.cpp in Sources */, - E97429BF231F1614006DA2D3 /* CMeshElement.cpp in Sources */, E90B4FE122DFDF94000ED392 /* CMMSIncEulerSolution.cpp in Sources */, E9F130CC1D513DA300EC8963 /* numerics_direct_mean_inc.cpp in Sources */, E9C830852061E60E004417A9 /* geometry_structure_fem_part.cpp in Sources */, E9D6EE672317B80600618E36 /* CMeshSolver.cpp in Sources */, 05E6DC2B17EB62A100FA1F7E /* solver_direct_turbulent.cpp in Sources */, E90B500222DFDFE4000ED392 /* CTurbSSTVariable.cpp in Sources */, + E97429E123235921006DA2D3 /* CDiscAdjFlowTractionInterface.cpp in Sources */, EB14FF9922F790500045FB27 /* CDiscAdjSinglezoneDriver.cpp in Sources */, E941BB941B71D124005C6C06 /* mpi_structure.cpp in Sources */, 05E6DC2F17EB62A100FA1F7E /* solver_structure.cpp in Sources */, + E97429CF232358E3006DA2D3 /* CInterface.cpp in Sources */, E9D6EE5A23165FD300618E36 /* CDummyDriver.cpp in Sources */, 05E6DC3017EB62A100FA1F7E /* solver_template.cpp in Sources */, EB14FF9B22F790500045FB27 /* CMultizoneDriver.cpp in Sources */, 05E6DC3117EB62A100FA1F7E /* SU2_CFD.cpp in Sources */, - E97429C1231F1614006DA2D3 /* CMeshVariable.cpp in Sources */, 400CEC2E21FA81A10019B790 /* printing_toolbox.cpp in Sources */, E9C830932061E799004417A9 /* solver_direct_mean_fem.cpp in Sources */, E90B501122DFE043000ED392 /* CSysSolve_b.cpp in Sources */, @@ -1092,10 +1089,8 @@ E9C830832061E60E004417A9 /* fem_work_estimate_metis.cpp in Sources */, E9F130CE1D513DA300EC8963 /* solver_direct_mean_inc.cpp in Sources */, E9D6EE722317B88F00618E36 /* CDiscAdjMeshBoundVariable.cpp in Sources */, - E9D9CE891C62A1C8004119E9 /* transfer_physics.cpp in Sources */, E90B4FFB22DFDFE4000ED392 /* CAdjNSVariable.cpp in Sources */, E90B500F22DFE043000ED392 /* CSysVector.cpp in Sources */, - E97429B1231F1577006DA2D3 /* CDiscAdjMeshSolver.cpp in Sources */, E9D6EE732317B88F00618E36 /* CFEAFSIBoundVariable.cpp in Sources */, E90B4FDA22DFDF94000ED392 /* CNSUnitQuadSolution.cpp in Sources */, E9C830802061E60E004417A9 /* fem_integration_rules.cpp in Sources */, From 20ad166fd2da3fc40a72f67c9b90817122f211c4 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Tue, 10 Sep 2019 11:58:16 -0700 Subject: [PATCH 03/57] More changes. Still needs testing. --- SU2_CFD/include/solver_structure.hpp | 17 +++++-- SU2_CFD/include/solver_structure.inl | 2 +- SU2_CFD/src/solver_direct_mean.cpp | 21 +++++---- SU2_CFD/src/solver_direct_turbulent.cpp | 43 +++++++---------- SU2_CFD/src/solver_structure.cpp | 63 +++++++++++++++++++++++++ 5 files changed, 107 insertions(+), 39 deletions(-) diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index ecd096683062..369dd172ea80 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -1295,9 +1295,18 @@ class CSolver { /*! * \brief A virtual member. + * \param[in] solver - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - virtual void ComputeUnderRelaxationFactor(CConfig *config); + virtual void ComputeUnderRelaxationFactor(CSolver **solver, CConfig *config); + + /*! + * \brief Adapt the CFL number based on the local under-relaxation parameters + * computed for each nonlinear iteration. + * \param[in] config - Definition of the particular problem. + * \param[in] solver_container - Container vector with all the solutions. + */ + void AdaptCFLNumber(CGeometry *geometry, CSolver **solver_container, CConfig *config); /*! * \brief A virtual member. @@ -5437,9 +5446,10 @@ class CEulerSolver : public CSolver { /*! * \brief Compute a suitable under-relaxation parameter to limit the change in the solution variables over a nonlinear iteration for stability. + * \param[in] solver - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - void ComputeUnderRelaxationFactor(CConfig *config); + void ComputeUnderRelaxationFactor(CSolver **solver, CConfig *config); /*! * \brief Compute the pressure forces and all the adimensional coefficients. @@ -9428,9 +9438,10 @@ class CTurbSolver : public CSolver { /*! * \brief Compute a suitable under-relaxation parameter to limit the change in the solution variables over a nonlinear iteration for stability. + * \param[in] solver - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - void ComputeUnderRelaxationFactor(CConfig *config); + void ComputeUnderRelaxationFactor(CSolver **solver, CConfig *config); /*! * \brief Load a solution from a restart file. diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index 620f3b38fac4..500a7fc4e02b 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -855,7 +855,7 @@ inline void CSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solv inline void CSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { } -inline void CSolver::ComputeUnderRelaxationFactor(CConfig *config) { } +inline void CSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { } inline void CSolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { } diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index a3c51a511fd1..89c88a421a29 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -3529,7 +3529,6 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain nonRealizableCounter[iEdge] = 0; Secondary_i[0] = S_i[0]; Secondary_i[1] = S_i[1]; Secondary_j[0] = S_i[0]; Secondary_j[1] = S_i[1]; - counter_local++; } if (neg_density_i || neg_pressure_i) { @@ -3538,7 +3537,6 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain isNonRealizable[iEdge] = true; nonRealizableCounter[iEdge] = 0; Secondary_i[0] = S_i[0]; Secondary_i[1] = S_i[1]; - counter_local++; } if (neg_density_j || neg_pressure_j) { @@ -3547,7 +3545,6 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain isNonRealizable[iEdge] = true; nonRealizableCounter[iEdge] = 0; Secondary_j[0] = S_j[0]; Secondary_j[1] = S_j[1]; - counter_local++; } /* Lastly, check for existing first-order points still active @@ -3556,15 +3553,15 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain if (isNonRealizable[iEdge]) { for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; - + counter_local++; } if ((!neg_sound_speed && !neg_density_i && !neg_pressure_i) && (!neg_sound_speed && !neg_density_j && !neg_pressure_j)) { nonRealizableCounter[iEdge]++; -// if (nonRealizableCounter[iEdge] > 20) -// isNonRealizable[iEdge] = false; + if (nonRealizableCounter[iEdge] > 100) + isNonRealizable[iEdge] = false; } // if (node[iPoint]->GetNon_Physical()) { @@ -5247,7 +5244,7 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver SetIterLinSolver(IterLinSol); - ComputeUnderRelaxationFactor(config); + ComputeUnderRelaxationFactor(solver_container, config); /*--- Update solution (system written in terms of increments) ---*/ @@ -5279,7 +5276,7 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver } -void CEulerSolver::ComputeUnderRelaxationFactor(CConfig *config) { +void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { /* Loop over the solution update given by relaxing the linear system for this nonlinear iteration. */ @@ -5303,6 +5300,14 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CConfig *config) { } } + /* In case of turbulence, take the min of the under-relaxation factor + between the mean flow and the turb model. */ + + if (config->GetKind_Turb_Model() != NONE) + localUnderRelaxation = min(localUnderRelaxation, solver_container[TURB_SOL]->node[iPoint]->GetUnderRelaxation()); + + if (localUnderRelaxation < 1e-10) localUnderRelaxation = 0.0; + /* Store the under-relaxation factor for this point. */ node[iPoint]->SetUnderRelaxation(localUnderRelaxation); diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index 9cde964ed088..968e61ce8556 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -397,28 +397,20 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); - ComputeUnderRelaxationFactor(config); + ComputeUnderRelaxationFactor(solver_container, config); /*--- Update solution (system written in terms of increments) ---*/ if (!adjoint) { - /*--- Update and clip trubulent solution ---*/ + /*--- Update the turbulent solution. Only SST variants are clipped. ---*/ switch (config->GetKind_Turb_Model()) { - case SA: case SA_E: case SA_COMP: case SA_E_COMP: + case SA: case SA_E: case SA_COMP: case SA_E_COMP: case SA_NEG: for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->AddClippedSolution(0, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint], lowerlimit[0], upperlimit[0]); - } - - break; - - case SA_NEG: - - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->AddSolution(0, config->GetRelaxation_Factor_Turb()*LinSysSol[iPoint]); + node[iPoint]->AddSolution(0, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint]); } break; @@ -437,7 +429,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ } for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddConservativeSolution(iVar, config->GetRelaxation_Factor_Turb()*LinSysSol[iPoint*nVar+iVar], density, density_old, lowerlimit[iVar], upperlimit[iVar]); + node[iPoint]->AddConservativeSolution(iVar, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint*nVar+iVar], density, density_old, lowerlimit[iVar], upperlimit[iVar]); } } @@ -463,14 +455,14 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ } -void CTurbSolver::ComputeUnderRelaxationFactor(CConfig *config) { +void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { /* Loop over the solution update given by relaxing the linear system for this nonlinear iteration. */ su2double localUnderRelaxation = 1.0; - const su2double allowableDecrease = -1.00; - const su2double allowableIncrease = 1.0; + const su2double allowableDecrease = -0.99; + const su2double allowableIncrease = 0.99; for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { @@ -482,14 +474,20 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CConfig *config) { const unsigned long index = iPoint*nVar + iVar; su2double ratio = LinSysSol[index]/(node[iPoint]->GetSolution(iVar)+EPS); - if (ratio > allowableIncrease && (fabs(LinSysSol[index]) > 1.0e-3)) { + if (ratio > allowableIncrease) { localUnderRelaxation = min(allowableIncrease/ratio, localUnderRelaxation); - } else if (ratio < allowableDecrease && (fabs(LinSysSol[index]) > 1.0e-3)) { + } else if (ratio < allowableDecrease) { localUnderRelaxation = min(fabs(allowableDecrease)/ratio, localUnderRelaxation); } } + /* Choose the min factor between mean flow and turbulence. */ + + localUnderRelaxation = min(localUnderRelaxation, solver_container[FLOW_SOL]->node[iPoint]->GetUnderRelaxation()); + + if (localUnderRelaxation < 1e-10) localUnderRelaxation = 0.0; + /* Store the under-relaxation factor for this point. */ node[iPoint]->SetUnderRelaxation(localUnderRelaxation); @@ -1112,15 +1110,6 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor } } - - /*--- Initialize lower and upper limits---*/ - - lowerlimit = new su2double[nVar]; - upperlimit = new su2double[nVar]; - - lowerlimit[0] = 1.0e-10; - upperlimit[0] = 1.0; - /*--- Read farfield conditions from config ---*/ diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 1d96521d5b34..996b991205a8 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -2248,6 +2248,69 @@ void CSolver::CompleteComms(CGeometry *geometry, } +void CSolver::AdaptCFLNumber(CGeometry *geometry, CSolver **solver_container, CConfig *config) { + + /* Adapt the CFL number based on the under-relaxation parameter. */ + + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { + + su2double CFLFactor = 1.0, MGFactor[100]; + + const su2double CFLMin = config->GetCFL_AdaptParam(2); + const su2double CFLMax = config->GetCFL_AdaptParam(3); + + /*--- Compute MG factor ---*/ + + for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; + else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); + } + + /* Get the current local CFL number at this point. */ + + su2double CFL = solver_container[FLOW_SOL]->node[iPoint]->GetLocalCFL(); + + /* If we apply a small under-relaxation parameter for stability, + then we should reduce the CFL before the next iteration. If we + are able to add the entire nonlinear update (under-relaxation = 1) + then we can increase the CFL number for the next iteration. */ + + su2double underRelaxationFlow = solver_container[FLOW_SOL]->node[iPoint]->GetUnderRelaxation(); + + su2double underRelaxationTurb = 1.0; + + bool turbulent = (config->GetKind_Turb_Model() != NONE); + if (turbulent) underRelaxationTurb = solver_container[TURB_SOL]->node[iPoint]->GetUnderRelaxation(); + + const su2double underRelaxation = min(underRelaxationFlow,underRelaxationTurb); + + if (underRelaxation < 0.1) { + CFLFactor = config->GetCFL_AdaptParam(0); + } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { + CFLFactor = 1.0; + } else { + CFLFactor = config->GetCFL_AdaptParam(1); + } + + /* Check if we are hitting the min or max and adjust. */ + + if (CFL <= CFLMin) { + CFL = CFLMin; + CFLFactor = 1.001*MGFactor[MGLevel]; + } else if (CFL >= CFLMax) { + CFL = CFLMax; + CFLFactor = 0.999*MGFactor[MGLevel]; + } + + /* Apply the adjustment to the CFL and store local values. */ + CFL *= CFLFactor; + solver_container[FLOW_SOL]->node[iPoint]->SetLocalCFL(CFL); + solver_container[FLOW_SOL]->node[iPoint]->SetLocalCFLFactor(CFLFactor); + + } + +} + void CSolver::SetResidual_RMS(CGeometry *geometry, CConfig *config) { unsigned short iVar; From 5a274a9c4112ae727684681579ff66ca3641c3f5 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 12 Sep 2019 22:51:05 -0700 Subject: [PATCH 04/57] Changed reconstruction gradient. Moved new CFL adaption and removed old implementation. Added robustness features for incompressible solver. Clean up. --- SU2_CFD/include/output_structure.hpp | 13 - SU2_CFD/include/solver_structure.hpp | 21 +- SU2_CFD/include/solver_structure.inl | 2 +- SU2_CFD/include/variables/CEulerVariable.hpp | 23 ++ .../include/variables/CIncEulerVariable.hpp | 30 ++- SU2_CFD/include/variables/CVariable.hpp | 37 ++- SU2_CFD/src/drivers/CDriver.cpp | 28 -- SU2_CFD/src/iteration_structure.cpp | 17 +- SU2_CFD/src/output_structure.cpp | 125 +-------- SU2_CFD/src/solver_adjoint_mean.cpp | 89 +++++-- SU2_CFD/src/solver_direct_heat.cpp | 14 +- SU2_CFD/src/solver_direct_mean.cpp | 240 ++++++------------ SU2_CFD/src/solver_direct_mean_inc.cpp | 206 +++++++++++---- SU2_CFD/src/solver_direct_turbulent.cpp | 71 +----- SU2_CFD/src/solver_structure.cpp | 133 ++++++---- SU2_CFD/src/variables/CEulerVariable.cpp | 34 ++- SU2_CFD/src/variables/CIncEulerVariable.cpp | 41 ++- SU2_CFD/src/variables/CVariable.cpp | 27 +- 18 files changed, 562 insertions(+), 589 deletions(-) diff --git a/SU2_CFD/include/output_structure.hpp b/SU2_CFD/include/output_structure.hpp index 7257fee20977..a3d1c3df78b7 100644 --- a/SU2_CFD/include/output_structure.hpp +++ b/SU2_CFD/include/output_structure.hpp @@ -784,19 +784,6 @@ class COutput { */ void SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry ****geometry, CConfig **config, unsigned short val_iZone, bool output); - /*! - * \brief Write the history file and the convergence on the screen for serial computations. - * \param[in] ConvHist_file - Pointer to the convergence history file (which is defined in the main subroutine). - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] integration - Generic subroutines for space integration, time integration, and monitoring. - * \param[in] iExtIter - Current external (time) iteration. - * \param[in] timeused - Current number of clock tick in the computation (related with total time). - * \param[in] val_nZone - iZone index. - */ - void SetCFL_Number(CSolver *****solver_container, CConfig **config, unsigned short val_iZone); - /*! * \brief Write the sensitivity (including mesh sensitivity) computed with the discrete adjoint method * on the surface and in the volume to a file. diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 369dd172ea80..4e17d23f92df 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -155,10 +155,7 @@ class CSolver { su2double ***VertexTractionAdjoint; /*- Also temporary -*/ public: - vector isNonRealizable; - vector nonRealizableCounter; - vector isNonRealizablePoint; - + CSysVector LinSysSol; /*!< \brief vector to store iterative solution of implicit linear system. */ CSysVector LinSysRes; /*!< \brief vector to store iterative residual of implicit linear system. */ CSysVector LinSysAux; /*!< \brief vector to store iterative residual of implicit linear system. */ @@ -1303,10 +1300,11 @@ class CSolver { /*! * \brief Adapt the CFL number based on the local under-relaxation parameters * computed for each nonlinear iteration. + * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. * \param[in] solver_container - Container vector with all the solutions. */ - void AdaptCFLNumber(CGeometry *geometry, CSolver **solver_container, CConfig *config); + void AdaptCFLNumber(CGeometry **geometry, CSolver ***solver_container, CConfig *config); /*! * \brief A virtual member. @@ -1444,7 +1442,7 @@ class CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - virtual void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config); + virtual void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction = false); /*! * \brief A virtual member. @@ -5066,7 +5064,7 @@ class CEulerSolver : public CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config); + void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction = false); /*! * \brief Compute the limiter of the primitive variables. @@ -7341,7 +7339,7 @@ class CIncEulerSolver : public CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config); + void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction = false); /*! * \brief Compute the limiter of the primitive variables. @@ -7520,6 +7518,13 @@ class CIncEulerSolver : public CSolver { */ void ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config); + /*! + * \brief Compute a suitable under-relaxation parameter to limit the change in the solution variables over a nonlinear iteration for stability. + * \param[in] solver - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + */ + void ComputeUnderRelaxationFactor(CSolver **solver, CConfig *config); + /*! * \brief Provide the non dimensional lift coefficient (inviscid contribution). * \param val_marker Surface where the coefficient is going to be computed. diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index 500a7fc4e02b..04e50aff4d94 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -104,7 +104,7 @@ inline su2double CSolver::GetPsiE_Inf(void) { return 0; } inline void CSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config) { } -inline void CSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config) { } +inline void CSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction) { } inline void CSolver::SetPrimitive_Limiter_MPI(CGeometry *geometry, CConfig *config) { } diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index cf23d4b39007..655b714463d0 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -57,6 +57,7 @@ class CEulerVariable : public CVariable { su2double *Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ su2double **Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ + su2double **Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term (T, vx, vy, vz, P, rho). */ su2double *Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ /*--- Secondary variable definition ---*/ @@ -255,6 +256,28 @@ class CEulerVariable : public CVariable { */ inline su2double *GetLimiter_Secondary(void) {return Limiter_Secondary; } + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \return Value of the primitive variables gradient. + */ + inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \param[in] val_value - Value of the gradient. + */ + inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \return Value of the primitive variables gradient. + */ + inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } + /*! * \brief A virtual member. */ diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 11f77fa8a026..04b2c81f0d32 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -51,9 +51,11 @@ class CIncEulerVariable : public CVariable { /*--- Primitive variable definition ---*/ - su2double *Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ - su2double **Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - su2double *Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ + su2double *Primitive; /*!< \brief Primitive variables (P, vx, vy, vz, T, rho ...) for incompressible flows. */ + su2double **Gradient_Primitive; /*!< \brief Gradient of the primitive variables */ + su2double **Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term */ + + su2double *Limiter_Primitive; /*!< \brief Limiter of the primitive variables */ /*--- Old solution container for BGS iterations ---*/ @@ -159,6 +161,28 @@ class CIncEulerVariable : public CVariable { */ inline su2double *GetLimiter_Primitive(void) {return Limiter_Primitive; } + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \return Value of the primitive variables gradient. + */ + inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \param[in] val_value - Value of the gradient. + */ + inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \return Value of the primitive variables gradient. + */ + inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } + /*! * \brief Set the value of the pressure. */ diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 379d19bb0bcc..d2b27eda5e0e 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -84,7 +84,6 @@ class CVariable { *Residual_Sum; /*!< \brief Auxiliar structure for residual smoothing. */ su2double UnderRelaxation; /*!< \brief Value of the under-relxation parameter local to the control volume. */ su2double LocalCFL; /*!< \brief Value of the CFL number local to the control volume. */ - su2double LocalCFLFactor; /*!< \brief Value of the factor to increase/decrease the CFL number local to the control volume. */ static unsigned short nDim; /*!< \brief Number of dimension of the problem. */ unsigned short nVar; /*!< \brief Number of variables of the problem, @@ -510,19 +509,7 @@ class CVariable { * \return Value of the local CFL number for this CV. */ inline su2double GetLocalCFL(void) { return LocalCFL; } - - /*! - * \brief Set the value of the factor to increase/decrease the local CFL number for the current control volume (CV). - * \param[in] val_cfl_factor - the input value of the factor to increase/decrease the local CFL number for this CV. - */ - inline void SetLocalCFLFactor(su2double val_cfl_factor) { LocalCFLFactor = val_cfl_factor; } - - /*! - * \brief Get the value of the factor to increase/decrease the local CFL number for the current control volume (CV). - * \return Value of the factor to increase/decrease the local CFL number for this CV. - */ - inline su2double GetLocalCFLFactor(void) { return LocalCFLFactor; } - + /*! * \brief Set auxiliar variables, we are looking for the gradient of that variable. * \param[in] val_auxvar - Value of the auxiliar variable. @@ -1901,6 +1888,28 @@ class CVariable { */ inline virtual su2double *GetLimiter_Secondary(void) {return NULL; } + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \return Value of the primitive variables gradient. + */ + inline virtual su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) { return 0; } + + /*! + * \brief Set the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \param[in] val_value - Value of the gradient. + */ + inline virtual void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) { } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \return Value of the primitive gradient for MUSCL reconstruction. + */ + inline virtual su2double **GetGradient_Reconstruction(void) { return NULL; } + /*! * \brief Set the blending function for the blending of k-w and k-eps. * \param[in] val_viscosity - Value of the vicosity. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 01416786fec0..339a8155542f 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -3943,14 +3943,6 @@ bool CDriver::Monitor(unsigned long ExtIter) { } } -// /*--- Evaluate the new CFL number (adaptive). ---*/ -// if (config_container[ZONE_0]->GetCFL_Adapt() == YES) { -// for (iZone = 0; iZone < nZone; iZone++){ -// if (!(config_container[iZone]->GetMultizone_Problem())) // This needs to be changed everywhere in the code, in a future PR -// output->SetCFL_Number(solver_container, config_container, iZone); -// } -// } - /*--- Check whether the current simulation has reached the specified convergence criteria, and set StopCalc to true, if so. ---*/ @@ -4311,26 +4303,6 @@ bool CTurbomachineryDriver::Monitor(unsigned long ExtIter) { config_container, integration_container, false, UsedTime, iZone, iInst); } - -// /*--- Evaluate the new CFL number (adaptive). ---*/ -// if (config_container[ZONE_0]->GetCFL_Adapt() == YES) { -// if(mixingplane){ -// CFL = 0; -// for (iZone = 0; iZone < nZone; iZone++){ -// output->SetCFL_Number(solver_container, config_container, iZone); -// CFL += config_container[iZone]->GetCFL(MESH_0); -// } -// /*--- For fluid-multizone the new CFL number is the same for all the zones and it is equal to the zones' minimum value. ---*/ -// for (iZone = 0; iZone < nZone; iZone++){ -// config_container[iZone]->SetCFL(MESH_0, CFL/nZone); -// } -// } -// else{ -// output->SetCFL_Number(solver_container, config_container, ZONE_0); -// } -// } - - /*--- ROTATING FRAME Ramp: Compute the updated rotational velocity. ---*/ if (config_container[ZONE_0]->GetGrid_Movement() && config_container[ZONE_0]->GetRampRotatingFrame()) { rampFreq = SU2_TYPE::Int(config_container[ZONE_0]->GetRampRotatingFrame_Coeff(1)); diff --git a/SU2_CFD/src/iteration_structure.cpp b/SU2_CFD/src/iteration_structure.cpp index a1ca3e54b747..d946f8e864fd 100644 --- a/SU2_CFD/src/iteration_structure.cpp +++ b/SU2_CFD/src/iteration_structure.cpp @@ -568,11 +568,6 @@ void CFluidIteration::Preprocess(COutput *output, SetWind_GustField(config[val_iZone], geometry[val_iZone][val_iInst], solver[val_iZone][val_iInst]); } -// /*--- Evaluate the new CFL number (adaptive). ---*/ -// if ((config[val_iZone]->GetCFL_Adapt() == YES) && ( OuterIter != 0 ) ) { -// output->SetCFL_Number(solver, config, val_iZone); -// } - } void CFluidIteration::Iterate(COutput *output, @@ -647,6 +642,13 @@ void CFluidIteration::Iterate(COutput *output, config, RUNTIME_HEAT_SYS, IntIter, val_iZone, val_iInst); } + /*--- Adapt the CFL number using an exponential progression + with under-relaxation approach. ---*/ + + if (config[val_iZone]->GetCFL_Adapt() == YES) { + solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->AdaptCFLNumber(geometry[val_iZone][val_iInst], solver[val_iZone][val_iInst], config[val_iZone]); + } + /*--- Call Dynamic mesh update if AEROELASTIC motion was specified ---*/ if ((config[val_iZone]->GetGrid_Movement()) && (config[val_iZone]->GetAeroelastic_Simulation()) && unsteady) { @@ -1286,11 +1288,6 @@ void CHeatIteration::Preprocess(COutput *output, unsigned long OuterIter = config[val_iZone]->GetOuterIter(); -// /*--- Evaluate the new CFL number (adaptive). ---*/ -// if ((config[val_iZone]->GetCFL_Adapt() == YES) && ( OuterIter != 0 ) ) { -// output->SetCFL_Number(solver, config, val_iZone); -// } - } void CHeatIteration::Iterate(COutput *output, diff --git a/SU2_CFD/src/output_structure.cpp b/SU2_CFD/src/output_structure.cpp index 8171a7c0eeee..a8a4d9b993a5 100644 --- a/SU2_CFD/src/output_structure.cpp +++ b/SU2_CFD/src/output_structure.cpp @@ -6396,102 +6396,6 @@ void COutput::SetConvHistory_Body(ofstream *ConvHist_file, } } -void COutput::SetCFL_Number(CSolver *****solver_container, CConfig **config, unsigned short val_iZone) { - - su2double CFLFactor = 1.0, power = 1.0, CFL = 0.0, CFLMin = 0.0, CFLMax = 0.0, Div = 1.0, Diff = 0.0, MGFactor[100]; - unsigned short iMesh; - - unsigned short FinestMesh = config[val_iZone]->GetFinestMesh(); - unsigned long ExtIter = config[val_iZone]->GetExtIter(); - unsigned short nVar = 1; - - bool energy = config[val_iZone]->GetEnergy_Equation(); - bool weakly_coupled_heat = config[val_iZone]->GetWeakly_Coupled_Heat(); - - switch( config[val_iZone]->GetKind_Solver()) { - case EULER : case NAVIER_STOKES : case RANS: - case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS: - if (energy) { - nVar = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetnVar(); - RhoRes_New = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetRes_RMS(nVar-1); - } - else if (weakly_coupled_heat) { - RhoRes_New = solver_container[val_iZone][INST_0][FinestMesh][HEAT_SOL]->GetRes_RMS(0); - } - else { - RhoRes_New = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetRes_RMS(0); - } - break; - case ADJ_EULER : case ADJ_NAVIER_STOKES: case ADJ_RANS: - RhoRes_New = solver_container[val_iZone][INST_0][FinestMesh][ADJFLOW_SOL]->GetRes_RMS(0); - break; - case HEAT_EQUATION_FVM: - RhoRes_New = solver_container[val_iZone][INST_0][FinestMesh][HEAT_SOL]->GetRes_RMS(0); - break; - } - - if (RhoRes_New < EPS) RhoRes_New = EPS; - if (RhoRes_Old[val_iZone] < EPS) RhoRes_Old[val_iZone] = RhoRes_New; - - Div = RhoRes_Old[val_iZone]/RhoRes_New; - Diff = RhoRes_New-RhoRes_Old[val_iZone]; - - /*--- Compute MG factor ---*/ - - for (iMesh = 0; iMesh <= config[val_iZone]->GetnMGLevels(); iMesh++) { - if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; - else MGFactor[iMesh] = MGFactor[iMesh-1] * config[val_iZone]->GetCFL(iMesh)/config[val_iZone]->GetCFL(iMesh-1); - } - - if (Div < 1.0) power = config[val_iZone]->GetCFL_AdaptParam(0); - else power = config[val_iZone]->GetCFL_AdaptParam(1); - - /*--- Detect a stall in the residual ---*/ - - if ((fabs(Diff) <= RhoRes_New*1E-8) && (ExtIter != 0)) { Div = 0.1; power = config[val_iZone]->GetCFL_AdaptParam(1); } - - CFLMin = config[val_iZone]->GetCFL_AdaptParam(2); - CFLMax = config[val_iZone]->GetCFL_AdaptParam(3); - - CFLFactor = pow(Div, power); - - for (iMesh = 0; iMesh <= config[val_iZone]->GetnMGLevels(); iMesh++) { - CFL = config[val_iZone]->GetCFL(iMesh); - CFL *= CFLFactor; - - if ((iMesh == MESH_0) && (CFL <= CFLMin)) { - for (iMesh = 0; iMesh <= config[val_iZone]->GetnMGLevels(); iMesh++) { - config[val_iZone]->SetCFL(iMesh, 1.001*CFLMin*MGFactor[iMesh]); - } - break; - } - if ((iMesh == MESH_0) && (CFL >= CFLMax)) { - for (iMesh = 0; iMesh <= config[val_iZone]->GetnMGLevels(); iMesh++) - config[val_iZone]->SetCFL(iMesh, 0.999*CFLMax*MGFactor[iMesh]); - break; - } - - config[val_iZone]->SetCFL(iMesh, CFL); - } - - switch( config[val_iZone]->GetKind_Solver()) { - case EULER : case NAVIER_STOKES : case RANS: - case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS: - nVar = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetnVar(); - if (energy) RhoRes_Old[val_iZone] = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetRes_RMS(nVar-1); - else if (weakly_coupled_heat) RhoRes_Old[val_iZone] = solver_container[val_iZone][INST_0][FinestMesh][HEAT_SOL]->GetRes_RMS(0); - else RhoRes_Old[val_iZone] = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetRes_RMS(0); - break; - case ADJ_EULER : case ADJ_NAVIER_STOKES: case ADJ_RANS: - RhoRes_Old[val_iZone] = solver_container[val_iZone][INST_0][FinestMesh][ADJFLOW_SOL]->GetRes_RMS(0); - break; - case HEAT_EQUATION_FVM: - RhoRes_Old[val_iZone] = solver_container[val_iZone][INST_0][FinestMesh][HEAT_SOL]->GetRes_RMS(0); - break; - } - -} - void COutput::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry ****geometry, CConfig **config, unsigned short val_iZone, bool output) { char cstr[200]; @@ -6512,8 +6416,12 @@ void COutput::SpecialOutput_ForcesBreakdown(CSolver *****solver, CGeometry ****g unsigned short FinestMesh = config[val_iZone]->GetFinestMesh(); unsigned short nDim = geometry[val_iZone][INST_0][FinestMesh]->GetnDim(); - bool flow = ((config[val_iZone]->GetKind_Solver() == EULER) || (config[val_iZone]->GetKind_Solver() == NAVIER_STOKES) || - (config[val_iZone]->GetKind_Solver() == RANS)); + bool flow = ((config[val_iZone]->GetKind_Solver() == EULER) || + (config[val_iZone]->GetKind_Solver() == NAVIER_STOKES) || + (config[val_iZone]->GetKind_Solver() == RANS) || + (config[val_iZone]->GetKind_Solver() == INC_EULER) || + (config[val_iZone]->GetKind_Solver() == INC_NAVIER_STOKES) || + (config[val_iZone]->GetKind_Solver() == INC_RANS)); /*--- Output the mean flow solution using only the master node ---*/ @@ -12761,18 +12669,6 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * if (SecondIndex != NONE) nVar_Second = solver[SecondIndex]->GetnVar(); nVar_Consv_Par = nVar_First + nVar_Second; - vector First_Order(geometry->GetnPoint(),0.0); - for (unsigned long iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { - if (solver[FLOW_SOL]->isNonRealizable[iEdge]) { - iPoint = geometry->edge[iEdge]->GetNode(0); - jPoint = geometry->edge[iEdge]->GetNode(1); - - First_Order[iPoint] = 1.0; - First_Order[jPoint] = 1.0; - - } - } - /*--------------------------------------------------------------------------*/ /*--- Step 1: Register the variables that will be output. To register a ---*/ /*--- variable, two things are required. First, increment the ---*/ @@ -13019,13 +12915,8 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * nVar_Par +=1; Variable_Names.push_back("Local_CFL"); nVar_Par +=1; - Variable_Names.push_back("Local_CFL_Factor"); - nVar_Par +=1; Variable_Names.push_back("Under_Relaxation"); - - nVar_Par +=1; - Variable_Names.push_back("First_Order"); - + nVar_Par += 5*nDim; Variable_Names.push_back("GradT_x"); Variable_Names.push_back("GradT_y"); @@ -13366,9 +13257,7 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * } Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetLocalCFL(); iVar++; - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetLocalCFLFactor(); iVar++; Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetUnderRelaxation(); iVar++; - Local_Data[jPoint][iVar] = First_Order[iPoint]; iVar++; su2double **gradient = solver[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); diff --git a/SU2_CFD/src/solver_adjoint_mean.cpp b/SU2_CFD/src/solver_adjoint_mean.cpp index 8d33d44db44a..c92e732ecc3f 100644 --- a/SU2_CFD/src/solver_adjoint_mean.cpp +++ b/SU2_CFD/src/solver_adjoint_mean.cpp @@ -1627,9 +1627,9 @@ void CAdjEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve void CAdjEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - unsigned long iPoint, ErrorCounter = 0; + unsigned long iPoint, nonPhysicalPoints = 0; su2double SharpEdge_Distance; - bool RightSol = true; + bool physical = true; /*--- Retrieve information about the spatial and temporal integration for the adjoint equations (note that the flow problem may use different methods). ---*/ @@ -1653,16 +1653,15 @@ void CAdjEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai /*--- Get the distance form a sharp edge ---*/ SharpEdge_Distance = geometry->node[iPoint]->GetSharpEdge_Distance(); - - /*--- Initialize the non-physical points vector ---*/ - node[iPoint]->SetNon_Physical(false); - /*--- Set the primitive variables compressible adjoint variables ---*/ - RightSol = node[iPoint]->SetPrimVar(SharpEdge_Distance, false, config); - if (!RightSol) { node[iPoint]->SetNon_Physical(true); ErrorCounter++; } + physical = node[iPoint]->SetPrimVar(SharpEdge_Distance, false, config); + + /* Check for non-realizable states for reporting. */ + + if (!physical) nonPhysicalPoints++; /*--- Initialize the convective residual vector ---*/ @@ -1703,10 +1702,10 @@ void CAdjEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai if (config->GetComm_Level() == COMM_FULL) { #ifdef HAVE_MPI - unsigned long MyErrorCounter = ErrorCounter; ErrorCounter = 0; - SU2_MPI::Allreduce(&MyErrorCounter, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + unsigned long MyErrorCounter = nonPhysicalPoints; nonPhysicalPoints = 0; + SU2_MPI::Allreduce(&MyErrorCounter, &nonPhysicalPoints, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - if (iMesh == MESH_0) config->SetNonphysical_Points(ErrorCounter); + if (iMesh == MESH_0) config->SetNonphysical_Points(nonPhysicalPoints); } } @@ -1786,8 +1785,8 @@ void CAdjEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { su2double **Gradient_i, **Gradient_j, Project_Grad_i, Project_Grad_j, *Limiter_i = NULL, - *Limiter_j = NULL, *Psi_i = NULL, *Psi_j = NULL, *V_i, *V_j, Non_Physical = 1.0; - unsigned long iEdge, iPoint, jPoint; + *Limiter_j = NULL, *Psi_i = NULL, *Psi_j = NULL, *V_i, *V_j; + unsigned long iEdge, iPoint, jPoint, counter_local = 0, counter_global = 0; unsigned short iDim, iVar; bool implicit = (config->GetKind_TimeIntScheme_AdjFlow() == EULER_IMPLICIT); @@ -1837,10 +1836,9 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont for (iVar = 0; iVar < nVar; iVar++) { Project_Grad_i = 0; Project_Grad_j = 0; - Non_Physical = node[iPoint]->GetNon_Physical()*node[jPoint]->GetNon_Physical(); for (iDim = 0; iDim < nDim; iDim++) { - Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]*Non_Physical; - Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]*Non_Physical; + Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]; + Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]; } if (limiter) { Solution_i[iVar] = Psi_i[iVar] + Project_Grad_i*Limiter_i[iDim]; @@ -1852,6 +1850,33 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont } } + /* Check our reconstruction for exceeding bounds on the + adjoint density. */ + + su2double adj_limit = config->GetAdjointLimit(); + bool phi_bound_i = (fabs(Solution_i[0]) > adj_limit); + bool phi_bound_j = (fabs(Solution_j[0]) > adj_limit); + + if (phi_bound_i) node[iPoint]->SetNon_Physical(true); + else node[iPoint]->SetNon_Physical(false); + + if (phi_bound_j) node[jPoint]->SetNon_Physical(true); + else node[jPoint]->SetNon_Physical(false); + + /* Lastly, check for existing first-order points still active + from previous iterations. */ + + if (node[iPoint]->GetNon_Physical()) { + counter_local++; + for (iVar = 0; iVar < nVar; iVar++) + Solution_i[iVar] = Psi_i[iVar]; + } + if (node[jPoint]->GetNon_Physical()) { + counter_local++; + for (iVar = 0; iVar < nVar; iVar++) + Solution_j[iVar] = Psi_j[iVar]; + } + numerics->SetAdjointVar(Solution_i, Solution_j); } @@ -1876,6 +1901,17 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont } + /*--- Warning message about non-physical reconstructions. ---*/ + + if (config->GetComm_Level() == COMM_FULL) { +#ifdef HAVE_MPI + SU2_MPI::Reduce(&counter_local, &counter_global, 1, MPI_UNSIGNED_LONG, MPI_SUM, MASTER_NODE, MPI_COMM_WORLD); +#else + counter_global = counter_local; +#endif + if (iMesh == MESH_0) config->SetNonphysical_Reconstr(counter_global); + } + } void CAdjEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CNumerics *second_numerics, @@ -5170,9 +5206,9 @@ void CAdjNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, void CAdjNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { - unsigned long iPoint, ErrorCounter = 0; + unsigned long iPoint, nonPhysicalPoints = 0; su2double SharpEdge_Distance; - bool RightSol = true; + bool physical = true; /*--- Retrieve information about the spatial and temporal integration for the adjoint equations (note that the flow problem may use different methods). ---*/ @@ -5195,15 +5231,14 @@ void CAdjNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container SharpEdge_Distance = geometry->node[iPoint]->GetSharpEdge_Distance(); - /*--- Initialize the non-physical points vector ---*/ - - node[iPoint]->SetNon_Physical(false); - /*--- Set the primitive variables compressible adjoint variables ---*/ - RightSol = node[iPoint]->SetPrimVar(SharpEdge_Distance, false, config); - if (!RightSol) { node[iPoint]->SetNon_Physical(true); ErrorCounter++; } + physical = node[iPoint]->SetPrimVar(SharpEdge_Distance, false, config); + + /* Check for non-realizable states for reporting. */ + + if (!physical) nonPhysicalPoints++; /*--- Initialize the convective residual vector ---*/ @@ -5242,10 +5277,10 @@ void CAdjNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container if (config->GetComm_Level() == COMM_FULL) { #ifdef HAVE_MPI - unsigned long MyErrorCounter = ErrorCounter; ErrorCounter = 0; - SU2_MPI::Allreduce(&MyErrorCounter, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + unsigned long MyErrorCounter = nonPhysicalPoints; nonPhysicalPoints = 0; + SU2_MPI::Allreduce(&MyErrorCounter, &nonPhysicalPoints, 1, MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); #endif - if (iMesh == MESH_0) config->SetNonphysical_Points(ErrorCounter); + if (iMesh == MESH_0) config->SetNonphysical_Points(nonPhysicalPoints); } } diff --git a/SU2_CFD/src/solver_direct_heat.cpp b/SU2_CFD/src/solver_direct_heat.cpp index 7cfad4f4d037..f873bd3e3497 100644 --- a/SU2_CFD/src/solver_direct_heat.cpp +++ b/SU2_CFD/src/solver_direct_heat.cpp @@ -551,7 +551,7 @@ void CHeatSolverFVM::Centered_Residual(CGeometry *geometry, CSolver **solver_con void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { su2double *V_i, *V_j, Temp_i, Temp_i_Corrected, Temp_j, Temp_j_Corrected, **Gradient_i, **Gradient_j, Project_Grad_i, Project_Grad_j, - **Temp_i_Grad, **Temp_j_Grad, Project_Temp_i_Grad, Project_Temp_j_Grad, Non_Physical = 1.0; + **Temp_i_Grad, **Temp_j_Grad, Project_Temp_i_Grad, Project_Temp_j_Grad; unsigned short iDim, iVar; unsigned long iEdge, iPoint, jPoint; bool flow = ((config->GetKind_Solver() == INC_NAVIER_STOKES) @@ -590,8 +590,8 @@ void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta Vector_j[iDim] = 0.5*(geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim)); } - Gradient_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); - Gradient_j = solver_container[FLOW_SOL]->node[jPoint]->GetGradient_Primitive(); + Gradient_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = solver_container[FLOW_SOL]->node[jPoint]->GetGradient_Reconstruction(); Temp_i_Grad = node[iPoint]->GetGradient(); Temp_j_Grad = node[jPoint]->GetGradient(); @@ -601,8 +601,8 @@ void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta /*Apply the Gradient to get the right temperature value on the edge */ Project_Grad_i = 0.0; Project_Grad_j = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]*Non_Physical; - Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]*Non_Physical; + Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]; + Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]; } Primitive_Flow_i[iVar] = V_i[iVar] + Project_Grad_i; @@ -612,8 +612,8 @@ void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta /* Correct the temperature variables */ Project_Temp_i_Grad = 0.0; Project_Temp_j_Grad = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Project_Temp_i_Grad += Vector_i[iDim]*Temp_i_Grad[0][iDim]*Non_Physical; - Project_Temp_j_Grad += Vector_j[iDim]*Temp_j_Grad[0][iDim]*Non_Physical; + Project_Temp_i_Grad += Vector_i[iDim]*Temp_i_Grad[0][iDim]; + Project_Temp_j_Grad += Vector_j[iDim]*Temp_j_Grad[0][iDim]; } Temp_i_Corrected = Temp_i + Project_Temp_i_Grad; diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 89c88a421a29..be251580313b 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -494,17 +494,13 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short gradients by least squares, S matrix := inv(R)*traspose(inv(R)), c vector := transpose(WA)*(Wb) ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { - - Smatrix = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Smatrix[iDim] = new su2double [nDim]; - - Cvector = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Cvector[iVar] = new su2double [nDim]; - - } + Smatrix = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Smatrix[iDim] = new su2double [nDim]; + + Cvector = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) + Cvector[iVar] = new su2double [nDim]; /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ @@ -908,12 +904,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short for (iPoint = 0; iPoint < nPoint; iPoint++) { const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); - node[iPoint]->SetLocalCFLFactor(1.0); } - - /* Create helper vector to track non-physical faces. */ - isNonRealizable.resize(geometry->GetnEdge(),false); - nonRealizableCounter.resize(geometry->GetnEdge(),0); } @@ -3043,6 +3034,10 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container if ((muscl && !center) && (iMesh == MESH_0) && !Output) { + /*--- Gradient computation for MUSCL reconstruction. ---*/ + + SetPrimitive_Gradient_LS(geometry, config, true); + /*--- Gradient computation ---*/ if (config->GetKind_Gradient_Method() == GREEN_GAUSS) { @@ -3051,7 +3046,6 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { SetPrimitive_Gradient_LS(geometry, config); } - /*--- Limiter computation ---*/ @@ -3100,26 +3094,19 @@ void CEulerSolver::Postprocessing(CGeometry *geometry, CSolver **solver_containe unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { - unsigned long iPoint, ErrorCounter = 0; - bool RightSol = true; + unsigned long iPoint, nonPhysicalPoints = 0; + bool physical = true; for (iPoint = 0; iPoint < nPoint; iPoint ++) { /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ - RightSol = node[iPoint]->SetPrimVar(FluidModel); + physical = node[iPoint]->SetPrimVar(FluidModel); node[iPoint]->SetSecondaryVar(FluidModel); - if (!RightSol) { node[iPoint]->SetNon_Physical(true); } - else { - /*--- Initialize the non-physical points vector ---*/ - - node[iPoint]->SetNon_Physical(false); - - } - - if (node[iPoint]->GetNon_Physical() == true) ErrorCounter++; + /* Check for non-realizable states for reporting. */ + if (!physical) nonPhysicalPoints++; /*--- Initialize the convective, source and viscous residual vector ---*/ @@ -3127,7 +3114,7 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, C } - return ErrorCounter; + return nonPhysicalPoints; } void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { @@ -3375,7 +3362,7 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain CConfig *config, unsigned short iMesh) { su2double **Gradient_i, **Gradient_j, Project_Grad_i, Project_Grad_j, RoeVelocity[3] = {0.0,0.0,0.0}, R, sq_vel, RoeEnthalpy, - *V_i, *V_j, *S_i, *S_j, *Limiter_i = NULL, *Limiter_j = NULL, sqvel, Non_Physical = 1.0, Sensor_i, Sensor_j, Dissipation_i, Dissipation_j, *Coord_i, *Coord_j; + *V_i, *V_j, *S_i, *S_j, *Limiter_i = NULL, *Limiter_j = NULL, sqvel, Sensor_i, Sensor_j, Dissipation_i, Dissipation_j, *Coord_i, *Coord_j; su2double z, velocity2_i, velocity2_j, mach_i, mach_j, vel_i_corr[3], vel_j_corr[3]; @@ -3431,8 +3418,8 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Vector_j[iDim] = 0.5*(geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim)); } - Gradient_i = node[iPoint]->GetGradient_Primitive(); - Gradient_j = node[jPoint]->GetGradient_Primitive(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); if (limiter) { Limiter_i = node[iPoint]->GetLimiter_Primitive(); Limiter_j = node[jPoint]->GetLimiter_Primitive(); @@ -3522,61 +3509,46 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain if (neg_sound_speed) { for (iVar = 0; iVar < nPrimVar; iVar++) { Primitive_i[iVar] = V_i[iVar]; - Primitive_j[iVar] = V_j[iVar]; } - //node[iPoint]->SetNon_Physical(true); - //node[jPoint]->SetNon_Physical(true); - isNonRealizable[iEdge] = true; - nonRealizableCounter[iEdge] = 0; + Primitive_j[iVar] = V_j[iVar]; + } + node[iPoint]->SetNon_Physical(true); + node[jPoint]->SetNon_Physical(true); Secondary_i[0] = S_i[0]; Secondary_i[1] = S_i[1]; Secondary_j[0] = S_i[0]; Secondary_j[1] = S_i[1]; } if (neg_density_i || neg_pressure_i) { for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; - //node[iPoint]->SetNon_Physical(true); - isNonRealizable[iEdge] = true; - nonRealizableCounter[iEdge] = 0; + node[iPoint]->SetNon_Physical(true); Secondary_i[0] = S_i[0]; Secondary_i[1] = S_i[1]; } if (neg_density_j || neg_pressure_j) { for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; - //node[jPoint]->SetNon_Physical(true); - isNonRealizable[iEdge] = true; - nonRealizableCounter[iEdge] = 0; + node[jPoint]->SetNon_Physical(true); Secondary_j[0] = S_j[0]; Secondary_j[1] = S_j[1]; } + if (!neg_sound_speed && !neg_density_i && !neg_pressure_i) + node[iPoint]->SetNon_Physical(false); + + if (!neg_sound_speed && !neg_density_j && !neg_pressure_j) + node[jPoint]->SetNon_Physical(false); + /* Lastly, check for existing first-order points still active from previous iterations. */ - - if (isNonRealizable[iEdge]) { - for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; + + if (node[iPoint]->GetNon_Physical()) { counter_local++; + for (iVar = 0; iVar < nPrimVar; iVar++) + Primitive_i[iVar] = V_i[iVar]; } - - - if ((!neg_sound_speed && !neg_density_i && !neg_pressure_i) && - (!neg_sound_speed && !neg_density_j && !neg_pressure_j)) { - nonRealizableCounter[iEdge]++; - if (nonRealizableCounter[iEdge] > 100) - isNonRealizable[iEdge] = false; + if (node[jPoint]->GetNon_Physical()) { + counter_local++; + for (iVar = 0; iVar < nPrimVar; iVar++) + Primitive_j[iVar] = V_j[iVar]; } - -// if (node[iPoint]->GetNon_Physical()) { -// for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; -// } -// if (node[jPoint]->GetNon_Physical()) { -// for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; -// } -// -// if (!neg_sound_speed && !neg_density_i && !neg_pressure_i) -// node[iPoint]->SetNon_Physical(false); -// -// if (!neg_sound_speed && !neg_density_j && !neg_pressure_j) -// node[jPoint]->SetNon_Physical(false); -// + numerics->SetPrimitive(Primitive_i, Primitive_j); numerics->SetSecondary(Secondary_i, Secondary_j); @@ -5282,7 +5254,7 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CCon system for this nonlinear iteration. */ su2double localUnderRelaxation = 1.0; - const su2double allowableRatio = 0.20; + const su2double allowableRatio = 0.2; for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { localUnderRelaxation = 1.0; @@ -5306,6 +5278,10 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CCon if (config->GetKind_Turb_Model() != NONE) localUnderRelaxation = min(localUnderRelaxation, solver_container[TURB_SOL]->node[iPoint]->GetUnderRelaxation()); + /* Threshold the relaxation factor in the event that there is + a very small value. This helps avoid catastrophic crashes due + to non-realizable states by canceling the update. */ + if (localUnderRelaxation < 1e-10) localUnderRelaxation = 0.0; /* Store the under-relaxation factor for this point. */ @@ -5314,62 +5290,6 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CCon } - /* Adapt the CFL number based on the under-relaxation parameter. */ - - if (config->GetCFL_Adapt()) { - - for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - - su2double CFLFactor = 1.0, MGFactor[100]; - - const su2double CFLMin = config->GetCFL_AdaptParam(2); - const su2double CFLMax = config->GetCFL_AdaptParam(3); - - /*--- Compute MG factor ---*/ - - for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; - else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); - } - - /* Get the current local CFL number at this point. */ - - su2double CFL = node[iPoint]->GetLocalCFL(); - - /* If we apply a small under-relaxation parameter for stability, - then we should reduce the CFL before the next iteration. If we - are able to add the entire nonlinear update (under-relaxation = 1) - then we can increase the CFL number for the next iteration. */ - - const su2double underRelaxation = node[iPoint]->GetUnderRelaxation(); - - if (underRelaxation < 0.1) { - CFLFactor = config->GetCFL_AdaptParam(0); - } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { - CFLFactor = 1.0; - } else { - CFLFactor = config->GetCFL_AdaptParam(1); - } - - /* Check if we are hitting the min or max and adjust. */ - - if (CFL <= CFLMin) { - CFL = CFLMin; - CFLFactor = 1.001*MGFactor[MGLevel]; - } else if (CFL >= CFLMax) { - CFL = CFLMax; - CFLFactor = 0.999*MGFactor[MGLevel]; - } - - /* Apply the adjustment to the CFL and store local values. */ - CFL *= CFLFactor; - node[iPoint]->SetLocalCFL(CFL); - node[iPoint]->SetLocalCFLFactor(CFLFactor); - - } - - } - } void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config) { @@ -5472,7 +5392,7 @@ void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config } -void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config) { +void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction) { unsigned short iVar, iDim, jDim, iNeigh; unsigned long iPoint, jPoint; @@ -5514,9 +5434,13 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config PrimVar_j = node[jPoint]->GetPrimitive(); - weight = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - weight += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); + if (reconstruction) { + weight = 1.0; + } else { + weight = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + weight += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); + } /*--- Sumations for entries of upper triangular matrix R ---*/ @@ -5635,6 +5559,8 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { node[iPoint]->SetGradient_Primitive(iVar, iDim, Cvector[iVar][iDim]); + if (reconstruction) + node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Cvector[iVar][iDim]); } } @@ -5735,8 +5661,8 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Primitive(); - Gradient_j = node[jPoint]->GetGradient_Primitive(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -5852,8 +5778,8 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Primitive(); - Gradient_j = node[jPoint]->GetGradient_Primitive(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -14600,16 +14526,13 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) gradients by least squares, S matrix := inv(R)*traspose(inv(R)), c vector := transpose(WA)*(Wb) ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { - - Smatrix = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Smatrix[iDim] = new su2double [nDim]; - - Cvector = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Cvector[iVar] = new su2double [nDim]; - } + Smatrix = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Smatrix[iDim] = new su2double [nDim]; + + Cvector = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) + Cvector[iVar] = new su2double [nDim]; /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ @@ -15130,12 +15053,7 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) for (iPoint = 0; iPoint < nPoint; iPoint++) { const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); - node[iPoint]->SetLocalCFLFactor(1.0); } - - /* Create helper vector to track non-physical faces. */ - isNonRealizable.resize(geometry->GetnEdge(),false); - nonRealizableCounter.resize(geometry->GetnEdge(),0); } @@ -15278,6 +15196,11 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C } } + /*--- Compute gradient for MUSCL reconstruction. ---*/ + + if ((config->GetMUSCL_Flow()) && (iMesh == MESH_0)) + SetPrimitive_Gradient_LS(geometry, config, true); + /*--- Compute gradient of the primitive variables ---*/ if (config->GetKind_Gradient_Method() == GREEN_GAUSS) { @@ -15345,10 +15268,10 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { - unsigned long iPoint, ErrorCounter = 0; + unsigned long iPoint, nonPhysicalPoints = 0; su2double eddy_visc = 0.0, turb_ke = 0.0, DES_LengthScale = 0.0; unsigned short turb_model = config->GetKind_Turb_Model(); - bool RightSol = true; + bool physical = true; bool tkeNeeded = ((turb_model == SST) || (turb_model == SST_SUST)) ; @@ -15367,19 +15290,12 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ - RightSol = node[iPoint]->SetPrimVar(eddy_visc, turb_ke, FluidModel); + physical = node[iPoint]->SetPrimVar(eddy_visc, turb_ke, FluidModel); node[iPoint]->SetSecondaryVar(FluidModel); - if (!RightSol) { node[iPoint]->SetNon_Physical(true); - } - else { - /*--- Initialize the non-physical points vector ---*/ - - node[iPoint]->SetNon_Physical(false); - - } + /* Check for non-realizable states for reporting. */ - if (node[iPoint]->GetNon_Physical() == true) ErrorCounter++; + if (!physical) nonPhysicalPoints++; /*--- Set the DES length scale ---*/ @@ -15391,7 +15307,7 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon } - return ErrorCounter; + return nonPhysicalPoints; } void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index 52cc3ec67a8f..7c88cf68e782 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -342,7 +342,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned gradients by least squares, S matrix := inv(R)*traspose(inv(R)), c vector := transpose(WA)*(Wb) ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + //if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -352,7 +352,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned for (iVar = 0; iVar < nPrimVarGrad; iVar++) Cvector[iVar] = new su2double [nDim]; - } + // } /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ @@ -624,6 +624,13 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned InitiateComms(geometry, config, SOLUTION); CompleteComms(geometry, config, SOLUTION); + /* Store the initial CFL number for all grid points. */ + + for (iPoint = 0; iPoint < nPoint; iPoint++) { + const su2double CFL = config->GetCFL(MGLevel); + node[iPoint]->SetLocalCFL(CFL); + } + } CIncEulerSolver::~CIncEulerSolver(void) { @@ -1558,7 +1565,11 @@ void CIncEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai if ((muscl && !center) && (iMesh == MESH_0) && !Output) { - /*--- Gradient computation ---*/ + /*--- Gradient computation for MUSCL reconstruction. ---*/ + + SetPrimitive_Gradient_LS(geometry, config, true); + + /*--- Gradient computation for all other terms. ---*/ if (config->GetKind_Gradient_Method() == GREEN_GAUSS) { SetPrimitive_Gradient_GG(geometry, config); @@ -1614,22 +1625,18 @@ void CIncEulerSolver::Postprocessing(CGeometry *geometry, CSolver **solver_conta unsigned long CIncEulerSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { - unsigned long iPoint, ErrorCounter = 0; + unsigned long iPoint, nonPhysicalPoints = 0; bool physical = true; for (iPoint = 0; iPoint < nPoint; iPoint ++) { - - /*--- Initialize the non-physical points vector ---*/ - - node[iPoint]->SetNon_Physical(false); - + /*--- Incompressible flow, primitive variables ---*/ physical = node[iPoint]->SetPrimVar(FluidModel); - /*--- Record any non-physical points. ---*/ - - if (!physical) { node[iPoint]->SetNon_Physical(true); ErrorCounter++; } + /* Check for non-realizable states for reporting. */ + + if (!physical) nonPhysicalPoints++; /*--- Initialize the convective, source and viscous residual vector ---*/ @@ -1637,7 +1644,7 @@ unsigned long CIncEulerSolver::SetPrimitive_Variables(CSolver **solver_container } - return ErrorCounter; + return nonPhysicalPoints; } void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, @@ -1755,7 +1762,7 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain Vol = geometry->node[iPoint]->GetVolume(); if (Vol != 0.0) { - Local_Delta_Time = config->GetCFL(iMesh)*Vol / node[iPoint]->GetMax_Lambda_Inv(); + Local_Delta_Time = node[iPoint]->GetLocalCFL()*Vol / node[iPoint]->GetMax_Lambda_Inv(); Global_Delta_Time = min(Global_Delta_Time, Local_Delta_Time); Min_Delta_Time = min(Min_Delta_Time, Local_Delta_Time); Max_Delta_Time = max(Max_Delta_Time, Local_Delta_Time); @@ -1903,7 +1910,7 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont CConfig *config, unsigned short iMesh) { su2double **Gradient_i, **Gradient_j, Project_Grad_i, Project_Grad_j, - *V_i, *V_j, *S_i, *S_j, *Limiter_i = NULL, *Limiter_j = NULL, Non_Physical = 1.0; + *V_i, *V_j, *S_i, *S_j, *Limiter_i = NULL, *Limiter_j = NULL; unsigned long iEdge, iPoint, jPoint, counter_local = 0, counter_global = 0; unsigned short iDim, iVar; @@ -1942,8 +1949,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Vector_j[iDim] = 0.5*(geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim)); } - Gradient_i = node[iPoint]->GetGradient_Primitive(); - Gradient_j = node[jPoint]->GetGradient_Primitive(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); if (limiter) { Limiter_i = node[iPoint]->GetLimiter_Primitive(); Limiter_j = node[jPoint]->GetLimiter_Primitive(); @@ -1951,10 +1958,9 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont for (iVar = 0; iVar < nPrimVarGrad; iVar++) { Project_Grad_i = 0.0; Project_Grad_j = 0.0; - Non_Physical = node[iPoint]->GetNon_Physical()*node[jPoint]->GetNon_Physical(); for (iDim = 0; iDim < nDim; iDim++) { - Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]*Non_Physical; - Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]*Non_Physical; + Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]; + Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]; } if (limiter) { if (van_albada){ @@ -1975,6 +1981,47 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Primitive_j[iVar] = V_j[iVar]; } + /*--- Check for non-physical solutions after reconstruction. If found, + use the cell-average value of the solution. This results in a locally + first-order approximation, but this is typically only active + during the start-up of a calculation or difficult transients. For + incompressible flow, only the temperature and density need to be + checked. Pressure is the dynamic pressure (can be negative). ---*/ + + if (config->GetEnergy_Equation()) { + bool neg_temperature_i = (Primitive_i[nDim+1] < 0.0); + bool neg_temperature_j = (Primitive_j[nDim+1] < 0.0); + + bool neg_density_i = (Primitive_i[nDim+2] < 0.0); + bool neg_density_j = (Primitive_j[nDim+2] < 0.0); + + if (neg_density_i || neg_temperature_i) { + node[iPoint]->SetNon_Physical(true); + } else { + node[iPoint]->SetNon_Physical(false); + } + + if (neg_density_j || neg_temperature_j) { + node[jPoint]->SetNon_Physical(true); + } else { + node[jPoint]->SetNon_Physical(false); + } + + /* Lastly, check for existing first-order points still active + from previous iterations. */ + + if (node[iPoint]->GetNon_Physical()) { + counter_local++; + for (iVar = 0; iVar < nPrimVar; iVar++) + Primitive_i[iVar] = V_i[iVar]; + } + if (node[jPoint]->GetNon_Physical()) { + counter_local++; + for (iVar = 0; iVar < nPrimVar; iVar++) + Primitive_j[iVar] = V_j[iVar]; + } + } + numerics->SetPrimitive(Primitive_i, Primitive_j); } else { @@ -3483,7 +3530,7 @@ void CIncEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol if (!adjoint) { for (iPoint = 0; iPoint < nPointDomain; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddSolution(iVar, config->GetRelaxation_Factor_Flow()*LinSysSol[iPoint*nVar+iVar]); + node[iPoint]->AddSolution(iVar, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint*nVar+iVar]); } } } @@ -3508,6 +3555,50 @@ void CIncEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol } +void CIncEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { + + /* Loop over the solution update given by relaxing the linear + system for this nonlinear iteration. */ + + su2double localUnderRelaxation = 1.0; + const su2double allowableRatio = 0.2; + for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { + + localUnderRelaxation = 1.0; + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + + /* We impose a limit on the maximum percentage that the + pressure and temperature can change over a nonlinear iteration. */ + + if ( (config->GetEnergy_Equation() && (iVar == nVar-1))) { + const unsigned long index = iPoint*nVar + iVar; + su2double ratio = fabs(LinSysSol[index])/(node[iPoint]->GetSolution(iVar)+EPS); + if (ratio > allowableRatio) { + localUnderRelaxation = min(allowableRatio/ratio, localUnderRelaxation); + } + } + } + + /* In case of turbulence, take the min of the under-relaxation factor + between the mean flow and the turb model. */ + + if (config->GetKind_Turb_Model() != NONE) + localUnderRelaxation = min(localUnderRelaxation, solver_container[TURB_SOL]->node[iPoint]->GetUnderRelaxation()); + + /* Threshold the relaxation factor in the event that there is + a very small value. This helps avoid catastrophic crashes due + to non-realizable states by canceling the update. */ + + if (localUnderRelaxation < 1e-10) localUnderRelaxation = 0.0; + + /* Store the under-relaxation factor for this point. */ + + node[iPoint]->SetUnderRelaxation(localUnderRelaxation); + + } + +} + void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config) { unsigned long iPoint, jPoint, iEdge, iVertex; unsigned short iDim, iVar, iMarker; @@ -3603,7 +3694,7 @@ void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *con } -void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config) { +void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction) { unsigned short iVar, iDim, jDim, iNeigh; unsigned long iPoint, jPoint; @@ -3645,9 +3736,13 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con PrimVar_j = node[jPoint]->GetPrimitive(); - weight = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - weight += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); + if (reconstruction) { + weight = 1.0; + } else { + weight = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + weight += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); + } /*--- Sumations for entries of upper triangular matrix R ---*/ @@ -3766,6 +3861,8 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { node[iPoint]->SetGradient_Primitive(iVar, iDim, Cvector[iVar][iDim]); + if (reconstruction) + node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Cvector[iVar][iDim]); } } @@ -3867,8 +3964,8 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Primitive(); - Gradient_j = node[jPoint]->GetGradient_Primitive(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -3984,8 +4081,8 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Primitive(); - Gradient_j = node[jPoint]->GetGradient_Primitive(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -7005,16 +7102,13 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short gradients by least squares, S matrix := inv(R)*traspose(inv(R)), c vector := transpose(WA)*(Wb) ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { - - Smatrix = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Smatrix[iDim] = new su2double [nDim]; - - Cvector = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Cvector[iVar] = new su2double [nDim]; - } + Smatrix = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Smatrix[iDim] = new su2double [nDim]; + + Cvector = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) + Cvector[iVar] = new su2double [nDim]; /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ @@ -7388,6 +7482,13 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short InitiateComms(geometry, config, SOLUTION); CompleteComms(geometry, config, SOLUTION); + /* Store the initial CFL number for all grid points. */ + + for (iPoint = 0; iPoint < nPoint; iPoint++) { + const su2double CFL = config->GetCFL(MGLevel); + node[iPoint]->SetLocalCFL(CFL); + } + } CIncNSSolver::~CIncNSSolver(void) { @@ -7480,6 +7581,11 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container ErrorCounter = SetPrimitive_Variables(solver_container, config, Output); + /*--- Compute gradient for MUSCL reconstruction. ---*/ + + if ((config->GetMUSCL_Flow()) && (iMesh == MESH_0)) + SetPrimitive_Gradient_LS(geometry, config, true); + /*--- Compute gradient of the primitive variables ---*/ if (config->GetKind_Gradient_Method() == GREEN_GAUSS) { @@ -7560,7 +7666,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, CConfig *config, bool Output) { - unsigned long iPoint, ErrorCounter = 0; + unsigned long iPoint, nonPhysicalPoints = 0; su2double eddy_visc = 0.0, turb_ke = 0.0, DES_LengthScale = 0.0; unsigned short turb_model = config->GetKind_Turb_Model(); bool physical = true; @@ -7579,19 +7685,15 @@ unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, C DES_LengthScale = solver_container[TURB_SOL]->node[iPoint]->GetDES_LengthScale(); } } - - /*--- Initialize the non-physical points vector ---*/ - - node[iPoint]->SetNon_Physical(false); - + /*--- Incompressible flow, primitive variables --- */ physical = node[iPoint]->SetPrimVar(eddy_visc, turb_ke, FluidModel); - /*--- Record any non-physical points. ---*/ - - if (!physical) { node[iPoint]->SetNon_Physical(true); ErrorCounter++; } - + /* Check for non-realizable states for reporting. */ + + if (!physical) nonPhysicalPoints++; + /*--- Set the DES length scale ---*/ node[iPoint]->SetDES_LengthScale(DES_LengthScale); @@ -7602,7 +7704,7 @@ unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, C } - return ErrorCounter; + return nonPhysicalPoints; } @@ -7747,8 +7849,8 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Vol = geometry->node[iPoint]->GetVolume(); if (Vol != 0.0) { - Local_Delta_Time = config->GetCFL(iMesh)*Vol / node[iPoint]->GetMax_Lambda_Inv(); - Local_Delta_Time_Visc = config->GetCFL(iMesh)*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); + Local_Delta_Time = node[iPoint]->GetLocalCFL()*Vol / node[iPoint]->GetMax_Lambda_Inv(); + Local_Delta_Time_Visc = node[iPoint]->GetLocalCFL()*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); Local_Delta_Time = min(Local_Delta_Time, Local_Delta_Time_Visc); Global_Delta_Time = min(Global_Delta_Time, Local_Delta_Time); Min_Delta_Time = min(Min_Delta_Time, Local_Delta_Time); diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index 968e61ce8556..ffda9bb82f1a 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -136,8 +136,8 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe /*--- Mean flow primitive variables using gradient reconstruction and limiters ---*/ - Gradient_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); - Gradient_j = solver_container[FLOW_SOL]->node[jPoint]->GetGradient_Primitive(); + Gradient_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = solver_container[FLOW_SOL]->node[jPoint]->GetGradient_Reconstruction(); if (limiter) { Limiter_i = solver_container[FLOW_SOL]->node[iPoint]->GetLimiter_Primitive(); Limiter_j = solver_container[FLOW_SOL]->node[jPoint]->GetLimiter_Primitive(); @@ -460,7 +460,7 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf /* Loop over the solution update given by relaxing the linear system for this nonlinear iteration. */ - su2double localUnderRelaxation = 1.0; + su2double localUnderRelaxation = 1.00; const su2double allowableDecrease = -0.99; const su2double allowableIncrease = 0.99; @@ -482,10 +482,14 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf } - /* Choose the min factor between mean flow and turbulence. */ + /* Choose the minimum factor between mean flow and turbulence. */ localUnderRelaxation = min(localUnderRelaxation, solver_container[FLOW_SOL]->node[iPoint]->GetUnderRelaxation()); + /* Threshold the relaxation factor in the event that there is + a very small value. This helps avoid catastrophic crashes due + to non-realizable states by canceling the update. */ + if (localUnderRelaxation < 1e-10) localUnderRelaxation = 0.0; /* Store the under-relaxation factor for this point. */ @@ -494,63 +498,6 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf } - /* Adapt the CFL number based on the under-relaxation parameter. */ - - if (config->GetCFL_Adapt()) { - - for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - - su2double CFLFactor = 1.0, MGFactor[100]; - - const su2double CFLMin = config->GetCFL_AdaptParam(2); - const su2double CFLMax = config->GetCFL_AdaptParam(3); - - /*--- Compute MG factor ---*/ - - for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; - else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); - } - - - /* Get the current local CFL number at this point. */ - - su2double CFL = node[iPoint]->GetLocalCFL(); - - /* If we apply a small under-relaxation parameter for stability, - then we should reduce the CFL before the next iteration. If we - are able to add the entire nonlinear update (under-relaxation = 1) - then we can increase the CFL number for the next iteration. */ - - const su2double underRelaxation = node[iPoint]->GetUnderRelaxation(); - - if (underRelaxation < 0.1) { - CFLFactor = config->GetCFL_AdaptParam(0); - } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { - CFLFactor = 1.0; - } else { - CFLFactor = config->GetCFL_AdaptParam(1); - } - - /* Check if we are hitting the min or max and adjust. */ - - if (CFL <= CFLMin) { - CFL = CFLMin; - CFLFactor = 1.001*MGFactor[MGLevel]; - } else if (CFL >= CFLMax) { - CFL = CFLMax; - CFLFactor = 0.999*MGFactor[MGLevel]; - } - - /* Apply the adjustment to the CFL and store local values. */ - CFL *= CFLFactor; - node[iPoint]->SetLocalCFL(CFL); - node[iPoint]->SetLocalCFLFactor(CFLFactor); - - } - - } - } void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, @@ -1203,7 +1150,6 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor for (iPoint = 0; iPoint < nPoint; iPoint++) { const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); - node[iPoint]->SetLocalCFLFactor(1.0); } } @@ -3530,7 +3476,6 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh for (iPoint = 0; iPoint < nPoint; iPoint++) { const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); - node[iPoint]->SetLocalCFLFactor(1.0); } } diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 996b991205a8..64e8e63b97fd 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -1878,7 +1878,7 @@ void CSolver::InitiateComms(CGeometry *geometry, MPI_TYPE = COMM_TYPE_DOUBLE; break; case PRIMITIVE_GRADIENT: - COUNT_PER_POINT = nPrimVarGrad*nDim; + COUNT_PER_POINT = nPrimVarGrad*nDim*2; MPI_TYPE = COMM_TYPE_DOUBLE; break; case PRIMITIVE_LIMITER: @@ -2011,9 +2011,12 @@ void CSolver::InitiateComms(CGeometry *geometry, bufDSend[buf_offset+iVar*nDim+iDim] = node[iPoint]->GetGradient(iVar, iDim); break; case PRIMITIVE_GRADIENT: - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - for (iDim = 0; iDim < nDim; iDim++) + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + for (iDim = 0; iDim < nDim; iDim++) { bufDSend[buf_offset+iVar*nDim+iDim] = node[iPoint]->GetGradient_Primitive(iVar, iDim); + bufDSend[buf_offset+iVar*nDim+iDim+nDim*nPrimVarGrad] = node[iPoint]->GetGradient_Reconstruction(iVar, iDim); + } + } break; case PRIMITIVE_LIMITER: for (iVar = 0; iVar < nPrimVarGrad; iVar++) @@ -2173,9 +2176,12 @@ void CSolver::CompleteComms(CGeometry *geometry, node[iPoint]->SetGradient(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim]); break; case PRIMITIVE_GRADIENT: - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - for (iDim = 0; iDim < nDim; iDim++) + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + for (iDim = 0; iDim < nDim; iDim++) { node[iPoint]->SetGradient_Primitive(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim]); + node[iPoint]->SetGradient_Reconstruction(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim+nDim*nPrimVarGrad]); + } + } break; case PRIMITIVE_LIMITER: for (iVar = 0; iVar < nPrimVarGrad; iVar++) @@ -2248,65 +2254,88 @@ void CSolver::CompleteComms(CGeometry *geometry, } -void CSolver::AdaptCFLNumber(CGeometry *geometry, CSolver **solver_container, CConfig *config) { +void CSolver::AdaptCFLNumber(CGeometry **geometry, + CSolver ***solver_container, + CConfig *config) { - /* Adapt the CFL number based on the under-relaxation parameter. */ + /* Adapt the CFL number on all multigrid levels using an + exponential progression with under-relaxation approach. */ + + vector MGFactor(config->GetnMGLevels()+1,1.0); + const su2double CFLFactorDecrease = config->GetCFL_AdaptParam(0); + const su2double CFLFactorIncrease = config->GetCFL_AdaptParam(1); + const su2double CFLMin = config->GetCFL_AdaptParam(2); + const su2double CFLMax = config->GetCFL_AdaptParam(3); - for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { - - su2double CFLFactor = 1.0, MGFactor[100]; - - const su2double CFLMin = config->GetCFL_AdaptParam(2); - const su2double CFLMax = config->GetCFL_AdaptParam(3); - - /*--- Compute MG factor ---*/ - - for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; - else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); - } + for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - /* Get the current local CFL number at this point. */ + /* Store the mean flow, and turbulence solvers more clearly. */ - su2double CFL = solver_container[FLOW_SOL]->node[iPoint]->GetLocalCFL(); + const CSolver *solverFlow = solver_container[iMesh][FLOW_SOL]; + const CSolver *solverTurb = solver_container[iMesh][TURB_SOL]; - /* If we apply a small under-relaxation parameter for stability, - then we should reduce the CFL before the next iteration. If we - are able to add the entire nonlinear update (under-relaxation = 1) - then we can increase the CFL number for the next iteration. */ + /* Compute the reduction factor for CFLs on the coarse levels. */ - su2double underRelaxationFlow = solver_container[FLOW_SOL]->node[iPoint]->GetUnderRelaxation(); - - su2double underRelaxationTurb = 1.0; - - bool turbulent = (config->GetKind_Turb_Model() != NONE); - if (turbulent) underRelaxationTurb = solver_container[TURB_SOL]->node[iPoint]->GetUnderRelaxation(); - - const su2double underRelaxation = min(underRelaxationFlow,underRelaxationTurb); - - if (underRelaxation < 0.1) { - CFLFactor = config->GetCFL_AdaptParam(0); - } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { - CFLFactor = 1.0; + if (iMesh == MESH_0) { + MGFactor[iMesh] = 1.0; } else { - CFLFactor = config->GetCFL_AdaptParam(1); + const su2double CFLRatio = config->GetCFL(iMesh)/config->GetCFL(iMesh-1); + MGFactor[iMesh] = MGFactor[iMesh-1]*CFLRatio; } - /* Check if we are hitting the min or max and adjust. */ + /* Loop over all points on this grid and apply CFL adaption. */ - if (CFL <= CFLMin) { - CFL = CFLMin; - CFLFactor = 1.001*MGFactor[MGLevel]; - } else if (CFL >= CFLMax) { - CFL = CFLMax; - CFLFactor = 0.999*MGFactor[MGLevel]; + for (unsigned long iPoint = 0; iPoint < geometry[iMesh]->GetnPointDomain(); iPoint++) { + + /* Get the current local flow CFL number at this point. */ + + su2double CFL = solverFlow->node[iPoint]->GetLocalCFL(); + + /* Get the current under-relaxation parameters that were computed + during the previous nonlinear update. If we have a turbulence model, + take the minimum under-relaxation parameter between the mean flow + and turbulence systems. */ + + su2double underRelaxationFlow = solverFlow->node[iPoint]->GetUnderRelaxation(); + su2double underRelaxationTurb = 1.0; + if (config->GetKind_Turb_Model() != NONE) + underRelaxationTurb = solverTurb->node[iPoint]->GetUnderRelaxation(); + const su2double underRelaxation = min(underRelaxationFlow,underRelaxationTurb); + + /* If we apply a small under-relaxation parameter for stability, + then we should reduce the CFL before the next iteration. If we + are able to add the entire nonlinear update (under-relaxation = 1) + then we schedule an increase the CFL number for the next iteration. */ + + su2double CFLFactor = 1.0; + if (underRelaxation < 0.1) { + CFLFactor = CFLFactorDecrease; + } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { + CFLFactor = 1.0; + } else { + CFLFactor = CFLFactorIncrease; + } + + /* Check if we are hitting the min or max and adjust. */ + + if (CFL*CFLFactor <= CFLMin) { + CFL = CFLMin; + CFLFactor = 1.001*MGFactor[iMesh]; + } else if (CFL*CFLFactor >= CFLMax) { + CFL = CFLMax; + CFLFactor = 0.999*MGFactor[iMesh]; + } + + /* Apply the adjustment to the CFL and store local values. */ + + CFL *= CFLFactor; + solverFlow->node[iPoint]->SetLocalCFL(CFL); + if (config->GetKind_Turb_Model() != NONE) { + solverTurb->node[iPoint]->SetLocalCFL(CFL); + } + } - /* Apply the adjustment to the CFL and store local values. */ - CFL *= CFLFactor; - solver_container[FLOW_SOL]->node[iPoint]->SetLocalCFL(CFL); - solver_container[FLOW_SOL]->node[iPoint]->SetLocalCFLFactor(CFLFactor); - } } diff --git a/SU2_CFD/src/variables/CEulerVariable.cpp b/SU2_CFD/src/variables/CEulerVariable.cpp index 00348a2b926b..349da2dc4413 100644 --- a/SU2_CFD/src/variables/CEulerVariable.cpp +++ b/SU2_CFD/src/variables/CEulerVariable.cpp @@ -45,8 +45,9 @@ CEulerVariable::CEulerVariable(void) : CVariable() { Primitive = NULL; Secondary = NULL; - Gradient_Primitive = NULL; - Gradient_Secondary = NULL; + Gradient_Primitive = NULL; + Gradient_Reconstruction = NULL; + Gradient_Secondary = NULL; Limiter_Primitive = NULL; Limiter_Secondary = NULL; @@ -83,8 +84,9 @@ CEulerVariable::CEulerVariable(su2double val_density, su2double *val_velocity, s Primitive = NULL; Secondary = NULL; - Gradient_Primitive = NULL; - Gradient_Secondary = NULL; + Gradient_Primitive = NULL; + Gradient_Reconstruction = NULL; + Gradient_Secondary = NULL; Limiter_Primitive = NULL; Limiter_Secondary = NULL; @@ -220,6 +222,13 @@ CEulerVariable::CEulerVariable(su2double val_density, su2double *val_velocity, s Gradient_Primitive[iVar][iDim] = 0.0; } + Gradient_Reconstruction = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + Gradient_Reconstruction[iVar] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + Gradient_Secondary = new su2double* [nSecondaryVarGrad]; for (iVar = 0; iVar < nSecondaryVarGrad; iVar++) { Gradient_Secondary[iVar] = new su2double [nDim]; @@ -256,8 +265,9 @@ CEulerVariable::CEulerVariable(su2double *val_solution, unsigned short val_nDim, Primitive = NULL; Secondary = NULL; - Gradient_Primitive = NULL; - Gradient_Secondary = NULL; + Gradient_Primitive = NULL; + Gradient_Reconstruction = NULL; + Gradient_Secondary = NULL; Limiter_Primitive = NULL; Limiter_Secondary = NULL; @@ -386,6 +396,13 @@ CEulerVariable::CEulerVariable(su2double *val_solution, unsigned short val_nDim, Gradient_Primitive[iVar][iDim] = 0.0; } + Gradient_Reconstruction = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + Gradient_Reconstruction[iVar] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + Gradient_Secondary = new su2double* [nSecondaryVarGrad]; for (iVar = 0; iVar < nSecondaryVarGrad; iVar++) { Gradient_Secondary[iVar] = new su2double [nDim]; @@ -419,6 +436,11 @@ CEulerVariable::~CEulerVariable(void) { if (Gradient_Primitive[iVar] != NULL) delete [] Gradient_Primitive[iVar]; delete [] Gradient_Primitive; } + if (Gradient_Reconstruction != NULL) { + for (iVar = 0; iVar < nPrimVarGrad; iVar++) + if (Gradient_Reconstruction[iVar] != NULL) delete [] Gradient_Reconstruction[iVar]; + delete [] Gradient_Reconstruction; + } if (Gradient_Secondary != NULL) { for (iVar = 0; iVar < nSecondaryVarGrad; iVar++) if (Gradient_Secondary[iVar] != NULL) delete [] Gradient_Secondary[iVar]; diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 62b997113a8b..0336a02ba003 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -41,9 +41,10 @@ CIncEulerVariable::CIncEulerVariable(void) : CVariable() { /*--- Array initialization ---*/ - Primitive = NULL; - Gradient_Primitive = NULL; - Limiter_Primitive = NULL; + Primitive = NULL; + Gradient_Primitive = NULL; + Gradient_Reconstruction = NULL; + Limiter_Primitive = NULL; Grad_AuxVar = NULL; @@ -72,9 +73,10 @@ CIncEulerVariable::CIncEulerVariable(su2double val_pressure, su2double *val_velo /*--- Array initialization ---*/ - Primitive = NULL; - Gradient_Primitive = NULL; - Limiter_Primitive = NULL; + Primitive = NULL; + Gradient_Primitive = NULL; + Gradient_Reconstruction = NULL; + Limiter_Primitive = NULL; Grad_AuxVar = NULL; @@ -169,6 +171,13 @@ CIncEulerVariable::CIncEulerVariable(su2double val_pressure, su2double *val_velo Gradient_Primitive[iVar][iDim] = 0.0; } + Gradient_Reconstruction = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + Gradient_Reconstruction[iVar] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + /*--- If axisymmetric and viscous, we need an auxiliary gradient. ---*/ if (axisymmetric && viscous) @@ -200,9 +209,10 @@ CIncEulerVariable::CIncEulerVariable(su2double *val_solution, unsigned short val /*--- Array initialization ---*/ - Primitive = NULL; - Gradient_Primitive = NULL; - Limiter_Primitive = NULL; + Primitive = NULL; + Gradient_Primitive = NULL; + Gradient_Reconstruction = NULL; + Limiter_Primitive = NULL; Grad_AuxVar = NULL; @@ -290,6 +300,13 @@ CIncEulerVariable::CIncEulerVariable(su2double *val_solution, unsigned short val Gradient_Primitive[iVar][iDim] = 0.0; } + Gradient_Reconstruction = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + Gradient_Reconstruction[iVar] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + /*--- If axisymmetric and viscous, we need an auxiliary gradient. ---*/ if (axisymmetric && viscous) @@ -317,6 +334,12 @@ CIncEulerVariable::~CIncEulerVariable(void) { delete [] Gradient_Primitive; } + if (Gradient_Reconstruction != NULL) { + for (iVar = 0; iVar < nPrimVarGrad; iVar++) + if (Gradient_Reconstruction!=NULL) delete [] Gradient_Reconstruction[iVar]; + delete [] Gradient_Reconstruction; + } + if (Solution_BGS_k != NULL) delete [] Solution_BGS_k; } diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 70fdcdb44a55..c02c95aee0a3 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -57,12 +57,11 @@ CVariable::CVariable(void) { Residual_Sum = NULL; Solution_Adj_Old = NULL; - /* Under-relaxation parameters. */ + /* Under-relaxation parameter. */ UnderRelaxation = 1.0; - LocalCFLFactor = 1.0; /* Non-physical point (first-order) initialization. */ - Non_Physical = false; + Non_Physical = false; Non_Physical_Counter = 0; } @@ -98,12 +97,11 @@ CVariable::CVariable(unsigned short val_nvar, CConfig *config) { for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - /* Under-relaxation parameters. */ + /* Under-relaxation parameter. */ UnderRelaxation = 1.0; - LocalCFLFactor = 1.0; /* Non-physical point (first-order) initialization. */ - Non_Physical = false; + Non_Physical = false; Non_Physical_Counter = 0; } @@ -164,21 +162,18 @@ CVariable::CVariable(unsigned short val_nDim, unsigned short val_nvar, CConfig * Solution_Adj_Old = new su2double [nVar]; } - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { - Rmatrix = new su2double*[nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - Rmatrix[iDim] = new su2double[nDim]; - for (jDim = 0; jDim < nDim; jDim++) - Rmatrix[iDim][jDim] = 0.0; - } + Rmatrix = new su2double*[nDim]; + for (iDim = 0; iDim < nDim; iDim++) { + Rmatrix[iDim] = new su2double[nDim]; + for (jDim = 0; jDim < nDim; jDim++) + Rmatrix[iDim][jDim] = 0.0; } - /* Under-relaxation parameters. */ + /* Under-relaxation parameter. */ UnderRelaxation = 1.0; - LocalCFLFactor = 1.0; /* Non-physical point (first-order) initialization. */ - Non_Physical = false; + Non_Physical = false; Non_Physical_Counter = 0; } From ccea15aa31496f03aee3b5ff25c2da165011e9c3 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Sat, 14 Sep 2019 08:22:52 -0700 Subject: [PATCH 05/57] Preparing for PR. --- SU2_CFD/src/output_structure.cpp | 41 +------------------------- SU2_CFD/src/solver_direct_heat.cpp | 2 +- SU2_CFD/src/solver_direct_mean_inc.cpp | 4 +-- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/SU2_CFD/src/output_structure.cpp b/SU2_CFD/src/output_structure.cpp index a8a4d9b993a5..46c73be65b54 100644 --- a/SU2_CFD/src/output_structure.cpp +++ b/SU2_CFD/src/output_structure.cpp @@ -12912,32 +12912,6 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * Variable_Names.push_back("Volume_Ratio"); } - nVar_Par +=1; - Variable_Names.push_back("Local_CFL"); - nVar_Par +=1; - Variable_Names.push_back("Under_Relaxation"); - - nVar_Par += 5*nDim; - Variable_Names.push_back("GradT_x"); - Variable_Names.push_back("GradT_y"); - if (geometry->GetnDim() == 3) Variable_Names.push_back("GradT_z"); - - Variable_Names.push_back("GradVelx_x"); - Variable_Names.push_back("GradVelx_y"); - if (geometry->GetnDim() == 3) Variable_Names.push_back("GradVelx_z"); - - Variable_Names.push_back("GradVely_x"); - Variable_Names.push_back("GradVely_y"); - if (geometry->GetnDim() == 3) Variable_Names.push_back("GradVely_z"); - - Variable_Names.push_back("GradP_x"); - Variable_Names.push_back("GradP_y"); - if (geometry->GetnDim() == 3) Variable_Names.push_back("GradP_z"); - - Variable_Names.push_back("GradDensity_x"); - Variable_Names.push_back("GradDensity_y"); - if (geometry->GetnDim() == 3) Variable_Names.push_back("GradDensity_z"); - } /*--- Auxiliary vectors for variables defined on surfaces only. ---*/ @@ -13255,20 +13229,7 @@ void COutput::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSolver * Local_Data[jPoint][iVar] = geometry->Aspect_Ratio[iPoint]; iVar++; Local_Data[jPoint][iVar] = geometry->Volume_Ratio[iPoint]; iVar++; } - - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetLocalCFL(); iVar++; - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetUnderRelaxation(); iVar++; - - su2double **gradient = solver[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); - - /* First, write the primitive gradients from the solution. */ - for (jVar = 0; jVar < 5; jVar++) { - for (iDim = 0; iDim < nDim; iDim ++){ - Local_Data[jPoint][iVar] = gradient[jVar][iDim]; - iVar++; - } - } - + } /*--- Increment the point counter, as there may have been halos we diff --git a/SU2_CFD/src/solver_direct_heat.cpp b/SU2_CFD/src/solver_direct_heat.cpp index f873bd3e3497..8993887feb2b 100644 --- a/SU2_CFD/src/solver_direct_heat.cpp +++ b/SU2_CFD/src/solver_direct_heat.cpp @@ -1359,7 +1359,7 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe /*--- Compute spectral radius based on thermal conductivity ---*/ - Min_Delta_Time = 1.E6; Max_Delta_Time = 0.0; + Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; CFL_Reduction = config->GetCFLRedCoeff_Turb(); for (iPoint = 0; iPoint < nPointDomain; iPoint++) { diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index 7c88cf68e782..35e0980b21b7 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -1662,7 +1662,7 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain bool dual_time = ((config->GetUnsteady_Simulation() == DT_STEPPING_1ST) || (config->GetUnsteady_Simulation() == DT_STEPPING_2ND)); - Min_Delta_Time = 1.E6; Max_Delta_Time = 0.0; + Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ @@ -7721,7 +7721,7 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, (config->GetUnsteady_Simulation() == DT_STEPPING_2ND)); bool energy = config->GetEnergy_Equation(); - Min_Delta_Time = 1.E6; Max_Delta_Time = 0.0; + Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed and viscosity ---*/ From 9b3b4a2156655f9232241ec4b41d31ef6547804b Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Sat, 14 Sep 2019 09:01:02 -0700 Subject: [PATCH 06/57] Removed unused variable. --- SU2_CFD/src/drivers/CDriver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index d4b265cce727..2bf480d259b7 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -4268,7 +4268,6 @@ void CTurbomachineryDriver::SetTurboPerformance(unsigned short targetZone){ bool CTurbomachineryDriver::Monitor(unsigned long ExtIter) { - su2double CFL; su2double rot_z_ini, rot_z_final ,rot_z; su2double outPres_ini, outPres_final, outPres; unsigned long rampFreq, finalRamp_Iter; From 071ead0a307d5c43a7e90b8297695107322966c3 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 26 Sep 2019 10:31:24 -0700 Subject: [PATCH 07/57] Added new option for reconstruction gradient. Activated recon. gradient for scalar equations. Adding checks for linear and nonlinear residual reductions in CFL adaption which need testing. --- Common/include/config_structure.hpp | 25 ++- Common/include/config_structure.inl | 6 + Common/include/option_structure.hpp | 8 +- Common/src/config_structure.cpp | 59 ++++++- Common/src/linear_algebra/CSysSolve.cpp | 8 +- SU2_CFD/include/solver_structure.hpp | 57 ++++++- SU2_CFD/include/solver_structure.inl | 10 +- .../include/variables/CAdjEulerVariable.hpp | 25 +++ SU2_CFD/include/variables/CEulerVariable.hpp | 1 + .../include/variables/CHeatFVMVariable.hpp | 26 ++- .../include/variables/CIncEulerVariable.hpp | 1 + SU2_CFD/include/variables/CTurbVariable.hpp | 25 +++ SU2_CFD/src/solver_adjoint_mean.cpp | 34 +++- SU2_CFD/src/solver_adjoint_turbulent.cpp | 55 +----- SU2_CFD/src/solver_direct_heat.cpp | 15 +- SU2_CFD/src/solver_direct_mean.cpp | 60 ++++--- SU2_CFD/src/solver_direct_mean_inc.cpp | 66 +++++--- SU2_CFD/src/solver_direct_transition.cpp | 2 +- SU2_CFD/src/solver_direct_turbulent.cpp | 40 +++-- SU2_CFD/src/solver_structure.cpp | 156 ++++++++++++++---- SU2_CFD/src/variables/CAdjEulerVariable.cpp | 33 ++++ SU2_CFD/src/variables/CEulerVariable.cpp | 35 ++-- SU2_CFD/src/variables/CHeatFVMVariable.cpp | 17 +- SU2_CFD/src/variables/CIncEulerVariable.cpp | 35 ++-- SU2_CFD/src/variables/CTurbVariable.cpp | 24 ++- config_template.cfg | 4 + 26 files changed, 628 insertions(+), 199 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 699714ea4f18..d70334006da3 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -471,6 +471,7 @@ class CConfig { *Kind_SurfaceMovement, /*!< \brief Kind of the static mesh movement. */ nKind_SurfaceMovement, /*!< \brief Kind of the dynamic mesh movement. */ Kind_Gradient_Method, /*!< \brief Numerical method for computation of spatial gradients. */ + Kind_Gradient_Method_Recon, /*!< \brief Numerical method for computation of spatial gradients used for upwind reconstruction. */ Kind_Deform_Linear_Solver, /*!< Numerical method to deform the grid */ Kind_Deform_Linear_Solver_Prec, /*!< \brief Preconditioner of the linear solver. */ Kind_Linear_Solver, /*!< \brief Numerical solver for the implicit scheme. */ @@ -526,6 +527,8 @@ class CConfig { Kind_Solver_Fluid_FSI, /*!< \brief Kind of solver for the fluid in FSI applications. */ Kind_Solver_Struc_FSI, /*!< \brief Kind of solver for the structure in FSI applications. */ Kind_BGS_RelaxMethod; /*!< \brief Kind of relaxation method for Block Gauss Seidel method in FSI problems. */ + bool ReconstructionGradientRequired; /*!< \brief Enable or disable a second gradient calculation for upwind reconstruction only. */ + bool LeastSquaresRequired; /*!< \brief Enable or disable memory allocation for least-squares gradient methods. */ bool Energy_Equation; /*!< \brief Solve the energy equation for incompressible flows. */ bool MUSCL, /*!< \brief MUSCL scheme .*/ MUSCL_Flow, /*!< \brief MUSCL scheme for the flow equations.*/ @@ -4013,11 +4016,29 @@ class CConfig { void SetKt_PolyCoeffND(su2double val_coeff, unsigned short val_index); /*! - * \brief Get the kind of method for computation of spatial gradients. - * \return Numerical method for computation of spatial gradients. + * \brief Get the kind of method for computation of spatial gradients used for viscous and source terms. + * \return Numerical method for computation of spatial gradients used for viscous and source terms. */ unsigned short GetKind_Gradient_Method(void); + /*! + * \brief Get the kind of method for computation of spatial gradients used for upwind reconstruction. + * \return Numerical method for computation of spatial gradients used for upwind reconstruction. + */ + unsigned short GetKind_Gradient_Method_Recon(void); + + /*! + * \brief Get flag for whether a second gradient calculation is required for upwind reconstruction alone. + * \return TRUE means that a second gradient will be calculated for upwind reconstruction. + */ + bool GetReconstructionGradientRequired(void); + + /*! + * \brief Get flag for whether a least-squares gradient method is being applied. + * \return TRUE means that a least-squares gradient method is being applied. + */ + bool GetLeastSquaresRequired(void); + /*! * \brief Get the kind of solver for the implicit solver. * \return Numerical solver for implicit formulation (solving the linear system). diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl index ff6967cd8c78..4507f6b9e7d0 100644 --- a/Common/include/config_structure.inl +++ b/Common/include/config_structure.inl @@ -1001,6 +1001,12 @@ inline su2double CConfig::GetmaxTurkelBeta() { return Max_Beta_RoeTurkel; } inline unsigned short CConfig::GetKind_Gradient_Method(void) { return Kind_Gradient_Method; } +inline unsigned short CConfig::GetKind_Gradient_Method_Recon(void) { return Kind_Gradient_Method_Recon; } + +inline bool CConfig::GetReconstructionGradientRequired(void) { return ReconstructionGradientRequired; } + +inline bool CConfig::GetLeastSquaresRequired(void) { return LeastSquaresRequired; } + inline unsigned short CConfig::GetKind_Linear_Solver(void) { return Kind_Linear_Solver; } inline unsigned short CConfig::GetKind_Deform_Linear_Solver(void) { return Kind_Deform_Linear_Solver; } diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index e9fdbe537ea4..0574d43d14ce 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -996,11 +996,15 @@ static const map Space_Ite_Map_FEA = CCreateMap Gradient_Map = CCreateMap +("NONE", NO_GRADIENT) ("GREEN_GAUSS", GREEN_GAUSS) +("LEAST_SQUARES", LEAST_SQUARES) ("WEIGHTED_LEAST_SQUARES", WEIGHTED_LEAST_SQUARES); /*! diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 62c68a51a64c..ebc01fdee64e 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -1554,6 +1554,9 @@ void CConfig::SetConfig_Options() { /*!\brief NUM_METHOD_GRAD * \n DESCRIPTION: Numerical method for spatial gradients \n OPTIONS: See \link Gradient_Map \endlink. \n DEFAULT: WEIGHTED_LEAST_SQUARES. \ingroup Config*/ addEnumOption("NUM_METHOD_GRAD", Kind_Gradient_Method, Gradient_Map, WEIGHTED_LEAST_SQUARES); + /*!\brief NUM_METHOD_GRAD + * \n DESCRIPTION: Numerical method for spatial gradients used only for upwind reconstruction \n OPTIONS: See \link Gradient_Map \endlink. \n DEFAULT: NO_GRADIENT. \ingroup Config*/ + addEnumOption("NUM_METHOD_GRAD_RECON", Kind_Gradient_Method_Recon, Gradient_Map, NO_GRADIENT); /*!\brief VENKAT_LIMITER_COEFF * \n DESCRIPTION: Coefficient for the limiter. DEFAULT value 0.5. Larger values decrease the extent of limiting, values approaching zero cause lower-order approximation to the solution. \ingroup Config */ addDoubleOption("VENKAT_LIMITER_COEFF", Venkat_LimiterCoeff, 0.05); @@ -4510,6 +4513,52 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } + /* 2nd-order MUSCL is not possible for the continuous adjoint + turbulence model. */ + + if (MUSCL_AdjTurb) { + SU2_MPI::Error(string("MUSCL_ADJTURB= YES not currently supported.\n") + + string("Please select MUSCL_ADJTURB= NO (first-order)."), + CURRENT_FUNCTION); + } + + /* Check for whether we need a second gradient method to calculate + gradients for uwpind reconstruction. Set additional booleans to + minimize overhead as appropriate. */ + + if (MUSCL_Flow || MUSCL_Turb || MUSCL_Heat || MUSCL_AdjFlow) { + + ReconstructionGradientRequired = true; + + if ((Kind_Gradient_Method_Recon == NO_GRADIENT) || + (Kind_Gradient_Method_Recon == Kind_Gradient_Method)) { + + /* The default behavior if no reconstruction gradient is specified + is to use the same gradient as needed for the viscous/source terms + without recomputation. If they are using the same method, then + we also want to avoid recomputation. */ + + ReconstructionGradientRequired = false; + Kind_Gradient_Method_Recon = Kind_Gradient_Method; + } + + } + + /* Simpler boolean to control allocation of least-squares memory. */ + + if ((Kind_Gradient_Method_Recon == LEAST_SQUARES) || + (Kind_Gradient_Method_Recon == WEIGHTED_LEAST_SQUARES) || + (Kind_Gradient_Method == LEAST_SQUARES) || + (Kind_Gradient_Method == WEIGHTED_LEAST_SQUARES)) { + LeastSquaresRequired = true; + } + + if (Kind_Gradient_Method == LEAST_SQUARES) { + SU2_MPI::Error(string("LEAST_SQUARES gradient method not allowed for viscous / source terms.\n") + + string("Please select either WEIGHTED_LEAST_SQUARES or GREEN_GAUSS."), + CURRENT_FUNCTION); + } + } void CConfig::SetMarkers(unsigned short val_software) { @@ -5912,9 +5961,15 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { Kind_Solver != DISC_ADJ_FEM_EULER && Kind_Solver != DISC_ADJ_FEM_NS && Kind_Solver != DISC_ADJ_FEM_RANS) { if (!fea){ + switch (Kind_Gradient_Method_Recon) { + case GREEN_GAUSS: cout << "Gradient for upwind reconstruction: Green-Gauss." << endl; break; + case LEAST_SQUARES: cout << "Gradient for upwind reconstruction: unweighted Least-Squares." << endl; break; + case WEIGHTED_LEAST_SQUARES: cout << "Gradient for upwind reconstruction: inverse-distance weighted Least-Squares." << endl; break; + } switch (Kind_Gradient_Method) { - case GREEN_GAUSS: cout << "Gradient computation using Green-Gauss theorem." << endl; break; - case WEIGHTED_LEAST_SQUARES: cout << "Gradient Computation using weighted Least-Squares method." << endl; break; + case GREEN_GAUSS: cout << "Gradient for viscous and source terms: Green-Gauss." << endl; break; + case LEAST_SQUARES: cout << "Gradient for viscous and source terms: unweighted Least-Squares." << endl; break; + case WEIGHTED_LEAST_SQUARES: cout << "Gradient for viscous and source terms: inverse-distance weighted Least-Squares." << endl; break; } } else{ diff --git a/Common/src/linear_algebra/CSysSolve.cpp b/Common/src/linear_algebra/CSysSolve.cpp index 19cd6b605e65..306c0f606b25 100644 --- a/Common/src/linear_algebra/CSysSolve.cpp +++ b/Common/src/linear_algebra/CSysSolve.cpp @@ -333,7 +333,7 @@ unsigned long CSysSolve::CG_LinSolver(const CSysVector & } - (*residual) = norm_r; + (*residual) = norm_r/norm0; return (unsigned long) i; } @@ -489,7 +489,7 @@ unsigned long CSysSolve::FGMRES_LinSolver(const CSysVector::BCGSTAB_LinSolver(const CSysVector::Smoother_LinSolver(const CSysVector NonLinRes_Series; /*!< \brief Vector holding the nonlinear residual indicator series. */ + su2double Old_Func, /*!< \brief Old value of the nonlinear residual indicator. */ + New_Func; /*!< \brief Current value of the nonlinear residual indicator. */ + unsigned short nVar, /*!< \brief Number of variables of the problem. */ + nPrimVar, /*!< \brief Number of primitive variables of the problem. */ + nPrimVarGrad, /*!< \brief Number of primitive variables of the problem in the gradient computation. */ nSecondaryVar, /*!< \brief Number of primitive variables of the problem. */ nSecondaryVarGrad, /*!< \brief Number of primitive variables of the problem in the gradient computation. */ nVarGrad, /*!< \brief Number of variables for deallocating the LS Cvector. */ @@ -237,6 +245,12 @@ class CSolver { */ void SetIterLinSolver(unsigned short val_iterlinsolver); + /*! + * \brief Set the final linear solver residual. + * \param[in] val_relinsolver - Value of final linear solver residual. + */ + void SetResLinSolver(su2double val_reslinsolver); + /*! * \brief Set the value of the max residual and RMS residual. * \param[in] val_iterlinsolver - Number of linear iterations. @@ -285,6 +299,24 @@ class CSolver { */ unsigned short GetIterLinSolver(void); + /*! + * \brief Get the final linear solver residual. + * \return Value of final linear solver residual. + */ + su2double GetResLinSolver(void); + + /*! + * \brief Set the nonlinear residual monitor. + * \param[in] val_nonlinearResMonitor - Value of the nonlinear residual monitor. + */ + void SetNonlinearResMonitor(su2double val_nonlinearResMonitor); + + /*! + * \brief Get the nonlinear residual monitor. + * \return Value of the nonlinear residual monitor. + */ + su2double GetNonlinearResMonitor(void); + /*! * \brief Get the value of the maximum delta time. * \return Value of the maximum delta time. @@ -513,15 +545,18 @@ class CSolver { /*! * \brief Compute the Green-Gauss gradient of the solution. * \param[in] geometry - Geometrical definition of the problem. + * \param[in] config - Definition of the particular problem. + * \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction. */ - void SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config); + void SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config, bool reconstruction = false); /*! * \brief Compute the Least Squares gradient of the solution. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction. */ - void SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config); + void SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction = false); /*! * \brief Compute the Least Squares gradient of the grid velocity. @@ -1435,13 +1470,15 @@ class CSolver { * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction. */ - virtual void SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config); + virtual void SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config, bool reconstruction = false); /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction. */ virtual void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction = false); @@ -5056,14 +5093,16 @@ class CEulerSolver : public CSolver { * and stores the result in the Gradient_Primitive variable. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction. */ - void SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config); + void SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config, bool reconstruction = false); /*! * \brief Compute the gradient of the primitive variables using a Least-Squares method, * and stores the result in the Gradient_Primitive variable. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction. */ void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction = false); @@ -7331,14 +7370,16 @@ class CIncEulerSolver : public CSolver { * and stores the result in the Gradient_Primitive variable. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction. */ - void SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config); + void SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config, bool reconstruction = false); /*! * \brief Compute the gradient of the primitive variables using a Least-Squares method, * and stores the result in the Gradient_Primitive variable. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] reconstruction - indicator that the gradient being computed is for upwind reconstruction. */ void SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction = false); diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index 04e50aff4d94..6d6e15e193ea 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -39,10 +39,18 @@ inline void CSolver::SetIterLinSolver(unsigned short val_iterlinsolver) { IterLinSolver = val_iterlinsolver; } +inline void CSolver::SetResLinSolver(su2double val_reslinsolver) { ResLinSolver = val_reslinsolver; } + inline void CSolver::SetNondimensionalization(CConfig *config, unsigned short iMesh) { } inline unsigned short CSolver::GetIterLinSolver(void) { return IterLinSolver; } +inline su2double CSolver::GetResLinSolver(void) { return ResLinSolver; } + +inline void CSolver::SetNonlinearResMonitor(su2double val_nonlinearResMonitor) { NonlinearResMonitor = val_nonlinearResMonitor; } + +inline su2double CSolver::GetNonlinearResMonitor(void) { return NonlinearResMonitor; } + inline su2double CSolver::GetCSensitivity(unsigned short val_marker, unsigned long val_vertex) { return 0; } inline void CSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, @@ -102,7 +110,7 @@ inline su2double* CSolver::GetPsiRhos_Inf(void) { return NULL; } inline su2double CSolver::GetPsiE_Inf(void) { return 0; } -inline void CSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config) { } +inline void CSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config, bool reconstruction) { } inline void CSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction) { } diff --git a/SU2_CFD/include/variables/CAdjEulerVariable.hpp b/SU2_CFD/include/variables/CAdjEulerVariable.hpp index c03a070d4965..e7d564cc282b 100644 --- a/SU2_CFD/include/variables/CAdjEulerVariable.hpp +++ b/SU2_CFD/include/variables/CAdjEulerVariable.hpp @@ -53,6 +53,9 @@ class CAdjEulerVariable : public CVariable { su2double *IntBoundary_Jump; /*!< \brief Interior boundary jump vector. */ su2double *HB_Source; /*!< \brief Harmonic balance source term. */ bool incompressible; + su2double **Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ + bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ + public: /*! @@ -147,4 +150,26 @@ class CAdjEulerVariable : public CVariable { * \return Value of the harmonic balance source term for the index val_var. */ inline su2double GetHarmonicBalance_Source(unsigned short val_var) {return HB_Source[val_var]; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \return Value of the primitive variables gradient. + */ + inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \param[in] val_value - Value of the gradient. + */ + inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \return Value of the primitive variables gradient. + */ + inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } }; diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 655b714463d0..aa04841f2648 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -58,6 +58,7 @@ class CEulerVariable : public CVariable { su2double *Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ su2double **Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ su2double **Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term (T, vx, vy, vz, P, rho). */ + bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ su2double *Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ /*--- Secondary variable definition ---*/ diff --git a/SU2_CFD/include/variables/CHeatFVMVariable.hpp b/SU2_CFD/include/variables/CHeatFVMVariable.hpp index c9d50f05b6af..969a06df9a18 100644 --- a/SU2_CFD/include/variables/CHeatFVMVariable.hpp +++ b/SU2_CFD/include/variables/CHeatFVMVariable.hpp @@ -49,7 +49,9 @@ class CHeatFVMVariable : public CVariable { protected: su2double* Solution_Direct; /*!< \brief Direct solution container for use in the adjoint Heat solver. */ su2double* Solution_BGS_k; /*!< \brief Old solution container for BGS iterations ---*/ - + su2double **Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ + bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ + public: /*! @@ -71,4 +73,26 @@ class CHeatFVMVariable : public CVariable { */ ~CHeatFVMVariable(void); + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \return Value of the primitive variables gradient. + */ + inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \param[in] val_value - Value of the gradient. + */ + inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \return Value of the primitive variables gradient. + */ + inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } + }; diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 04b2c81f0d32..7622b4c53b14 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -54,6 +54,7 @@ class CIncEulerVariable : public CVariable { su2double *Primitive; /*!< \brief Primitive variables (P, vx, vy, vz, T, rho ...) for incompressible flows. */ su2double **Gradient_Primitive; /*!< \brief Gradient of the primitive variables */ su2double **Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term */ + bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ su2double *Limiter_Primitive; /*!< \brief Limiter of the primitive variables */ diff --git a/SU2_CFD/include/variables/CTurbVariable.hpp b/SU2_CFD/include/variables/CTurbVariable.hpp index 10eeefedc8f4..28e0152be71e 100644 --- a/SU2_CFD/include/variables/CTurbVariable.hpp +++ b/SU2_CFD/include/variables/CTurbVariable.hpp @@ -49,6 +49,8 @@ class CTurbVariable : public CVariable { protected: su2double muT; /*!< \brief Eddy viscosity. */ su2double *HB_Source; /*!< \brief Harmonic Balance source term. */ + su2double **Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ + bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ public: /*! @@ -80,5 +82,28 @@ class CTurbVariable : public CVariable { * \param[in] val_muT - Value of the eddy viscosity. */ inline void SetmuT(su2double val_muT) { muT = val_muT; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \return Value of the primitive variables gradient. + */ + inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \param[in] val_var - Index of the variable. + * \param[in] val_dim - Index of the dimension. + * \param[in] val_value - Value of the gradient. + */ + inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + + /*! + * \brief Get the value of the primitive gradient for MUSCL reconstruction. + * \return Value of the primitive variables gradient. + */ + inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } + }; diff --git a/SU2_CFD/src/solver_adjoint_mean.cpp b/SU2_CFD/src/solver_adjoint_mean.cpp index c92e732ecc3f..389bbddcb091 100644 --- a/SU2_CFD/src/solver_adjoint_mean.cpp +++ b/SU2_CFD/src/solver_adjoint_mean.cpp @@ -203,7 +203,7 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned } /*--- Computation of gradients by least squares ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + if (config->GetLeastSquaresRequired()) { /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -1669,13 +1669,16 @@ void CAdjEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai } - if ((muscl) && (iMesh == MESH_0)) { - /*--- Compute gradients for upwind second-order reconstruction ---*/ - - if (config->GetKind_Gradient_Method() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config); - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config); + /*--- Gradient computation for MUSCL reconstruction. ---*/ + + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetSolution_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); /*--- Limiter computation ---*/ @@ -1831,8 +1834,13 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Adjoint variables using gradient reconstruction and limiters ---*/ - Gradient_i = node[iPoint]->GetGradient(); Gradient_j = node[jPoint]->GetGradient(); - if (limiter) { Limiter_i = node[iPoint]->GetLimiter(); Limiter_j = node[jPoint]->GetLimiter(); } + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + + if (limiter) { + Limiter_i = node[iPoint]->GetLimiter(); + Limiter_j = node[jPoint]->GetLimiter(); + } for (iVar = 0; iVar < nVar; iVar++) { Project_Grad_i = 0; Project_Grad_j = 0; @@ -5029,7 +5037,7 @@ CAdjNSSolver::CAdjNSSolver(CGeometry *geometry, CConfig *config, unsigned short } /*--- Array structures for computation of gradients by least squares ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + if (config->GetLeastSquaresRequired()) { /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -5248,6 +5256,14 @@ void CAdjNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- Compute gradients adj for solution reconstruction and viscous term ---*/ + if (config->GetReconstructionGradientRequired()) { + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetSolution_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); + } if (config->GetKind_Gradient_Method() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config); if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config); diff --git a/SU2_CFD/src/solver_adjoint_turbulent.cpp b/SU2_CFD/src/solver_adjoint_turbulent.cpp index 0e2cf8e5eaff..5a60b454adb0 100644 --- a/SU2_CFD/src/solver_adjoint_turbulent.cpp +++ b/SU2_CFD/src/solver_adjoint_turbulent.cpp @@ -110,7 +110,7 @@ CAdjTurbSolver::CAdjTurbSolver(CGeometry *geometry, CConfig *config, unsigned sh LinSysRes.Initialize(nPoint, nPointDomain, nVar, 0.0); /*--- Computation of gradients by least squares ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + if (config->GetLeastSquaresRequired()) { /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -316,17 +316,6 @@ void CAdjTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta unsigned long iEdge, iPoint, jPoint; su2double *U_i, *U_j, *TurbPsi_i, *TurbPsi_j, **TurbVar_Grad_i, **TurbVar_Grad_j; -// su2double *Limiter_i = NULL, *Limiter_j = NULL, **Gradient_i, **Gradient_j, Project_Grad_i, Project_Grad_j; -// unsigned short iDim, iVar; - - bool muscl = config->GetMUSCL_AdjTurb(); - bool limiter = (config->GetKind_SlopeLimit_AdjTurb() != NO_LIMITER); - - if (muscl) { - if (config->GetKind_Gradient_Method() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config); - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config); - if (limiter) SetSolution_Limiter(geometry, config); - } for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { @@ -352,48 +341,6 @@ void CAdjTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta TurbVar_Grad_j = solver_container[TURB_SOL]->node[jPoint]->GetGradient(); numerics->SetTurbVarGradient(TurbVar_Grad_i, TurbVar_Grad_j); -// if (muscl) { -// -// /*--- Conservative solution using gradient reconstruction ---*/ -// for (iDim = 0; iDim < nDim; iDim++) { -// Vector_i[iDim] = 0.5*(geometry->node[jPoint]->GetCoord(iDim) - geometry->node[iPoint]->GetCoord(iDim)); -// Vector_j[iDim] = 0.5*(geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim)); -// } -// Gradient_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient(); -// Gradient_j = solver_container[FLOW_SOL]->node[jPoint]->GetGradient(); -// for (iVar = 0; iVar < solver_container[FLOW_SOL]->GetnVar(); iVar++) { -// Project_Grad_i = 0; Project_Grad_j = 0; -// for (iDim = 0; iDim < nDim; iDim++) { -// Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]; -// Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]; -// } -// FlowSolution_i[iVar] = U_i[iVar] + Project_Grad_i; -// FlowSolution_j[iVar] = U_j[iVar] + Project_Grad_j; -// } -// numerics->SetConservative(FlowSolution_i, FlowSolution_j); -// -// /*--- Adjoint turbulent variables using gradient reconstruction ---*/ -// Gradient_i = node[iPoint]->GetGradient(); Gradient_j = node[jPoint]->GetGradient(); -// if (limiter) { Limiter_i = node[iPoint]->GetLimiter(); Limiter_j = node[jPoint]->GetLimiter(); } -// for (iVar = 0; iVar < nVar; iVar++) { -// Project_Grad_i = 0; Project_Grad_j = 0; -// for (iDim = 0; iDim < nDim; iDim++) { -// Project_Grad_i += Vector_i[iDim]*Gradient_i[iVar][iDim]; -// Project_Grad_j += Vector_j[iDim]*Gradient_j[iVar][iDim]; -// } -// if (limiter) { -// Solution_i[iVar] = TurbPsi_i[iVar] + Project_Grad_i*Limiter_i[iVar]; -// Solution_j[iVar] = TurbPsi_j[iVar] + Project_Grad_j*Limiter_j[iVar]; -// } -// else { -// Solution_i[iVar] = TurbPsi_i[iVar] + Project_Grad_i; -// Solution_j[iVar] = TurbPsi_j[iVar] + Project_Grad_j; -// } -// } -// numerics->SetTurbVar(Solution_i, Solution_j); -// -// } - /*--- Set normal vectors and length ---*/ numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); diff --git a/SU2_CFD/src/solver_direct_heat.cpp b/SU2_CFD/src/solver_direct_heat.cpp index 8993887feb2b..1b81de4a04da 100644 --- a/SU2_CFD/src/solver_direct_heat.cpp +++ b/SU2_CFD/src/solver_direct_heat.cpp @@ -151,11 +151,15 @@ CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned sh /*--- Computation of gradients by least squares ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + if (config->GetLeastSquaresRequired()) { /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) Smatrix[iDim] = new su2double [nDim]; + /*--- c vector := transpose(WA)*(Wb) ---*/ + Cvector = new su2double* [nVar+1]; + for (iVar = 0; iVar < nVar+1; iVar++) + Cvector[iVar] = new su2double [nDim]; } Heat_Flux = new su2double[nMarker]; @@ -272,6 +276,11 @@ void CHeatSolverFVM::Preprocessing(CGeometry *geometry, CSolver **solver_contain /*--- Initialize the Jacobian matrices ---*/ Jacobian.SetValZero(); + if (config->GetReconstructionGradientRequired()) { + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config, true); + } if (config->GetKind_Gradient_Method() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config); if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config); } @@ -592,8 +601,8 @@ void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta Gradient_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Reconstruction(); Gradient_j = solver_container[FLOW_SOL]->node[jPoint]->GetGradient_Reconstruction(); - Temp_i_Grad = node[iPoint]->GetGradient(); - Temp_j_Grad = node[jPoint]->GetGradient(); + Temp_i_Grad = node[iPoint]->GetGradient_Reconstruction(); + Temp_j_Grad = node[jPoint]->GetGradient_Reconstruction(); /*Loop to correct the flow variables*/ for (iVar = 0; iVar < nVarFlow; iVar++) { diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index be251580313b..0ae1318fadd6 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -3035,17 +3035,13 @@ void CEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container if ((muscl && !center) && (iMesh == MESH_0) && !Output) { /*--- Gradient computation for MUSCL reconstruction. ---*/ - - SetPrimitive_Gradient_LS(geometry, config, true); - - /*--- Gradient computation ---*/ - - if (config->GetKind_Gradient_Method() == GREEN_GAUSS) { - SetPrimitive_Gradient_GG(geometry, config); - } - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { - SetPrimitive_Gradient_LS(geometry, config); - } + + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetPrimitive_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetPrimitive_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetPrimitive_Gradient_LS(geometry, config, true); /*--- Limiter computation ---*/ @@ -5212,6 +5208,10 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + /*--- Store the value of the residual. ---*/ + + SetResLinSolver(System.GetResidual()); + /*--- The the number of iterations of the linear solver ---*/ SetIterLinSolver(IterLinSol); @@ -5292,7 +5292,7 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CCon } -void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config) { +void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config, bool reconstruction) { unsigned long iPoint, jPoint, iEdge, iVertex; unsigned short iDim, iVar, iMarker; su2double *PrimVar_Vertex, *PrimVar_i, *PrimVar_j, PrimVar_Average, @@ -5375,7 +5375,10 @@ void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { Partial_Gradient = node[iPoint]->GetGradient_Primitive(iVar, iDim)/Vol; - node[iPoint]->SetGradient_Primitive(iVar, iDim, Partial_Gradient); + if (reconstruction) + node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Partial_Gradient); + else + node[iPoint]->SetGradient_Primitive(iVar, iDim, Partial_Gradient); } } @@ -5401,6 +5404,16 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config su2double z11, z12, z13, z22, z23, z33, detR2; bool singular; + /*--- Set a flag for unweighted or weighted least-squares. ---*/ + + bool weighted = true; + if (reconstruction) { + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + weighted = false; + } else if (config->GetKind_Gradient_Method() == LEAST_SQUARES) { + weighted = false; + } + /*--- Loop over points of the grid ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { @@ -5434,12 +5447,12 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config PrimVar_j = node[jPoint]->GetPrimitive(); - if (reconstruction) { - weight = 1.0; - } else { + if (weighted) { weight = 0.0; for (iDim = 0; iDim < nDim; iDim++) weight += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); + } else { + weight = 1.0; } /*--- Sumations for entries of upper triangular matrix R ---*/ @@ -5558,16 +5571,17 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->SetGradient_Primitive(iVar, iDim, Cvector[iVar][iDim]); if (reconstruction) node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Cvector[iVar][iDim]); + else + node[iPoint]->SetGradient_Primitive(iVar, iDim, Cvector[iVar][iDim]); } } } /*--- Communicate the gradient values via MPI. ---*/ - + InitiateComms(geometry, config, PRIMITIVE_GRADIENT); CompleteComms(geometry, config, PRIMITIVE_GRADIENT); @@ -15198,8 +15212,14 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C /*--- Compute gradient for MUSCL reconstruction. ---*/ - if ((config->GetMUSCL_Flow()) && (iMesh == MESH_0)) - SetPrimitive_Gradient_LS(geometry, config, true); + if (config->GetReconstructionGradientRequired() && (iMesh == MESH_0)) { + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetPrimitive_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetPrimitive_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetPrimitive_Gradient_LS(geometry, config, true); + } /*--- Compute gradient of the primitive variables ---*/ diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index e53b7273f294..6fdc8a133e97 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -342,7 +342,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned gradients by least squares, S matrix := inv(R)*traspose(inv(R)), c vector := transpose(WA)*(Wb) ---*/ - //if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + if (config->GetLeastSquaresRequired()) { Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -352,7 +352,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned for (iVar = 0; iVar < nPrimVarGrad; iVar++) Cvector[iVar] = new su2double [nDim]; - // } + } /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ @@ -1566,17 +1566,13 @@ void CIncEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai if ((muscl && !center) && (iMesh == MESH_0) && !Output) { /*--- Gradient computation for MUSCL reconstruction. ---*/ - - SetPrimitive_Gradient_LS(geometry, config, true); - - /*--- Gradient computation for all other terms. ---*/ - if (config->GetKind_Gradient_Method() == GREEN_GAUSS) { - SetPrimitive_Gradient_GG(geometry, config); - } - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { - SetPrimitive_Gradient_LS(geometry, config); - } + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetPrimitive_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetPrimitive_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetPrimitive_Gradient_LS(geometry, config, true); /*--- Limiter computation ---*/ @@ -3524,6 +3520,10 @@ void CIncEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + /*--- Store the value of the residual. ---*/ + + SetResLinSolver(System.GetResidual()); + /*--- The the number of iterations of the linear solver ---*/ SetIterLinSolver(IterLinSol); @@ -3571,9 +3571,9 @@ void CIncEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, C for (unsigned short iVar = 0; iVar < nVar; iVar++) { /* We impose a limit on the maximum percentage that the - pressure and temperature can change over a nonlinear iteration. */ + temperature can change over a nonlinear iteration. */ - if ( (config->GetEnergy_Equation() && (iVar == nVar-1))) { + if ((config->GetEnergy_Equation() && (iVar == nVar-1))) { const unsigned long index = iPoint*nVar + iVar; su2double ratio = fabs(LinSysSol[index])/(node[iPoint]->GetSolution(iVar)+EPS); if (ratio > allowableRatio) { @@ -3602,7 +3602,7 @@ void CIncEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, C } -void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config) { +void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config, bool reconstruction) { unsigned long iPoint, jPoint, iEdge, iVertex; unsigned short iDim, iVar, iMarker; su2double *PrimVar_Vertex, *PrimVar_i, *PrimVar_j, PrimVar_Average, @@ -3681,7 +3681,10 @@ void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *con for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { Partial_Gradient = node[iPoint]->GetGradient_Primitive(iVar, iDim)/Vol; - node[iPoint]->SetGradient_Primitive(iVar, iDim, Partial_Gradient); + if (reconstruction) + node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Partial_Gradient); + else + node[iPoint]->SetGradient_Primitive(iVar, iDim, Partial_Gradient); } } } @@ -3706,6 +3709,16 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con su2double z11, z12, z13, z22, z23, z33, detR2; bool singular; + /*--- Set a flag for unweighted or weighted least-squares. ---*/ + + bool weighted = true; + if (reconstruction) { + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + weighted = false; + } else if (config->GetKind_Gradient_Method() == LEAST_SQUARES) { + weighted = false; + } + /*--- Loop over points of the grid ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { @@ -3739,12 +3752,12 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con PrimVar_j = node[jPoint]->GetPrimitive(); - if (reconstruction) { - weight = 1.0; - } else { + if (weighted) { weight = 0.0; for (iDim = 0; iDim < nDim; iDim++) weight += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); + } else { + weight = 1.0; } /*--- Sumations for entries of upper triangular matrix R ---*/ @@ -3863,9 +3876,10 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->SetGradient_Primitive(iVar, iDim, Cvector[iVar][iDim]); if (reconstruction) node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Cvector[iVar][iDim]); + else + node[iPoint]->SetGradient_Primitive(iVar, iDim, Cvector[iVar][iDim]); } } @@ -7554,9 +7568,15 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container ErrorCounter = SetPrimitive_Variables(solver_container, config, Output); /*--- Compute gradient for MUSCL reconstruction. ---*/ - - if ((config->GetMUSCL_Flow()) && (iMesh == MESH_0)) - SetPrimitive_Gradient_LS(geometry, config, true); + +if (config->GetReconstructionGradientRequired() && (iMesh == MESH_0)) { + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetPrimitive_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetPrimitive_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetPrimitive_Gradient_LS(geometry, config, true); + } /*--- Compute gradient of the primitive variables ---*/ diff --git a/SU2_CFD/src/solver_direct_transition.cpp b/SU2_CFD/src/solver_direct_transition.cpp index 64349e88bf41..04bc9cd0e949 100644 --- a/SU2_CFD/src/solver_direct_transition.cpp +++ b/SU2_CFD/src/solver_direct_transition.cpp @@ -116,7 +116,7 @@ CTransLMSolver::CTransLMSolver(CGeometry *geometry, CConfig *config, unsigned sh } /*--- Computation of gradients by least squares ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + if (config->GetLeastSquaresRequired()) { /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index ffda9bb82f1a..8e61d70b4cbe 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -163,8 +163,8 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe /*--- Turbulent variables using gradient reconstruction and limiters ---*/ - Gradient_i = node[iPoint]->GetGradient(); - Gradient_j = node[jPoint]->GetGradient(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); if (limiter) { Limiter_i = node[iPoint]->GetLimiter(); Limiter_j = node[jPoint]->GetLimiter(); @@ -395,7 +395,12 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ /*--- Solve or smooth the linear system ---*/ - System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + unsigned long IterLinSol = System.Solve(Jacobian, LinSysRes, LinSysSol, geometry, config); + SetIterLinSolver(IterLinSol); + + /*--- Store the value of the residual. ---*/ + + SetResLinSolver(System.GetResidual()); ComputeUnderRelaxationFactor(solver_container, config); @@ -1028,14 +1033,13 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor /*--- Computation of gradients by least squares ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + if (config->GetLeastSquaresRequired()) { /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) Smatrix[iDim] = new su2double [nDim]; /*--- c vector := transpose(WA)*(Wb) ---*/ - Cvector = new su2double* [nVar]; for (iVar = 0; iVar < nVar; iVar++) Cvector[iVar] = new su2double [nDim]; @@ -1205,11 +1209,19 @@ void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_containe Jacobian.SetValZero(); + /*--- Upwind second order reconstruction and gradients ---*/ + + if (config->GetReconstructionGradientRequired()) { + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetSolution_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); + } if (config->GetKind_Gradient_Method() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config); if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config); - /*--- Upwind second order reconstruction ---*/ - if (limiter_turb) SetSolution_Limiter(geometry, config); if (kind_hybridRANSLES != NO_HYBRIDRANSLES){ @@ -3361,7 +3373,7 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- Computation of gradients by least squares ---*/ - if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + if (config->GetLeastSquaresRequired()) { /*--- S matrix := inv(R)*traspose(inv(R)) ---*/ Smatrix = new su2double* [nDim]; for (iDim = 0; iDim < nDim; iDim++) @@ -3530,9 +3542,17 @@ void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contain /*--- Initialize the Jacobian matrices ---*/ Jacobian.SetValZero(); - - /*--- Upwind second order reconstruction ---*/ + /*--- Upwind second order reconstruction and gradients ---*/ + + if (config->GetReconstructionGradientRequired()) { + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetSolution_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); + } if (config->GetKind_Gradient_Method() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config); if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config); diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 64e8e63b97fd..f569031a28da 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -132,6 +132,14 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { VertexTraction = NULL; VertexTractionAdjoint = NULL; + /*--- Auxiliary data needed for CFL adaption. ---*/ + + NonLinRes_Value = 0; + NonLinRes_Func = 0; + Old_Func = 0; + New_Func = 0; + NonLinRes_Counter = 0; + NonLinRes_Series.resize(50,0.0); } @@ -1874,7 +1882,7 @@ void CSolver::InitiateComms(CGeometry *geometry, MPI_TYPE = COMM_TYPE_DOUBLE; break; case SOLUTION_GRADIENT: - COUNT_PER_POINT = nVar*nDim; + COUNT_PER_POINT = nVar*nDim*2; MPI_TYPE = COMM_TYPE_DOUBLE; break; case PRIMITIVE_GRADIENT: @@ -2006,9 +2014,12 @@ void CSolver::InitiateComms(CGeometry *geometry, bufDSend[buf_offset] = node[iPoint]->GetSensor(); break; case SOLUTION_GRADIENT: - for (iVar = 0; iVar < nVar; iVar++) - for (iDim = 0; iDim < nDim; iDim++) + for (iVar = 0; iVar < nVar; iVar++) { + for (iDim = 0; iDim < nDim; iDim++) { bufDSend[buf_offset+iVar*nDim+iDim] = node[iPoint]->GetGradient(iVar, iDim); + bufDSend[buf_offset+iVar*nDim+iDim+nDim*nVar] = node[iPoint]->GetGradient_Reconstruction(iVar, iDim); + } + } break; case PRIMITIVE_GRADIENT: for (iVar = 0; iVar < nPrimVarGrad; iVar++) { @@ -2171,9 +2182,12 @@ void CSolver::CompleteComms(CGeometry *geometry, node[iPoint]->SetSensor(bufDRecv[buf_offset]); break; case SOLUTION_GRADIENT: - for (iVar = 0; iVar < nVar; iVar++) - for (iDim = 0; iDim < nDim; iDim++) + for (iVar = 0; iVar < nVar; iVar++) { + for (iDim = 0; iDim < nDim; iDim++) { node[iPoint]->SetGradient(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim]); + node[iPoint]->SetGradient_Reconstruction(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim+nDim*nVar]); + } + } break; case PRIMITIVE_GRADIENT: for (iVar = 0; iVar < nPrimVarGrad; iVar++) { @@ -2255,8 +2269,8 @@ void CSolver::CompleteComms(CGeometry *geometry, } void CSolver::AdaptCFLNumber(CGeometry **geometry, - CSolver ***solver_container, - CConfig *config) { + CSolver ***solver_container, + CConfig *config) { /* Adapt the CFL number on all multigrid levels using an exponential progression with under-relaxation approach. */ @@ -2271,8 +2285,8 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, /* Store the mean flow, and turbulence solvers more clearly. */ - const CSolver *solverFlow = solver_container[iMesh][FLOW_SOL]; - const CSolver *solverTurb = solver_container[iMesh][TURB_SOL]; + CSolver *solverFlow = solver_container[iMesh][FLOW_SOL]; + CSolver *solverTurb = solver_container[iMesh][TURB_SOL]; /* Compute the reduction factor for CFLs on the coarse levels. */ @@ -2283,6 +2297,70 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, MGFactor[iMesh] = MGFactor[iMesh-1]*CFLRatio; } + /* Check whether we achieved the requested reduction in the linear + solver residual within the specified number of linear iterations. */ + + bool reduceCFL = false; +// unsigned short linIterFlow = solverFlow->GetIterLinSolver(); +// su2double linResFlow = solverFlow->GetResLinSolver(); +// +// //if (rank == MASTER_NODE) cout << " Iter Flow: " << linIterFlow << " Res FLow: " << linResFlow; +// +// unsigned short linIterTurb = 0; +// su2double linResTurb = -1.0; +// if (config->GetKind_Turb_Model() != NONE) { +// linIterTurb = solverTurb->GetIterLinSolver(); +// linResTurb = solverTurb->GetResLinSolver(); +// //if (rank == MASTER_NODE) cout << " Iter Flow: " << linIterTurb << " Res FLow: " << linResTurb; +// +// } +// +// su2double maxLinResid = max(linResFlow, linResTurb); +// if (maxLinResid > 0.5) { +// reduceCFL = true; +// // if (rank == MASTER_NODE) cout << " Decreasing CFL due to linear res tolerance not met." << endl; +// } +// +// //if (rank == MASTER_NODE)cout << endl; +// +// /* Check that we are meeting our nonlinear residual reduction target +// over time so that we do not get stuck in limit cycles. */ +// +// /*--- Initialize at the fist iteration ---*/ +// +//// if (Iteration == 0) { +//// NonLinRes_Value = 0.0; +//// NonLinRes_Counter = 0; +//// for (unsigned short iCounter = 0; iCounter < 50; iCounter++) +//// NonLinRes_Series[iCounter] = 0.0; +//// } +//// +// Old_Func = New_Func; +// New_Func = GetRes_RMS(0); +// NonLinRes_Func = (New_Func - Old_Func); +// +// NonLinRes_Series[NonLinRes_Counter] = NonLinRes_Func; +// NonLinRes_Counter++; +// +// if (NonLinRes_Counter == 50) NonLinRes_Counter = 0; +// +// NonLinRes_Value = -1.0; +// if (config->GetExtIter() >= 50) { +// NonLinRes_Value = 0.0; +// for (unsigned short iCounter = 0; iCounter < 50; iCounter++) +// NonLinRes_Value += NonLinRes_Series[iCounter]; +// } +// +// if (NonLinRes_Value > 0.0) { //> 0.01*GetRes_RMS(0)) { +// reduceCFL = true; +// NonLinRes_Counter = 0; +// for (unsigned short iCounter = 0; iCounter < 50; iCounter++) +// NonLinRes_Series[iCounter] = -1.0; +// if (rank == MASTER_NODE) cout << " Decreasing CFL due to nonlinear res stall." << endl; +// +// } +// +// /* Loop over all points on this grid and apply CFL adaption. */ for (unsigned long iPoint = 0; iPoint < geometry[iMesh]->GetnPointDomain(); iPoint++) { @@ -2308,7 +2386,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, then we schedule an increase the CFL number for the next iteration. */ su2double CFLFactor = 1.0; - if (underRelaxation < 0.1) { + if (reduceCFL || (underRelaxation < 0.1)) { CFLFactor = CFLFactorDecrease; } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { CFLFactor = 1.0; @@ -2805,7 +2883,7 @@ void CSolver::SetAuxVar_Gradient_LS(CGeometry *geometry, CConfig *config) { } -void CSolver::SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config) { +void CSolver::SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config, bool reconstruction) { unsigned long Point = 0, iPoint = 0, jPoint = 0, iEdge, iVertex; unsigned short iVar, iDim, iMarker; su2double *Solution_Vertex, *Solution_i, *Solution_j, Solution_Average, **Gradient, @@ -2872,7 +2950,10 @@ void CSolver::SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config) { for (iDim = 0; iDim < nDim; iDim++) { Gradient = node[iPoint]->GetGradient(); Grad_Val = Gradient[iVar][iDim] / (Vol+EPS); - node[iPoint]->SetGradient(iVar, iDim, Grad_Val); + if (reconstruction) + node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Grad_Val); + else + node[iPoint]->SetGradient(iVar, iDim, Grad_Val); } } @@ -2885,7 +2966,7 @@ void CSolver::SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config) { } -void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config) { +void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool reconstruction) { unsigned short iDim, jDim, iVar, iNeigh; unsigned long iPoint, jPoint; @@ -2893,10 +2974,16 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config) { su2double r11, r12, r13, r22, r23, r23_a, r23_b, r33, weight; su2double detR2, z11, z12, z13, z22, z23, z33; bool singular = false; + + /*--- Set a flag for unweighted or weighted least-squares. ---*/ - su2double **Cvector = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Cvector[iVar] = new su2double [nDim]; + bool weighted = true; + if (reconstruction) { + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + weighted = false; + } else if (config->GetKind_Gradient_Method() == LEAST_SQUARES) { + weighted = false; + } /*--- Loop over points of the grid ---*/ @@ -2931,9 +3018,13 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config) { Solution_j = node[jPoint]->GetSolution(); - weight = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - weight += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); + if (weighted) { + weight = 0.0; + for (iDim = 0; iDim < nDim; iDim++) + weight += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); + } else { + weight = 1.0; + } /*--- Sumations for entries of upper triangular matrix R ---*/ @@ -3054,18 +3145,15 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config) { for (iVar = 0; iVar < nVar; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->SetGradient(iVar, iDim, Cvector[iVar][iDim]); + if (reconstruction) + node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Cvector[iVar][iDim]); + else + node[iPoint]->SetGradient(iVar, iDim, Cvector[iVar][iDim]); } } } - /*--- Deallocate memory ---*/ - - for (iVar = 0; iVar < nVar; iVar++) - delete [] Cvector[iVar]; - delete [] Cvector; - /*--- Gradient MPI ---*/ InitiateComms(geometry, config, SOLUTION_GRADIENT); @@ -3384,8 +3472,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient(); - Gradient_j = node[jPoint]->GetGradient(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -3501,8 +3589,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient(); - Gradient_j = node[jPoint]->GetGradient(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -3594,8 +3682,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient(); - Gradient_j = node[jPoint]->GetGradient(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -3666,8 +3754,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient(); - Gradient_j = node[jPoint]->GetGradient(); + Gradient_i = node[iPoint]->GetGradient_Reconstruction(); + Gradient_j = node[jPoint]->GetGradient_Reconstruction(); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); diff --git a/SU2_CFD/src/variables/CAdjEulerVariable.cpp b/SU2_CFD/src/variables/CAdjEulerVariable.cpp index bca84cd6548f..da27978f4ac2 100644 --- a/SU2_CFD/src/variables/CAdjEulerVariable.cpp +++ b/SU2_CFD/src/variables/CAdjEulerVariable.cpp @@ -45,6 +45,7 @@ CAdjEulerVariable::CAdjEulerVariable(void) : CVariable() { ObjFuncSource = NULL; IntBoundary_Jump = NULL; HB_Source = NULL; + GradReconAllocated = false; } @@ -63,6 +64,7 @@ CAdjEulerVariable::CAdjEulerVariable(su2double val_psirho, su2double *val_phi, s ObjFuncSource = NULL; IntBoundary_Jump = NULL; HB_Source = NULL; + GradReconAllocated = false; /*--- Allocate residual structures ---*/ Res_TruncError = new su2double [nVar]; @@ -117,6 +119,18 @@ CAdjEulerVariable::CAdjEulerVariable(su2double val_psirho, su2double *val_phi, s } + if (config->GetReconstructionGradientRequired()) { + GradReconAllocated = true; + Gradient_Reconstruction = new su2double*[nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Gradient_Reconstruction[iVar] = new su2double[nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + } else { + Gradient_Reconstruction = Gradient; + } + /*--- Allocate auxiliar vector for sensitivity computation ---*/ Grad_AuxVar = new su2double [nDim]; @@ -153,6 +167,7 @@ CAdjEulerVariable::CAdjEulerVariable(su2double *val_solution, unsigned short val ObjFuncSource = NULL; IntBoundary_Jump = NULL; HB_Source = NULL; + GradReconAllocated = false; /*--- Allocate residual structures ---*/ Res_TruncError = new su2double [nVar]; @@ -202,6 +217,18 @@ CAdjEulerVariable::CAdjEulerVariable(su2double *val_solution, unsigned short val } } + if (config->GetReconstructionGradientRequired()) { + GradReconAllocated = true; + Gradient_Reconstruction = new su2double*[nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Gradient_Reconstruction[iVar] = new su2double[nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + } else { + Gradient_Reconstruction = Gradient; + } + /*--- Allocate auxiliar vector for sensitivity computation ---*/ Grad_AuxVar = new su2double [nDim]; @@ -232,6 +259,12 @@ CAdjEulerVariable::~CAdjEulerVariable(void) { if (IntBoundary_Jump != NULL) delete [] IntBoundary_Jump; if (HB_Source != NULL) delete [] HB_Source; + if (GradReconAllocated) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) + if (Gradient_Reconstruction!=NULL) delete [] Gradient_Reconstruction[iVar]; + delete [] Gradient_Reconstruction; + } + } bool CAdjEulerVariable::SetPrimVar(su2double SharpEdge_Distance, bool check, CConfig *config) { diff --git a/SU2_CFD/src/variables/CEulerVariable.cpp b/SU2_CFD/src/variables/CEulerVariable.cpp index 349da2dc4413..087257bf5e1d 100644 --- a/SU2_CFD/src/variables/CEulerVariable.cpp +++ b/SU2_CFD/src/variables/CEulerVariable.cpp @@ -47,6 +47,7 @@ CEulerVariable::CEulerVariable(void) : CVariable() { Gradient_Primitive = NULL; Gradient_Reconstruction = NULL; + GradReconAllocated = false; Gradient_Secondary = NULL; Limiter_Primitive = NULL; @@ -86,6 +87,7 @@ CEulerVariable::CEulerVariable(su2double val_density, su2double *val_velocity, s Gradient_Primitive = NULL; Gradient_Reconstruction = NULL; + GradReconAllocated = false; Gradient_Secondary = NULL; Limiter_Primitive = NULL; @@ -222,11 +224,16 @@ CEulerVariable::CEulerVariable(su2double val_density, su2double *val_velocity, s Gradient_Primitive[iVar][iDim] = 0.0; } - Gradient_Reconstruction = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Reconstruction[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; + if (config->GetReconstructionGradientRequired()) { + GradReconAllocated = true; + Gradient_Reconstruction = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + Gradient_Reconstruction[iVar] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + } else { + Gradient_Reconstruction = Gradient_Primitive; } Gradient_Secondary = new su2double* [nSecondaryVarGrad]; @@ -267,6 +274,7 @@ CEulerVariable::CEulerVariable(su2double *val_solution, unsigned short val_nDim, Gradient_Primitive = NULL; Gradient_Reconstruction = NULL; + GradReconAllocated = false; Gradient_Secondary = NULL; Limiter_Primitive = NULL; @@ -396,11 +404,16 @@ CEulerVariable::CEulerVariable(su2double *val_solution, unsigned short val_nDim, Gradient_Primitive[iVar][iDim] = 0.0; } - Gradient_Reconstruction = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Reconstruction[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; + if (config->GetReconstructionGradientRequired()) { + GradReconAllocated = true; + Gradient_Reconstruction = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + Gradient_Reconstruction[iVar] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + } else { + Gradient_Reconstruction = Gradient_Primitive; } Gradient_Secondary = new su2double* [nSecondaryVarGrad]; @@ -436,7 +449,7 @@ CEulerVariable::~CEulerVariable(void) { if (Gradient_Primitive[iVar] != NULL) delete [] Gradient_Primitive[iVar]; delete [] Gradient_Primitive; } - if (Gradient_Reconstruction != NULL) { + if (GradReconAllocated) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) if (Gradient_Reconstruction[iVar] != NULL) delete [] Gradient_Reconstruction[iVar]; delete [] Gradient_Reconstruction; diff --git a/SU2_CFD/src/variables/CHeatFVMVariable.cpp b/SU2_CFD/src/variables/CHeatFVMVariable.cpp index 1d7cf9cf78f3..f75d7c241af4 100644 --- a/SU2_CFD/src/variables/CHeatFVMVariable.cpp +++ b/SU2_CFD/src/variables/CHeatFVMVariable.cpp @@ -42,13 +42,13 @@ CHeatFVMVariable::CHeatFVMVariable(void) : CVariable() { /*--- Array initialization ---*/ Solution_Direct = NULL; Solution_BGS_k = NULL; - + GradReconAllocated = false; } CHeatFVMVariable::CHeatFVMVariable(su2double val_Heat, unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : CVariable(val_nDim, val_nvar, config) { - unsigned short iVar, iMesh, nMGSmooth = 0; + unsigned short iDim, iVar, iMesh, nMGSmooth = 0; bool low_fidelity = false; bool dual_time = ((config->GetUnsteady_Simulation() == DT_STEPPING_1ST) || (config->GetUnsteady_Simulation() == DT_STEPPING_2ND)); @@ -57,6 +57,7 @@ CHeatFVMVariable::CHeatFVMVariable(su2double val_Heat, unsigned short val_nDim, /*--- Array initialization ---*/ Solution_Direct = NULL; Solution_BGS_k = NULL; + GradReconAllocated = false; /*--- Initialization of heat variable ---*/ Solution[0] = val_Heat; Solution_Old[0] = val_Heat; @@ -89,6 +90,18 @@ CHeatFVMVariable::CHeatFVMVariable(su2double val_Heat, unsigned short val_nDim, Undivided_Laplacian = new su2double [nVar]; } + if (config->GetReconstructionGradientRequired()) { + GradReconAllocated = true; + Gradient_Reconstruction = new su2double*[nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Gradient_Reconstruction[iVar] = new su2double[nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + } else { + Gradient_Reconstruction = Gradient; + } + if (multizone){ Solution_BGS_k = new su2double [1]; Solution_BGS_k[0] = val_Heat; diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 0336a02ba003..297dfeda537e 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -44,6 +44,7 @@ CIncEulerVariable::CIncEulerVariable(void) : CVariable() { Primitive = NULL; Gradient_Primitive = NULL; Gradient_Reconstruction = NULL; + GradReconAllocated = false; Limiter_Primitive = NULL; Grad_AuxVar = NULL; @@ -76,6 +77,7 @@ CIncEulerVariable::CIncEulerVariable(su2double val_pressure, su2double *val_velo Primitive = NULL; Gradient_Primitive = NULL; Gradient_Reconstruction = NULL; + GradReconAllocated = false; Limiter_Primitive = NULL; Grad_AuxVar = NULL; @@ -171,11 +173,16 @@ CIncEulerVariable::CIncEulerVariable(su2double val_pressure, su2double *val_velo Gradient_Primitive[iVar][iDim] = 0.0; } - Gradient_Reconstruction = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Reconstruction[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; + if (config->GetReconstructionGradientRequired()) { + GradReconAllocated = true; + Gradient_Reconstruction = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + Gradient_Reconstruction[iVar] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + } else { + Gradient_Reconstruction = Gradient_Primitive; } /*--- If axisymmetric and viscous, we need an auxiliary gradient. ---*/ @@ -212,6 +219,7 @@ CIncEulerVariable::CIncEulerVariable(su2double *val_solution, unsigned short val Primitive = NULL; Gradient_Primitive = NULL; Gradient_Reconstruction = NULL; + GradReconAllocated = false; Limiter_Primitive = NULL; Grad_AuxVar = NULL; @@ -300,11 +308,16 @@ CIncEulerVariable::CIncEulerVariable(su2double *val_solution, unsigned short val Gradient_Primitive[iVar][iDim] = 0.0; } - Gradient_Reconstruction = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Reconstruction[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; + if (config->GetReconstructionGradientRequired()) { + GradReconAllocated = true; + Gradient_Reconstruction = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) { + Gradient_Reconstruction[iVar] = new su2double [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + } else { + Gradient_Reconstruction = Gradient_Primitive; } /*--- If axisymmetric and viscous, we need an auxiliary gradient. ---*/ @@ -334,7 +347,7 @@ CIncEulerVariable::~CIncEulerVariable(void) { delete [] Gradient_Primitive; } - if (Gradient_Reconstruction != NULL) { + if (GradReconAllocated) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) if (Gradient_Reconstruction!=NULL) delete [] Gradient_Reconstruction[iVar]; delete [] Gradient_Reconstruction; diff --git a/SU2_CFD/src/variables/CTurbVariable.cpp b/SU2_CFD/src/variables/CTurbVariable.cpp index e9a1d90b0149..2b0b3427b311 100644 --- a/SU2_CFD/src/variables/CTurbVariable.cpp +++ b/SU2_CFD/src/variables/CTurbVariable.cpp @@ -41,17 +41,20 @@ CTurbVariable::CTurbVariable(void) : CVariable() { /*--- Array initialization ---*/ HB_Source = NULL; + Gradient_Reconstruction = NULL; + GradReconAllocated = false; } CTurbVariable::CTurbVariable(unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : CVariable(val_nDim, val_nvar, config) { - unsigned short iVar; + unsigned short iVar, iDim; /*--- Array initialization ---*/ HB_Source = NULL; + GradReconAllocated = false; /*--- Allocate space for the harmonic balance source terms ---*/ @@ -75,8 +78,27 @@ CTurbVariable::CTurbVariable(unsigned short val_nDim, unsigned short val_nvar, C Solution_Min[iVar] = 0.0; } + if (config->GetReconstructionGradientRequired()) { + GradReconAllocated = true; + Gradient_Reconstruction = new su2double*[nVar]; + for (iVar = 0; iVar < nVar; iVar++) { + Gradient_Reconstruction[iVar] = new su2double[nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Gradient_Reconstruction[iVar][iDim] = 0.0; + } + } else { + Gradient_Reconstruction = Gradient; + } + } CTurbVariable::~CTurbVariable(void) { if (HB_Source != NULL) delete [] HB_Source; + + if (GradReconAllocated) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) + if (Gradient_Reconstruction!=NULL) delete [] Gradient_Reconstruction[iVar]; + delete [] Gradient_Reconstruction; + } + } diff --git a/config_template.cfg b/config_template.cfg index f0581fe56546..481b82f53f9d 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -751,6 +751,10 @@ MARKER_ANALYZE_AVERAGE = MASSFLUX % Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) NUM_METHOD_GRAD= GREEN_GAUSS % +% Numerical method for spatial gradients used for upwind reconstruction +% (NONE, GREEN_GAUSS, LEAST_SQUARES, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD_RECON= LEAST_SQUARES +% % CFL number (initial value for the adaptive CFL number) CFL_NUMBER= 15.0 % From 3eb5bbd3480beba1f156c83143fef534dfb3d16a Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 27 Sep 2019 18:40:40 -0700 Subject: [PATCH 08/57] Coupled CFL adaption to linear solver residual and nonlinear residuals to help avoid stall or divergence. --- Common/include/config_structure.hpp | 6 ++ SU2_CFD/src/solver_structure.cpp | 134 +++++++++++++++------------- 2 files changed, 78 insertions(+), 62 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index d70334006da3..afe01f46fb68 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -1634,6 +1634,12 @@ class CConfig { */ su2double GetCFL_AdaptParam(unsigned short val_index); + /*! + * \brief Get the values of the CFL adapation. + * \return Value of CFL adapation + */ + inline void SetCFL_AdaptParam(unsigned short val_index, su2double val_cfl_param) { CFL_AdaptParam[val_index] = val_cfl_param; } + /*! * \brief Get the values of the CFL adapation. * \return Value of CFL adapation diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index f569031a28da..d68f8f2bd62d 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -139,7 +139,6 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { Old_Func = 0; New_Func = 0; NonLinRes_Counter = 0; - NonLinRes_Series.resize(50,0.0); } @@ -2301,66 +2300,69 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, solver residual within the specified number of linear iterations. */ bool reduceCFL = false; -// unsigned short linIterFlow = solverFlow->GetIterLinSolver(); -// su2double linResFlow = solverFlow->GetResLinSolver(); -// -// //if (rank == MASTER_NODE) cout << " Iter Flow: " << linIterFlow << " Res FLow: " << linResFlow; -// -// unsigned short linIterTurb = 0; -// su2double linResTurb = -1.0; -// if (config->GetKind_Turb_Model() != NONE) { -// linIterTurb = solverTurb->GetIterLinSolver(); -// linResTurb = solverTurb->GetResLinSolver(); -// //if (rank == MASTER_NODE) cout << " Iter Flow: " << linIterTurb << " Res FLow: " << linResTurb; -// -// } -// -// su2double maxLinResid = max(linResFlow, linResTurb); -// if (maxLinResid > 0.5) { -// reduceCFL = true; -// // if (rank == MASTER_NODE) cout << " Decreasing CFL due to linear res tolerance not met." << endl; -// } -// -// //if (rank == MASTER_NODE)cout << endl; -// -// /* Check that we are meeting our nonlinear residual reduction target -// over time so that we do not get stuck in limit cycles. */ -// -// /*--- Initialize at the fist iteration ---*/ -// -//// if (Iteration == 0) { -//// NonLinRes_Value = 0.0; -//// NonLinRes_Counter = 0; -//// for (unsigned short iCounter = 0; iCounter < 50; iCounter++) -//// NonLinRes_Series[iCounter] = 0.0; -//// } -//// -// Old_Func = New_Func; -// New_Func = GetRes_RMS(0); -// NonLinRes_Func = (New_Func - Old_Func); -// -// NonLinRes_Series[NonLinRes_Counter] = NonLinRes_Func; -// NonLinRes_Counter++; -// -// if (NonLinRes_Counter == 50) NonLinRes_Counter = 0; -// -// NonLinRes_Value = -1.0; -// if (config->GetExtIter() >= 50) { -// NonLinRes_Value = 0.0; -// for (unsigned short iCounter = 0; iCounter < 50; iCounter++) -// NonLinRes_Value += NonLinRes_Series[iCounter]; -// } -// -// if (NonLinRes_Value > 0.0) { //> 0.01*GetRes_RMS(0)) { -// reduceCFL = true; -// NonLinRes_Counter = 0; -// for (unsigned short iCounter = 0; iCounter < 50; iCounter++) -// NonLinRes_Series[iCounter] = -1.0; -// if (rank == MASTER_NODE) cout << " Decreasing CFL due to nonlinear res stall." << endl; -// -// } -// -// + su2double linResFlow = solverFlow->GetResLinSolver(); + su2double linResTurb = -1.0; + if (config->GetKind_Turb_Model() != NONE) { + linResTurb = solverTurb->GetResLinSolver(); + } + + su2double maxLinResid = max(linResFlow, linResTurb); + if (maxLinResid > 0.5) { + reduceCFL = true; + } + + /* Check that we are meeting our nonlinear residual reduction target + over time so that we do not get stuck in limit cycles. */ + + Old_Func = New_Func; + unsigned short Res_Count = 100; + if (NonLinRes_Series.size() == 0) NonLinRes_Series.resize(Res_Count,0.0); + + /* Sum the RMS residuals for all equations. */ + + New_Func = 0.0; + for (unsigned short iVar = 0; iVar < solverFlow->GetnVar(); iVar++) { + New_Func += solverFlow->GetRes_RMS(iVar); + } + if (config->GetKind_Turb_Model() != NONE) { + for (unsigned short iVar = 0; iVar < solverTurb->GetnVar(); iVar++) { + New_Func += solverTurb->GetRes_RMS(iVar); + } + } + + /* Compute the difference in the nonlinear residuals between the + current and previous iterations. */ + + NonLinRes_Func = (New_Func - Old_Func); + NonLinRes_Series[NonLinRes_Counter] = NonLinRes_Func; + + /* Increment the counter, if we hit the max size, then start over. */ + + NonLinRes_Counter++; + if (NonLinRes_Counter == Res_Count) NonLinRes_Counter = 0; + + /* Sum the total change in nonlinear residuals over the previous + set of all stored iterations. */ + + NonLinRes_Value = New_Func; + if (config->GetExtIter() >= Res_Count) { + NonLinRes_Value = 0.0; + for (unsigned short iCounter = 0; iCounter < Res_Count; iCounter++) + NonLinRes_Value += NonLinRes_Series[iCounter]; + } + + /* If the sum is larger than a small fraction of the current nonlinear + residual, then we are not decreasing the nonlinear residual at a high + rate. In this situation, we force a reduction of the CFL in all cells. + Reset the array so that we delay the next decrease for some iterations. */ + + if (fabs(NonLinRes_Value) < 0.1*New_Func) { + reduceCFL = true; + NonLinRes_Counter = 0; + for (unsigned short iCounter = 0; iCounter < Res_Count; iCounter++) + NonLinRes_Series[iCounter] = New_Func; + } + /* Loop over all points on this grid and apply CFL adaption. */ for (unsigned long iPoint = 0; iPoint < geometry[iMesh]->GetnPointDomain(); iPoint++) { @@ -2386,7 +2388,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, then we schedule an increase the CFL number for the next iteration. */ su2double CFLFactor = 1.0; - if (reduceCFL || (underRelaxation < 0.1)) { + if ((underRelaxation < 0.1)) { CFLFactor = CFLFactorDecrease; } else if (underRelaxation >= 0.1 && underRelaxation < 1.0) { CFLFactor = 1.0; @@ -2404,6 +2406,14 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, CFLFactor = 0.999*MGFactor[iMesh]; } + /* If we detect a stalled nonlinear residual, then force the CFL + for all points to the minimum temporarily to restart the ramp. */ + + if (reduceCFL) { + CFL = CFLMin; + CFLFactor = 1.001*MGFactor[iMesh]; + } + /* Apply the adjustment to the CFL and store local values. */ CFL *= CFLFactor; From 0271c69bc928eed6e7034b8965a3b535ba7e1908 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 30 Sep 2019 17:34:08 -0700 Subject: [PATCH 09/57] Removed some unused code. --- SU2_CFD/include/solver_structure.hpp | 15 +-------------- SU2_CFD/include/solver_structure.inl | 4 ---- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index c538e08f1165..c20bc71e9b27 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -86,7 +86,6 @@ class CSolver { unsigned short MGLevel; /*!< \brief Multigrid level of this solver object. */ unsigned short IterLinSolver; /*!< \brief Linear solver iterations. */ su2double ResLinSolver; /*!< \brief Final linear solver residual. */ - su2double NonlinearResMonitor; /*!< \brief Nonlinear residual monitor. */ su2double NonLinRes_Value, /*!< \brief Summed value of the nonlinear residual indicator. */ NonLinRes_Func; /*!< \brief Current value of the nonlinear residual indicator at one iteration. */ unsigned short NonLinRes_Counter; /*!< \brief Number of elements of the nonlinear residual indicator series. */ @@ -304,19 +303,7 @@ class CSolver { * \return Value of final linear solver residual. */ su2double GetResLinSolver(void); - - /*! - * \brief Set the nonlinear residual monitor. - * \param[in] val_nonlinearResMonitor - Value of the nonlinear residual monitor. - */ - void SetNonlinearResMonitor(su2double val_nonlinearResMonitor); - - /*! - * \brief Get the nonlinear residual monitor. - * \return Value of the nonlinear residual monitor. - */ - su2double GetNonlinearResMonitor(void); - + /*! * \brief Get the value of the maximum delta time. * \return Value of the maximum delta time. diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index 6d6e15e193ea..9ec53f618372 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -47,10 +47,6 @@ inline unsigned short CSolver::GetIterLinSolver(void) { return IterLinSolver; } inline su2double CSolver::GetResLinSolver(void) { return ResLinSolver; } -inline void CSolver::SetNonlinearResMonitor(su2double val_nonlinearResMonitor) { NonlinearResMonitor = val_nonlinearResMonitor; } - -inline su2double CSolver::GetNonlinearResMonitor(void) { return NonlinearResMonitor; } - inline su2double CSolver::GetCSensitivity(unsigned short val_marker, unsigned long val_vertex) { return 0; } inline void CSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, From 9e5cc2d68476b2e318a1a22696e65d9162027bc8 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 2 Oct 2019 11:44:12 -0700 Subject: [PATCH 10/57] Couple of fixes related to the turbulence models. --- SU2_CFD/src/solver_direct_turbulent.cpp | 34 ++++++++++++++++--------- SU2_CFD/src/solver_structure.cpp | 8 +++--- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index 62c92d0b560f..6918ab6b939e 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -471,6 +471,14 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { + /* Only apply the turbulent under-relaxation to the SA variants. */ + + bool sa_model = ((config->GetKind_Turb_Model() == SA) || + (config->GetKind_Turb_Model() == SA_E) || + (config->GetKind_Turb_Model() == SA_COMP) || + (config->GetKind_Turb_Model() == SA_E_COMP) || + (config->GetKind_Turb_Model() == SA_NEG)); + /* Loop over the solution update given by relaxing the linear system for this nonlinear iteration. */ @@ -481,19 +489,21 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { localUnderRelaxation = 1.0; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - - /* We impose a limit on the maximum percentage that the - turbulence variables can change over a nonlinear iteration. */ - - const unsigned long index = iPoint*nVar + iVar; - su2double ratio = LinSysSol[index]/(node[iPoint]->GetSolution(iVar)+EPS); - if (ratio > allowableIncrease) { - localUnderRelaxation = min(allowableIncrease/ratio, localUnderRelaxation); - } else if (ratio < allowableDecrease) { - localUnderRelaxation = min(fabs(allowableDecrease)/ratio, localUnderRelaxation); + if (sa_model) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) { + + /* We impose a limit on the maximum percentage that the + turbulence variables can change over a nonlinear iteration. */ + + const unsigned long index = iPoint*nVar + iVar; + su2double ratio = LinSysSol[index]/(node[iPoint]->GetSolution(iVar)+EPS); + if (ratio > allowableIncrease) { + localUnderRelaxation = min(allowableIncrease/ratio, localUnderRelaxation); + } else if (ratio < allowableDecrease) { + localUnderRelaxation = min(fabs(allowableDecrease)/ratio, localUnderRelaxation); + } + } - } /* Choose the minimum factor between mean flow and turbulence. */ diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index d68f8f2bd62d..aed4d565c8b6 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -2302,7 +2302,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, bool reduceCFL = false; su2double linResFlow = solverFlow->GetResLinSolver(); su2double linResTurb = -1.0; - if (config->GetKind_Turb_Model() != NONE) { + if ((iMesh == MESH_0) && (config->GetKind_Turb_Model() != NONE)) { linResTurb = solverTurb->GetResLinSolver(); } @@ -2324,7 +2324,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, for (unsigned short iVar = 0; iVar < solverFlow->GetnVar(); iVar++) { New_Func += solverFlow->GetRes_RMS(iVar); } - if (config->GetKind_Turb_Model() != NONE) { + if ((iMesh == MESH_0) && (config->GetKind_Turb_Model() != NONE)) { for (unsigned short iVar = 0; iVar < solverTurb->GetnVar(); iVar++) { New_Func += solverTurb->GetRes_RMS(iVar); } @@ -2378,7 +2378,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, su2double underRelaxationFlow = solverFlow->node[iPoint]->GetUnderRelaxation(); su2double underRelaxationTurb = 1.0; - if (config->GetKind_Turb_Model() != NONE) + if ((iMesh == MESH_0) && (config->GetKind_Turb_Model() != NONE)) underRelaxationTurb = solverTurb->node[iPoint]->GetUnderRelaxation(); const su2double underRelaxation = min(underRelaxationFlow,underRelaxationTurb); @@ -2418,7 +2418,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, CFL *= CFLFactor; solverFlow->node[iPoint]->SetLocalCFL(CFL); - if (config->GetKind_Turb_Model() != NONE) { + if ((iMesh == MESH_0) && (config->GetKind_Turb_Model() != NONE)) { solverTurb->node[iPoint]->SetLocalCFL(CFL); } From f9951ffeaccd256bccf4a5b88809197dced67328 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 3 Oct 2019 18:12:22 -0700 Subject: [PATCH 11/57] Removed old CFL adaption routine. Sync of the linear solver residual routines. --- SU2_CFD/include/output/COutput.hpp | 9 +-- SU2_CFD/include/solver_structure.hpp | 10 +-- SU2_CFD/include/solver_structure.inl | 2 - SU2_CFD/src/drivers/CDriver.cpp | 14 +--- SU2_CFD/src/iteration_structure.cpp | 5 -- SU2_CFD/src/output/CElasticityOutput.cpp | 2 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 4 +- SU2_CFD/src/output/CFlowIncOutput.cpp | 4 +- SU2_CFD/src/output/COutput.cpp | 94 ------------------------ SU2_CFD/src/solver_direct_elasticity.cpp | 2 +- SU2_CFD/src/solver_direct_mean.cpp | 4 - SU2_CFD/src/solver_direct_mean_inc.cpp | 4 - SU2_CFD/src/solver_structure.cpp | 2 +- 13 files changed, 13 insertions(+), 143 deletions(-) diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index d9b3cb6be8b3..aaab4a2bc76d 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -350,14 +350,7 @@ class COutput { * \return - The current restart filename */ inline string GetRestart_Filename() {return restartFilename;} - - /*! - * \brief Set the CFL number based on the current residuals - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - */ - void SetCFL_Number(CSolver ****solver_container, CConfig *config); - + /*! * \brief Set the current iteration indices * \param[in] TimeIter - Timer iteration index diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 0579230365df..0ef43fbc4ee4 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -163,8 +163,6 @@ class CSolver { string SolverName; /*!< \brief Store the name of the solver for output purposes. */ - su2double valResidual; /*!< \brief Store the residual of the linear system solution. */ - public: CSysVector LinSysSol; /*!< \brief vector to store iterative solution of implicit linear system. */ @@ -307,7 +305,7 @@ class CSolver { * \brief Get the final linear solver residual. * \return Value of final linear solver residual. */ - su2double GetResLinSolver(void); + inline su2double GetResLinSolver(void) { return ResLinSolver; } /*! * \brief Get the value of the maximum delta time. @@ -4511,12 +4509,6 @@ class CSolver { */ virtual su2double GetMaximum_Volume(){ return 0.0; } - /*! - * \brief Get residual of the linear solver - * \return - */ - su2double GetLinSol_Residual(){ return valResidual; } - protected: /*! * \brief Allocate the memory for the verification solution, if necessary. diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index 5cd865d227ea..60ea75629cd4 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -45,8 +45,6 @@ inline void CSolver::SetNondimensionalization(CConfig *config, unsigned short iM inline unsigned short CSolver::GetIterLinSolver(void) { return IterLinSolver; } -inline su2double CSolver::GetResLinSolver(void) { return ResLinSolver; } - inline su2double CSolver::GetCSensitivity(unsigned short val_marker, unsigned long val_vertex) { return 0; } inline void CSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 48dc377996c2..60affee71a62 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -707,8 +707,10 @@ void CDriver::Geometrical_Preprocessing(CConfig* config, CGeometry **&geometry, /*--- If activated by the compile directive, perform a partition analysis. ---*/ #if PARTITION - if( fem_solver ) Partition_Analysis_FEM(geometry[MESH_0], config); - else Partition_Analysis(geometry[MESH_0], config); + if (!dummy){ + if( fem_solver ) Partition_Analysis_FEM(geometry[MESH_0], config); + else Partition_Analysis(geometry[MESH_0], config); + } #endif /*--- Check if Euler & Symmetry markers are straight/plane. This information @@ -4152,14 +4154,6 @@ bool CFluidDriver::Monitor(unsigned long ExtIter) { runtime->SetTimeIter(ExtIter); delete runtime; - /*--- Evaluate the new CFL number (adaptive). ---*/ - if (config_container[ZONE_0]->GetCFL_Adapt() == YES) { - for (iZone = 0; iZone < nZone; iZone++){ - if (!(config_container[iZone]->GetMultizone_Problem())) // This needs to be changed everywhere in the code, in a future PR - output_container[iZone]->SetCFL_Number(solver_container[iZone], config_container[iZone]); - } - } - /*--- Check whether the current simulation has reached the specified convergence criteria, and set StopCalc to true, if so. ---*/ diff --git a/SU2_CFD/src/iteration_structure.cpp b/SU2_CFD/src/iteration_structure.cpp index 0fbad9e88f33..67e6f099a5f4 100644 --- a/SU2_CFD/src/iteration_structure.cpp +++ b/SU2_CFD/src/iteration_structure.cpp @@ -688,11 +688,6 @@ bool CFluidIteration::Monitor(COutput *output, config[val_iZone]->GetOuterIter(), config[val_iZone]->GetInnerIter()); } - - if (config[val_iZone]->GetCFL_Adapt() == YES) { - if (!(config[val_iZone]->GetMultizone_Problem())) // This needs to be changed everywhere in the code, in a future PR - output->SetCFL_Number(solver[val_iZone], config[val_iZone]); - } /*--- If convergence was reached --*/ StopCalc = output->GetConvergence(); diff --git a/SU2_CFD/src/output/CElasticityOutput.cpp b/SU2_CFD/src/output/CElasticityOutput.cpp index 9d041cb55a69..d1db7ec89a64 100644 --- a/SU2_CFD/src/output/CElasticityOutput.cpp +++ b/SU2_CFD/src/output/CElasticityOutput.cpp @@ -141,7 +141,7 @@ void CElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("LOAD_RAMP", fea_solver->GetForceCoeff()); SetHistoryOutputValue("LINSOL_ITER", fea_solver->GetIterLinSolver()); - SetHistoryOutputValue("LINSOL_RESIDUAL", log10(fea_solver->GetLinSol_Residual())); + SetHistoryOutputValue("LINSOL_RESIDUAL", log10(fea_solver->GetResLinSolver())); } diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 8d22c4faddc0..a77f74f5400a 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -622,13 +622,13 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0)); SetHistoryOutputValue("LINSOL_ITER", flow_solver->GetIterLinSolver()); - SetHistoryOutputValue("LINSOL_RESIDUAL", log10(flow_solver->GetLinSol_Residual())); + SetHistoryOutputValue("LINSOL_RESIDUAL", log10(flow_solver->GetResLinSolver())); if (config->GetDeform_Mesh()){ SetHistoryOutputValue("DEFORM_MIN_VOLUME", mesh_solver->GetMinimum_Volume()); SetHistoryOutputValue("DEFORM_MAX_VOLUME", mesh_solver->GetMaximum_Volume()); SetHistoryOutputValue("DEFORM_ITER", mesh_solver->GetIterLinSolver()); - SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->GetLinSol_Residual())); + SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->GetResLinSolver())); } /*--- Set the analyse surface history values --- */ diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 03a3c572cfd2..806b9348c5cd 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -297,13 +297,13 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv } SetHistoryOutputValue("LINSOL_ITER", flow_solver->GetIterLinSolver()); - SetHistoryOutputValue("LINSOL_RESIDUAL", log10(flow_solver->GetLinSol_Residual())); + SetHistoryOutputValue("LINSOL_RESIDUAL", log10(flow_solver->GetResLinSolver())); if (config->GetDeform_Mesh()){ SetHistoryOutputValue("DEFORM_MIN_VOLUME", mesh_solver->GetMinimum_Volume()); SetHistoryOutputValue("DEFORM_MAX_VOLUME", mesh_solver->GetMaximum_Volume()); SetHistoryOutputValue("DEFORM_ITER", mesh_solver->GetIterLinSolver()); - SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->GetLinSol_Residual())); + SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->GetResLinSolver())); } SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0)); diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index df756497af54..055b4d86d733 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -279,100 +279,6 @@ void COutput::SetMultizoneHistory_Output(COutput **output, CConfig **config, CCo } -} -void COutput::SetCFL_Number(CSolver ****solver_container, CConfig *config) { - - su2double CFLFactor = 1.0, power = 1.0, CFL = 0.0, CFLMin = 0.0, CFLMax = 0.0, Div = 1.0, Diff = 0.0, MGFactor[100]; - unsigned short iMesh; - - unsigned short FinestMesh = config->GetFinestMesh(); - unsigned short nVar = 1; - - bool energy = config->GetEnergy_Equation(); - bool weakly_coupled_heat = config->GetWeakly_Coupled_Heat(); - - switch( config->GetKind_Solver()) { - case EULER : case NAVIER_STOKES : case RANS: - case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS: - if (energy) { - nVar = solver_container[INST_0][FinestMesh][FLOW_SOL]->GetnVar(); - rhoResNew = solver_container[INST_0][FinestMesh][FLOW_SOL]->GetRes_RMS(nVar-1); - } - else if (weakly_coupled_heat) { - rhoResNew = solver_container[INST_0][FinestMesh][HEAT_SOL]->GetRes_RMS(0); - } - else { - rhoResNew = solver_container[INST_0][FinestMesh][FLOW_SOL]->GetRes_RMS(0); - } - break; - case ADJ_EULER : case ADJ_NAVIER_STOKES: case ADJ_RANS: - rhoResNew = solver_container[INST_0][FinestMesh][ADJFLOW_SOL]->GetRes_RMS(0); - break; - case HEAT_EQUATION_FVM: - rhoResNew = solver_container[INST_0][FinestMesh][HEAT_SOL]->GetRes_RMS(0); - break; - } - - if (rhoResNew < EPS) rhoResNew = EPS; - if (rhoResOld < EPS) rhoResOld = rhoResNew; - - Div = rhoResOld/rhoResNew; - Diff = rhoResNew-rhoResOld; - - /*--- Compute MG factor ---*/ - - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - if (iMesh == MESH_0) MGFactor[iMesh] = 1.0; - else MGFactor[iMesh] = MGFactor[iMesh-1] * config->GetCFL(iMesh)/config->GetCFL(iMesh-1); - } - - if (Div < 1.0) power = config->GetCFL_AdaptParam(0); - else power = config->GetCFL_AdaptParam(1); - - /*--- Detect a stall in the residual ---*/ - - if ((fabs(Diff) <= rhoResNew*1E-8) && (curInnerIter != 0)) { Div = 0.1; power = config->GetCFL_AdaptParam(1); } - - CFLMin = config->GetCFL_AdaptParam(2); - CFLMax = config->GetCFL_AdaptParam(3); - - CFLFactor = pow(Div, power); - - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - CFL = config->GetCFL(iMesh); - CFL *= CFLFactor; - - if ((iMesh == MESH_0) && (CFL <= CFLMin)) { - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - config->SetCFL(iMesh, 1.001*CFLMin*MGFactor[iMesh]); - } - break; - } - if ((iMesh == MESH_0) && (CFL >= CFLMax)) { - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) - config->SetCFL(iMesh, 0.999*CFLMax*MGFactor[iMesh]); - break; - } - - config->SetCFL(iMesh, CFL); - } - - switch( config->GetKind_Solver()) { - case EULER : case NAVIER_STOKES : case RANS: - case INC_EULER : case INC_NAVIER_STOKES : case INC_RANS: - nVar = solver_container[INST_0][FinestMesh][FLOW_SOL]->GetnVar(); - if (energy) rhoResOld = solver_container[INST_0][FinestMesh][FLOW_SOL]->GetRes_RMS(nVar-1); - else if (weakly_coupled_heat) rhoResOld = solver_container[INST_0][FinestMesh][HEAT_SOL]->GetRes_RMS(0); - else rhoResOld = solver_container[INST_0][FinestMesh][FLOW_SOL]->GetRes_RMS(0); - break; - case ADJ_EULER : case ADJ_NAVIER_STOKES: case ADJ_RANS: - rhoResOld = solver_container[INST_0][FinestMesh][ADJFLOW_SOL]->GetRes_RMS(0); - break; - case HEAT_EQUATION_FVM: - rhoResOld = solver_container[INST_0][FinestMesh][HEAT_SOL]->GetRes_RMS(0); - break; - } - } void COutput::AllocateDataSorters(CConfig *config, CGeometry *geometry){ diff --git a/SU2_CFD/src/solver_direct_elasticity.cpp b/SU2_CFD/src/solver_direct_elasticity.cpp index ad51b191021c..28113e871a44 100644 --- a/SU2_CFD/src/solver_direct_elasticity.cpp +++ b/SU2_CFD/src/solver_direct_elasticity.cpp @@ -3639,7 +3639,7 @@ void CFEASolver::Solve_System(CGeometry *geometry, CConfig *config) { /*--- Store the value of the residual. ---*/ - valResidual = System.GetResidual(); + SetIterLinSolver(System.GetResidual()); } diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 4dd78796ed47..1fe4a6e0e152 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -5215,10 +5215,6 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver SetIterLinSolver(IterLinSol); ComputeUnderRelaxationFactor(solver_container, config); - - /*--- Set the residual --- */ - - valResidual = System.GetResidual(); /*--- Update solution (system written in terms of increments) ---*/ diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index c2c2cec629af..77a3cd0d2867 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -3531,10 +3531,6 @@ void CIncEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol SetIterLinSolver(IterLinSol); - /*--- Set the residual --- */ - - valResidual = System.GetResidual(); - /*--- Update solution (system written in terms of increments) ---*/ if (!adjoint) { diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 37dcde6d3ded..283b2d71b479 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -102,7 +102,7 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { Restart_Data = NULL; node = NULL; nOutputVariables = 0; - valResidual = 0.0; + ResLinSolver = 0.0; /*--- Inlet profile data structures. ---*/ From 2827ea84d9848d9d005b2a9948060f64493230ba Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 7 Oct 2019 18:52:36 -0700 Subject: [PATCH 12/57] Added reporting of min/max delta time and min/max/avg CFL to output. Added checks for unsteady problems with CFL adaption. Adjusted time step calculations. --- Common/src/config_structure.cpp | 29 ++++++++- SU2_CFD/include/solver_structure.hpp | 21 +++++++ SU2_CFD/src/output/CFlowCompOutput.cpp | 14 ++++- SU2_CFD/src/output/CFlowIncOutput.cpp | 17 +++++- SU2_CFD/src/solver_direct_mean.cpp | 81 +++++++++++++++++-------- SU2_CFD/src/solver_direct_mean_inc.cpp | 65 +++++++++++++++----- SU2_CFD/src/solver_direct_turbulent.cpp | 12 +++- SU2_CFD/src/solver_structure.cpp | 32 ++++++++++ 8 files changed, 221 insertions(+), 50 deletions(-) diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 5286116bf690..2b6e93a9bc82 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -237,8 +237,6 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], CConfig *config) { if (runtime_file) { if (all_options.find("TIME_ITER") == all_options.end()) config->SetnTime_Iter(nTimeIter); - if (all_options.find("CFL_NUMBER") == all_options.end()) - config->SetCFL(MESH_0, CFLFineGrid); } } @@ -4612,6 +4610,33 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ CURRENT_FUNCTION); } + /* Protect against using CFL adaption for non-flow or certain + unsteady flow problems. */ + + bool fvm_flow = ((Kind_Solver == INC_EULER) || + (Kind_Solver == INC_NAVIER_STOKES) || + (Kind_Solver == INC_RANS) || + (Kind_Solver == EULER) || + (Kind_Solver == NAVIER_STOKES) || + (Kind_Solver == RANS) || + (Kind_Solver == DISC_ADJ_EULER) || + (Kind_Solver == DISC_ADJ_RANS) || + (Kind_Solver == DISC_ADJ_NAVIER_STOKES) || + (Kind_Solver == DISC_ADJ_INC_EULER) || + (Kind_Solver == DISC_ADJ_INC_RANS) || + (Kind_Solver == DISC_ADJ_INC_NAVIER_STOKES)); + if (CFL_Adapt && !fvm_flow) { + SU2_MPI::Error(string("CFL adaption only available for finite-volume fluid solvers.\n") + + string("Please select CFL_ADAPT = NO."), + CURRENT_FUNCTION); + } + + if (CFL_Adapt && (TimeMarching == TIME_STEPPING)) { + SU2_MPI::Error(string("CFL adaption not available for TIME_STEPPING integration.\n") + + string("Please select CFL_ADAPT = NO."), + CURRENT_FUNCTION); + } + } void CConfig::SetMarkers(unsigned short val_software) { diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 0ef43fbc4ee4..1b6c11fd90ba 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -103,6 +103,9 @@ class CSolver { unsigned long nPointDomain; /*!< \brief Number of points of the computational grid. */ su2double Max_Delta_Time, /*!< \brief Maximum value of the delta time for all the control volumes. */ Min_Delta_Time; /*!< \brief Minimum value of the delta time for all the control volumes. */ + su2double Max_CFL_Local; /*!< \brief Maximum value of the CFL across all the control volumes. */ + su2double Min_CFL_Local; /*!< \brief Minimum value of the CFL across all the control volumes. */ + su2double Avg_CFL_Local; /*!< \brief Average value of the CFL across all the control volumes. */ su2double *Residual_RMS, /*!< \brief Vector with the mean residual for each variable. */ *Residual_Max, /*!< \brief Vector with the maximal residual for each variable. */ *Residual, /*!< \brief Auxiliary nVar vector. */ @@ -331,6 +334,24 @@ class CSolver { */ virtual su2double GetMin_Delta_Time(unsigned short val_Species); + /*! + * \brief Get the value of the maximum local CFL number. + * \return Value of the maximum local CFL number. + */ + inline su2double GetMax_CFL_Local(void) { return Max_CFL_Local; } + + /*! + * \brief Get the value of the minimum local CFL number. + * \return Value of the minimum local CFL number. + */ + inline su2double GetMin_CFL_Local(void) { return Min_CFL_Local; } + + /*! + * \brief Get the value of the average local CFL number. + * \return Value of the average local CFL number. + */ + inline su2double GetAvg_CFL_Local(void) { return Avg_CFL_Local; } + /*! * \brief Get the number of variables of the problem. */ diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index a77f74f5400a..745bb1ace2c5 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -233,7 +233,12 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ AddHistoryOutput("TEMPERATURE", "Temp", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total avg. temperature on all surfaces set with MARKER_MONITORING.", HistoryFieldType::COEFFICIENT); /// END_GROUP - AddHistoryOutput("CFL_NUMBER", "CFL number", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current value of the CFL number"); + AddHistoryOutput("MIN_DELTA_TIME", "Min DT", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current minimum local time step"); + AddHistoryOutput("MAX_DELTA_TIME", "Max DT", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current maximum local time step"); + + AddHistoryOutput("MIN_CFL", "Min CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current minimum of the local CFL numbers"); + AddHistoryOutput("MAX_CFL", "Max CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current maximum of the local CFL numbers"); + AddHistoryOutput("AVG_CFL", "Avg CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current average of the local CFL numbers"); if (config->GetDeform_Mesh()){ AddHistoryOutput("DEFORM_MIN_VOLUME", "MinVolume", ScreenOutputFormat::SCIENTIFIC, "DEFORM", "Minimum volume in the mesh"); @@ -619,7 +624,12 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol SetHistoryOutputValue("HEATFLUX_MAX", flow_solver->GetTotal_MaxHeatFlux()); SetHistoryOutputValue("TEMPERATURE", flow_solver->GetTotal_AvgTemperature()); - SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0)); + SetHistoryOutputValue("MIN_DELTA_TIME", flow_solver->GetMin_Delta_Time()); + SetHistoryOutputValue("MAX_DELTA_TIME", flow_solver->GetMax_Delta_Time()); + + SetHistoryOutputValue("MIN_CFL", flow_solver->GetMin_CFL_Local()); + SetHistoryOutputValue("MAX_CFL", flow_solver->GetMax_CFL_Local()); + SetHistoryOutputValue("AVG_CFL", flow_solver->GetAvg_CFL_Local()); SetHistoryOutputValue("LINSOL_ITER", flow_solver->GetIterLinSolver()); SetHistoryOutputValue("LINSOL_RESIDUAL", log10(flow_solver->GetResLinSolver())); diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 806b9348c5cd..8f40985459c6 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -199,7 +199,14 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ /// DESCRIPTION: Linear solver iterations AddHistoryOutput("LINSOL_ITER", "LinSolIter", ScreenOutputFormat::INTEGER, "LINSOL", "Number of iterations of the linear solver."); AddHistoryOutput("LINSOL_RESIDUAL", "LinSolRes", ScreenOutputFormat::FIXED, "LINSOL", "Residual of the linear solver."); - AddHistoryOutput("CFL_NUMBER", "CFL number", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current value of the CFL number"); + + AddHistoryOutput("MIN_DELTA_TIME", "Min DT", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current minimum local time step"); + AddHistoryOutput("MAX_DELTA_TIME", "Max DT", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current maximum local time step"); + + AddHistoryOutput("MIN_CFL", "Min CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current minimum of the local CFL numbers"); + AddHistoryOutput("MAX_CFL", "Max CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current maximum of the local CFL numbers"); + AddHistoryOutput("AVG_CFL", "Avg CFL", ScreenOutputFormat::SCIENTIFIC, "CFL_NUMBER", "Current average of the local CFL numbers"); + if (config->GetDeform_Mesh()){ AddHistoryOutput("DEFORM_MIN_VOLUME", "MinVolume", ScreenOutputFormat::SCIENTIFIC, "DEFORM", "Minimum volume in the mesh"); @@ -306,8 +313,12 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv SetHistoryOutputValue("DEFORM_RESIDUAL", log10(mesh_solver->GetResLinSolver())); } - SetHistoryOutputValue("CFL_NUMBER", config->GetCFL(MESH_0)); - + SetHistoryOutputValue("MIN_DELTA_TIME", flow_solver->GetMin_Delta_Time()); + SetHistoryOutputValue("MAX_DELTA_TIME", flow_solver->GetMax_Delta_Time()); + + SetHistoryOutputValue("MIN_CFL", flow_solver->GetMin_CFL_Local()); + SetHistoryOutputValue("MAX_CFL", flow_solver->GetMax_CFL_Local()); + SetHistoryOutputValue("AVG_CFL", flow_solver->GetAvg_CFL_Local()); /*--- Set the analyse surface history values --- */ diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 1fe4a6e0e152..cffb9b1b1ffd 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -896,10 +896,13 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /* Store the initial CFL number for all grid points. */ + const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); } + Min_CFL_Local = CFL; + Max_CFL_Local = CFL; + Avg_CFL_Local = CFL; /*--- Add the solver name (max 8 characters) ---*/ SolverName = "C.FLOW"; @@ -3118,10 +3121,10 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, unsigned long iEdge, iVertex, iPoint, jPoint; unsigned short iDim, iMarker; - bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool time_steping = config->GetTime_Marching() == TIME_STEPPING; - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); + bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); + bool time_stepping = config->GetTime_Marching() == TIME_STEPPING; + bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND)); Min_Delta_Time = 1.E30; Max_Delta_Time = 0.0; @@ -3244,7 +3247,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- For exact time solution use the minimum delta time of the whole mesh ---*/ - if (time_steping) { + if (time_stepping) { #ifdef HAVE_MPI su2double rbuf_time, sbuf_time; sbuf_time = Global_Delta_Time; @@ -3252,26 +3255,35 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); Global_Delta_Time = rbuf_time; #endif - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - - /*--- Sets the regular CFL equal to the unsteady CFL ---*/ - config->SetCFL(iMesh,config->GetUnst_CFL()); - - /*--- If the unsteady CFL is set to zero, it uses the defined unsteady time step, otherwise - it computes the time step based on the unsteady CFL ---*/ - if (config->GetCFL(iMesh) == 0.0) { - node[iPoint]->SetDelta_Time(config->GetDelta_UnstTime()); - } else { - node[iPoint]->SetDelta_Time(Global_Delta_Time); - } - } + /*--- If the unsteady CFL is set to zero, it uses the defined + unsteady time step, otherwise it computes the time step based + on the unsteady CFL ---*/ + + if (config->GetUnst_CFL() == 0.0) { + Global_Delta_Time = config->GetDelta_UnstTime(); + } + config->SetDelta_UnstTimeND(Global_Delta_Time); + for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + + /*--- Sets the regular CFL equal to the unsteady CFL ---*/ + + node[iPoint]->SetLocalCFL(config->GetUnst_CFL()); + node[iPoint]->SetDelta_Time(Global_Delta_Time); + Min_Delta_Time = Global_Delta_Time; + Max_Delta_Time = Global_Delta_Time; + + } } /*--- Recompute the unsteady time step for the dual time strategy if the unsteady CFL is diferent from 0 ---*/ if ((dual_time) && (Iteration == 0) && (config->GetUnst_CFL() != 0.0) && (iMesh == MESH_0)) { - Global_Delta_UnstTimeND = config->GetUnst_CFL()*Global_Delta_Time/config->GetCFL(iMesh); + + Global_Delta_UnstTimeND = 1e30; + for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/node[iPoint]->GetLocalCFL()); + } #ifdef HAVE_MPI su2double rbuf_time, sbuf_time; @@ -14885,10 +14897,13 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /* Store the initial CFL number for all grid points. */ + const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); } + Min_CFL_Local = CFL; + Max_CFL_Local = CFL; + Avg_CFL_Local = CFL; /*--- Add the solver name (max 8 characters) ---*/ SolverName = "C.FLOW"; @@ -15328,16 +15343,34 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); Global_Delta_Time = rbuf_time; #endif - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetDelta_Time(Global_Delta_Time); + /*--- If the unsteady CFL is set to zero, it uses the defined + unsteady time step, otherwise it computes the time step based + on the unsteady CFL ---*/ + if (config->GetUnst_CFL() == 0.0) { + Global_Delta_Time = config->GetDelta_UnstTime(); + } config->SetDelta_UnstTimeND(Global_Delta_Time); + for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + + /*--- Sets the regular CFL equal to the unsteady CFL ---*/ + + node[iPoint]->SetLocalCFL(config->GetUnst_CFL()); + node[iPoint]->SetDelta_Time(Global_Delta_Time); + Min_Delta_Time = Global_Delta_Time; + Max_Delta_Time = Global_Delta_Time; + + } } /*--- Recompute the unsteady time step for the dual time strategy if the unsteady CFL is diferent from 0 ---*/ if ((dual_time) && (Iteration == 0) && (config->GetUnst_CFL() != 0.0) && (iMesh == MESH_0)) { - Global_Delta_UnstTimeND = config->GetUnst_CFL()*Global_Delta_Time/config->GetCFL(iMesh); + + Global_Delta_UnstTimeND = 1e30; + for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/node[iPoint]->GetLocalCFL()); + } #ifdef HAVE_MPI su2double rbuf_time, sbuf_time; diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index 77a3cd0d2867..2d68000a3fe5 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -626,10 +626,13 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned /* Store the initial CFL number for all grid points. */ + const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); } + Min_CFL_Local = CFL; + Max_CFL_Local = CFL; + Avg_CFL_Local = CFL; /*--- Add the solver name (max 8 characters) ---*/ SolverName = "INC.FLOW"; @@ -1657,7 +1660,7 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain unsigned short iDim, iMarker; bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - bool time_steping = config->GetTime_Marching() == TIME_STEPPING; + bool time_stepping = config->GetTime_Marching() == TIME_STEPPING; bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND)); @@ -1794,7 +1797,7 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain /*--- For time-accurate simulations use the minimum delta time of the whole mesh (global) ---*/ - if (time_steping) { + if (time_stepping) { #ifdef HAVE_MPI su2double rbuf_time, sbuf_time; sbuf_time = Global_Delta_Time; @@ -1802,20 +1805,23 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); Global_Delta_Time = rbuf_time; #endif + /*--- If the unsteady CFL is set to zero, it uses the defined + unsteady time step, otherwise it computes the time step based + on the unsteady CFL ---*/ + + if (config->GetUnst_CFL() == 0.0) { + Global_Delta_Time = config->GetDelta_UnstTime(); + } + config->SetDelta_UnstTimeND(Global_Delta_Time); for (iPoint = 0; iPoint < nPointDomain; iPoint++){ /*--- Sets the regular CFL equal to the unsteady CFL ---*/ - config->SetCFL(iMesh,config->GetUnst_CFL()); - - /*--- If the unsteady CFL is set to zero, it uses the defined unsteady time step, otherwise - it computes the time step based on the unsteady CFL ---*/ + node[iPoint]->SetLocalCFL(config->GetUnst_CFL()); + node[iPoint]->SetDelta_Time(Global_Delta_Time); + Min_Delta_Time = Global_Delta_Time; + Max_Delta_Time = Global_Delta_Time; - if (config->GetCFL(iMesh) == 0.0){ - node[iPoint]->SetDelta_Time(config->GetDelta_UnstTime()); - } else { - node[iPoint]->SetDelta_Time(Global_Delta_Time); - } } } @@ -1823,7 +1829,11 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain if the unsteady CFL is diferent from 0 ---*/ if ((dual_time) && (Iteration == 0) && (config->GetUnst_CFL() != 0.0) && (iMesh == MESH_0)) { - Global_Delta_UnstTimeND = config->GetUnst_CFL()*Global_Delta_Time/config->GetCFL(iMesh); + + Global_Delta_UnstTimeND = 1e30; + for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/node[iPoint]->GetLocalCFL()); + } #ifdef HAVE_MPI su2double rbuf_time, sbuf_time; @@ -7395,10 +7405,13 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short /* Store the initial CFL number for all grid points. */ + const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); } + Min_CFL_Local = CFL; + Max_CFL_Local = CFL; + Avg_CFL_Local = CFL; /*--- Add the solver name (max 8 characters) ---*/ SolverName = "INC.FLOW"; @@ -7810,14 +7823,34 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, SU2_MPI::Bcast(&rbuf_time, 1, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); Global_Delta_Time = rbuf_time; #endif - for (iPoint = 0; iPoint < nPointDomain; iPoint++) + /*--- If the unsteady CFL is set to zero, it uses the defined + unsteady time step, otherwise it computes the time step based + on the unsteady CFL ---*/ + + if (config->GetUnst_CFL() == 0.0) { + Global_Delta_Time = config->GetDelta_UnstTime(); + } + config->SetDelta_UnstTimeND(Global_Delta_Time); + for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + + /*--- Sets the regular CFL equal to the unsteady CFL ---*/ + + node[iPoint]->SetLocalCFL(config->GetUnst_CFL()); node[iPoint]->SetDelta_Time(Global_Delta_Time); + Min_Delta_Time = Global_Delta_Time; + Max_Delta_Time = Global_Delta_Time; + + } } /*--- Recompute the unsteady time step for the dual time strategy if the unsteady CFL is diferent from 0 ---*/ if ((dual_time) && (Iteration == 0) && (config->GetUnst_CFL() != 0.0) && (iMesh == MESH_0)) { - Global_Delta_UnstTimeND = config->GetUnst_CFL()*Global_Delta_Time/config->GetCFL(iMesh); + + Global_Delta_UnstTimeND = 1e30; + for (iPoint = 0; iPoint < nPointDomain; iPoint++){ + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/node[iPoint]->GetLocalCFL()); + } #ifdef HAVE_MPI su2double rbuf_time, sbuf_time; diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index ebca8998a8f9..9265a633269b 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -1152,11 +1152,14 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor SetImplicitPeriodic(true); /* Store the initial CFL number for all grid points. */ - + + const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); } + Min_CFL_Local = CFL; + Max_CFL_Local = CFL; + Avg_CFL_Local = CFL; /*--- Add the solver name (max 8 characters) ---*/ SolverName = "SA"; @@ -3490,10 +3493,13 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /* Store the initial CFL number for all grid points. */ + const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - const su2double CFL = config->GetCFL(MGLevel); node[iPoint]->SetLocalCFL(CFL); } + Min_CFL_Local = CFL; + Max_CFL_Local = CFL; + Avg_CFL_Local = CFL; /*--- Add the solver name (max 8 characters) ---*/ SolverName = "K-W SST"; diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 283b2d71b479..3f206b1f8ff7 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -2371,6 +2371,9 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, /* Loop over all points on this grid and apply CFL adaption. */ + su2double myCFLMin = 1e30; + su2double myCFLMax = 0.0; + su2double myCFLSum = 0.0; for (unsigned long iPoint = 0; iPoint < geometry[iMesh]->GetnPointDomain(); iPoint++) { /* Get the current local flow CFL number at this point. */ @@ -2428,8 +2431,37 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, solverTurb->node[iPoint]->SetLocalCFL(CFL); } + /* Store min and max CFL for reporting on fine grid. */ + + myCFLMin = min(CFL,myCFLMin); + myCFLMax = max(CFL,myCFLMax); + myCFLSum += CFL; + } + /* Reduce the min/max/avg local CFL numbers. */ + + su2double rbuf_min, sbuf_min; + sbuf_min = myCFLMin; + SU2_MPI::Allreduce(&sbuf_min, &rbuf_min, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); + Min_CFL_Local = rbuf_min; + + su2double rbuf_max, sbuf_max; + sbuf_max = myCFLMax; + SU2_MPI::Allreduce(&sbuf_max, &rbuf_max, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); + Max_CFL_Local = rbuf_max; + + su2double rbuf_sum, sbuf_sum; + sbuf_sum = myCFLSum; + SU2_MPI::Allreduce(&sbuf_sum, &rbuf_sum, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + Avg_CFL_Local = rbuf_sum; + + unsigned long Global_nPointDomain; + unsigned long Local_nPointDomain = geometry[iMesh]->GetnPointDomain(); + SU2_MPI::Allreduce(&Local_nPointDomain, &Global_nPointDomain, 1, + MPI_UNSIGNED_LONG, MPI_SUM, MPI_COMM_WORLD); + Avg_CFL_Local /= (su2double)Global_nPointDomain; + } } From 6d69ae8c9203e6b5ce9cd58b6c4629fd3b31393c Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Sat, 12 Oct 2019 17:55:54 -0700 Subject: [PATCH 13/57] Added new class for marker profile reader and template writer. --- Common/include/config_structure.hpp | 13 - Common/include/config_structure.inl | 4 - Common/src/config_structure.cpp | 2 - SU2_CFD/include/CMarkerProfileReaderFVM.hpp | 168 ++++++ SU2_CFD/include/output/COutput.hpp | 2 +- SU2_CFD/include/output/COutputLegacy.hpp | 28 - SU2_CFD/include/solver_structure.hpp | 16 - SU2_CFD/obj/Makefile.am | 1 + SU2_CFD/src/CMarkerProfileReaderFVM.cpp | 482 ++++++++++++++++++ SU2_CFD/src/meson.build | 1 + .../src/output/output_structure_legacy.cpp | 416 --------------- SU2_CFD/src/solver_structure.cpp | 249 ++------- SU2_DEF/src/meson.build | 1 + SU2_DOT/src/meson.build | 1 + .../Xcode/SU2_CFD.xcodeproj/project.pbxproj | 6 + SU2_SOL/src/meson.build | 1 + 16 files changed, 713 insertions(+), 678 deletions(-) create mode 100644 SU2_CFD/include/CMarkerProfileReaderFVM.hpp create mode 100644 SU2_CFD/src/CMarkerProfileReaderFVM.cpp diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 3cd167e38a65..78fce2f2c317 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -762,7 +762,6 @@ class CConfig { Wrt_Halo, /*!< \brief Write rind layers in solution files */ Wrt_Performance, /*!< \brief Write the performance summary at the end of a calculation. */ Wrt_MeshQuality, /*!< \brief Write the mesh quality statistics to the visualization files. */ - Wrt_InletFile, /*!< \brief Write a template inlet profile file */ Wrt_Slice, /*!< \brief Write 1D slice of a 2D cartesian solution */ Wrt_Projected_Sensitivity, /*!< \brief Write projected sensitivities (dJ/dx) on surfaces to ASCII file. */ Plot_Section_Forces; /*!< \brief Write sectional forces for specified markers. */ @@ -3267,18 +3266,6 @@ class CConfig { * \return TRUE means that the mesh quality metrics will be written to the visualization files. */ bool GetWrt_MeshQuality(void); - - /*! - * \brief Get information about writing a template inlet profile file. - * \return TRUE means that a template inlet profile file will be written. - */ - bool GetWrt_InletFile(void); - - /*! - * \brief Set information about writing a template inlet profile file. - * \param[in] val_wrt_inletfile - flag for whether to write a template inlet profile file. - */ - void SetWrt_InletFile(bool val_wrt_inletfile); /*! * \brief Get information about writing a 1D slice of a 2D cartesian solution. diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl index 4823dec40f49..e5af07442666 100644 --- a/Common/include/config_structure.inl +++ b/Common/include/config_structure.inl @@ -1677,10 +1677,6 @@ inline bool CConfig::GetWrt_Performance(void) { return Wrt_Performance; } inline bool CConfig::GetWrt_MeshQuality(void) { return Wrt_MeshQuality; } -inline bool CConfig::GetWrt_InletFile(void) { return Wrt_InletFile; } - -inline void CConfig::SetWrt_InletFile(bool val_wrt_inletfile) { Wrt_InletFile = val_wrt_inletfile; } - inline bool CConfig::GetWrt_Slice(void) { return Wrt_Slice; } inline bool CConfig::GetWrt_Projected_Sensitivity(void) { return Wrt_Projected_Sensitivity; } diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 2b6e93a9bc82..3d9cd9e281b0 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -781,8 +781,6 @@ void CConfig::SetPointersNull(void) { Aeroelastic_Simulation = false; nSpanMaxAllZones = 1; - - Wrt_InletFile = false; Restart_Bandwidth_Agg = 0.0; diff --git a/SU2_CFD/include/CMarkerProfileReaderFVM.hpp b/SU2_CFD/include/CMarkerProfileReaderFVM.hpp new file mode 100644 index 000000000000..39e30bbecf65 --- /dev/null +++ b/SU2_CFD/include/CMarkerProfileReaderFVM.hpp @@ -0,0 +1,168 @@ + +/*! + * \file CMarkerProfileReaderFVM.hpp + * \brief Header file for the class CMarkerProfileReaderFVM. + * The implementations are in the CMarkerProfileReaderFVM.cpp file. + * \author T. Economon + * \version 6.2.0 "Falcon" + * + * The current SU2 release has been coordinated by the + * SU2 International Developers Society + * with selected contributions from the open-source community. + * + * The main research teams contributing to the current release are: + * - Prof. Juan J. Alonso's group at Stanford University. + * - Prof. Piero Colonna's group at Delft University of Technology. + * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. + * - Prof. Alberto Guardone's group at Polytechnic University of Milan. + * - Prof. Rafael Palacios' group at Imperial College London. + * - Prof. Vincent Terrapon's group at the University of Liege. + * - Prof. Edwin van der Weide's group at the University of Twente. + * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. + * + * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, + * Tim Albring, and the SU2 contributors. + * + * 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 . + */ + +#pragma once + +#include +#include +#include +#include + +#include "../../Common/include/mpi_structure.hpp" +#include "../../Common/include/config_structure.hpp" +#include "../../Common/include/geometry_structure.hpp" + +using namespace std; + +/*! + * \class CMarkerProfileReaderFVM + * \brief Class for the marker profile reader of the finite volume solver (FVM). + * \author: T. Economon + */ +class CMarkerProfileReaderFVM { + +protected: + + int rank; /*!< \brief MPI Rank. */ + int size; /*!< \brief MPI Size. */ + + CConfig *config; /*!< \brief Local pointer to the config parameter object. */ + + CGeometry *geometry; /*!< \brief Local pointer to the geometry object. */ + + unsigned short dimension; /*!< \brief Dimension of the problem (2 or 3). */ + unsigned short markerType; /*!< \brief Type of marker where the profiles are being applied. */ + + unsigned short numberOfVars; /*!< \brief Number of variables added to the number of coordinates to write each line in the template profile file. */ + + unsigned long numberOfProfiles; /*!< \brief Auxiliary structure for holding the number of markers in a profile file. */ + + string filename; /*!< \brief File name of the marker profile file. */ + + vector profileTags; /*!< \brief Auxiliary structure for holding the string names of the markers in a profile file. */ + + vector numberOfRowsInProfile; /*!< \brief Auxiliary structure for holding the number of rows for a particular marker in a profile file. */ + vector numberOfColumnsInProfile; /*!< \brief Auxiliary structure for holding the number of columns for a particular marker in a profile file. */ + + vector > profileData; /*!< \brief Auxiliary structure for holding the data values from a profile file. */ + vector > > profileCoords; /*!< \brief Data structure for holding the merged inlet boundary coordinates from all ranks. */ + +private: + + /*! + * \brief Read a native SU2 marker profile file in ASCII format. + */ + void ReadMarkerProfile(); + + /*! + * \brief Merge the node coordinates of all profile-type boundaries from all processors. + */ + void MergeProfileMarkers(); + + /*! + * \brief Write a template profile file if the requested file is not found. + */ + void WriteMarkerProfileTemplate(); + +public: + + /*! + * \brief Constructor of the CMarkerProfileReaderFVM class. + * \param[in] val_geometry - Pointer to the current geometry + * \param[in] val_config - Pointer to the current config structure + * \param[in] val_filename - Name of the profile file to be read + * \param[in] val_kind_marker - Type of marker where profile will be applied + * \param[in] val_number_vars - Number of columns of profile data to be written to template file (excluding coordinates) + */ + CMarkerProfileReaderFVM(CGeometry *val_geometry, + CConfig *val_config, + string val_filename, + unsigned short val_kind_marker, + unsigned short val_number_vars); + + /*! + * \brief Destructor of the CMeshReaderFVM class. + */ + ~CMarkerProfileReaderFVM(void); + + /*! + * \brief Get the number of profiles found within the input file. + * \returns Number of profiles found within the input file. + */ + inline unsigned long GetNumberOfProfiles() { + return numberOfProfiles; + } + + /*! + * \brief Get the string tag for the marker where the profile is applied. + * \param[in] val_iProfile - current profile index. + * \returns String tag for the marker where the profile is applied. + */ + inline const string &GetTagForProfile(int val_iProfile) const { + return profileTags[val_iProfile]; + } + + /*! + * \brief Get the number of rows of data in a profile. + * \param[in] val_iProfile - current profile index. + * \returns Number of rows of data in a profile. + */ + inline unsigned long GetNumberOfRowsInProfile(int val_iProfile) { + return numberOfRowsInProfile[val_iProfile]; + } + + /*! + * \brief Get the number of columns of data in a profile. + * \param[in] val_iProfile - current profile index. + * \returns Number of columns of data in a profile. + */ + inline unsigned long GetNumberOfColumnsInProfile(int val_iProfile) { + return numberOfColumnsInProfile[val_iProfile]; + } + + /*! + * \brief Get the 1D vector of data for a profile from the input file. + * \param[in] val_iProfile - current profile index. + * \returns 1D vector of data for a profile from the input file. + */ + inline const vector &GetDataForProfile(int val_iProfile) const { + return profileData[val_iProfile]; + } + +}; diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index aaab4a2bc76d..8bef90ecf4a6 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -227,7 +227,7 @@ class COutput { su2double cauchyValue, /*!< \brief Summed value of the convergence indicator. */ cauchyFunc; /*!< \brief Current value of the convergence indicator at one iteration. */ unsigned short Cauchy_Counter; /*!< \brief Number of elements of the Cauchy serial. */ - vector> cauchySerie; /*!< \brief Complete Cauchy serial. */ + vector > cauchySerie; /*!< \brief Complete Cauchy serial. */ unsigned long nCauchy_Elems; /*!< \brief Total number of cauchy elems to monitor */ su2double cauchyEps; /*!< \brief Defines the threshold when to stop the solver. */ su2double minLogResidual; /*!< \brief Minimum value of the residual to reach */ diff --git a/SU2_CFD/include/output/COutputLegacy.hpp b/SU2_CFD/include/output/COutputLegacy.hpp index 8db5405aa77a..9a8d587abb77 100644 --- a/SU2_CFD/include/output/COutputLegacy.hpp +++ b/SU2_CFD/include/output/COutputLegacy.hpp @@ -205,12 +205,6 @@ class COutputLegacy { **NuFactorIn, **NuFactorOut; - unsigned long nMarker_InletFile; /*!< \brief Counter for total number of inlet boundaries written to inlet profile file. */ - vector Marker_Tags_InletFile; /*!< \brief Marker tags for the strings of the markers in the inlet profile file. */ - unsigned long *nRow_InletFile; /*!< \brief Counters for the number of points per marker in the inlet profile file. */ - unsigned long *nRowCum_InletFile; /*!< \brief Counters for the number of points per marker in cumulative storage format in the inlet profile file. */ - su2double **InletCoords; /*!< \brief Data structure for holding the merged inlet boundary coordinates from all ranks. */ - protected: int rank, /*!< \brief MPI Rank. */ @@ -1013,28 +1007,6 @@ class COutputLegacy { * \param[in] geometry - Geometrical definition of the problem. */ void DeallocateSurfaceData_Parallel(CConfig *config, CGeometry *geometry); - - /*! - * \brief Merge the node coordinates of all inlet boundaries from all processors. - * \param[in] config - Definition of the particular problem. - * \param[in] geometry - Geometrical definition of the problem. - */ - void MergeInletCoordinates(CConfig *config, CGeometry *geometry); - - /*! - * \brief Write a template inlet profile file for all inlets for flow problems. - * \param[in] config - Definition of the particular problem. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver - Solver container. - */ - void Write_InletFile_Flow(CConfig *config, CGeometry *geometry, CSolver **solver); - - /*! - * \brief Deallocate temporary memory needed for merging and writing inlet boundary coordinates. - * \param[in] config - Definition of the particular problem. - * \param[in] geometry - Geometrical definition of the problem. - */ - void DeallocateInletCoordinates(CConfig *config, CGeometry *geometry); /*! * \brief Create and write a CSV file with a slice of data. diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 1b6c11fd90ba..67d4b2e90ebc 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -148,14 +148,6 @@ class CSolver { unsigned long nMarker, /*!< \brief Total number of markers using the grid information. */ *nVertex; /*!< \brief Store nVertex at each marker for deallocation */ - unsigned long nMarker_InletFile; /*!< \brief Auxiliary structure for holding the number of markers in an inlet profile file. */ - vector Marker_Tags_InletFile; /*!< \brief Auxiliary structure for holding the string names of the markers in an inlet profile file. */ - unsigned long *nRow_InletFile; /*!< \brief Auxiliary structure for holding the number of rows for a particular marker in an inlet profile file. */ - unsigned long *nRowCum_InletFile; /*!< \brief Auxiliary structure for holding the number of rows in cumulative storage format for a particular marker in an inlet profile file. */ - unsigned long maxCol_InletFile; /*!< \brief Auxiliary structure for holding the maximum number of columns in all inlet marker profiles (for data structure size) */ - unsigned long *nCol_InletFile; /*!< \brief Auxiliary structure for holding the number of columns for a particular marker in an inlet profile file. */ - passivedouble *Inlet_Data; /*!< \brief Auxiliary structure for holding the data values from an inlet profile file. */ - bool rotate_periodic; /*!< \brief Flag that controls whether the periodic solution needs to be rotated for the solver. */ bool implicit_periodic; /*!< \brief Flag that controls whether the implicit system should be treated by the periodic BC comms. */ @@ -3524,14 +3516,6 @@ class CSolver { */ void Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bool adjoint_run, string val_filename); - /*! - * \brief Read a native SU2 inlet file in ASCII format. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - * \param[in] val_filename - String name of the restart file. - */ - void Read_InletFile_ASCII(CGeometry *geometry, CConfig *config, string val_filename); - /*! * \brief Load a inlet profile data from file into a particular solver. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index 1860eacd7947..ae6148e8af51 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -131,6 +131,7 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/solvers/CMeshSolver.cpp \ ../src/solver_structure.cpp \ ../src/solver_template.cpp \ + ../src/CMarkerProfileReaderFVM.cpp \ ../src/interfaces/CInterface.cpp \ ../src/interfaces/cfd/CConservativeVarsInterface.cpp \ ../src/interfaces/cfd/CMixingPlaneInterface.cpp \ diff --git a/SU2_CFD/src/CMarkerProfileReaderFVM.cpp b/SU2_CFD/src/CMarkerProfileReaderFVM.cpp new file mode 100644 index 000000000000..11a05b555d8b --- /dev/null +++ b/SU2_CFD/src/CMarkerProfileReaderFVM.cpp @@ -0,0 +1,482 @@ +/*! + * \file CMarkerProfileReaderFVM.cpp + * \brief Class that handles the reading of marker profile files. + * \author T. Economon + * \version 6.2.0 "Falcon" + * + * The current SU2 release has been coordinated by the + * SU2 International Developers Society + * with selected contributions from the open-source community. + * + * The main research teams contributing to the current release are: + * - Prof. Juan J. Alonso's group at Stanford University. + * - Prof. Piero Colonna's group at Delft University of Technology. + * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. + * - Prof. Alberto Guardone's group at Polytechnic University of Milan. + * - Prof. Rafael Palacios' group at Imperial College London. + * - Prof. Vincent Terrapon's group at the University of Liege. + * - Prof. Edwin van der Weide's group at the University of Twente. + * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. + * + * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, + * Tim Albring, and the SU2 contributors. + * + * 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 . + */ + +#include "../include/CMarkerProfileReaderFVM.hpp" + +CMarkerProfileReaderFVM::CMarkerProfileReaderFVM(CGeometry *val_geometry, + CConfig *val_config, + string val_filename, + unsigned short val_kind_marker, + unsigned short val_number_vars) { + + /*--- Store input values and pointers to class data. ---*/ + + rank = SU2_MPI::GetRank(); + size = SU2_MPI::GetSize(); + + this->config = val_config; + this->geometry = val_geometry; + dimension = geometry->GetnDim(); + + filename = val_filename; + markerType = val_kind_marker; + numberOfVars = val_number_vars; + + /* Attempt to open the specified file. */ + ifstream profile_file; + profile_file.open(filename.data(), ios::in); + + /* If the file is not found, then we merge the information necessary + and write a template marker profile file. Otherwise, we read and + store the information in the marker profile file. */ + + if (profile_file.fail()) { + MergeProfileMarkers(); + WriteMarkerProfileTemplate(); + } else { + ReadMarkerProfile(); + } + +} + +CMarkerProfileReaderFVM::~CMarkerProfileReaderFVM(void) { } + +void CMarkerProfileReaderFVM::ReadMarkerProfile() { + + /*--- Open the profile file (we have already error checked) ---*/ + + ifstream profile_file; + profile_file.open(filename.data(), ios::in); + + /*--- Identify the markers and data set in the profile file ---*/ + + string text_line; + while (getline (profile_file, text_line)) { + + string::size_type position = text_line.find ("NMARK=",0); + if (position != string::npos) { + text_line.erase (0,6); numberOfProfiles = atoi(text_line.c_str()); + + numberOfRowsInProfile.resize(numberOfProfiles); + numberOfColumnsInProfile.resize(numberOfProfiles); + + for (unsigned short iMarker = 0 ; iMarker < numberOfProfiles; iMarker++) { + + getline (profile_file, text_line); + text_line.erase (0,11); + for (unsigned short iChar = 0; iChar < 20; iChar++) { + position = text_line.find( " ", 0 ); if (position != string::npos) text_line.erase (position,1); + position = text_line.find( "\r", 0 ); if (position != string::npos) text_line.erase (position,1); + position = text_line.find( "\n", 0 ); if (position != string::npos) text_line.erase (position,1); + } + profileTags.push_back(text_line.c_str()); + + getline (profile_file, text_line); + text_line.erase (0,5); numberOfRowsInProfile[iMarker] = atoi(text_line.c_str()); + + getline (profile_file, text_line); + text_line.erase (0,5); numberOfColumnsInProfile[iMarker] = atoi(text_line.c_str()); + + /*--- Skip the data. This is read in the next loop. ---*/ + + for (unsigned long iRow = 0; iRow < numberOfRowsInProfile[iMarker]; iRow++) getline (profile_file, text_line); + + } + } else { + SU2_MPI::Error("While opening profile file, no \"NMARK=\" specification was found", CURRENT_FUNCTION); + } + } + + profile_file.close(); + + /*--- Compute array bounds and offsets. Allocate data structure. ---*/ + + profileData.resize(numberOfProfiles); + for (unsigned short iMarker = 0; iMarker < numberOfProfiles; iMarker++) { + profileData[iMarker].resize(numberOfRowsInProfile[iMarker]*numberOfColumnsInProfile[iMarker], 0.0); + } + + /*--- Read all lines in the profile file and extract data. ---*/ + + profile_file.open(filename.data(), ios::in); + + int counter = 0; + while (getline (profile_file, text_line)) { + + string::size_type position = text_line.find ("NMARK=",0); + if (position != string::npos) { + + for (unsigned short iMarker = 0; iMarker < numberOfProfiles; iMarker++) { + + /*--- Skip the tag, nRow, and nCol lines. ---*/ + + getline (profile_file, text_line); + getline (profile_file, text_line); + getline (profile_file, text_line); + + /*--- Now read the data for each row and store. ---*/ + + for (unsigned long iRow = 0; iRow < numberOfRowsInProfile[iMarker]; iRow++) { + + getline (profile_file, text_line); + + istringstream point_line(text_line); + + /*--- Store the values (starting with node coordinates) --*/ + + for (unsigned short iVar = 0; iVar < numberOfColumnsInProfile[iMarker]; iVar++) + point_line >> profileData[iMarker][iRow*numberOfColumnsInProfile[iMarker] + iVar]; + + /*--- Increment our local row counter. ---*/ + + counter++; + + } + } + } + } + + profile_file.close(); + +} + +void CMarkerProfileReaderFVM::MergeProfileMarkers() { + + /*--- Local variables needed on all processors ---*/ + + unsigned long iPoint, jPoint, kPoint; + + int iProcessor, nProcessor = size; + + unsigned long iVertex, iMarker; + unsigned long Buffer_Send_nPoin[1], *Buffer_Recv_nPoin = NULL; + unsigned long nLocalPoint = 0, MaxLocalPoint = 0; + + unsigned long index, iChar; + + char str_buf[MAX_STRING_SIZE]; + vector Marker_Tags; + vector::iterator it; + + vector nRowCum_Counter; + + if (rank == MASTER_NODE) Buffer_Recv_nPoin = new unsigned long[nProcessor]; + + /*--- Search all boundaries on the present rank to count the number + of nodes found on profile markers. ---*/ + + nLocalPoint = 0; numberOfProfiles = 0; + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + if (config->GetMarker_All_KindBC(iMarker) == markerType) { + numberOfProfiles++; + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + + /*--- Only communicate owned nodes to avoid duplicates. ---*/ + + if (geometry->node[iPoint]->GetDomain()) + nLocalPoint++; + + } + } + } + Buffer_Send_nPoin[0] = nLocalPoint; + + /*--- Communicate the total number of nodes on this domain. ---*/ + + SU2_MPI::Gather(&Buffer_Send_nPoin, 1, MPI_UNSIGNED_LONG, + Buffer_Recv_nPoin, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&nLocalPoint, &MaxLocalPoint, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); + + /*--- Send and Recv buffers. ---*/ + + su2double *Buffer_Send_X = new su2double[MaxLocalPoint]; + su2double *Buffer_Recv_X = NULL; + + su2double *Buffer_Send_Y = new su2double[MaxLocalPoint]; + su2double *Buffer_Recv_Y = NULL; + + su2double *Buffer_Send_Z = NULL, *Buffer_Recv_Z = NULL; + if (dimension == 3) Buffer_Send_Z = new su2double[MaxLocalPoint]; + + char *Buffer_Send_Str = new char[MaxLocalPoint*MAX_STRING_SIZE]; + char *Buffer_Recv_Str = NULL; + + /*--- Prepare the receive buffers in the master node only. ---*/ + + if (rank == MASTER_NODE) { + + Buffer_Recv_X = new su2double[nProcessor*MaxLocalPoint]; + Buffer_Recv_Y = new su2double[nProcessor*MaxLocalPoint]; + if (dimension == 3) Buffer_Recv_Z = new su2double[nProcessor*MaxLocalPoint]; + Buffer_Recv_Str = new char[nProcessor*MaxLocalPoint*MAX_STRING_SIZE]; + + /*--- Sum total number of nodes to be written and allocate arrays ---*/ + + unsigned long nGlobal_InletPoint = 0; + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { + nGlobal_InletPoint += Buffer_Recv_nPoin[iProcessor]; + } + + profileCoords.resize(numberOfProfiles); + for (iMarker = 0; iMarker < numberOfProfiles; iMarker++) { + profileCoords[iMarker].resize(dimension); + } + + } + + /*--- Main communication routine. Loop over each coordinate and perform + the MPI comm. Temporary 1-D buffers are used to send the coordinates at + all nodes on each partition to the master node. These are then unpacked + by the master and sorted by marker tag in one large n-dim. array. ---*/ + + su2double *Coords_Local; jPoint = 0; + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + if (config->GetMarker_All_KindBC(iMarker) == markerType) { + + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + + /*--- Only communicate owned nodes to avoid duplicates. ---*/ + + if (geometry->node[iPoint]->GetDomain()) { + + /*--- Retrieve local coordinates at this node. ---*/ + + Coords_Local = geometry->node[iPoint]->GetCoord(); + + /*--- Load local coords into the temporary send buffer. ---*/ + + Buffer_Send_X[jPoint] = Coords_Local[0]; + Buffer_Send_Y[jPoint] = Coords_Local[1]; + if (dimension == 3) Buffer_Send_Z[jPoint] = Coords_Local[2]; + + /*--- If US system, the output should be in inches ---*/ + + if (config->GetSystemMeasurements() == US) { + Buffer_Send_X[jPoint] *= 12.0; + Buffer_Send_Y[jPoint] *= 12.0; + if (dimension == 3) Buffer_Send_Z[jPoint] *= 12.0; + } + + /*--- Store the marker tag for this particular node. ---*/ + + SPRINTF(&Buffer_Send_Str[jPoint*MAX_STRING_SIZE], "%s", + config->GetMarker_All_TagBound(iMarker).c_str()); + + /*--- Increment jPoint as the counter. We need this because iPoint + may include halo nodes that we skip over during this loop. ---*/ + + jPoint++; + + } + } + } + } + + /*--- Gather the coordinate data on the master node using MPI. ---*/ + + SU2_MPI::Gather(Buffer_Send_X, (int)MaxLocalPoint, MPI_DOUBLE, + Buffer_Recv_X, (int)MaxLocalPoint, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + SU2_MPI::Gather(Buffer_Send_Y, (int)MaxLocalPoint, MPI_DOUBLE, + Buffer_Recv_Y, (int)MaxLocalPoint, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + if (dimension == 3) { + SU2_MPI::Gather(Buffer_Send_Z, (int)MaxLocalPoint, MPI_DOUBLE, + Buffer_Recv_Z, (int)MaxLocalPoint, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); + } + SU2_MPI::Gather(Buffer_Send_Str, (int)MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR, + Buffer_Recv_Str, (int)MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR, MASTER_NODE, MPI_COMM_WORLD); + + /*--- The master node unpacks and sorts this variable by marker tag. ---*/ + + if (rank == MASTER_NODE) { + + profileTags.clear(); + + /*--- First, parse the marker tags to count how many total profile markers + we have now on the master. ---*/ + + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { + for (iPoint = 0; iPoint < Buffer_Recv_nPoin[iProcessor]; iPoint++) { + index = (iProcessor*MaxLocalPoint + iPoint)*MAX_STRING_SIZE; + for (iChar = 0; iChar < MAX_STRING_SIZE; iChar++) { + str_buf[iChar] = Buffer_Recv_Str[index + iChar]; + } + Marker_Tags.push_back(str_buf); + profileTags.push_back(str_buf); + } + } + + /*--- Sort and remove the duplicate profile marker strings. ---*/ + + sort(profileTags.begin(), profileTags.end()); + profileTags.erase(unique(profileTags.begin(), + profileTags.end()), + profileTags.end()); + + /*--- Store the unique number of markers for writing later. ---*/ + + numberOfProfiles = profileTags.size(); + + /*--- Count the number of rows (nodes) per marker. ---*/ + + numberOfRowsInProfile.resize(numberOfProfiles,0.0); + jPoint = 0; + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { + for (iPoint = 0; iPoint < Buffer_Recv_nPoin[iProcessor]; iPoint++) { + for (iMarker = 0; iMarker < numberOfProfiles; iMarker++) { + if (profileTags[iMarker] == Marker_Tags[jPoint]) { + numberOfRowsInProfile[iMarker]++; + } + } + jPoint++; + } + } + + /*--- Load up the coordinates, sorted into chunks per marker. ---*/ + + jPoint = 0; kPoint = 0; + for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { + for (iPoint = 0; iPoint < Buffer_Recv_nPoin[iProcessor]; iPoint++) { + for (iMarker = 0; iMarker < numberOfProfiles; iMarker++) { + + if (profileTags[iMarker] == Marker_Tags[kPoint]) { + + /*--- Find our current index for this marker and store coords. ---*/ + + profileCoords[iMarker][0].push_back(Buffer_Recv_X[jPoint]); + profileCoords[iMarker][1].push_back(Buffer_Recv_Y[jPoint]); + if (dimension == 3) + profileCoords[iMarker][2].push_back(Buffer_Recv_Z[jPoint]); + + } + } + + /*--- Increment point counter for marker tags and data. ---*/ + + kPoint++; + jPoint++; + + } + + /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ + + jPoint = (iProcessor+1)*MaxLocalPoint; + + } + } + + /*--- Immediately release the temporary data buffers. ---*/ + + delete [] Buffer_Send_X; + delete [] Buffer_Send_Y; + if (Buffer_Send_Z != NULL) delete [] Buffer_Send_Z; + delete [] Buffer_Send_Str; + if (rank == MASTER_NODE) { + delete [] Buffer_Recv_X; + delete [] Buffer_Recv_Y; + if (Buffer_Recv_Z != NULL) delete [] Buffer_Recv_Z; + delete [] Buffer_Recv_nPoin; + delete [] Buffer_Recv_Str; + } + +} + +void CMarkerProfileReaderFVM::WriteMarkerProfileTemplate() { + + /*--- Count the number of columns that we have for this case. + Here, we have dimension entries for node coordinates and then the + total number of columns of data specified in the constructor. ---*/ + + const unsigned short nColumns = dimension + numberOfVars; + + /*--- Write the profile file. Note that we have already merged + all of the information for the markers and coordinates previously + in the MergeProfileMarkers() routine and only the master writes. ---*/ + + if (rank == MASTER_NODE) { + + ofstream node_file("profile_example.dat"); + + node_file << "NMARK= " << numberOfProfiles << endl; + + for (unsigned short iMarker = 0; iMarker < numberOfProfiles; iMarker++) { + + /*--- Access the default data for this marker. ---*/ + + string Marker_Tag = profileTags[iMarker]; + + /*--- Header information for this marker. ---*/ + + node_file << "MARKER_TAG= " << Marker_Tag << endl; + node_file << "NROW=" << numberOfRowsInProfile[iMarker] << endl; + node_file << "NCOL=" << nColumns << endl; + + node_file << setprecision(15); + node_file << std::scientific; + + /*--- Loop over the data structure and write the coords and vars. ---*/ + + for (unsigned long iPoint = 0; iPoint < numberOfRowsInProfile[iMarker]; iPoint++) { + + for (unsigned short iDim = 0; iDim < dimension; iDim++) { + node_file << profileCoords[iMarker][iDim][iPoint] << "\t"; + } + for (unsigned short iDim = 0; iDim < numberOfVars; iDim++) { + node_file << 0.0 << "\t"; + } + node_file << endl; + } + + } + node_file.close(); + + /*--- Print a message to inform the user about the template file. ---*/ + + stringstream err; + err << endl; + err << " Could not find the input file for the marker profile." << endl; + err << " Looked for: " << filename << "." << endl; + err << " Created a template profile file with node coordinates" << endl; + err << " and correct number of columns at `profile_example.dat`." << endl; + err << " You can use this file as a guide for making your own profile" << endl; + err << " specification." << endl << endl; + SU2_MPI::Error(err.str(), CURRENT_FUNCTION); + + } + +} diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 3195c085eff5..7d3be2212ced 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -34,6 +34,7 @@ su2_cfd_src = files(['solver_direct_transition.cpp', 'numerics_template.cpp', 'solver_adjoint_discrete.cpp', 'numerics_direct_elasticity_nonlinear.cpp', + 'CMarkerProfileReaderFVM.cpp', 'SU2_CFD.cpp']) su2_cfd_src += files(['output/CAdjElasticityOutput.cpp', diff --git a/SU2_CFD/src/output/output_structure_legacy.cpp b/SU2_CFD/src/output/output_structure_legacy.cpp index b4ae150d2e15..77ee8feff6a8 100644 --- a/SU2_CFD/src/output/output_structure_legacy.cpp +++ b/SU2_CFD/src/output/output_structure_legacy.cpp @@ -113,14 +113,6 @@ COutputLegacy::COutputLegacy(CConfig *config) { nPointLinear = NULL; nPointCumulative = NULL; - - /*--- Inlet profile data structures. ---*/ - - nRow_InletFile = NULL; - nRowCum_InletFile = NULL; - InletCoords = NULL; - - Marker_Tags_InletFile.clear(); /*--- Initialize CGNS write flag ---*/ @@ -12285,18 +12277,6 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container, default: break; } - /*--- Write a template inlet profile file if requested. ---*/ - - if (config[iZone]->GetWrt_InletFile()) { - MergeInletCoordinates(config[iZone], geometry[iZone][iInst][MESH_0]); - - if (rank == MASTER_NODE) { - Write_InletFile_Flow(config[iZone], geometry[iZone][iInst][MESH_0], solver_container[iZone][iInst][MESH_0]); - DeallocateInletCoordinates(config[iZone], geometry[iZone][iInst][MESH_0]); - } - config[iZone]->SetWrt_InletFile(false); - } - /*--- This switch statement will become a call to a virtual function defined within each of the "physics" output child classes that loads the local data for that particular problem alone. ---*/ @@ -18443,402 +18423,6 @@ void COutputLegacy::DeallocateSurfaceData_Parallel(CConfig *config, CGeometry *g } -void COutputLegacy::MergeInletCoordinates(CConfig *config, CGeometry *geometry) { - - /*--- Local variables needed on all processors ---*/ - - unsigned short iDim, nDim = geometry->GetnDim(); - unsigned long iPoint, jPoint, kPoint; - - int iProcessor, nProcessor = size; - - unsigned long iVertex, iMarker; - unsigned long Buffer_Send_nPoin[1], *Buffer_Recv_nPoin = NULL; - unsigned long nLocalPoint = 0, MaxLocalPoint = 0; - - unsigned long index, iChar; - - char str_buf[MAX_STRING_SIZE]; - vector Marker_Tags; - vector::iterator it; - - unsigned long *nRowCum_Counter = NULL; - - if (rank == MASTER_NODE) Buffer_Recv_nPoin = new unsigned long[nProcessor]; - - /*--- Search all boundaries on the present rank to count the number - of nodes found on inlet markers. ---*/ - - nLocalPoint = 0; - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if (config->GetMarker_All_KindBC(iMarker) == INLET_FLOW) { - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - - /*--- Only communicate owned nodes to avoid duplicates. ---*/ - - if (geometry->node[iPoint]->GetDomain()) - nLocalPoint++; - - } - } - } - Buffer_Send_nPoin[0] = nLocalPoint; - - /*--- Communicate the total number of nodes on this domain. ---*/ - -#ifdef HAVE_MPI - SU2_MPI::Gather(&Buffer_Send_nPoin, 1, MPI_UNSIGNED_LONG, - Buffer_Recv_nPoin, 1, MPI_UNSIGNED_LONG, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&nLocalPoint, &MaxLocalPoint, 1, MPI_UNSIGNED_LONG, MPI_MAX, MPI_COMM_WORLD); -#else - Buffer_Recv_nPoin[0] = Buffer_Send_nPoin[0]; - MaxLocalPoint = nLocalPoint; -#endif - - /*--- Send and Recv buffers. ---*/ - - su2double *Buffer_Send_X = new su2double[MaxLocalPoint]; - su2double *Buffer_Recv_X = NULL; - - su2double *Buffer_Send_Y = new su2double[MaxLocalPoint]; - su2double *Buffer_Recv_Y = NULL; - - su2double *Buffer_Send_Z = NULL, *Buffer_Recv_Z = NULL; - if (nDim == 3) Buffer_Send_Z = new su2double[MaxLocalPoint]; - - char *Buffer_Send_Str = new char[MaxLocalPoint*MAX_STRING_SIZE]; - char *Buffer_Recv_Str = NULL; - - /*--- Prepare the receive buffers in the master node only. ---*/ - - if (rank == MASTER_NODE) { - - Buffer_Recv_X = new su2double[nProcessor*MaxLocalPoint]; - Buffer_Recv_Y = new su2double[nProcessor*MaxLocalPoint]; - if (nDim == 3) Buffer_Recv_Z = new su2double[nProcessor*MaxLocalPoint]; - Buffer_Recv_Str = new char[nProcessor*MaxLocalPoint*MAX_STRING_SIZE]; - - /*--- Sum total number of nodes to be written and allocate arrays ---*/ - - unsigned long nGlobal_InletPoint = 0; - for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { - nGlobal_InletPoint += Buffer_Recv_nPoin[iProcessor]; - } - InletCoords = new su2double*[nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - InletCoords[iDim] = new su2double[nGlobal_InletPoint]; - } - } - - /*--- Main communication routine. Loop over each coordinate and perform - the MPI comm. Temporary 1-D buffers are used to send the coordinates at - all nodes on each partition to the master node. These are then unpacked - by the master and sorted by marker tag in one large n-dim. array. ---*/ - - /*--- Loop over this partition to collect the coords of the local points. ---*/ - - su2double *Coords_Local; jPoint = 0; - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if (config->GetMarker_All_KindBC(iMarker) == INLET_FLOW) { - - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - - /*--- Only communicate owned nodes to avoid duplicates. ---*/ - - if (geometry->node[iPoint]->GetDomain()) { - - /*--- Retrieve local coordinates at this node. ---*/ - - Coords_Local = geometry->node[iPoint]->GetCoord(); - - /*--- Load local coords into the temporary send buffer. ---*/ - - Buffer_Send_X[jPoint] = Coords_Local[0]; - Buffer_Send_Y[jPoint] = Coords_Local[1]; - if (nDim == 3) Buffer_Send_Z[jPoint] = Coords_Local[2]; - - /*--- If US system, the output should be in inches ---*/ - - if (config->GetSystemMeasurements() == US) { - Buffer_Send_X[jPoint] *= 12.0; - Buffer_Send_Y[jPoint] *= 12.0; - if (nDim == 3) Buffer_Send_Z[jPoint] *= 12.0; - } - - /*--- Store the marker tag for this particular node. ---*/ - - SPRINTF(&Buffer_Send_Str[jPoint*MAX_STRING_SIZE], "%s", - config->GetMarker_All_TagBound(iMarker).c_str()); - - /*--- Increment jPoint as the counter. We need this because iPoint - may include halo nodes that we skip over during this loop. ---*/ - - jPoint++; - - } - } - } - } - - /*--- Gather the coordinate data on the master node using MPI. ---*/ - -#ifdef HAVE_MPI - SU2_MPI::Gather(Buffer_Send_X, MaxLocalPoint, MPI_DOUBLE, Buffer_Recv_X, MaxLocalPoint, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); - SU2_MPI::Gather(Buffer_Send_Y, MaxLocalPoint, MPI_DOUBLE, Buffer_Recv_Y, MaxLocalPoint, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); - if (nDim == 3) { - SU2_MPI::Gather(Buffer_Send_Z, MaxLocalPoint, MPI_DOUBLE, Buffer_Recv_Z, MaxLocalPoint, MPI_DOUBLE, MASTER_NODE, MPI_COMM_WORLD); - } - SU2_MPI::Gather(Buffer_Send_Str, MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR, Buffer_Recv_Str, MaxLocalPoint*MAX_STRING_SIZE, MPI_CHAR, MASTER_NODE, MPI_COMM_WORLD); -#else - for (iPoint = 0; iPoint < MaxLocalPoint; iPoint++) { - Buffer_Recv_X[iPoint] = Buffer_Send_X[iPoint]; - Buffer_Recv_Y[iPoint] = Buffer_Send_Y[iPoint]; - if (nDim == 3) Buffer_Recv_Z[iPoint] = Buffer_Send_Z[iPoint]; - index = iPoint*MAX_STRING_SIZE; - for (iChar = 0; iChar < MAX_STRING_SIZE; iChar++) { - Buffer_Recv_Str[index + iChar] = Buffer_Send_Str[index + iChar]; - } - } -#endif - - /*--- The master node unpacks and sorts this variable by marker tag. ---*/ - - if (rank == MASTER_NODE) { - - Marker_Tags_InletFile.clear(); - - /*--- First, parse the marker tags to count how many total inlet markers - we have now on the master. ---*/ - - for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { - for (iPoint = 0; iPoint < Buffer_Recv_nPoin[iProcessor]; iPoint++) { - index = (iProcessor*MaxLocalPoint + iPoint)*MAX_STRING_SIZE; - for (iChar = 0; iChar < MAX_STRING_SIZE; iChar++) { - str_buf[iChar] = Buffer_Recv_Str[index + iChar]; - } - Marker_Tags.push_back(str_buf); - Marker_Tags_InletFile.push_back(str_buf); - } - } - - /*--- Sort and remove the duplicate inlet marker strings. ---*/ - - sort(Marker_Tags_InletFile.begin(), Marker_Tags_InletFile.end()); - Marker_Tags_InletFile.erase(unique(Marker_Tags_InletFile.begin(), - Marker_Tags_InletFile.end()), - Marker_Tags_InletFile.end()); - - /*--- Store the unique number of markers for writing later. ---*/ - - nMarker_InletFile = Marker_Tags_InletFile.size(); - - /*--- Count the number of rows (nodes) per marker. ---*/ - - nRow_InletFile = new unsigned long[nMarker_InletFile]; - for (iMarker = 0; iMarker < nMarker_InletFile; iMarker++) { - nRow_InletFile[iMarker] = 0; - } - - /*--- Now count the number of points per marker. ---*/ - - jPoint = 0; - for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { - for (iPoint = 0; iPoint < Buffer_Recv_nPoin[iProcessor]; iPoint++) { - for (iMarker = 0; iMarker < nMarker_InletFile; iMarker++) { - if (Marker_Tags_InletFile[iMarker] == Marker_Tags[jPoint]) { - nRow_InletFile[iMarker]++; - } - } - jPoint++; - } - } - - /*--- Now put the number of points per marker into cumulative storage. - We will also create an extra counter to make sorting easier. ---*/ - - nRowCum_InletFile = new unsigned long[nMarker_InletFile+1]; - nRowCum_Counter = new unsigned long[nMarker_InletFile+1]; - - nRowCum_InletFile[0] = 0; nRowCum_Counter[0] = 0; - for (iMarker = 0; iMarker < nMarker_InletFile; iMarker++) { - nRowCum_InletFile[iMarker+1] = nRowCum_InletFile[iMarker] + nRow_InletFile[iMarker]; - nRowCum_Counter[iMarker+1] = nRowCum_Counter[iMarker] + nRow_InletFile[iMarker]; - } - - /*--- Load up the coordinates, sorted into chunks per marker. ---*/ - - jPoint = 0; kPoint = 0; - for (iProcessor = 0; iProcessor < nProcessor; iProcessor++) { - for (iPoint = 0; iPoint < Buffer_Recv_nPoin[iProcessor]; iPoint++) { - for (iMarker = 0; iMarker < nMarker_InletFile; iMarker++) { - if (Marker_Tags_InletFile[iMarker] == Marker_Tags[kPoint]) { - - /*--- Find our current index for this marker and store coords. ---*/ - - index = nRowCum_Counter[iMarker]; - InletCoords[0][index] = Buffer_Recv_X[jPoint]; - InletCoords[1][index] = Buffer_Recv_Y[jPoint]; - if (nDim == 3) InletCoords[2][index] = Buffer_Recv_Z[jPoint]; - - /*--- Increment the counter for this marker. ---*/ - - nRowCum_Counter[iMarker]++; - - } - } - - /*--- Increment point counter for marker tags and data. ---*/ - - kPoint++; - jPoint++; - - } - - /*--- Adjust jPoint to index of next proc's data in the buffers. ---*/ - - jPoint = (iProcessor+1)*MaxLocalPoint; - - } - } - - /*--- Immediately release the temporary data buffers. ---*/ - - delete [] Buffer_Send_X; - delete [] Buffer_Send_Y; - if (Buffer_Send_Z != NULL) delete [] Buffer_Send_Z; - delete [] Buffer_Send_Str; - if (rank == MASTER_NODE) { - delete [] Buffer_Recv_X; - delete [] Buffer_Recv_Y; - if (Buffer_Recv_Z != NULL) delete [] Buffer_Recv_Z; - delete [] Buffer_Recv_nPoin; - delete [] Buffer_Recv_Str; - delete [] nRowCum_Counter; - } - -} - -void COutputLegacy::Write_InletFile_Flow(CConfig *config, CGeometry *geometry, CSolver **solver) { - - unsigned short iMarker, iDim, iVar; - unsigned long iPoint; - su2double turb_val[2] = {0.0,0.0}; - - const unsigned short nDim = geometry->GetnDim(); - - bool turbulent = (config->GetKind_Solver() == RANS || - config->GetKind_Solver() == INC_RANS || - config->GetKind_Solver() == ADJ_RANS || - config->GetKind_Solver() == DISC_ADJ_RANS || - config->GetKind_Solver() == DISC_ADJ_INC_RANS); - - unsigned short nVar_Turb = 0; - if (turbulent) - switch (config->GetKind_Turb_Model()) { - case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP: - nVar_Turb = 1; - turb_val[0] = solver[TURB_SOL]->GetNuTilde_Inf(); - break; - case SST: case SST_SUST: - nVar_Turb = 2; - turb_val[0] = solver[TURB_SOL]->GetTke_Inf(); - turb_val[1] = solver[TURB_SOL]->GetOmega_Inf(); - break; - default: - SU2_MPI::Error("Specified turbulence model unavailable or none selected", CURRENT_FUNCTION); - break; - } - - /*--- Count the number of columns that we have for this flow case. - Here, we have nDim entries for node coordinates, 2 entries for the total - conditions or mass flow, another nDim for the direction vector, and - finally entries for the number of turbulence variables. ---*/ - - unsigned short nCol_InletFile = nDim + 2 + nDim + nVar_Turb; - - /*--- Write the inlet profile file. Note that we have already merged - all of the information for the markers and coordinates previously - in the MergeInletCoordinates() routine. ---*/ - - ofstream node_file("inlet_example.dat"); - - node_file << "NMARK= " << nMarker_InletFile << endl; - - for (iMarker = 0; iMarker < nMarker_InletFile; iMarker++) { - - /*--- Access the default data for this marker. ---*/ - - string Marker_Tag = Marker_Tags_InletFile[iMarker]; - su2double p_total = config->GetInlet_Ptotal(Marker_Tag); - su2double t_total = config->GetInlet_Ttotal(Marker_Tag); - su2double* flow_dir = config->GetInlet_FlowDir(Marker_Tag); - - /*--- Header information for this marker. ---*/ - - node_file << "MARKER_TAG= " << Marker_Tag << endl; - node_file << "NROW=" << nRow_InletFile[iMarker] << endl; - node_file << "NCOL=" << nCol_InletFile << endl; - - node_file << setprecision(15); - node_file << std::scientific; - - /*--- Loop over the data structure and write the coords and vars to file. ---*/ - - for (iPoint = nRowCum_InletFile[iMarker]; iPoint < nRowCum_InletFile[iMarker+1]; iPoint++) { - - for (iDim = 0; iDim < nDim; iDim++) { - node_file << InletCoords[iDim][iPoint] << "\t"; - } - node_file << t_total << "\t" << p_total; - for (iDim = 0; iDim < nDim; iDim++) { - node_file << "\t" << flow_dir[iDim]; - } - for (iVar = 0; iVar < nVar_Turb; iVar++) { - node_file << "\t" << turb_val[iVar]; - } - node_file << endl; - } - - } - node_file.close(); - - /*--- Print a message to inform the user about the template file. ---*/ - - stringstream err; - err << endl; - err << " Created a template inlet profile file with node coordinates" << endl; - err << " and solver variables at `inlet_example.dat`." << endl; - err << " You can use this file as a guide for making your own inlet" << endl; - err << " specification." << endl << endl; - SU2_MPI::Error(err.str(), CURRENT_FUNCTION); - -} - -void COutputLegacy::DeallocateInletCoordinates(CConfig *config, CGeometry *geometry) { - - unsigned short iDim, nDim = geometry->GetnDim(); - - /*--- The master node alone owns all data found in this routine. ---*/ - - if (rank == MASTER_NODE) { - - /*--- Deallocate memory for inlet coordinate data ---*/ - - if (nRow_InletFile != NULL) delete [] nRow_InletFile; - if (nRowCum_InletFile != NULL) delete [] nRowCum_InletFile; - - Marker_Tags_InletFile.clear(); - - for (iDim = 0; iDim < nDim; iDim++) { - if (InletCoords[iDim] != NULL) delete [] InletCoords[iDim]; - } - if (InletCoords != NULL) delete [] InletCoords; - } - -} - void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geometry, CConfig *config, bool output) { unsigned short iDim, iMarker, iMarker_Analyze; diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 3f206b1f8ff7..00a629d401b7 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -50,6 +50,7 @@ #include "../../Common/include/toolboxes/MMS/CTGVSolution.hpp" #include "../../Common/include/toolboxes/MMS/CUserDefinedSolution.hpp" #include "../../Common/include/toolboxes/printing_toolbox.hpp" +#include "../include/CMarkerProfileReaderFVM.hpp" CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { @@ -103,14 +104,6 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { node = NULL; nOutputVariables = 0; ResLinSolver = 0.0; - - - /*--- Inlet profile data structures. ---*/ - - nRowCum_InletFile = NULL; - nRow_InletFile = NULL; - nCol_InletFile = NULL; - Inlet_Data = NULL; /*--- Variable initialization to avoid valgrid warnings when not used. ---*/ @@ -280,11 +273,6 @@ CSolver::~CSolver(void) { if (Restart_Vars != NULL) {delete [] Restart_Vars; Restart_Vars = NULL;} if (Restart_Data != NULL) {delete [] Restart_Data; Restart_Data = NULL;} - if (nRowCum_InletFile != NULL) {delete [] nRowCum_InletFile; nRowCum_InletFile = NULL;} - if (nRow_InletFile != NULL) {delete [] nRow_InletFile; nRow_InletFile = NULL;} - if (nCol_InletFile != NULL) {delete [] nCol_InletFile; nCol_InletFile = NULL;} - if (Inlet_Data != NULL) {delete [] Inlet_Data; Inlet_Data = NULL;} - if (VerificationSolution != NULL) {delete VerificationSolution; VerificationSolution = NULL;} } @@ -4985,121 +4973,6 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo } -void CSolver::Read_InletFile_ASCII(CGeometry *geometry, CConfig *config, string val_filename) { - - ifstream inlet_file; - string text_line; - unsigned long iVar, iMarker, iChar, iRow; - int counter = 0; - string::size_type position; - - /*--- Open the inlet profile file (we have already error checked) ---*/ - - inlet_file.open(val_filename.data(), ios::in); - - /*--- Identify the markers and data set in the inlet profile file ---*/ - - while (getline (inlet_file, text_line)) { - - position = text_line.find ("NMARK=",0); - if (position != string::npos) { - text_line.erase (0,6); nMarker_InletFile = atoi(text_line.c_str()); - - nRow_InletFile = new unsigned long[nMarker_InletFile]; - nRowCum_InletFile = new unsigned long[nMarker_InletFile+1]; - nCol_InletFile = new unsigned long[nMarker_InletFile]; - - for (iMarker = 0 ; iMarker < nMarker_InletFile; iMarker++) { - - getline (inlet_file, text_line); - text_line.erase (0,11); - for (iChar = 0; iChar < 20; iChar++) { - position = text_line.find( " ", 0 ); if (position != string::npos) text_line.erase (position,1); - position = text_line.find( "\r", 0 ); if (position != string::npos) text_line.erase (position,1); - position = text_line.find( "\n", 0 ); if (position != string::npos) text_line.erase (position,1); - } - Marker_Tags_InletFile.push_back(text_line.c_str()); - - getline (inlet_file, text_line); - text_line.erase (0,5); nRow_InletFile[iMarker] = atoi(text_line.c_str()); - - getline (inlet_file, text_line); - text_line.erase (0,5); nCol_InletFile[iMarker] = atoi(text_line.c_str()); - - /*--- Skip the data. This is read in the next loop. ---*/ - - for (iRow = 0; iRow < nRow_InletFile[iMarker]; iRow++) getline (inlet_file, text_line); - - } - } else { - SU2_MPI::Error("While opening inlet file, no \"NMARK=\" specification was found", CURRENT_FUNCTION); - } - } - - inlet_file.close(); - - /*--- Compute array bounds and offsets. Allocate data structure. ---*/ - - maxCol_InletFile = 0; nRowCum_InletFile[0] = 0; - for (iMarker = 0; iMarker < nMarker_InletFile; iMarker++) { - if (nCol_InletFile[iMarker] > maxCol_InletFile) - maxCol_InletFile = nCol_InletFile[iMarker]; - - /*--- Put nRow into cumulative storage format. ---*/ - - nRowCum_InletFile[iMarker+1] = nRowCum_InletFile[iMarker] + nRow_InletFile[iMarker]; - - } - - Inlet_Data = new passivedouble[nRowCum_InletFile[nMarker_InletFile]*maxCol_InletFile]; - - for (unsigned long iPoint = 0; iPoint < nRowCum_InletFile[nMarker_InletFile]*maxCol_InletFile; iPoint++) - Inlet_Data[iPoint] = 0.0; - - /*--- Read all lines in the inlet profile file and extract data. ---*/ - - inlet_file.open(val_filename.data(), ios::in); - - counter = 0; - while (getline (inlet_file, text_line)) { - - position = text_line.find ("NMARK=",0); - if (position != string::npos) { - - for (iMarker = 0; iMarker < nMarker_InletFile; iMarker++) { - - /*--- Skip the tag, nRow, and nCol lines. ---*/ - - getline (inlet_file, text_line); - getline (inlet_file, text_line); - getline (inlet_file, text_line); - - /*--- Now read the data for each row and store. ---*/ - - for (iRow = 0; iRow < nRow_InletFile[iMarker]; iRow++) { - - getline (inlet_file, text_line); - - istringstream point_line(text_line); - - /*--- Store the values (starting with node coordinates) --*/ - - for (iVar = 0; iVar < nCol_InletFile[iMarker]; iVar++) - point_line >> Inlet_Data[counter*maxCol_InletFile + iVar]; - - /*--- Increment our local row counter. ---*/ - - counter++; - - } - } - } - } - - inlet_file.close(); - -} - void CSolver::LoadInletProfile(CGeometry **geometry, CSolver ***solver, CConfig *config, @@ -5133,11 +5006,38 @@ void CSolver::LoadInletProfile(CGeometry **geometry, string profile_filename = config->GetInlet_FileName(); ifstream inlet_file; - su2double *Inlet_Values = NULL; - su2double *Inlet_Fine = NULL; su2double *Normal = new su2double[nDim]; unsigned long Marker_Counter = 0; + + bool turbulent = (config->GetKind_Solver() == RANS || + config->GetKind_Solver() == INC_RANS || + config->GetKind_Solver() == ADJ_RANS || + config->GetKind_Solver() == DISC_ADJ_RANS || + config->GetKind_Solver() == DISC_ADJ_INC_RANS); + + unsigned short nVar_Turb = 0; + if (turbulent) + switch (config->GetKind_Turb_Model()) { + case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP: + nVar_Turb = 1; + break; + case SST: case SST_SUST: + nVar_Turb = 2; + break; + default: + SU2_MPI::Error("Specified turbulence model unavailable or none selected", CURRENT_FUNCTION); + break; + } + + /*--- Count the number of columns that we have for this flow case, + excluding the coordinates. Here, we have 2 entries for the total + conditions or mass flow, another nDim for the direction vector, and + finally entries for the number of turbulence variables. ---*/ + + unsigned short nCol_InletFile = 2 + nDim + nVar_Turb; + vector Inlet_Values(nCol_InletFile); + vector Inlet_Fine(nCol_InletFile); /*--- Multizone problems require the number of the zone to be appended. ---*/ @@ -5149,30 +5049,14 @@ void CSolver::LoadInletProfile(CGeometry **geometry, if (dual_time || time_stepping) profile_filename = config->GetUnsteady_FileName(profile_filename, val_iter, ".dat"); - /*--- Open the file and check for problems. If a file can not be found, - then a warning will be printed, but the calculation will continue - using the uniform inlet values. A template inlet file will be written - at a later point using COutput. ---*/ - - inlet_file.open(profile_filename.data(), ios::in); - - if (!inlet_file.fail()) { - - /*--- Close the file and start the loading. ---*/ - - inlet_file.close(); - /*--- Read the profile data from an ASCII file. ---*/ - Read_InletFile_ASCII(geometry[MESH_0], config, profile_filename); - + CMarkerProfileReaderFVM profileReader(geometry[MESH_0], config, profile_filename, KIND_MARKER, nCol_InletFile); + /*--- Load data from the restart into correct containers. ---*/ Marker_Counter = 0; - - Inlet_Values = new su2double[maxCol_InletFile]; - Inlet_Fine = new su2double[maxCol_InletFile]; - + unsigned short global_failure = 0, local_failure = 0; ostringstream error_msg; @@ -5185,16 +5069,22 @@ void CSolver::LoadInletProfile(CGeometry **geometry, Marker_Tag = config->GetMarker_All_TagBound(iMarker); - for (jMarker = 0; jMarker < nMarker_InletFile; jMarker++) { + for (jMarker = 0; jMarker < profileReader.GetNumberOfProfiles(); jMarker++) { /*--- If we have found the matching marker string, continue. ---*/ - if (Marker_Tags_InletFile[jMarker] == Marker_Tag) { + if (profileReader.GetTagForProfile(jMarker) == Marker_Tag) { /*--- Increment our counter for marker matches. ---*/ Marker_Counter++; + /*--- Get data for this profile. ---*/ + + vector Inlet_Data = profileReader.GetDataForProfile(jMarker); + + unsigned short nColumns = profileReader.GetNumberOfColumnsInProfile(jMarker); + /*--- Loop through the nodes on this marker. ---*/ for (iVertex = 0; iVertex < geometry[MESH_0]->nVertex[iMarker]; iVertex++) { @@ -5205,11 +5095,11 @@ void CSolver::LoadInletProfile(CGeometry **geometry, /*--- Find the distance to the closest point in our inlet profile data. ---*/ - for (iRow = nRowCum_InletFile[jMarker]; iRow < nRowCum_InletFile[jMarker+1]; iRow++) { + for (iRow = 0; iRow < profileReader.GetNumberOfRowsInProfile(jMarker); iRow++) { /*--- Get the coords for this data point. ---*/ - index = iRow*maxCol_InletFile; + index = iRow*nColumns; dist = 0.0; for (unsigned short iDim = 0; iDim < nDim; iDim++) @@ -5220,7 +5110,7 @@ void CSolver::LoadInletProfile(CGeometry **geometry, if (dist < min_dist) { min_dist = dist; - for (iVar = 0; iVar < maxCol_InletFile; iVar++) + for (iVar = 0; iVar < nColumns; iVar++) Inlet_Values[iVar] = Inlet_Data[index+iVar]; } @@ -5232,7 +5122,7 @@ void CSolver::LoadInletProfile(CGeometry **geometry, if (min_dist < tolerance) { - solver[MESH_0][KIND_SOLVER]->SetInletAtVertex(Inlet_Values, iMarker, iVertex); + solver[MESH_0][KIND_SOLVER]->SetInletAtVertex(Inlet_Values.data(), iMarker, iVertex); } else { @@ -5294,7 +5184,7 @@ void CSolver::LoadInletProfile(CGeometry **geometry, /*--- Reset the values for the coarse point. ---*/ - for (iVar = 0; iVar < maxCol_InletFile; iVar++) Inlet_Values[iVar] = 0.0; + for (iVar = 0; iVar < nCol_InletFile; iVar++) Inlet_Values[iVar] = 0.0; /*-- Loop through the children and extract the inlet values from those nodes that lie on the boundary as well as their @@ -5305,59 +5195,22 @@ void CSolver::LoadInletProfile(CGeometry **geometry, for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); - for (iVar = 0; iVar < maxCol_InletFile; iVar++) Inlet_Fine[iVar] = 0.0; - Area_Children = solver[iMesh-1][KIND_SOLVER]->GetInletAtVertex(Inlet_Fine, Point_Fine, KIND_MARKER, Marker_Tag, geometry[iMesh-1], config); - for (iVar = 0; iVar < maxCol_InletFile; iVar++) { + for (iVar = 0; iVar < nCol_InletFile; iVar++) Inlet_Fine[iVar] = 0.0; + Area_Children = solver[iMesh-1][KIND_SOLVER]->GetInletAtVertex(Inlet_Fine.data(), Point_Fine, KIND_MARKER, Marker_Tag, geometry[iMesh-1], config); + for (iVar = 0; iVar < nCol_InletFile; iVar++) { Inlet_Values[iVar] += Inlet_Fine[iVar]*Area_Children/Area_Parent; } } /*--- Set the boundary area-averaged inlet values for the coarse point. ---*/ - solver[iMesh][KIND_SOLVER]->SetInletAtVertex(Inlet_Values, iMarker, iVertex); + solver[iMesh][KIND_SOLVER]->SetInletAtVertex(Inlet_Values.data(), iMarker, iVertex); } } } } - - /*--- Delete the class memory that is used to load the inlets. ---*/ - - Marker_Tags_InletFile.clear(); - - if (nRowCum_InletFile != NULL) {delete [] nRowCum_InletFile; nRowCum_InletFile = NULL;} - if (nRow_InletFile != NULL) {delete [] nRow_InletFile; nRow_InletFile = NULL;} - if (nCol_InletFile != NULL) {delete [] nCol_InletFile; nCol_InletFile = NULL;} - if (Inlet_Data != NULL) {delete [] Inlet_Data; Inlet_Data = NULL;} - - } else { - - if (rank == MASTER_NODE) { - cout << endl; - cout << "WARNING: Could not find the input file for the inlet profile." << endl; - cout << "Looked for: " << profile_filename << "." << endl; - cout << "A template inlet profile file will be written, and the " << endl; - cout << "calculation will continue with uniform inlets." << endl << endl; - } - - /*--- Set the bit to write a template inlet profile file. ---*/ - - config->SetWrt_InletFile(true); - - /*--- Set the mean flow inlets to uniform. ---*/ - - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - solver[iMesh][KIND_SOLVER]->SetUniformInlet(config, iMarker); - } - } - - } - - /*--- Deallocated local data. ---*/ - - if (Inlet_Values != NULL) delete [] Inlet_Values; - if (Inlet_Fine != NULL) delete [] Inlet_Fine; + delete [] Normal; } diff --git a/SU2_DEF/src/meson.build b/SU2_DEF/src/meson.build index de64bb1c555f..065973d9db59 100644 --- a/SU2_DEF/src/meson.build +++ b/SU2_DEF/src/meson.build @@ -2,6 +2,7 @@ su2_def_src = ['SU2_DEF.cpp'] if get_option('enable-normal') su2_cfd_obj = su2_cfd.extract_objects(['solver_structure.cpp', + 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/CMeshOutput.cpp', 'output/output_structure_legacy.cpp', diff --git a/SU2_DOT/src/meson.build b/SU2_DOT/src/meson.build index 50396bb79251..ebb972f448bf 100644 --- a/SU2_DOT/src/meson.build +++ b/SU2_DOT/src/meson.build @@ -1,6 +1,7 @@ su2_dot_src = ['SU2_DOT.cpp'] if get_option('enable-normal') su2_cfd_obj = su2_cfd.extract_objects(['solver_structure.cpp', + 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/output_structure_legacy.cpp', 'output/CBaselineOutput.cpp', diff --git a/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj b/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj index bea57a72f95b..974fa93b558f 100644 --- a/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj +++ b/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj @@ -130,6 +130,7 @@ E984B6842345767900AEDA72 /* CSurfaceFEMDataSorter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E984B6762345767900AEDA72 /* CSurfaceFEMDataSorter.cpp */; }; E984B6852345767900AEDA72 /* CFVMDataSorter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E984B6772345767900AEDA72 /* CFVMDataSorter.cpp */; }; E984B6862345767900AEDA72 /* CParaviewBinaryFileWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E984B6782345767900AEDA72 /* CParaviewBinaryFileWriter.cpp */; }; + E9BDB82023512EB900092CCF /* CMarkerProfileReaderFVM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9BDB81F23512EB900092CCF /* CMarkerProfileReaderFVM.cpp */; }; E9C8307F2061E60E004417A9 /* fem_geometry_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C830752061E60E004417A9 /* fem_geometry_structure.cpp */; }; E9C830802061E60E004417A9 /* fem_integration_rules.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C830762061E60E004417A9 /* fem_integration_rules.cpp */; }; E9C830812061E60E004417A9 /* fem_standard_element.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9C830772061E60E004417A9 /* fem_standard_element.cpp */; }; @@ -422,6 +423,8 @@ E984B6A22345770000AEDA72 /* CSurfaceFVMDataSorter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CSurfaceFVMDataSorter.hpp; path = ../../SU2_CFD/include/output/filewriter/CSurfaceFVMDataSorter.hpp; sourceTree = ""; }; E984B6A32345770000AEDA72 /* CFileWriter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CFileWriter.hpp; path = ../../SU2_CFD/include/output/filewriter/CFileWriter.hpp; sourceTree = ""; }; E984B6A42345771900AEDA72 /* output_structure_legacy.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = output_structure_legacy.inl; path = ../../SU2_CFD/include/output/output_structure_legacy.inl; sourceTree = ""; }; + E9BDB81F23512EB900092CCF /* CMarkerProfileReaderFVM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMarkerProfileReaderFVM.cpp; path = ../../SU2_CFD/src/CMarkerProfileReaderFVM.cpp; sourceTree = ""; }; + E9BDB82123512F0300092CCF /* CMarkerProfileReaderFVM.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMarkerProfileReaderFVM.hpp; path = ../../SU2_CFD/include/CMarkerProfileReaderFVM.hpp; sourceTree = ""; }; E9C2835022A701B5007B4E59 /* CMMSNSTwoHalfSpheresSolution.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMMSNSTwoHalfSpheresSolution.hpp; path = ../../Common/include/toolboxes/MMS/CMMSNSTwoHalfSpheresSolution.hpp; sourceTree = ""; }; E9C2835122A701B5007B4E59 /* CMMSNSTwoHalfCirclesSolution.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMMSNSTwoHalfCirclesSolution.hpp; path = ../../Common/include/toolboxes/MMS/CMMSNSTwoHalfCirclesSolution.hpp; sourceTree = ""; }; E9C2835222A701B5007B4E59 /* CMMSIncEulerSolution.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMMSIncEulerSolution.hpp; path = ../../Common/include/toolboxes/MMS/CMMSIncEulerSolution.hpp; sourceTree = ""; }; @@ -524,6 +527,7 @@ isa = PBXGroup; children = ( E9D6EE662317B80600618E36 /* CDiscAdjMeshSolver.cpp */, + E9BDB81F23512EB900092CCF /* CMarkerProfileReaderFVM.cpp */, E9D6EE652317B80500618E36 /* CMeshSolver.cpp */, E941BB8D1B71D0D0005C6C06 /* solver_adjoint_discrete.cpp */, E9225F741FCBC36D002F3682 /* solver_adjoint_elasticity.cpp */, @@ -691,6 +695,7 @@ E97429E223235937006DA2D3 /* CInterface.hpp */, E9C2835722A701B5007B4E59 /* CInviscidVortexSolution.hpp */, E9E51AD722FA314F00773E0C /* CLinearPartitioner.hpp */, + E9BDB82123512F0300092CCF /* CMarkerProfileReaderFVM.hpp */, E9D6EE822317B8CC00618E36 /* CMeshBoundVariable.hpp */, E9D6EE7C2317B8CC00618E36 /* CMeshElement.hpp */, E984B690234576EA00AEDA72 /* CMeshOutput.hpp */, @@ -1181,6 +1186,7 @@ E97429DD23235921006DA2D3 /* CDisplacementsInterfaceLegacy.cpp in Sources */, E9C830822061E60E004417A9 /* fem_wall_distance.cpp in Sources */, E90B4FF922DFDFE4000ED392 /* CIncEulerVariable.cpp in Sources */, + E9BDB82023512EB900092CCF /* CMarkerProfileReaderFVM.cpp in Sources */, E90B500122DFDFE4000ED392 /* CEulerVariable.cpp in Sources */, E90B501022DFE043000ED392 /* CSysMatrix.cpp in Sources */, E9C8307F2061E60E004417A9 /* fem_geometry_structure.cpp in Sources */, diff --git a/SU2_SOL/src/meson.build b/SU2_SOL/src/meson.build index 4549eac3e034..2eef5a2f9a87 100644 --- a/SU2_SOL/src/meson.build +++ b/SU2_SOL/src/meson.build @@ -1,6 +1,7 @@ su2_sol_src = ['SU2_SOL.cpp'] if get_option('enable-normal') su2_cfd_obj = su2_cfd.extract_objects(['solver_structure.cpp', + 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/output_structure_legacy.cpp', 'output/CBaselineOutput.cpp', From f00292d841c28335ee455cd3977709a432f12ca0 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Sat, 12 Oct 2019 18:16:21 -0700 Subject: [PATCH 14/57] Adjusting min/max CFL. --- SU2_CFD/src/solver_structure.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 00a629d401b7..82683523665f 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -2397,10 +2397,10 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, if (CFL*CFLFactor <= CFLMin) { CFL = CFLMin; - CFLFactor = 1.001*MGFactor[iMesh]; + CFLFactor = MGFactor[iMesh]; } else if (CFL*CFLFactor >= CFLMax) { CFL = CFLMax; - CFLFactor = 0.999*MGFactor[iMesh]; + CFLFactor = MGFactor[iMesh]; } /* If we detect a stalled nonlinear residual, then force the CFL @@ -2408,7 +2408,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, if (reduceCFL) { CFL = CFLMin; - CFLFactor = 1.001*MGFactor[iMesh]; + CFLFactor = MGFactor[iMesh]; } /* Apply the adjustment to the CFL and store local values. */ From 81ee0047222b5ff937a30814668abb5e84a15eea Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Tue, 15 Oct 2019 12:05:15 -0700 Subject: [PATCH 15/57] Merged contiguous cvariable changes and fixed conflicts. --- Common/include/ad_structure.hpp | 47 +- Common/include/ad_structure.inl | 54 +- Common/include/config_structure.hpp | 33 +- Common/include/config_structure.inl | 10 +- Common/include/dual_grid_structure.hpp | 22 +- Common/include/geometry_structure.hpp | 24 +- Common/include/toolboxes/C2DContainer.hpp | 505 +++++ Common/include/toolboxes/CVertexMap.hpp | 141 ++ .../toolboxes/signal_processing_toolbox.hpp | 6 +- Common/src/ad_structure.cpp | 1 + Common/src/config_structure.cpp | 49 +- Common/src/dual_grid_structure.cpp | 68 +- Common/src/geometry_structure.cpp | 28 +- Common/src/grid_movement_structure.cpp | 8 +- Common/src/linear_algebra/CSysSolve.cpp | 6 +- Common/src/primal_grid_structure.cpp | 2 +- .../toolboxes/signal_processing_toolbox.cpp | 8 +- SU2_CFD/include/SU2_CFD.hpp | 1 + SU2_CFD/include/definition_structure.hpp | 5 +- .../drivers/CDiscAdjMultizoneDriver.hpp | 181 ++ SU2_CFD/include/drivers/CDriver.hpp | 2 +- SU2_CFD/include/numerics_structure.hpp | 13 +- SU2_CFD/include/numerics_structure.inl | 4 - SU2_CFD/include/output/CFlowCompFEMOutput.hpp | 9 - SU2_CFD/include/output/CFlowCompOutput.hpp | 9 - SU2_CFD/include/output/CFlowIncOutput.hpp | 9 - SU2_CFD/include/output/CFlowOutput.hpp | 7 + SU2_CFD/include/output/CHeatOutput.hpp | 20 +- SU2_CFD/include/output/COutput.hpp | 14 +- SU2_CFD/include/solver_structure.hpp | 479 ++--- SU2_CFD/include/solver_structure.inl | 23 +- .../include/solvers/CDiscAdjMeshSolver.hpp | 14 +- SU2_CFD/include/solvers/CMeshSolver.hpp | 16 +- .../include/variables/CAdjEulerVariable.hpp | 128 +- SU2_CFD/include/variables/CAdjNSVariable.hpp | 62 +- .../include/variables/CAdjTurbVariable.hpp | 37 +- .../include/variables/CBaselineVariable.hpp | 16 +- .../variables/CDiscAdjFEABoundVariable.hpp | 73 +- .../include/variables/CDiscAdjFEAVariable.hpp | 230 ++- .../variables/CDiscAdjMeshBoundVariable.hpp | 77 +- .../variables/CDiscAdjMeshVariable.hpp | 67 - .../include/variables/CDiscAdjVariable.hpp | 154 +- SU2_CFD/include/variables/CEulerVariable.hpp | 403 ++-- .../include/variables/CFEABoundVariable.hpp | 141 +- .../variables/CFEAFSIBoundVariable.hpp | 132 -- SU2_CFD/include/variables/CFEAVariable.hpp | 303 ++- .../include/variables/CHeatFVMVariable.hpp | 60 +- .../include/variables/CIncEulerVariable.hpp | 255 +-- SU2_CFD/include/variables/CIncNSVariable.hpp | 78 +- .../include/variables/CMeshBoundVariable.hpp | 71 +- SU2_CFD/include/variables/CMeshElement.hpp | 2 +- SU2_CFD/include/variables/CMeshVariable.hpp | 60 +- SU2_CFD/include/variables/CNSVariable.hpp | 124 +- .../include/variables/CTransLMVariable.hpp | 27 +- SU2_CFD/include/variables/CTurbSAVariable.hpp | 55 +- .../include/variables/CTurbSSTVariable.hpp | 44 +- SU2_CFD/include/variables/CTurbVariable.hpp | 63 +- SU2_CFD/include/variables/CVariable.hpp | 1724 +++++++++-------- SU2_CFD/obj/Makefile.am | 1 + SU2_CFD/src/SU2_CFD.cpp | 20 +- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 867 +++++++++ SU2_CFD/src/drivers/CDriver.cpp | 103 +- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- SU2_CFD/src/integration_structure.cpp | 69 +- SU2_CFD/src/integration_time.cpp | 98 +- .../cfd/CConservativeVarsInterface.cpp | 4 +- .../src/interfaces/cfd/CSlidingInterface.cpp | 6 +- .../cht/CConjugateHeatInterface.cpp | 169 +- .../CDiscAdjDisplacementsInterfaceLegacy.cpp | 2 +- .../fsi/CDiscAdjFlowTractionInterface.cpp | 3 +- .../fsi/CDisplacementsInterface.cpp | 4 +- .../fsi/CDisplacementsInterfaceLegacy.cpp | 4 +- .../interfaces/fsi/CFlowTractionInterface.cpp | 11 +- SU2_CFD/src/iteration_structure.cpp | 176 +- SU2_CFD/src/meson.build | 3 +- SU2_CFD/src/numerics_direct_mean.cpp | 6 + SU2_CFD/src/output/CAdjElasticityOutput.cpp | 8 +- SU2_CFD/src/output/CAdjFlowCompOutput.cpp | 46 +- SU2_CFD/src/output/CAdjFlowIncOutput.cpp | 86 +- SU2_CFD/src/output/CAdjHeatOutput.cpp | 19 +- SU2_CFD/src/output/CBaselineOutput.cpp | 6 +- SU2_CFD/src/output/CElasticityOutput.cpp | 34 +- SU2_CFD/src/output/CFlowCompFEMOutput.cpp | 29 - SU2_CFD/src/output/CFlowCompOutput.cpp | 97 +- SU2_CFD/src/output/CFlowIncOutput.cpp | 97 +- SU2_CFD/src/output/CFlowOutput.cpp | 84 +- SU2_CFD/src/output/CHeatOutput.cpp | 17 +- SU2_CFD/src/output/COutput.cpp | 21 + .../src/output/output_structure_legacy.cpp | 261 ++- SU2_CFD/src/python_wrapper_structure.cpp | 78 +- SU2_CFD/src/solver_adjoint_discrete.cpp | 219 ++- SU2_CFD/src/solver_adjoint_elasticity.cpp | 266 ++- SU2_CFD/src/solver_adjoint_mean.cpp | 440 +++-- SU2_CFD/src/solver_adjoint_turbulent.cpp | 88 +- SU2_CFD/src/solver_direct_elasticity.cpp | 542 +++--- SU2_CFD/src/solver_direct_heat.cpp | 334 ++-- SU2_CFD/src/solver_direct_mean.cpp | 975 +++++----- SU2_CFD/src/solver_direct_mean_inc.cpp | 799 ++++---- SU2_CFD/src/solver_direct_transition.cpp | 119 +- SU2_CFD/src/solver_direct_turbulent.cpp | 363 ++-- SU2_CFD/src/solver_structure.cpp | 763 ++++---- SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp | 109 +- SU2_CFD/src/solvers/CMeshSolver.cpp | 119 +- SU2_CFD/src/variables/CAdjEulerVariable.cpp | 250 +-- SU2_CFD/src/variables/CAdjNSVariable.cpp | 14 +- SU2_CFD/src/variables/CAdjTurbVariable.cpp | 45 +- SU2_CFD/src/variables/CBaselineVariable.cpp | 10 +- .../variables/CDiscAdjFEABoundVariable.cpp | 28 +- SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp | 214 +- .../variables/CDiscAdjMeshBoundVariable.cpp | 45 +- .../src/variables/CDiscAdjMeshVariable.cpp | 50 - SU2_CFD/src/variables/CDiscAdjVariable.cpp | 138 +- SU2_CFD/src/variables/CEulerVariable.cpp | 467 +---- SU2_CFD/src/variables/CFEABoundVariable.cpp | 47 +- .../src/variables/CFEAFSIBoundVariable.cpp | 75 - SU2_CFD/src/variables/CFEAVariable.cpp | 180 +- SU2_CFD/src/variables/CHeatFVMVariable.cpp | 73 +- SU2_CFD/src/variables/CIncEulerVariable.cpp | 328 +--- SU2_CFD/src/variables/CIncNSVariable.cpp | 121 +- SU2_CFD/src/variables/CMeshBoundVariable.cpp | 34 +- SU2_CFD/src/variables/CMeshElement.cpp | 4 - SU2_CFD/src/variables/CMeshVariable.cpp | 57 +- SU2_CFD/src/variables/CNSVariable.cpp | 257 ++- SU2_CFD/src/variables/CTransLMVariable.cpp | 19 +- SU2_CFD/src/variables/CTurbSAVariable.cpp | 36 +- SU2_CFD/src/variables/CTurbSSTVariable.cpp | 71 +- SU2_CFD/src/variables/CTurbVariable.cpp | 67 +- SU2_CFD/src/variables/CVariable.cpp | 248 +-- SU2_DEF/src/SU2_DEF.cpp | 2 +- SU2_DOT/src/SU2_DOT.cpp | 8 +- SU2_GEO/src/SU2_GEO.cpp | 2 +- .../Xcode/SU2_CFD.xcodeproj/project.pbxproj | 28 +- SU2_MSH/src/SU2_MSH.cpp | 2 +- SU2_PY/pySU2/Makefile.am | 6 +- SU2_SOL/src/SU2_SOL.cpp | 2 +- .../disc_adj_incomp_2d/cht_2d_3cylinders.cfg | 79 + .../disc_adj_incomp_2d/flow_cylinder.cfg | 258 +++ .../disc_adj_incomp_2d/solid_cylinder1.cfg | 186 ++ .../disc_adj_incomp_2d/solid_cylinder2.cfg | 196 ++ .../disc_adj_incomp_2d/solid_cylinder3.cfg | 196 ++ .../incomp_2d/cht_2d_3cylinders.cfg | 79 + .../coupled_cht/incomp_2d/flow_cylinder.cfg | 258 +++ .../coupled_cht/incomp_2d/solid_cylinder1.cfg | 186 ++ .../coupled_cht/incomp_2d/solid_cylinder2.cfg | 196 ++ .../coupled_cht/incomp_2d/solid_cylinder3.cfg | 196 ++ .../coupled_cht/incompressible/config.cfg | 25 - TestCases/disc_adj_fsi/Airfoil_2d/config.cfg | 2 +- .../cylinder/heated_cylinder.cfg | 2 +- TestCases/fea_fsi/Airfoil_RBF/config.cfg | 14 +- TestCases/fea_fsi/Airfoil_RBF/configFEA.cfg | 52 +- TestCases/fea_fsi/Airfoil_RBF/configFlow.cfg | 89 +- TestCases/fea_fsi/Airfoil_RBF/settings.cfg | 171 -- TestCases/parallel_regression.py | 8 +- TestCases/parallel_regression_AD.py | 17 +- TestCases/serial_regression.py | 10 +- TestCases/serial_regression_AD.py | 19 +- meson.build | 8 +- 157 files changed, 10344 insertions(+), 8602 deletions(-) create mode 100644 Common/include/toolboxes/C2DContainer.hpp create mode 100644 Common/include/toolboxes/CVertexMap.hpp create mode 100644 SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp delete mode 100644 SU2_CFD/include/variables/CDiscAdjMeshVariable.hpp delete mode 100644 SU2_CFD/include/variables/CFEAFSIBoundVariable.hpp create mode 100644 SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp delete mode 100644 SU2_CFD/src/variables/CDiscAdjMeshVariable.cpp delete mode 100644 SU2_CFD/src/variables/CFEAFSIBoundVariable.cpp create mode 100644 TestCases/coupled_cht/disc_adj_incomp_2d/cht_2d_3cylinders.cfg create mode 100644 TestCases/coupled_cht/disc_adj_incomp_2d/flow_cylinder.cfg create mode 100644 TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder1.cfg create mode 100644 TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder2.cfg create mode 100644 TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder3.cfg create mode 100644 TestCases/coupled_cht/incomp_2d/cht_2d_3cylinders.cfg create mode 100644 TestCases/coupled_cht/incomp_2d/flow_cylinder.cfg create mode 100644 TestCases/coupled_cht/incomp_2d/solid_cylinder1.cfg create mode 100644 TestCases/coupled_cht/incomp_2d/solid_cylinder2.cfg create mode 100644 TestCases/coupled_cht/incomp_2d/solid_cylinder3.cfg delete mode 100644 TestCases/coupled_cht/incompressible/config.cfg delete mode 100644 TestCases/fea_fsi/Airfoil_RBF/settings.cfg diff --git a/Common/include/ad_structure.hpp b/Common/include/ad_structure.hpp index 2826b3f41b0d..822d68b0022e 100644 --- a/Common/include/ad_structure.hpp +++ b/Common/include/ad_structure.hpp @@ -65,17 +65,42 @@ namespace AD{ bool TapeActive(); /*! - * \brief Registers the variable as an input. I.e. as a leaf of the computational graph. + * \brief Prints out tape statistics. + */ + void PrintStatistics(); + + /*! + * \brief Registers the variable as an input and saves internal data (indices). I.e. as a leaf of the computational graph. * \param[in] data - The variable to be registered as input. */ void RegisterInput(su2double &data); + /*! + * \brief Registers the variable as an input. I.e. as a leaf of the computational graph. + * \param[in] data - The variable to be registered as input. + */ + void RegisterInput_intIndexBased(su2double &data); + /*! * \brief Registers the variable as an output. I.e. as the root of the computational graph. * \param[in] data - The variable to be registered as output. */ void RegisterOutput(su2double &data); + /*! + * \brief Sets the adjoint value at index to val + * \param[in] index - Position in the adjoint vector. + * \param[in] val - adjoint value to be set. + */ + void SetDerivative(int index, const double val); + + /*! + * \brief Extracts the adjoint value at index + * \param[in] index - position in the adjoint vector where the derivative will be extracted. + * \return Derivative value. + */ + double GetDerivative(int index); + /*! * \brief Clears the currently stored adjoints but keeps the computational graph. */ @@ -84,7 +109,14 @@ namespace AD{ /*! * \brief Computes the adjoints, i.e. the derivatives of the output with respect to the input variables. */ - void ComputeAdjoint(); + void ComputeAdjoint(); + + /*! + * \brief Computes the adjoints, i.e. the derivatives of the output with respect to the input variables. + * \param[in] enter - Position where we start evaluating the tape. + * \param[in] leave - Position where we stop evaluating the tape. + */ + void ComputeAdjoint(unsigned short enter, unsigned short leave); /*! * \brief Reset the tape structure to be ready for a new recording. @@ -209,6 +241,17 @@ namespace AD{ */ void EndExtFunc(); + /*! + * \brief Evaluates and saves gradient data from a variable. + * \param[in] data - variable whose gradient information will be extracted. + * \param[in] index - where obtained gradient information will be stored. + */ + void SetAdjIndex(int &index, const su2double &data); + + /*! + * \brief Pushes back the current tape position to the tape position's vector. + */ + void Push_TapePosition(); } /*--- Macro to begin and end sections with a passive tape ---*/ diff --git a/Common/include/ad_structure.inl b/Common/include/ad_structure.inl index 648e896a301b..ad8184f4c3cf 100644 --- a/Common/include/ad_structure.inl +++ b/Common/include/ad_structure.inl @@ -68,6 +68,8 @@ namespace AD{ extern su2double::TapeType::Position StartPosition, EndPosition; + extern std::vector TapePositions; + extern std::vector localInputValues; extern std::vector localOutputValues; @@ -77,6 +79,8 @@ namespace AD{ inline void RegisterInput(su2double &data) {AD::globalTape.registerInput(data); inputValues.push_back(data.getGradientData());} + inline void RegisterInput_intIndexBased(su2double &data) {AD::globalTape.registerInput(data);} + inline void RegisterOutput(su2double& data) {AD::globalTape.registerOutput(data);} inline void ResetInput(su2double &data) {data.getGradientData() = su2double::GradientData();} @@ -85,19 +89,43 @@ namespace AD{ inline void StopRecording() {AD::globalTape.setPassive();} - inline bool TapeActive() {return AD::globalTape.isActive();} + inline bool TapeActive() { return AD::globalTape.isActive(); } + + inline void PrintStatistics() {AD::globalTape.printStatistics();} inline void ClearAdjoints() {AD::globalTape.clearAdjoints(); } inline void ComputeAdjoint() {AD::globalTape.evaluate(); adjointVectorPosition = 0;} + inline void ComputeAdjoint(unsigned short enter, unsigned short leave) { + AD::globalTape.evaluate(TapePositions[enter], TapePositions[leave]); + if (leave == 0) { + adjointVectorPosition = 0; + } + } + inline void Reset() { + globalTape.reset(); if (inputValues.size() != 0) { - globalTape.reset(); adjointVectorPosition = 0; inputValues.clear(); } + if (TapePositions.size() != 0) { + TapePositions.clear(); + } + } + + inline void SetAdjIndex(int &index, const su2double &data) { + index = data.getGradientData(); + } + + inline void SetDerivative(int index, const double val) { + AD::globalTape.setGradient(index, val); + } + + inline double GetDerivative(int index) { + return AD::globalTape.getGradient(index); } inline void SetPreaccIn(const su2double &data) { @@ -167,6 +195,10 @@ namespace AD{ } } + inline void Push_TapePosition() { + TapePositions.push_back(AD::globalTape.getPosition()); + } + inline void EndPreacc(){ if (PreaccActive) { PreaccHelper.finish(false); @@ -239,18 +271,30 @@ namespace AD{ inline void RegisterInput(su2double &data) {} + inline void RegisterInput_intIndexBased(su2double &data) {} + inline void RegisterOutput(su2double& data) {} inline void StartRecording() {} inline void StopRecording() {} - inline bool TapeActive() {return false;} + inline bool TapeActive() { return false; } + + inline void PrintStatistics() {} inline void ClearAdjoints() {} inline void ComputeAdjoint() {} + inline void ComputeAdjoint(unsigned short enter, unsigned short leave) {} + + inline void SetAdjIndex(int &index, const su2double &data) {} + + inline void SetDerivative(int index, const double val) {} + + inline double GetDerivative(int position) { return 0.0; } + inline void Reset() {} inline void ResetInput(su2double &data) {} @@ -270,7 +314,9 @@ namespace AD{ inline void StartPreacc() {} inline void EndPreacc() {} - + + inline void Push_TapePosition() {} + inline void StartExtFunc(bool storePrimalInput, bool storePrimalOutput){} inline void SetExtFuncIn(const su2double &data) {} diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index 78fce2f2c317..c0aa01a7aea6 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -417,7 +417,6 @@ class CConfig { CFLRedCoeff_AdjFlow, /*!< \brief CFL reduction coefficient for the adjoint problem. */ CFLRedCoeff_AdjTurb, /*!< \brief CFL reduction coefficient for the adjoint problem. */ CFLFineGrid, /*!< \brief CFL of the finest grid. */ - CFLSolid, /*!< \brief CFL in (heat) solid solvers. */ Max_DeltaTime, /*!< \brief Max delta time. */ Unst_CFL; /*!< \brief Unsteady CFL number. */ bool ReorientElements; /*!< \brief Flag for enabling element reorientation. */ @@ -761,6 +760,7 @@ class CConfig { Wrt_SharpEdges, /*!< \brief Write residuals to solution file */ Wrt_Halo, /*!< \brief Write rind layers in solution files */ Wrt_Performance, /*!< \brief Write the performance summary at the end of a calculation. */ + Wrt_AD_Statistics, /*!< \brief Write the tape statistics (discrete adjoint). */ Wrt_MeshQuality, /*!< \brief Write the mesh quality statistics to the visualization files. */ Wrt_Slice, /*!< \brief Write 1D slice of a 2D cartesian solution */ Wrt_Projected_Sensitivity, /*!< \brief Write projected sensitivities (dJ/dx) on surfaces to ASCII file. */ @@ -876,6 +876,7 @@ class CConfig { bool Sine_Load; /*!< \brief option for sine load */ su2double *SineLoad_Coeff; /*!< \brief Stores the load coefficient */ su2double Thermal_Diffusivity; /*!< \brief Thermal diffusivity used in the heat solver. */ + bool CHT_Robin; /*!< \brief Option for boundary condition method at CHT interfaces. */ su2double Cyclic_Pitch, /*!< \brief Cyclic pitch for rotorcraft simulations. */ Collective_Pitch; /*!< \brief Collective pitch for rotorcraft simulations. */ su2double Mach_Motion; /*!< \brief Mach number based on mesh velocity and freestream quantities. */ @@ -977,7 +978,8 @@ class CConfig { Nonphys_Reconstr; /*!< \brief Current number of non-physical reconstructions for 2nd-order upwinding. */ bool ParMETIS; /*!< \brief Boolean for activating ParMETIS mode (while testing). */ unsigned short DirectDiff; /*!< \brief Direct Differentation mode. */ - bool DiscreteAdjoint; /*!< \brief AD-based discrete adjoint mode. */ + bool DiscreteAdjoint, /*!< \brief AD-based discrete adjoint mode. */ + FullTape; /*!< \brief Full tape mode for coupled discrete adjoints. */ unsigned long Wrt_Surf_Freq_DualTime; /*!< \brief Writing surface solution frequency for Dual Time. */ su2double Const_DES; /*!< \brief Detached Eddy Simulation Constant. */ unsigned short Kind_HybridRANSLES; /*!< \brief Kind of Hybrid RANS/LES. */ @@ -1406,7 +1408,7 @@ class CConfig { /*! * \brief Constructor of the class which reads the input file. */ - CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software, unsigned short val_nZone, bool verb_high); + CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software, bool verb_high); /*! * \brief Constructor of the class which reads the input file and uses default options from another config. @@ -2765,13 +2767,6 @@ class CConfig { * \return CFL number for each grid. */ su2double GetCFL(unsigned short val_mesh); - - /*! - * \brief Get the Courant Friedrich Levi number for solid solvers. - * \param[in] val_mesh - Index of the mesh were the CFL is applied. - * \return CFL number for each grid. - */ - su2double GetCFL_Solid(void); /*! * \brief Get the Courant Friedrich Levi number for each grid. @@ -3260,6 +3255,12 @@ class CConfig { * \return TRUE means that the performance summary will be written at the end of a calculation. */ bool GetWrt_Performance(void); + + /*! + * \brief Get information about the computational graph (e.g. memory usage) when using AD in reverse mode. + * \return TRUE means that the tape statistics will be written after each recording. + */ + bool GetWrt_AD_Statistics(void); /*! * \brief Get information about writing the mesh quality metrics to the visualization files. @@ -8448,6 +8449,12 @@ class CConfig { * \return the discrete adjoint indicator. */ bool GetDiscrete_Adjoint(void); + + /*! + * \brief Get the indicator whether we want to use full (coupled) tapes. + * \return the full tape indicator. + */ + bool GetFull_Tape(void); /*! * \brief Get the indicator whether we want to benchmark the MPI performance of FSI problems @@ -8954,6 +8961,12 @@ class CConfig { */ bool GetWeakly_Coupled_Heat(void); + /*! + * \brief Get the boundary condition method for CHT. + * \return YES if Robin BC is used. + */ + bool GetCHT_Robin(void); + /*! * \brief Check if values passed to the BC_HeatFlux-Routine are already integrated. * \return YES if the passed values is the integrated heat flux over the marker's surface. diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl index e5af07442666..18aab50d13f9 100644 --- a/Common/include/config_structure.inl +++ b/Common/include/config_structure.inl @@ -753,8 +753,6 @@ inline unsigned short CConfig::GetGeometryMode(void) { return GeometryMode; } inline su2double CConfig::GetCFL(unsigned short val_mesh) { return CFL[val_mesh]; } -inline su2double CConfig::GetCFL_Solid(void) { return CFLSolid; } - inline void CConfig::SetCFL(unsigned short val_mesh, su2double val_cfl) { CFL[val_mesh] = val_cfl; } inline su2double CConfig::GetUnst_CFL(void) { return Unst_CFL; } @@ -1675,6 +1673,8 @@ inline bool CConfig::GetWrt_Halo(void) { return Wrt_Halo; } inline bool CConfig::GetWrt_Performance(void) { return Wrt_Performance; } +inline bool CConfig::GetWrt_AD_Statistics(void) { return Wrt_AD_Statistics; } + inline bool CConfig::GetWrt_MeshQuality(void) { return Wrt_MeshQuality; } inline bool CConfig::GetWrt_Slice(void) { return Wrt_Slice; } @@ -1879,7 +1879,7 @@ inline bool CConfig::GetEulerPersson(void) { return EulerPersson; } inline void CConfig::SetEulerPersson(bool val_EulerPersson) { EulerPersson = val_EulerPersson; } -inline bool CConfig::GetFSI_Simulation(void) { return FSI_Problem; } +inline bool CConfig::GetFSI_Simulation(void) { return FSI_Problem || (nMarker_Fluid_Load > 0); } inline void CConfig::SetFSI_Simulation(bool FSI_sim) { FSI_Problem = FSI_sim; } @@ -1907,6 +1907,8 @@ inline unsigned short CConfig::GetDirectDiff() { return DirectDiff;} inline bool CConfig::GetDiscrete_Adjoint() { return DiscreteAdjoint;} +inline bool CConfig::GetFull_Tape() { return FullTape; } + inline unsigned short CConfig::GetRiemann_Solver_FEM(void) {return Riemann_Solver_FEM;} inline su2double CConfig::GetQuadrature_Factor_Straight(void) {return Quadrature_Factor_Straight;} @@ -1927,6 +1929,8 @@ inline bool CConfig::GetJacobian_Spatial_Discretization_Only(void) {return Jacob inline bool CConfig::GetWeakly_Coupled_Heat(void) { return Weakly_Coupled_Heat; } +inline bool CConfig::GetCHT_Robin(void) { return CHT_Robin; } + inline bool CConfig::GetIntegrated_HeatFlux(void) { return Integrated_HeatFlux; } inline bool CConfig::GetAD_Mode(void) { return AD_Mode;} diff --git a/Common/include/dual_grid_structure.hpp b/Common/include/dual_grid_structure.hpp index d749a0a55702..94bd81a44f37 100644 --- a/Common/include/dual_grid_structure.hpp +++ b/Common/include/dual_grid_structure.hpp @@ -176,6 +176,8 @@ class CPoint : public CDualGrid { unsigned short nNeighbor; /*!< \brief Number of neighbors. */ bool Flip_Orientation; /*!< \brief Flip the orientation of the normal. */ su2double MaxLength; /*!< \brief The maximum cell-center to cell-center length. */ + int *Input_AdjIndices, /*!< \brief Indices of Coord variables in the adjoint vector. */ + *Output_AdjIndices; /*!< \brief Indices of Coord variables in the adjoint vector after having been updated. */ public: @@ -289,7 +291,25 @@ class CPoint : public CDualGrid { * \param[in] val_dim - Position to store the coordinate. * \param[in] val_coord - Coordinate for val_dim. */ - void SetCoord(unsigned short val_dim, su2double val_coord); + void SetCoord(unsigned short val_dim, su2double val_coord); + + /*! + * \brief Set the adjoint vector indices of Coord vector. + * \param[in] input - Save them to the input or output indices vector. + */ + void SetAdjIndices(bool input); + + /*! + * \brief Set the adjoint values of the (geometric) coordinates. + * \param[in] adj_sol - Adjoint values of the Coord variables. + */ + void SetAdjointSolution(const su2double *adj_sol); + + /*! + * \brief Get the adjoint values of the (geometric) coordinates. + * \param[in] adj_sol - Adjoint values of the Coord variables. + */ + su2double GetAdjointSolution(unsigned short iDim); /*! * \brief Get the coordinates of the control volume. diff --git a/Common/include/geometry_structure.hpp b/Common/include/geometry_structure.hpp index bc8d00bc2077..5632a2b82325 100644 --- a/Common/include/geometry_structure.hpp +++ b/Common/include/geometry_structure.hpp @@ -926,19 +926,19 @@ class CGeometry { */ virtual void SetCoord(CGeometry *geometry); - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] val_marker - Index of the boundary marker. - */ - virtual void SetMultiGridWallHeatFlux(CGeometry *geometry, unsigned short val_marker); + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] val_marker - Index of the boundary marker. + */ + virtual void SetMultiGridWallHeatFlux(CGeometry *geometry, unsigned short val_marker); - /*! - * \brief A virtual member. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] val_marker - Index of the boundary marker. - */ - virtual void SetMultiGridWallTemperature(CGeometry *geometry, unsigned short val_marker); + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] val_marker - Index of the boundary marker. + */ + virtual void SetMultiGridWallTemperature(CGeometry *geometry, unsigned short val_marker); /*! * \brief A virtual member. diff --git a/Common/include/toolboxes/C2DContainer.hpp b/Common/include/toolboxes/C2DContainer.hpp new file mode 100644 index 000000000000..3924a35c7729 --- /dev/null +++ b/Common/include/toolboxes/C2DContainer.hpp @@ -0,0 +1,505 @@ +/*! + * \file C2DContainer.hpp + * \brief A templated vector/matrix object. + * \author P. Gomes + * \version 6.2.0 "Falcon" + * + * The current SU2 release has been coordinated by the + * SU2 International Developers Society + * with selected contributions from the open-source community. + * + * The main research teams contributing to the current release are: + * - Prof. Juan J. Alonso's group at Stanford University. + * - Prof. Piero Colonna's group at Delft University of Technology. + * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. + * - Prof. Alberto Guardone's group at Polytechnic University of Milan. + * - Prof. Rafael Palacios' group at Imperial College London. + * - Prof. Vincent Terrapon's group at the University of Liege. + * - Prof. Edwin van der Weide's group at the University of Twente. + * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. + * + * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, + * Tim Albring, and the SU2 contributors. + * + * 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 . + */ + +#pragma once + +#include +#include +#include + +/*! + * \enum StorageType + * \brief Supported ways to flatten a matrix into an array. + * Contiguous rows or contiguous columns respectively. + */ +enum class StorageType {RowMajor=0, ColumnMajor=1}; + +/*! + * \enum SizeType + * \brief Special value "DynamicSize" to indicate a dynamic size. + */ +enum SizeType : size_t {DynamicSize=0}; + + +/*--- Namespace to "hide" helper classes and + functions used by the container class. ---*/ +namespace container_helpers +{ +/*! + * \class AccessorImpl + * \brief Base accessor class and version of template for both sizes known at compile time. + * + * The actual container inherits from this class, this is to reduce the number of + * methods that need to be redefined with each size specialization. + */ +template +class AccessorImpl +{ + static_assert(!(StaticRows==1 && Store==StorageType::ColumnMajor), + "Row vector should have row-major storage."); + static_assert(!(StaticCols==1 && Store==StorageType::RowMajor), + "Column vector should have column-major storage."); +protected: + /*! + * For static specializations AlignSize will force the alignment + * specification of the entire class, not just the data. + */ + alignas(AlignSize) Scalar_t m_data[StaticRows*StaticCols]; + + /*! + * Static size specializations use this do-nothing macro. + */ +#define DUMMY_ALLOCATOR \ + void m_allocate(size_t sz, Index_t rows, Index_t cols) noexcept {} + /*! + * Dynamic size specializations use this one, EXTRA is used to set some + * runtime internal value that depend on the number of rows/columns. + * What values need setting depends on the specialization as not all have + * members for e.g. number of rows and cols (static size optimization). + */ +#define REAL_ALLOCATOR(EXTRA) \ + static_assert(AlignSize % alignof(Scalar_t)==0, \ + "AlignSize is not a multiple of the type's alignment spec."); \ + \ + void m_allocate(size_t sz, Index_t rows, Index_t cols) noexcept { \ + EXTRA; \ + if(AlignSize==0) \ + m_data = static_cast(malloc(sz)); \ + else \ + m_data = static_cast(aligned_alloc(AlignSize,sz)); \ + } + + DUMMY_ALLOCATOR + +public: + /*! + * Dynamic types need to manage internal data as the derived class would + * not compile if it tried to set m_data to null on static specializations. + * Move construct/assign are enabled by transferring ownership of data + * pointer, the rvalue is left in the empty state. + * The default ctor needs to "INIT" some fields. The move ctor/assign need + * to "MOVE" those fields, i.e. copy and set "other" appropriately. + */ +#define CUSTOM_CTOR_AND_DTOR_BASE(INIT,MOVE) \ + AccessorImpl() noexcept : m_data(nullptr) {INIT;} \ + \ + AccessorImpl(AccessorImpl&& other) noexcept \ + { \ + MOVE; m_data=other.m_data; other.m_data=nullptr; \ + } \ + \ + AccessorImpl& operator= (AccessorImpl&& other) noexcept \ + { \ + if(m_data!=nullptr) free(m_data); \ + MOVE; m_data=other.m_data; other.m_data=nullptr; \ + return *this; \ + } \ + \ + ~AccessorImpl() {if(m_data!=nullptr) free(m_data);} + /*! + * Shorthand for when specialization has only one more member than m_data. + */ +#define CUSTOM_CTOR_AND_DTOR(X) \ + CUSTOM_CTOR_AND_DTOR_BASE(X=0, X=other.X; other.X=0) + + /*! + * Universal accessors return a raw pointer to the data. + */ +#define UNIV_ACCESSORS \ + bool empty() const noexcept {return size()==0;} \ + Scalar_t* data() noexcept {return m_data;} \ + const Scalar_t* data() const noexcept {return m_data;} + + /*! + * Operator (,) gives pointwise access, operator [] returns a pointer to the + * first element of the row/column of a row/column-major matrix respectively. + */ +#define MATRIX_ACCESSORS(M,N) \ + UNIV_ACCESSORS \ + Index_t rows() const noexcept {return M;} \ + Index_t cols() const noexcept {return N;} \ + size_t size() const noexcept {return M*N;} \ + \ + const Scalar_t& operator() (const Index_t i, \ + const Index_t j) const noexcept \ + { \ + assert(i>=0 && i=0 && j( const_this(i,j) ); \ + } \ + \ + const Scalar_t* operator[] (const Index_t k) const noexcept \ + { \ + if(Store == StorageType::RowMajor) { \ + assert(k>=0 && k=0 && k( const_this[k] ); \ + } + + /*! + * Vectors do not provide operator [] as it is redundant + * since operator () already returns by reference. + */ +#define VECTOR_ACCESSORS(M,ROWMAJOR) \ + UNIV_ACCESSORS \ + Index_t rows() const noexcept {return ROWMAJOR? 1 : M;} \ + Index_t cols() const noexcept {return ROWMAJOR? M : 1;} \ + size_t size() const noexcept {return M;} \ + \ + Scalar_t& operator() (const Index_t i) noexcept \ + { \ + assert(i>=0 && i=0 && i +class AccessorImpl +{ + static_assert(!(StaticCols==1 && Store==StorageType::RowMajor), + "Column vector should have column-major storage."); +protected: + Index_t m_rows; + Scalar_t* m_data; + + REAL_ALLOCATOR(m_rows=rows) + +public: + CUSTOM_CTOR_AND_DTOR(m_rows) + + MATRIX_ACCESSORS(m_rows,StaticCols) +}; + +/*! + * Specialization for compile-time number of columns. + */ +template +class AccessorImpl +{ + static_assert(!(StaticRows==1 && Store==StorageType::ColumnMajor), + "Row vector should have row-major storage."); +protected: + Index_t m_cols; + Scalar_t* m_data; + + REAL_ALLOCATOR(m_cols=cols) + +public: + CUSTOM_CTOR_AND_DTOR(m_cols) + + MATRIX_ACCESSORS(StaticRows,m_cols) +}; + +/*! + * Specialization for fully dynamic sizes (generic matrix). + */ +template +class AccessorImpl +{ +protected: + Index_t m_rows, m_cols; + Scalar_t* m_data; + + REAL_ALLOCATOR(m_rows=rows; m_cols=cols) + +public: + CUSTOM_CTOR_AND_DTOR_BASE(m_rows = 0; m_cols = 0, + m_rows = other.m_rows; other.m_rows = 0; + m_cols = other.m_cols; other.m_cols = 0) + + MATRIX_ACCESSORS(m_rows,m_cols) +}; + +/*! + * Specialization for static column-vector. + */ +template +class AccessorImpl +{ +protected: + alignas(AlignSize) Scalar_t m_data[StaticRows]; + + DUMMY_ALLOCATOR + +public: + VECTOR_ACCESSORS(StaticRows,false) +}; + +/*! + * Specialization for dynamic column-vector. + */ +template +class AccessorImpl +{ +protected: + Index_t m_rows; + Scalar_t* m_data; + + REAL_ALLOCATOR(m_rows=rows) + +public: + CUSTOM_CTOR_AND_DTOR(m_rows) + + VECTOR_ACCESSORS(m_rows,false) +}; + +/*! + * Specialization for static row-vector. + */ +template +class AccessorImpl +{ +protected: + alignas(AlignSize) Scalar_t m_data[StaticCols]; + + DUMMY_ALLOCATOR + +public: + VECTOR_ACCESSORS(StaticCols,true) +}; + +/*! + * Specialization for dynamic row-vector. + */ +template +class AccessorImpl +{ +protected: + Index_t m_cols; + Scalar_t* m_data; + + REAL_ALLOCATOR(m_cols=cols) + +public: + CUSTOM_CTOR_AND_DTOR(m_cols) + + VECTOR_ACCESSORS(m_cols,true) +}; + +#undef CUSTOM_CTOR_AND_DTOR_BASE +#undef CUSTOM_CTOR_AND_DTOR +#undef DUMMY_ALLOCATOR +#undef REAL_ALLOCATOR +#undef MATRIX_ACCESSORS +#undef VECTOR_ACCESSORS +#undef UNIV_ACCESSORS +} + +/*! + * \class C2DContainer + * \brief A templated matrix/vector-like object. + * + * See notes about MATRIX_ACCESSORS and VECTOR_ACCESSORS for how to access data. + * For how to construct/resize/initialize see methods below. + * + * Template parameters: + * + * \param Index_t - The data type (built-in) for indices, signed and unsigned allowed. + * \param Scalar_t - The stored data type, anything that can be default constructed. + * \param Store - Mode to map 1D to 2D, row-major or column-major. + * \param AlignSize - Desired alignment for the data in bytes, 0 means default. + * \param StaticRows - Number of rows at compile time, for dynamic (sized at runtime) use "DynamicSize". + * \param StaticCols - As above for columns. + * + * \note All accesses to data are range checked via assertions, for + * release compile with -DNDEBUG to avoid the associated overhead. + * + */ +template +class C2DContainer : + public container_helpers::AccessorImpl +{ +private: + using Base = container_helpers::AccessorImpl; + using Base::m_data; + using Base::m_allocate; +public: + using Base::size; + +private: + /*! + * \brief Logic to resize data according to arguments, a non DynamicSize cannot be changed. + */ + size_t m_resize(Index_t rows, Index_t cols) noexcept + { + /*--- fully static, no allocation needed ---*/ + if(StaticRows!=DynamicSize && StaticCols!=DynamicSize) + return StaticRows*StaticCols; + + /*--- dynamic row vector, swap size specification ---*/ + if(StaticRows==1 && StaticCols==DynamicSize) {cols = rows; rows = 1;} + + /*--- assert a static size is not being asked to change ---*/ + if(StaticRows!=DynamicSize) assert(rows==StaticRows && "A static size was asked to change."); + if(StaticCols!=DynamicSize) assert(cols==StaticCols && "A static size was asked to change."); + + /*--- "rectify" sizes before continuing as asserts are usually dissabled ---*/ + rows = (StaticRows!=DynamicSize)? StaticRows : rows; + cols = (StaticCols!=DynamicSize)? StaticCols : cols; + + /*--- number of requested elements ---*/ + size_t reqSize = rows*cols; + + /*--- compare with current dimensions to determine if deallocation + is needed, also makes the container safe against self assignment + no need to check for 0 size as the allocators handle that ---*/ + if(m_data!=nullptr) + { + if(rows==this->rows() && cols==this->cols()) + return reqSize; + free(m_data); + } + + /*--- round up size to a multiple of the alignment specification if necessary ---*/ + size_t bytes = reqSize*sizeof(Scalar_t); + size_t allocSize = (AlignSize==0)? bytes : ((bytes+AlignSize-1)/AlignSize)*AlignSize; + + /*--- request actual allocation to base class as it needs specialization ---*/ + m_allocate(allocSize,rows,cols); + + return reqSize; + } + +public: + /*! + * \brief Default ctor. + */ + C2DContainer() noexcept : Base() {} + + /*! + * \brief Sizing ctor (no initialization of data). + * For matrices size1 is rows and size2 columns, for vectors size1 is lenght and size2 is ignored. + */ + C2DContainer(const Index_t size1, const Index_t size2 = 1) noexcept : + Base() {m_resize(size1,size2);} + + /*! + * \brief Copy ctor. + */ + C2DContainer(const C2DContainer& other) noexcept : Base() + { + size_t sz = m_resize(other.rows(),other.cols()); + for(size_t i=0; i using su2vector = C2DContainer; +template using su2matrix = C2DContainer; + +using su2activevector = su2vector; +using su2activematrix = su2matrix; + +using su2passivevector = su2vector; +using su2passivematrix = su2matrix; diff --git a/Common/include/toolboxes/CVertexMap.hpp b/Common/include/toolboxes/CVertexMap.hpp new file mode 100644 index 000000000000..65cfa9ded4dc --- /dev/null +++ b/Common/include/toolboxes/CVertexMap.hpp @@ -0,0 +1,141 @@ +/*! + * \file CVertexMap.hpp + * \brief An index to index lookup vector. + * \author P. Gomes + * \version 6.2.0 "Falcon" + * + * The current SU2 release has been coordinated by the + * SU2 International Developers Society + * with selected contributions from the open-source community. + * + * The main research teams contributing to the current release are: + * - Prof. Juan J. Alonso's group at Stanford University. + * - Prof. Piero Colonna's group at Delft University of Technology. + * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. + * - Prof. Alberto Guardone's group at Polytechnic University of Milan. + * - Prof. Rafael Palacios' group at Imperial College London. + * - Prof. Vincent Terrapon's group at the University of Liege. + * - Prof. Edwin van der Weide's group at the University of Twente. + * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. + * + * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, + * Tim Albring, and the SU2 contributors. + * + * 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 . + */ + +#pragma once + +#include "C2DContainer.hpp" +#include +#include + +/*! + * \class CVertexMap + * \brief A lookup type map, maps indices in a large range to indices in a smaller one. + * + * The usage case is: + * 1 - Initialize via Reset for the large range size. + * 2 - Use SetIsVertex to define what large range indices have small range correspondence. + * 3 - Call Build, vertices are given a sequential index in increasing order of iPoint, + * not in order of calls to SetIsVertex. Keep this in mind when allocating vertex data. + * 4 - Use GetVertexIndex to convert a point index to vertex index. + * + * Only consider using this class if you have no reasonable way to keep track of vertices. + * For example if you need to assume every point might be a vertex, but you do not want to + * allocate data for the entire set of points. + * + * \note For efficiency use the smallest type that can fit the maximum number of vertices. + */ +template +class CVertexMap { + static_assert(std::is_unsigned::value && std::is_integral::value, + "Vertex map requires an unsigned integral type (e.g. unsigned)."); + + private: + su2vector Map; /*!< \brief Map from range 0-(nPoint-1) to 1-nVertex. */ + bool isValid = false; /*!< \brief Set to true when it is safe to use the accessors. */ + T nVertex = 0; /*!< \brief Number of vertices. */ + + public: + /*! + * \brief Check if the current mapping is valid. + */ + inline bool GetIsValid() const { return isValid; } + + /*! + * \brief Get the number of vertices currently mapped. + */ + inline T GetnVertex() const { return nVertex; } + + /*! + * \brief Reset the map for size nPoint, marks every point as not-a-vertex. + */ + void Reset(unsigned long nPoint) { + Map.resize(nPoint) = 0; + nVertex = 0; + isValid = true; + } + + /*! + * \brief Set the vertex status of a point. + */ + inline bool SetIsVertex(unsigned long iPoint, bool isVertex) { + /*--- Invalidate map if change is requested as that destroys it. ---*/ + if (isVertex != bool(Map(iPoint))) { + isValid = false; + Map(iPoint) = T(isVertex); + } + return isValid; + } + + /*! + * \brief Get wheter a point is marked as vertex. + */ + inline bool GetIsVertex(unsigned long iPoint) const { + return (Map(iPoint) != 0); + } + + /*! + * \brief Build the point to vertex map. + */ + T Build() { + if (!isValid) { + /*--- The map is 1 based, the accessors correct + accordingly when returning vertex indices. ---*/ + nVertex = 0; + + for (unsigned long iPoint = 0; iPoint < Map.size(); ++iPoint) + if (Map(iPoint)!=0) + Map(iPoint) = ++nVertex; + + isValid = true; + } + return nVertex; + } + + /*! + * \brief Convert a point index to vertex index. + * \param[in,out] iVertex - On entry point index, on exit vertex index. + * \return True if conversion is successful (i.e. point is vertex). + */ + inline bool GetVertexIndex(unsigned long &iVertex) const { + assert(isValid && "Vertex map is not in valid state."); + iVertex = Map(iVertex); + if(iVertex==0) return false; // not a vertex + iVertex--; // decrement for 0 based + return true; // is a vertex + } + +}; diff --git a/Common/include/toolboxes/signal_processing_toolbox.hpp b/Common/include/toolboxes/signal_processing_toolbox.hpp index 8f2128cb5390..9eb35fea067a 100644 --- a/Common/include/toolboxes/signal_processing_toolbox.hpp +++ b/Common/include/toolboxes/signal_processing_toolbox.hpp @@ -5,7 +5,7 @@ namespace Signal_Processing { - su2double Average(std::vector &data); + su2double Average(const std::vector &data); class RunningAverage { @@ -25,11 +25,11 @@ namespace Signal_Processing { return val; } - su2double Get(){ + su2double Get() const{ return val; } - unsigned long Count(){ + unsigned long Count() const{ return count; } diff --git a/Common/src/ad_structure.cpp b/Common/src/ad_structure.cpp index 8ed974bd02ef..7511fa41d34c 100644 --- a/Common/src/ad_structure.cpp +++ b/Common/src/ad_structure.cpp @@ -49,6 +49,7 @@ namespace AD { su2double::TapeType& globalTape = su2double::getGlobalTape(); su2double::TapeType::Position StartPosition, EndPosition; + std::vector TapePositions; bool Status = false; bool PreaccActive = false; diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 3d9cd9e281b0..68134df49f1f 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -63,7 +63,7 @@ vector GEMM_Profile_MaxTime; /*!< \brief Maximum time spent for thi #include "../include/ad_structure.hpp" #include "../include/toolboxes/printing_toolbox.hpp" -CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software, unsigned short val_nZone, bool verb_high) { +CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software, bool verb_high) { base_config = true; @@ -72,8 +72,8 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); - iZone = val_nZone; - nZone = val_nZone; + iZone = 0; + nZone = 1; /*--- Initialize pointers to Null---*/ @@ -90,6 +90,10 @@ CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_softwar /*--- Set the default values for all of the options that weren't set ---*/ SetDefault(); + + /*--- Set number of zone ---*/ + + SetnZone(); /*--- Configuration file postprocessing ---*/ @@ -157,6 +161,8 @@ CConfig::CConfig(CConfig* config, char case_filename[MAX_STRING_SIZE], unsigned if ((rank == MASTER_NODE) && verb_high) SetOutput(val_software, val_iZone); + Multizone_Problem = config->GetMultizone_Problem(); + } CConfig::CConfig(char case_filename[MAX_STRING_SIZE], unsigned short val_software) { @@ -870,6 +876,8 @@ void CConfig::SetConfig_Options() { addEnumOption("MULTIZONE_SOLVER", Kind_MZSolver, Multizone_Map, MZ_BLOCK_GAUSS_SEIDEL); /*!\brief MATH_PROBLEM \n DESCRIPTION: Mathematical problem \n Options: DIRECT, ADJOINT \ingroup Config*/ addMathProblemOption("MATH_PROBLEM", ContinuousAdjoint, false, DiscreteAdjoint, false, Restart_Flow, false); + /*!\brief FULL_TAPE \n DESCRIPTION: Use full (coupled) tapes for multiphysics discrete adjoint. \ingroup Config*/ + addBoolOption("FULL_TAPE", FullTape, YES); /*!\brief KIND_TURB_MODEL \n DESCRIPTION: Specify turbulence model \n Options: see \link Turb_Model_Map \endlink \n DEFAULT: NO_TURB_MODEL \ingroup Config*/ addEnumOption("KIND_TURB_MODEL", Kind_Turb_Model, Turb_Model_Map, NO_TURB_MODEL); /*!\brief KIND_TRANS_MODEL \n DESCRIPTION: Specify transition model OPTIONS: see \link Trans_Model_Map \endlink \n DEFAULT: NO_TRANS_MODEL \ingroup Config*/ @@ -1365,8 +1373,6 @@ void CConfig::SetConfig_Options() { addEnumOption("TIME_MARCHING", TimeMarching, TimeMarching_Map, STEADY); /* DESCRIPTION: Courant-Friedrichs-Lewy condition of the finest grid */ addDoubleOption("CFL_NUMBER", CFLFineGrid, 1.25); - /* DESCRIPTION: Courant-Friedrichs-Lewy condition of the finest grid in (heat fvm) solid solvers */ - addDoubleOption("CFL_NUMBER_SOLID", CFLSolid, 1.25); /* DESCRIPTION: Max time step in local time stepping simulations */ addDoubleOption("MAX_DELTA_TIME", Max_DeltaTime, 1000000); /* DESCRIPTION: Activate The adaptive CFL number. */ @@ -1790,6 +1796,8 @@ void CConfig::SetConfig_Options() { addBoolOption("WRT_HALO", Wrt_Halo, false); /* DESCRIPTION: Output the performance summary to the console at the end of SU2_CFD \ingroup Config*/ addBoolOption("WRT_PERFORMANCE", Wrt_Performance, false); + /* DESCRIPTION: Output the tape statistics (discrete adjoint) \ingroup Config*/ + addBoolOption("WRT_AD_STATISTICS", Wrt_AD_Statistics, false); /* DESCRIPTION: Write the mesh quality metrics to the visualization files. \ingroup Config*/ addBoolOption("WRT_MESH_QUALITY", Wrt_MeshQuality, false); /* DESCRIPTION: Output a 1D slice of a 2D cartesian solution \ingroup Config*/ @@ -2269,6 +2277,10 @@ void CConfig::SetConfig_Options() { /*!\par CONFIG_CATEGORY: Heat solver \ingroup Config*/ /*--- options related to the heat solver ---*/ + /* DESCRIPTION: Use Robin (default) or Neumann BC at CHT interface. */ + /* Options: NO, YES \ingroup Config */ + addBoolOption("CHT_ROBIN", CHT_Robin, true); + /* DESCRIPTION: Thermal diffusivity constant */ addDoubleOption("THERMAL_DIFFUSIVITY", Thermal_Diffusivity, 1.172E-5); @@ -2463,7 +2475,7 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Multipoint design for outlet quantities (varying back pressure or mass flow operating points). */ addPythonOption("MULTIPOINT_OUTLET_VALUE"); - + /* DESCRIPTION: Multipoint mesh filenames, if using different meshes for each point */ addPythonOption("MULTIPOINT_MESH_FILENAME"); @@ -2902,14 +2914,13 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ SU2_MPI::Error("A turbulence model must be specified with KIND_TURB_MODEL if SOLVER= INC_RANS", CURRENT_FUNCTION); } -#ifndef HAVE_TECIO - for (unsigned short iOutputFile = 0; iOutputFile < nVolumeOutputFiles; iOutputFile++) { - if (VolumeOutputFiles[iOutputFile] == TECPLOT_BINARY) { - cout << "Tecplot binary file requested but SU2 was built without TecIO support.\n Writing Tecplot ASCII instead." << "\n"; - VolumeOutputFiles[iOutputFile] = TECPLOT; - } - } -#endif + +//#ifndef HAVE_TECIO +// if (Output_FileFormat == TECPLOT_BINARY) { +// cout << "Tecplot binary file requested but SU2 was built without TecIO support." << "\n"; +// Output_FileFormat = TECPLOT; +// } +//#endif /*--- Set the boolean Wall_Functions equal to true if there is a definition for the wall founctions ---*/ @@ -4554,6 +4565,9 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ case FEM_ELASTICITY: Kind_Solver = DISC_ADJ_FEM; break; + case HEAT_EQUATION_FVM: + Kind_Solver = DISC_ADJ_HEAT; + break; default: break; } @@ -6318,7 +6332,6 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { cout << endl <<"------------------ Convergence Criteria ( Zone " << iZone << " ) ---------------------" << endl; - cout << "Maximum number of solver subiterations: " << nInnerIter <<"."<< endl; cout << "Maximum number of physical time-steps: " << nTimeIter <<"."<< endl; @@ -7567,7 +7580,7 @@ string CConfig::GetFilename(string filename, string ext, unsigned long Iter){ filename = filename + string(ext); /*--- Append the zone number if multizone problems ---*/ - if (GetnZone() > 1) + if (Multizone_Problem) filename = GetMultizone_FileName(filename, GetiZone(), ext); /*--- Append the zone number if multiple instance problems ---*/ @@ -7620,7 +7633,7 @@ string CConfig::GetMultizone_FileName(string val_filename, int val_iZone, string unsigned short lastindex = multizone_filename.find_last_of("."); multizone_filename = multizone_filename.substr(0, lastindex); - if (GetnZone() > 1 ) { + if (Multizone_Problem) { SPRINTF (buffer, "_%d", SU2_TYPE::Int(val_iZone)); multizone_filename.append(string(buffer)); } @@ -7635,7 +7648,7 @@ string CConfig::GetMultizone_HistoryFileName(string val_filename, int val_iZone, char buffer[50]; unsigned short lastindex = multizone_filename.find_last_of("."); multizone_filename = multizone_filename.substr(0, lastindex); - if (GetnZone() > 1 ) { + if (Multizone_Problem) { SPRINTF (buffer, "_%d", SU2_TYPE::Int(val_iZone)); multizone_filename.append(string(buffer)); } diff --git a/Common/src/dual_grid_structure.cpp b/Common/src/dual_grid_structure.cpp index 233c8c06dc7e..4ed88ce88e0a 100644 --- a/Common/src/dual_grid_structure.cpp +++ b/Common/src/dual_grid_structure.cpp @@ -52,10 +52,11 @@ CPoint::CPoint(unsigned short val_nDim, unsigned long val_globalindex, CConfig * Point.clear(); nPoint = 0; Edge.clear(); - Volume = NULL; Vertex = NULL; - Coord = NULL; Coord_Old = NULL; Coord_Sum = NULL; - Coord_n = NULL; Coord_n1 = NULL; Coord_p1 = NULL; - GridVel = NULL; GridVel_Grad = NULL; + Volume = NULL; Vertex = NULL; + Coord = NULL; Coord_Old = NULL; Coord_Sum = NULL; + Coord_n = NULL; Coord_n1 = NULL; Coord_p1 = NULL; + GridVel = NULL; GridVel_Grad = NULL; + Input_AdjIndices = NULL; Output_AdjIndices = NULL; /*--- Volume (0 -> Vol_nP1, 1-> Vol_n, 2 -> Vol_nM1 ) and coordinates of the control volume ---*/ @@ -72,6 +73,11 @@ CPoint::CPoint(unsigned short val_nDim, unsigned long val_globalindex, CConfig * Coord = new su2double[nDim]; + if(config->GetAD_Mode() && config->GetMultizone_Problem()) { + Input_AdjIndices = new int[nDim]; + Output_AdjIndices = new int[nDim]; + } + /*--- Indicator if the control volume has been agglomerated ---*/ Parent_CV = 0; Agglomerate = false; @@ -161,10 +167,11 @@ CPoint::CPoint(su2double val_coord_0, su2double val_coord_1, unsigned long val_g Point.clear(); nPoint = 0; Edge.clear(); - Volume = NULL; Vertex = NULL; - Coord = NULL; Coord_Old = NULL; Coord_Sum = NULL; - Coord_n = NULL; Coord_n1 = NULL; Coord_p1 = NULL; - GridVel = NULL; GridVel_Grad = NULL; + Volume = NULL; Vertex = NULL; + Coord = NULL; Coord_Old = NULL; Coord_Sum = NULL; + Coord_n = NULL; Coord_n1 = NULL; Coord_p1 = NULL; + GridVel = NULL; GridVel_Grad = NULL; + Input_AdjIndices = NULL; Output_AdjIndices = NULL; /*--- Volume (0 -> Vol_nP1, 1-> Vol_n, 2 -> Vol_nM1 ) and coordinates of the control volume ---*/ @@ -183,6 +190,11 @@ CPoint::CPoint(su2double val_coord_0, su2double val_coord_1, unsigned long val_g Coord[0] = val_coord_0; Coord[1] = val_coord_1; + if(config->GetAD_Mode() && config->GetMultizone_Problem()) { + Input_AdjIndices = new int[nDim]; + Output_AdjIndices = new int[nDim]; + } + /*--- Indicator if the control volume has been agglomerated ---*/ Parent_CV = 0; Agglomerate = false; @@ -271,10 +283,11 @@ CPoint::CPoint(su2double val_coord_0, su2double val_coord_1, su2double val_coord Point.clear(); nPoint = 0; Edge.clear(); - Volume = NULL; Vertex = NULL; - Coord = NULL; Coord_Old = NULL; Coord_Sum = NULL; - Coord_n = NULL; Coord_n1 = NULL; Coord_p1 = NULL; - GridVel = NULL; GridVel_Grad = NULL; + Volume = NULL; Vertex = NULL; + Coord = NULL; Coord_Old = NULL; Coord_Sum = NULL; + Coord_n = NULL; Coord_n1 = NULL; Coord_p1 = NULL; + GridVel = NULL; GridVel_Grad = NULL; + Input_AdjIndices = NULL; Output_AdjIndices = NULL; /*--- Volume (0 -> Vol_nP1, 1-> Vol_n, 2 -> Vol_nM1 ) and coordinates of the control volume ---*/ if ( config->GetTime_Marching() == NO ) { @@ -293,6 +306,11 @@ CPoint::CPoint(su2double val_coord_0, su2double val_coord_1, su2double val_coord Coord[1] = val_coord_1; Coord[2] = val_coord_2; + if(config->GetAD_Mode() && config->GetMultizone_Problem()) { + Input_AdjIndices = new int[nDim]; + Output_AdjIndices = new int[nDim]; + } + /*--- Indicator if the control volume has been agglomerated ---*/ Parent_CV = 0; Agglomerate = false; @@ -389,8 +407,9 @@ CPoint::~CPoint() { delete [] GridVel_Grad[iDim]; delete [] GridVel_Grad; } - -} + if (Input_AdjIndices != NULL) delete[] Input_AdjIndices; + if (Output_AdjIndices != NULL) delete[] Output_AdjIndices; + } void CPoint::SetPoint(unsigned long val_point) { @@ -430,6 +449,27 @@ void CPoint::SetBoundary(unsigned short val_nmarker) { } +void CPoint::SetAdjIndices(bool input) { + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + if(input) { + AD::SetAdjIndex(Input_AdjIndices[iDim], Coord[iDim]); + } + else { + AD::SetAdjIndex(Output_AdjIndices[iDim], Coord[iDim]); + } + } +} + +void CPoint::SetAdjointSolution(const su2double *adj_sol) { + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + AD::SetDerivative(Output_AdjIndices[iDim], SU2_TYPE::GetValue(adj_sol[iDim])); + } +} + +su2double CPoint::GetAdjointSolution(unsigned short iDim) { + return AD::GetDerivative(Input_AdjIndices[iDim]); +} + CEdge::CEdge(unsigned long val_iPoint, unsigned long val_jPoint, unsigned short val_nDim) : CDualGrid(val_nDim) { unsigned short iDim; diff --git a/Common/src/geometry_structure.cpp b/Common/src/geometry_structure.cpp index 0ffdbce65b4e..ab3b550e5a5e 100644 --- a/Common/src/geometry_structure.cpp +++ b/Common/src/geometry_structure.cpp @@ -2682,10 +2682,20 @@ void CGeometry::ComputeAirfoil_Section(su2double *Plane_P0, su2double *Plane_Nor void CGeometry::RegisterCoordinates(CConfig *config) { unsigned short iDim; unsigned long iPoint; + + bool input = true; for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iDim = 0; iDim < nDim; iDim++) { - AD::RegisterInput(node[iPoint]->GetCoord()[iDim]); + if(config->GetMultizone_Problem()) { + for (iDim = 0; iDim < nDim; iDim++) { + AD::RegisterInput_intIndexBased(node[iPoint]->GetCoord()[iDim]); + node[iPoint]->SetAdjIndices(input); + } + } + else { + for (iDim = 0; iDim < nDim; iDim++) { + AD::RegisterInput(node[iPoint]->GetCoord()[iDim]); + } } } } @@ -2695,8 +2705,18 @@ void CGeometry::RegisterOutput_Coordinates(CConfig *config){ unsigned long iPoint; for (iPoint = 0; iPoint < nPoint; iPoint++){ - for (iDim = 0; iDim < nDim; iDim++){ - AD::RegisterOutput(node[iPoint]->GetCoord()[iDim]); + if(config->GetMultizone_Problem()) { + for (iDim = 0; iDim < nDim; iDim++) { +// In case we are dealing with mesh adjoints the following two lines might be needed +// AD::RegisterOutput(node[iPoint]->GetCoord()[iDim]); +// node[iPoint]->SetAdjIndices(false); + AD::RegisterOutput(node[iPoint]->GetCoord()[iDim]); + } + } + else { + for (iDim = 0; iDim < nDim; iDim++) { + AD::RegisterOutput(node[iPoint]->GetCoord()[iDim]); + } } } } diff --git a/Common/src/grid_movement_structure.cpp b/Common/src/grid_movement_structure.cpp index 067e19a385be..87f66058421a 100644 --- a/Common/src/grid_movement_structure.cpp +++ b/Common/src/grid_movement_structure.cpp @@ -138,7 +138,6 @@ void CVolumetricMovement::SetVolume_Deformation(CGeometry *geometry, CConfig *co su2double MinVolume, MaxVolume, NumError, Residual = 0.0, Residual_Init = 0.0; bool Screen_Output; - /*--- Retrieve number or iterations, tol, output, etc. from config ---*/ Smoothing_Iter = config->GetGridDef_Linear_Iter(); @@ -270,7 +269,6 @@ void CVolumetricMovement::SetVolume_Deformation(CGeometry *geometry, CConfig *co MaxIter = Smoothing_Iter - IterLinSol; IterLinSol = System.FGMRES_LinSolver(LinSysRes, LinSysSol, *mat_vec, *precond, NumError, MaxIter, &Residual, false, config); - Tot_Iter += IterLinSol; if ((rank == MASTER_NODE) && Screen_Output) { cout << " " << Tot_Iter << " " << Residual/Residual_Init << endl; } @@ -1906,7 +1904,6 @@ void CVolumetricMovement::Rigid_Rotation(CGeometry *geometry, CConfig *config, bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint()); - /*--- Problem dimension and physical time step ---*/ nDim = geometry->GetnDim(); dt = config->GetDelta_UnstTimeND(); @@ -2068,7 +2065,6 @@ void CVolumetricMovement::Rigid_Pitching(CGeometry *geometry, CConfig *config, u unsigned long iPoint; bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint()); - /*--- Retrieve values from the config file ---*/ deltaT = config->GetDelta_UnstTimeND(); @@ -2208,14 +2204,13 @@ void CVolumetricMovement::Rigid_Pitching(CGeometry *geometry, CConfig *config, u void CVolumetricMovement::Rigid_Plunging(CGeometry *geometry, CConfig *config, unsigned short iZone, unsigned long iter) { /*--- Local variables ---*/ - su2double deltaX[3], newCoord[3], Center[3], *Coord, Omega[3], Ampl[3], Lref; + su2double deltaX[3], newCoord[3] = {0.0, 0.0, 0.0}, Center[3], *Coord, Omega[3], Ampl[3], Lref; su2double *GridVel, newGridVel[3] = {0.0, 0.0, 0.0}, xDot[3]; su2double deltaT, time_new, time_old; unsigned short iDim, nDim = geometry->GetnDim(); unsigned long iPoint; bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint()); - /*--- Retrieve values from the config file ---*/ deltaT = config->GetDelta_UnstTimeND(); @@ -2347,7 +2342,6 @@ void CVolumetricMovement::Rigid_Translation(CGeometry *geometry, CConfig *config unsigned long iPoint; bool harmonic_balance = (config->GetTime_Marching() == HARMONIC_BALANCE); bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint()); - /*--- Retrieve values from the config file ---*/ deltaT = config->GetDelta_UnstTimeND(); diff --git a/Common/src/linear_algebra/CSysSolve.cpp b/Common/src/linear_algebra/CSysSolve.cpp index 99c693d267f0..9a072133a823 100644 --- a/Common/src/linear_algebra/CSysSolve.cpp +++ b/Common/src/linear_algebra/CSysSolve.cpp @@ -242,7 +242,7 @@ unsigned long CSysSolve::CG_LinSolver(const CSysVector & norm_r = r.norm(); norm0 = b.norm(); - if ( (norm_r < tol*norm0) || (norm_r < eps) ) { + if ((norm_r < tol*norm0) || (norm_r < eps)) { if (rank == MASTER_NODE) cout << "CSysSolve::ConjugateGradient(): system solved by initial guess." << endl; return 0; } @@ -391,7 +391,7 @@ unsigned long CSysSolve::FGMRES_LinSolver(const CSysVector::BCGSTAB_LinSolver(const CSysVector &data){ +su2double Signal_Processing::Average(const std::vector &data){ su2double avg = 0.0; - for (std::vector::iterator it = data.begin(); it != data.end(); it++){ - avg += (*it); + for (const su2double& val : data){ + avg += val; } - return avg/=data.size(); + return avg/data.size(); } diff --git a/SU2_CFD/include/SU2_CFD.hpp b/SU2_CFD/include/SU2_CFD.hpp index 5925bd6bf722..a77fb2988a7a 100644 --- a/SU2_CFD/include/SU2_CFD.hpp +++ b/SU2_CFD/include/SU2_CFD.hpp @@ -47,6 +47,7 @@ #include "drivers/CSinglezoneDriver.hpp" #include "drivers/CMultizoneDriver.hpp" #include "drivers/CDiscAdjSinglezoneDriver.hpp" +#include "drivers/CDiscAdjMultizoneDriver.hpp" #include "drivers/CDummyDriver.hpp" #include "solver_structure.hpp" #include "integration_structure.hpp" diff --git a/SU2_CFD/include/definition_structure.hpp b/SU2_CFD/include/definition_structure.hpp index 6c96cc27674f..b54f3898ea59 100644 --- a/SU2_CFD/include/definition_structure.hpp +++ b/SU2_CFD/include/definition_structure.hpp @@ -42,10 +42,9 @@ #include -#include "../../Common/include/config_structure.hpp" -#include "../../Common/include/geometry_structure.hpp" #include "../../Common/include/fem_geometry_structure.hpp" - +#include "../../Common/include/geometry_structure.hpp" +#include "../../Common/include/config_structure.hpp" using namespace std; diff --git a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp new file mode 100644 index 000000000000..7b48f3cc39b1 --- /dev/null +++ b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp @@ -0,0 +1,181 @@ +/*! + * \class CDiscAdjMultizoneDriver.hpp + * \brief Class for driving adjoint multi-zone problems. + * \author O. Burghardt, T. Albring, R. Sanchez + * \version 6.2.0 "Falcon" + * + * The current SU2 release has been coordinated by the + * SU2 International Developers Society + * with selected contributions from the open-source community. + * + * The main research teams contributing to the current release are: + * - Prof. Juan J. Alonso's group at Stanford University. + * - Prof. Piero Colonna's group at Delft University of Technology. + * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. + * - Prof. Alberto Guardone's group at Polytechnic University of Milan. + * - Prof. Rafael Palacios' group at Imperial College London. + * - Prof. Vincent Terrapon's group at the University of Liege. + * - Prof. Edwin van der Weide's group at the University of Twente. + * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. + * + * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, + * Tim Albring, and the SU2 contributors. + * + * 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 . + */ + +#pragma once +#include "CMultizoneDriver.hpp" + +class CDiscAdjMultizoneDriver : public CMultizoneDriver { + +protected: + + /*! + * \brief Kinds of recordings (three different ones). + */ + enum class Kind_Tape { + FULL_TAPE, /*!< \brief Entire derivative information for a coupled adjoint + solution update. */ + OBJECTIVE_FUNCTION_TAPE, /*!< \brief Record only the dependence of the objective function + w.r.t. solver variables (from all zones). */ + ZONE_SPECIFIC_TAPE /*!< \brief Record only the dependence of the solution update in a + specified zone w.r.t. solver variables (from all zones). */ + }; + + /*! + * \brief Position markers within a tape. + */ + enum Tape_Positions { + START = 0, /*!< \brief Beginning of the tape. */ + REGISTERED = 1, /*!< \brief Solver variables are registered on the tape. */ + DEPENDENCIES = 2, /*!< \brief Derived values (e.g. gradients) are set. */ + OBJECTIVE_FUNCTION = 3, /*!< \brief Objective function is set. */ + TRANSFER = 4, /*!< \brief Solution data is transferred between coupled solvers of + different physical zones (giving cross contributions). */ + ITERATION_READY = 5 /*!< \brief Until here, all derivative information is gathered so + that it can be connected to a solver update evaluation. */ + }; + + int RecordingState; /*!< \brief The kind of recording that the tape currently holds. */ + bool retape; /*!< \brief Boolean whether a full tape can be kept in memory. */ + + su2double ObjFunc; /*!< \brief Value of the objective function. */ + int ObjFunc_Index; /*!< \brief Index of the value of the objective function. */ + + CIteration*** direct_iteration; /*!< \brief Array of pointers to the direct iterations. */ + COutput** direct_output; /*!< \brief Array of pointers to the direct outputs. */ + unsigned short* direct_nInst; /*!< \brief Total number of instances in the direct problem. */ + unsigned short* nInnerIter; /*!< \brief Number of inner iterations for each zone. */ + + +public: + + /*! + * \brief Constructor of the class. + * \param[in] confFile - Configuration file name. + * \param[in] val_nZone - Total number of zones. + * \param[in] MPICommunicator - MPI communicator for SU2. + */ + CDiscAdjMultizoneDriver(char* confFile, + unsigned short val_nZone, + SU2_Comm MPICommunicator); + + /*! + * \brief Destructor of the class. + */ + ~CDiscAdjMultizoneDriver(void); + + /*! + * \brief [Overload] Launch the computation for discrete adjoint multizone problems. + */ + void StartSolver() override; + + /*! + * \brief [Overload] Run an discrete adjoint update of all solvers within multiple zones. + */ + void Run() override; + + /*! + * \brief Record one iteration of a flow iteration in within multiple zones. + * \param[in] kind_recording - Kind of variables with regard to which we are recording. + * \param[in] tape_type - indicator which part of a solution update will be recorded + * \param[in] record_zone - zone where solution update will be recorded + */ + void SetRecording(unsigned short kind_recording, Kind_Tape tape_type, unsigned short record_zone); + + /*! + * \brief Run one direct iteration in a zone. + * \param[in] iZone - Zone in which we run an iteration. + * \param[in] kind_recording - Kind of variables with regard to which we are recording. + */ + void DirectIteration(unsigned short iZone, unsigned short kind_recording); + + /*! + * \brief Set the objective function. + * \param[in] kind_recording - Kind of variables with regard to which we are recording. + */ + void SetObjFunction(unsigned short kind_recording); + + /*! + * \brief Initialize the adjoint value of the objective function. + */ + void SetAdj_ObjFunction(); + + /*! + * \brief Summary of all routines to evaluate the adjoints in iZone. + * \param[in] iZone - Zone in which adjoints are evaluated depending on their (preceding) seeding. + */ + void ComputeAdjoints(unsigned short iZone); + + /*! + * \brief Add External_Old vector to Solution. + * \param[in] iZone - Zone where data between solvers is transferred. + */ + void Add_ExternalOld_To_Solution(unsigned short iZone); + + /*! + * \brief Sets External to zero. + */ + void SetExternal_Zero(void); + + /*! + * \brief Set External_Old to External. + */ + void Set_OldExternal(void); + + /*! + * \brief Add Solution vector to External. + * \param[in] iZone - Zone where data between solvers is transferred. + */ + void Add_Solution_To_External(unsigned short iZone); + + /*! + * \brief Add Solution vector to External_Old. + * \param[in] iZone - Zone where data between solvers is transferred. + */ + void Add_Solution_To_ExternalOld(unsigned short iZone); + + /*! + * \brief Saves the current (adjoint) Solution vector to Solution_BGS_k. + * \param[in] iZone - Zone where data between solvers is transferred. + */ + void Set_BGSSolution(unsigned short iZone); + + /*! + * \brief Compute BGS residuals. + * \param[in] iZone - Zone where solver residuals are computed. + */ + void SetResidual_BGS(unsigned short iZone); +}; diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index e77961bbb260..2c3040d7be0c 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -38,7 +38,7 @@ #pragma once -#include "../../Common/include/mpi_structure.hpp" +#include "../../../Common/include/mpi_structure.hpp" #include "../iteration_structure.hpp" #include "../solver_structure.hpp" #include "../integration_structure.hpp" diff --git a/SU2_CFD/include/numerics_structure.hpp b/SU2_CFD/include/numerics_structure.hpp index ef6b44d854ee..d4788a3dd3b3 100644 --- a/SU2_CFD/include/numerics_structure.hpp +++ b/SU2_CFD/include/numerics_structure.hpp @@ -272,12 +272,6 @@ class CNumerics { */ void SetTimeStep(su2double val_timestep); - /*! - * \brief Get the Preconditioning Beta. - * \return val_Beta - Value of the low Mach Preconditioner. - */ - virtual su2double GetPrecond_Beta(); - /*! * \brief Set the freestream velocity square. * \param[in] SetVelocity2_Inf - Value of the square of the freestream velocity. @@ -1835,12 +1829,7 @@ class CUpwTurkel_Flow : public CNumerics { * \param[in] config - Definition of the particular problem. */ void ComputeResidual(su2double *val_residual, su2double **val_Jacobian_i, su2double **val_Jacobian_j, CConfig *config); - - /*! - * \brief Get the Preconditioning Beta. - * \return Beta - Value of the low Mach Preconditioner. - */ - su2double GetPrecond_Beta(); + }; /*! diff --git a/SU2_CFD/include/numerics_structure.inl b/SU2_CFD/include/numerics_structure.inl index ce1bcae6502d..57c836b396fe 100644 --- a/SU2_CFD/include/numerics_structure.inl +++ b/SU2_CFD/include/numerics_structure.inl @@ -201,8 +201,6 @@ inline void CNumerics::ComputeChemistry(su2double *val_residual, su2double **val inline void CNumerics::GetKeqConstants(su2double *A, unsigned short val_reaction, CConfig *config) { } -inline su2double CNumerics::GetPrecond_Beta() { return 0; } - inline void CNumerics::SetUndivided_Laplacian(su2double *val_und_lapl_i, su2double *val_und_lapl_j) { Und_Lapl_i = val_und_lapl_i; Und_Lapl_j = val_und_lapl_j; @@ -566,8 +564,6 @@ inline su2double CSourcePieceWise_TurbSA_Neg::GetDestruction(void) { return Dest inline su2double CSourcePieceWise_TurbSA_Neg::GetCrossProduction(void) { return CrossProduction; } -inline su2double CUpwTurkel_Flow::GetPrecond_Beta() { return Beta; } - inline void CNumerics::ComputeResidual(su2double **val_Jacobian_i, su2double *val_Jacobian_mui, su2double ***val_Jacobian_gradi, CConfig *config) { } inline void CNumerics::ComputeResidual(su2double **val_Jacobian_i, su2double *val_Jacobian_mui, su2double ***val_Jacobian_gradi, diff --git a/SU2_CFD/include/output/CFlowCompFEMOutput.hpp b/SU2_CFD/include/output/CFlowCompFEMOutput.hpp index fa407f93c497..5195a1be62f4 100644 --- a/SU2_CFD/include/output/CFlowCompFEMOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompFEMOutput.hpp @@ -106,15 +106,6 @@ class CFlowCompFEMOutput final: public CFlowOutput { * \param[in] config - Definition of the particular problem. */ void SetHistoryOutputFields(CConfig *config) override; - - /*! - * \brief Compute value of the Q criteration for vortex idenfitication - * \param[in] config - Definition of the particular problem. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] node_flow - The flow variable node - * \return Value of the Q criteration at the node - */ - su2double GetQ_Criterion(CConfig *config, CGeometry *geometry, CVariable *node_flow); /*! * \brief Check whether the base values for relative residuals should be initialized diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index 06385afeaba5..b48714ddb931 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -103,15 +103,6 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] config - Definition of the particular problem. */ void SetHistoryOutputFields(CConfig *config) override; - - /*! - * \brief Compute value of the Q criteration for vortex idenfitication - * \param[in] config - Definition of the particular problem. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] node_flow - The flow variable node - * \return Value of the Q criteration at the node - */ - su2double GetQ_Criterion(CConfig *config, CGeometry *geometry, CVariable *node_flow); /*! * \brief Check whether the base values for relative residuals should be initialized diff --git a/SU2_CFD/include/output/CFlowIncOutput.hpp b/SU2_CFD/include/output/CFlowIncOutput.hpp index 7efeb9467777..153dd8ce2e33 100644 --- a/SU2_CFD/include/output/CFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CFlowIncOutput.hpp @@ -104,15 +104,6 @@ class CFlowIncOutput final: public CFlowOutput { * \param[in] config - Definition of the particular problem. */ void SetHistoryOutputFields(CConfig *config) override; - - /*! - * \brief Compute value of the Q criteration for vortex idenfitication - * \param[in] config - Definition of the particular problem. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] node_flow - The flow variable node - * \return Value of the Q criteration at the node - */ - su2double GetQ_Criterion(CConfig *config, CGeometry *geometry, CVariable *node_flow); /*! * \brief Check whether the base values for relative residuals should be initialized diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index f5d0e3aa1f5b..0e663404b286 100644 --- a/SU2_CFD/include/output/CFlowOutput.hpp +++ b/SU2_CFD/include/output/CFlowOutput.hpp @@ -96,6 +96,13 @@ class CFlowOutput : public COutput{ */ void Set_CpInverseDesign(CSolver *solver, CGeometry *geometry, CConfig *config); + /*! + * \brief Compute value of the Q criteration for vortex idenfitication + * \param[in] VelocityGradient - Velocity gradients + * \return Value of the Q criteration at the node + */ + su2double GetQ_Criterion(su2double** VelocityGradient) const; + /*! * \brief Write information to meta data file * \param[in] output - Container holding the output instances per zone. diff --git a/SU2_CFD/include/output/CHeatOutput.hpp b/SU2_CFD/include/output/CHeatOutput.hpp index 8a41c49f45b8..81cad15dcd51 100644 --- a/SU2_CFD/include/output/CHeatOutput.hpp +++ b/SU2_CFD/include/output/CHeatOutput.hpp @@ -59,6 +59,12 @@ class CHeatOutput final: public COutput { */ ~CHeatOutput(void) override; + /*! + * \brief Set the available history output fields + * \param[in] config - Definition of the particular problem. + */ + void SetHistoryOutputFields(CConfig *config) override; + /*! * \brief Load the history output field values * \param[in] config - Definition of the particular problem. @@ -78,11 +84,17 @@ class CHeatOutput final: public COutput { * \param[in] solver - The container holding all solution data. * \param[in] iPoint - Index of the point. */ - void LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint) override; - + void LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint) override; + /*! - * \brief Set the available history output fields + * \brief LoadSurfaceData * \param[in] config - Definition of the particular problem. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver - The container holding all solution data. + * \param[in] iPoint - Index of the point. + * \param[in] iMarker - Index of the surface marker. + * \param[in] iVertex - Index of the vertex on the marker. */ - void SetHistoryOutputFields(CConfig *config) override; + void LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint, + unsigned short iMarker, unsigned long iVertex); }; diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 8bef90ecf4a6..768c8d65e4b5 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -90,9 +90,9 @@ class COutput { string historyFilename; /*!< \brief The history filename*/ /*! \brief Temporary variable to store the history filename */ - char char_histfile[200]; - /*! \brief Output file stream for the history */ - ofstream histFile; + char char_histfile[200]; + /*! \brief Output file stream for the history */ + ofstream histFile; /** \brief Enum to identify the screen output format. */ enum class ScreenOutputFormat { @@ -371,6 +371,10 @@ class COutput { su2double GetHistoryFieldValue(string field){ return historyOutput_Map[field].value; } + + su2double GetHistoryFieldValuePerSurface(string field, unsigned short iMarker){ + return historyOutputPerSurface_Map[field][iMarker].value; + } /*! * \brief Get a vector with all output fields in a particular group @@ -735,8 +739,8 @@ class COutput { * \param[in] config - Definition of the particular problem. */ inline virtual void SetVolumeOutputFields(CConfig *config){} - - + + /*! * \brief Load the history output field values * \param[in] config - Definition of the particular problem. diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 67d4b2e90ebc..75780a3f449c 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -56,8 +56,6 @@ #include "task_definition.hpp" #include "numerics_structure.hpp" #include "sgs_model.hpp" -#include "variables/CVariable.hpp" -#include "variables/CMeshElement.hpp" #include "../../Common/include/gauss_structure.hpp" #include "../../Common/include/element_structure.hpp" #include "../../Common/include/fem_geometry_structure.hpp" @@ -71,6 +69,18 @@ #include "../../Common/include/graph_coloring_structure.hpp" #include "../../Common/include/toolboxes/MMS/CVerificationSolution.hpp" +/*--- CVariable includes, ToDo: Once this file is split, one per class these includes can also be separated. ---*/ +#include "variables/CBaselineVariable.hpp" +#include "variables/CEulerVariable.hpp" +#include "variables/CIncEulerVariable.hpp" +#include "variables/CTurbVariable.hpp" +#include "variables/CAdjEulerVariable.hpp" +#include "variables/CAdjTurbVariable.hpp" +#include "variables/CHeatFVMVariable.hpp" +#include "variables/CDiscAdjVariable.hpp" +#include "variables/CDiscAdjFEABoundVariable.hpp" +#include "variables/CMeshElement.hpp" + using namespace std; /*! @@ -83,6 +93,7 @@ class CSolver { protected: int rank, /*!< \brief MPI Rank. */ size; /*!< \brief MPI Size. */ + bool adjoint; /*!< \brief Boolean to determine whether solver is initialized as a direct or an adjoint solver. */ unsigned short MGLevel; /*!< \brief Multigrid level of this solver object. */ unsigned short IterLinSolver; /*!< \brief Linear solver iterations. */ su2double ResLinSolver; /*!< \brief Final linear solver residual. */ @@ -157,7 +168,28 @@ class CSolver { su2double ***VertexTractionAdjoint; /*- Also temporary -*/ string SolverName; /*!< \brief Store the name of the solver for output purposes. */ - + + /*! + * \brief Pure virtual function, all derived solvers MUST implement a method returning their "nodes". + * \note Don't forget to call SetBaseClassPointerToNodes() in the constructor of the derived CSolver. + * \return Nodes of the solver, upcast to their base class (CVariable). + */ + virtual CVariable* GetBaseClassPointerToNodes() = 0; + + /*! + * \brief Call this method to set "base_nodes" after the "nodes" variable of the derived solver is instantiated. + * \note One could set base_nodes directly if it were not private but that could lead to confusion + */ + inline void SetBaseClassPointerToNodes() { base_nodes = GetBaseClassPointerToNodes(); } + +private: + + /*--- Private to prevent use by derived solvers, each solver MUST have its own "nodes" member of the + most derived type possible, e.g. CEulerVariable has nodes of CEulerVariable* and not CVariable*. + This variable is to avoid two virtual functions calls per call i.e. CSolver::GetNodes() returns + directly instead of calling GetBaseClassPointerToNodes() or doing something equivalent. ---*/ + CVariable* base_nodes; /*!< \brief Pointer to CVariable to allow polymorphic access to solver nodes. */ + public: CSysVector LinSysSol; /*!< \brief vector to store iterative solution of implicit linear system. */ @@ -175,10 +207,7 @@ class CSolver { CSysVector OutputVariables; /*!< \brief vector to store the extra variables to be written. */ string* OutputHeadingNames; /*< \brief vector of strings to store the headings for the exra variables */ - - CVariable** node; /*!< \brief Vector which the define the variables for each problem. */ - CVariable* node_infty; /*!< \brief CVariable storing the free stream conditions. */ - + CVerificationSolution *VerificationSolution; /*!< \brief Verification solution class used within the solver. */ vector fields; @@ -191,7 +220,16 @@ class CSolver { * \brief Destructor of the class. */ virtual ~CSolver(void); - + + /*! + * \brief Allow outside access to the nodes of the solver, containing conservatives, primitives, etc. + * \return Nodes of the solver. + */ + inline CVariable* GetNodes() { + assert(base_nodes!=nullptr && "CSolver::base_nodes was not set properly, see brief for CSolver::SetBaseClassPointerToNodes()"); + return base_nodes; + } + /*! * \brief Routine to load a solver quantity into the data structures for MPI point-to-point communication and to launch non-blocking sends and recvs. * \param[in] geometry - Geometrical definition of the problem. @@ -273,9 +311,8 @@ class CSolver { /*! * \brief Store the BGS solution in the previous subiteration in the corresponding vector. - * \param[in] val_iterlinsolver - Number of linear iterations. */ - virtual void UpdateSolution_BGS(CGeometry *geometry, CConfig *config); + void UpdateSolution_BGS(CGeometry *geometry, CConfig *config); /*! * \brief Set the solver nondimensionalization. @@ -284,6 +321,12 @@ class CSolver { */ virtual void SetNondimensionalization(CConfig *config, unsigned short iMesh); + /*! + * \brief Get information whether the initialization is an adjoint solver or not. + * \return TRUE means that it is an adjoint solver. + */ + bool GetAdjoint(void); + /*! * \brief Compute the pressure at the infinity. * \return Value of the pressure at the infinity. @@ -517,7 +560,14 @@ class CSolver { * \return Pointer to the location (x, y, z) of the biggest residual for the variable val_var. */ su2double* GetPoint_Max_Coord_BGS(unsigned short val_var); - + + /*! + * \brief Set the value of the RMS residual respective solution. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] config - Definition of the particular problem. + */ + void SetResidual_Solution(CGeometry *geometry, CConfig *config); + /*! * \brief Set Value of the residual due to the Geometric Conservation Law (GCL) for steady rotating frame problems. * \param[in] geometry - Geometrical definition of the problem. @@ -545,6 +595,24 @@ class CSolver { */ void SetAuxVar_Surface_Gradient(CGeometry *geometry, CConfig *config); + /*! + * \brief Add External_Old to Solution vector. + * \param[in] geometry - The geometrical definition of the problem. + */ + void Add_ExternalOld_To_Solution(CGeometry *geometry); + + /*! + * \brief Add the current Solution vector to External. + * \param[in] geometry - The geometrical definition of the problem. + */ + void Add_Solution_To_External(CGeometry *geometry); + + /*! + * \brief Add the current Solution vector to External_Old. + * \param[in] geometry - The geometrical definition of the problem. + */ + void Add_Solution_To_ExternalOld(CGeometry *geometry); + /*! * \brief Compute the Green-Gauss gradient of the solution. * \param[in] geometry - Geometrical definition of the problem. @@ -4531,8 +4599,16 @@ class CSolver { * \brief Main class for defining a baseline solution from a restart file (for output). * \author F. Palacios, T. Economon. */ -class CBaselineSolver : public CSolver { - +class CBaselineSolver final : public CSolver { +protected: + + CBaselineVariable* nodes = nullptr; /*!< \brief Variables of the baseline solver. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -4607,6 +4683,8 @@ class CBaselineSolver_FEM : public CSolver { vector VecSolDOFs; /*!< \brief Vector, which stores the solution variables in all the DOFs. */ + CVariable* GetBaseClassPointerToNodes() {return nullptr;} + public: /*! @@ -4931,6 +5009,13 @@ class CEulerSolver : public CSolver { su2double ****SlidingState; int **SlidingStateNodes; + CEulerVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: @@ -7215,6 +7300,13 @@ class CIncEulerSolver : public CSolver { su2double ****SlidingState; int **SlidingStateNodes; + CIncEulerVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -9375,12 +9467,21 @@ class CTurbSolver : public CSolver { su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ su2double*** Inlet_TurbVars; /*!< \brief Turbulence variables at inlet profiles */ - + + CTurbVariable* snode; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + /* Sliding meshes variables */ su2double ****SlidingState; int **SlidingStateNodes; + CTurbVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -10349,7 +10450,14 @@ class CAdjEulerSolver : public CSolver { unsigned long AoA_Counter; su2double ACoeff, ACoeff_inc, ACoeff_old; bool Update_ACoeff; - + + CAdjEulerVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -10983,7 +11091,14 @@ class CAdjTurbSolver : public CSolver { su2double Gamma; /*!< \brief Fluid's Gamma constant (ratio of specific heats). */ su2double Gamma_Minus_One; /*!< \brief Fluids's Gamma - 1.0 . */ - + + CAdjTurbVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -11095,290 +11210,6 @@ class CAdjTurbSolver : public CSolver { }; -/*! \class CPoissonSolver - * \brief Main class for defining the poisson potential solver. - * \author F. Palacios - * \date May 3, 2010. - */ -class CPoissonSolver : public CSolver { -private: - su2double *Source_Vector; /*!< \brief Auxiliary vector for storing element source vector. */ - su2double **StiffMatrix_Elem; /*!< \brief Auxiliary matrices for storing point to point Stiffness Matrices. */ - su2double **StiffMatrix_Node; /*!< \brief Auxiliary matrices for storing point to point Stiffness Matrices. */ - -public: - - /*! - * \brief Constructor of the class. - */ - CPoissonSolver(void); - - /*! - * \overload - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - CPoissonSolver(CGeometry *geometry, CConfig *config); - - /*! - * \brief A virtual member. - * \param[in] solver1_geometry - Geometrical definition of the problem. - * \param[in] solver1_solution - Container vector with all the solutions. - * \param[in] solver1_config - Definition of the particular problem. - * \param[in] solver2_geometry - Geometrical definition of the problem. - * \param[in] solver2_solution - Container vector with all the solutions. - * \param[in] solver2_config - Definition of the particular problem. - */ - void Copy_Zone_Solution(CSolver ***solver1_solution, CGeometry **solver1_geometry, CConfig *solver1_config, CSolver ***solver2_solution, CGeometry **solver2_geometry, CConfig *solver2_config); - - /*! - * \brief Destructor of the class. - */ - ~CPoissonSolver(void); - - /*! - * \brief Integrate the Poisson equation using a Galerkin method. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - */ - void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, - unsigned short iMesh, unsigned short iRKStep); - - /*! - * \brief Integrate the Poisson equation using a Galerkin method. - * \param[in] StiffMatrix_Elem - Element stiffness matrix - */ - void AddStiffMatrix(su2double **StiffMatrix_Elem, unsigned long Point_0, unsigned long Point_1, unsigned long Point_2, unsigned long Point_3); - - /*! - * \brief Compute the residual. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - */ - void Compute_Residual(CGeometry *geometry, CSolver **solver_container, CConfig *config, - unsigned short iMesh); - - /*! - * \brief Impose via the residual the Dirichlet boundary condition. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] val_marker - Surface marker where the boundary condition is applied. - */ - void BC_Dirichlet(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short val_marker); - - /*! - * \brief Impose via the residual the Neumann boundary condition. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] val_marker - Surface marker where the boundary condition is applied. - */ - void BC_Neumann(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short val_marker); - - /*! - * \brief Set residuals to zero. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] iRKStep - Current step of the Runge-Kutta iteration. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Output - boolean to determine whether to print output. - */ - void Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output); - - /*! - * \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 - Description of the numerical method. - * \param[in] second_numerics - Description of the second 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, CNumerics *second_numerics, - CConfig *config, unsigned short iMesh); - - /*! - * \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 - 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_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, - CConfig *config, unsigned short iMesh); - - /*! - * \brief Update the solution using an implicit solver. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - */ - void ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config); - -}; - -/*! \class CWaveSolver - * \brief Main class for defining the wave solver. - * \author F. Palacios - * \date May 3, 2010. - */ -class CWaveSolver : public CSolver { -private: - su2double *CWave; /*!< \brief Wave strength for each boundary. */ - su2double AllBound_CWave; /*!< \brief Total wave strength for all the boundaries. */ - su2double Total_CWave; /*!< \brief Total wave strength for all the boundaries. */ - - CSysMatrix StiffMatrixSpace; /*!< \brief Sparse structure for storing the stiffness matrix in Galerkin computations. */ - CSysMatrix StiffMatrixTime; /*!< \brief Sparse structure for storing the stiffness matrix in Galerkin computations. */ - - su2double **StiffMatrix_Elem, /*!< \brief Auxiliary matrices for storing point to point Stiffness Matrices. */ - **StiffMatrix_Node; /*!< \brief Auxiliary matrices for storing point to point Stiffness Matrices. */ - -public: - - /*! - * \brief Constructor of the class. - */ - CWaveSolver(void); - - /*! - * \overload - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - CWaveSolver(CGeometry *geometry, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CWaveSolver(void); - - /*! - * \brief Integrate the Poisson equation using a Galerkin method. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] iRKStep - Current step of the Runge-Kutta iteration. - */ - void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, - unsigned short iMesh, unsigned short iRKStep); - - /*! - * \brief Impose via the residual the Euler wall boundary condition. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] numerics - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] val_marker - Surface marker where the boundary condition is applied. - */ - void BC_Euler_Wall(CGeometry *geometry, - CSolver **solver_container, - CNumerics *conv_numerics, - CNumerics *visc_numerics, - CConfig *config, - unsigned short val_marker) override; - - /*! - * \brief Impose a Dirichlet boundary condition. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] conv_numerics - Description of the numerical method. - * \param[in] visc_numerics - Description of the numerical method. - * \param[in] config - Definition of the particular problem. - * \param[in] val_marker - Surface marker where the boundary condition is applied. - */ - void BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, - unsigned short val_marker); - - /*! - * \brief Set residuals to zero. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] iRKStep - Current step of the Runge-Kutta iteration. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - * \param[in] Output - boolean to determine whether to print output. - */ - void Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output); - - /*! - * \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 - Description of the numerical method. - * \param[in] second_numerics - Description of the second 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, CNumerics *second_numerics, - CConfig *config, unsigned short iMesh); - - /*! - * \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 - 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_Template(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, - CConfig *config, unsigned short iMesh); - - /*! - * \brief Update the solution using an implicit solver. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - */ - void ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config); - - /*! - * \brief Set the total residual adding the term that comes from the Dual Time Strategy. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Container vector with all the solutions. - * \param[in] config - Definition of the particular problem. - * \param[in] iRKStep - Current step of the Runge-Kutta iteration. - * \param[in] iMesh - Index of the mesh in multigrid computations. - * \param[in] RunTime_EqSystem - System of equations which is going to be solved. - */ - void SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, - unsigned short iRKStep, unsigned short iMesh, unsigned short RunTime_EqSystem); - - /*! - * \brief Compute the total wave strength coefficient. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - void Wave_Strength(CGeometry *geometry, CConfig *config); - - /*! - * \brief Build stiffness matrix in space. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - void SetSpace_Matrix(CGeometry *geometry, - CConfig *config); - - /*! - * \brief Provide the total wave strength. - * \return Value of the wave strength. - */ - su2double GetTotal_CWave(void); - -}; - /*! \class CHeatSolverFVM * \brief Main class for defining the finite-volume heat solver. * \author O. Burghardt @@ -11387,12 +11218,19 @@ class CWaveSolver : public CSolver { class CHeatSolverFVM : public CSolver { protected: unsigned short nVarFlow, nMarker, CurrentMesh; - su2double **HeatFlux, *Surface_HF, Total_HeatFlux, AllBound_HeatFlux, - *AvgTemperature, Total_AvgTemperature, AllBound_AvgTemperature, + su2double **HeatFlux, *HeatFlux_per_Marker, *Surface_HF, Total_HeatFlux, AllBound_HeatFlux, + *AverageT_per_Marker, Total_AverageT, AllBound_AverageT, *Primitive, *Primitive_Flow_i, *Primitive_Flow_j, *Surface_Areas, Total_HeatFlux_Areas, Total_HeatFlux_Areas_Monitor; su2double ***ConjugateVar, ***InterfaceVar; + CHeatFVMVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -11727,6 +11565,13 @@ class CFEASolver : public CSolver { su2double *Res_Stress_i; /*!< \brief Submatrix to store the nodal stress contribution of node i. */ + CVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: CSysVector TimeRes_Aux; /*!< \brief Auxiliary vector for adding mass and damping contributions to the residual. */ @@ -12373,7 +12218,14 @@ class CFEASolver : public CSolver { */ class CTemplateSolver : public CSolver { private: - + + CVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -12604,7 +12456,14 @@ class CDiscAdjSolver : public CSolver { su2double Mach, Alpha, Beta, Pressure, Temperature, BPressure, ModVel; su2double *Solution_Geometry; /*!< \brief Auxiliary vector for the geometry solution (dimension nDim instead of nVar). */ - + + CDiscAdjVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -12846,7 +12705,7 @@ class CDiscAdjSolver : public CSolver { * \param[in] val_update_geo - Flag for updating coords and grid velocity. */ void LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo); - + void ComputeResidual_Multizone(CGeometry *geometry, CConfig *config); }; @@ -12903,6 +12762,13 @@ class CDiscAdjFEASolver : public CSolver { su2double *Local_Sens_DV, *Global_Sens_DV; /*!< \brief Local and global sensitivity of the Design Variable. */ su2double *Total_Sens_DV; + CDiscAdjFEABoundVariable* nodes = nullptr; /*!< \brief The highest level in the variable hierarchy this solver can safely use. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -13435,6 +13301,9 @@ class CFEM_DG_EulerSolver : public CSolver { vector tasksList; /*!< \brief List of tasks to be carried out in the computationally intensive part of the solver. */ + + CVariable* GetBaseClassPointerToNodes() {return nullptr;} + public: /*! diff --git a/SU2_CFD/include/solver_structure.inl b/SU2_CFD/include/solver_structure.inl index 60ea75629cd4..345c91feb443 100644 --- a/SU2_CFD/include/solver_structure.inl +++ b/SU2_CFD/include/solver_structure.inl @@ -43,6 +43,8 @@ inline void CSolver::SetResLinSolver(su2double val_reslinsolver) { ResLinSolver inline void CSolver::SetNondimensionalization(CConfig *config, unsigned short iMesh) { } +inline bool CSolver::GetAdjoint(void) { return adjoint; } + inline unsigned short CSolver::GetIterLinSolver(void) { return IterLinSolver; } inline su2double CSolver::GetCSensitivity(unsigned short val_marker, unsigned long val_vertex) { return 0; } @@ -937,12 +939,7 @@ inline unsigned long CSolver::GetPoint_Max_BGS(unsigned short val_var) { return inline su2double* CSolver::GetPoint_Max_Coord_BGS(unsigned short val_var) { return Point_Max_Coord_BGS[val_var]; } -inline void CSolver::Set_OldSolution(CGeometry *geometry) { - for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) - node[iPoint]->Set_OldSolution(); // The loop should be over nPoints - // to guarantee that the boundaries are - // well updated -} +inline void CSolver::Set_OldSolution(CGeometry *geometry) { base_nodes->Set_OldSolution(); } inline void CSolver::Set_NewSolution(CGeometry *geometry) { } @@ -1048,10 +1045,7 @@ inline void CSolver::SetTauWall_WF(CGeometry *geometry, CSolver** solver_contain inline void CSolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {} -inline void CEulerSolver::Set_NewSolution(CGeometry *geometry) { - for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) - node[iPoint]->SetSolution_New(); -} +inline void CEulerSolver::Set_NewSolution(CGeometry *geometry) { nodes->SetSolution_New(); } inline void CSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){} @@ -2267,7 +2261,7 @@ inline su2double CHeatSolverFVM::GetTotal_HeatFlux() { return Total_HeatFlux; } inline su2double CHeatSolverFVM::GetHeatFlux(unsigned short val_marker, unsigned long val_vertex) { return HeatFlux[val_marker][val_vertex]; } -inline su2double CHeatSolverFVM::GetTotal_AvgTemperature() { return Total_AvgTemperature; } +inline su2double CHeatSolverFVM::GetTotal_AvgTemperature() { return Total_AverageT; } inline su2double CHeatSolverFVM::GetConjugateHeatVariable(unsigned short val_marker, unsigned long val_vertex, unsigned short pos_var) { return ConjugateVar[val_marker][val_vertex][pos_var]; } @@ -2454,16 +2448,15 @@ inline void CTurbSolver::SetInlet_TurbVar(unsigned short val_marker, unsigned lo } inline void CTurbSASolver::SetFreeStream_Solution(CConfig *config) { - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint]->SetSolution(0, nu_tilde_Inf); + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) nodes->SetSolution(iPoint, 0, nu_tilde_Inf); } inline su2double CTurbSASolver::GetNuTilde_Inf(void) { return nu_tilde_Inf; } inline void CTurbSSTSolver::SetFreeStream_Solution(CConfig *config){ for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++){ - node[iPoint]->SetSolution(0, kine_Inf); - node[iPoint]->SetSolution(1, omega_Inf); + nodes->SetSolution(iPoint, 0, kine_Inf); + nodes->SetSolution(iPoint, 1, omega_Inf); } } diff --git a/SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp b/SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp index 66dadb27fd15..8e50d04d895b 100644 --- a/SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp @@ -39,6 +39,7 @@ #pragma once #include "../solver_structure.hpp" +#include "../variables/CDiscAdjMeshBoundVariable.hpp" /*! * \class CDiscAdjMeshSolver @@ -51,6 +52,13 @@ class CDiscAdjMeshSolver : public CSolver { unsigned short KindDirect_Solver; CSolver *direct_solver; + CDiscAdjMeshBoundVariable* nodes = nullptr; /*!< \brief Variables of the discrete adjoint mesh solver. */ + + /*! + * \brief Return nodes to allow CSolver::base_nodes to be set. + */ + inline CVariable* GetBaseClassPointerToNodes() override { return nodes; } + public: /*! @@ -110,12 +118,6 @@ class CDiscAdjMeshSolver : public CSolver { */ void ComputeResidual_Multizone(CGeometry *geometry, CConfig *config); - /*! - * \brief Store the BGS solution in the previous subiteration in the corresponding vector. - * \param[in] val_iterlinsolver - Number of linear iterations. - */ - void UpdateSolution_BGS(CGeometry *geometry, CConfig *config); - /*! * \brief Prepare the solver for a new recording. * \param[in] kind_recording - Kind of AD recording. diff --git a/SU2_CFD/include/solvers/CMeshSolver.hpp b/SU2_CFD/include/solvers/CMeshSolver.hpp index 614fbe06a50f..7bfc6c62e03c 100644 --- a/SU2_CFD/include/solvers/CMeshSolver.hpp +++ b/SU2_CFD/include/solvers/CMeshSolver.hpp @@ -116,7 +116,7 @@ class CMeshSolver : public CFEASolver { * \param[in] iDim - Dimension required. */ inline su2double Get_ValCoord(CGeometry *geometry, unsigned long indexNode, unsigned short iDim) { - return node[indexNode]->GetMesh_Coord(iDim); + return nodes->GetMesh_Coord(indexNode,iDim); } /*! @@ -154,12 +154,6 @@ class CMeshSolver : public CFEASolver { */ void SetBoundaryDisplacements(CGeometry *geometry, CNumerics *numerics, CConfig *config); - /*! - * \brief Set the value of the max residual and BGS residual. - * \param[in] val_iterlinsolver - Number of linear iterations. - */ - void ComputeResidual_Multizone(CGeometry *geometry, CConfig *config); - /*! * \brief Move the mesh in time. */ @@ -181,14 +175,6 @@ class CMeshSolver : public CFEASolver { */ void Restart_OldGeometry(CGeometry *geometry, CConfig *config); - /*! - * \brief Store the old displacement before a new deformation is done. - */ - inline void SetSolution_Old(void){ - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint]->Set_OldSolution(); - } - /*! * \brief Get minimun volume in the mesh * \return diff --git a/SU2_CFD/include/variables/CAdjEulerVariable.hpp b/SU2_CFD/include/variables/CAdjEulerVariable.hpp index e7d564cc282b..d407a187d628 100644 --- a/SU2_CFD/include/variables/CAdjEulerVariable.hpp +++ b/SU2_CFD/include/variables/CAdjEulerVariable.hpp @@ -47,129 +47,133 @@ */ class CAdjEulerVariable : public CVariable { protected: - su2double *Psi; /*!< \brief Vector of the adjoint variables. */ - su2double *ForceProj_Vector; /*!< \brief Vector d. */ - su2double *ObjFuncSource; /*!< \brief Vector containing objective function sensitivity for discrete adjoint. */ - su2double *IntBoundary_Jump; /*!< \brief Interior boundary jump vector. */ - su2double *HB_Source; /*!< \brief Harmonic balance source term. */ - bool incompressible; - su2double **Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ - bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ - -public: + MatrixType Psi; /*!< \brief Vector of the adjoint variables. */ + MatrixType ForceProj_Vector; /*!< \brief Vector d. */ + MatrixType ObjFuncSource; /*!< \brief Vector containing objective function sensitivity for discrete adjoint. */ + MatrixType IntBoundary_Jump; /*!< \brief Interior boundary jump vector. */ + MatrixType HB_Source; /*!< \brief Harmonic balance source term. */ - /*! - * \brief Constructor of the class. - */ - CAdjEulerVariable(void); - - /*! - * \overload - * \param[in] val_psirho - Value of the adjoint density (initialization value). - * \param[in] val_phi - Value of the adjoint velocity (initialization value). - * \param[in] val_psie - Value of the adjoint energy (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CAdjEulerVariable(su2double val_psirho, su2double *val_phi, su2double val_psie, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ +public: /*! - * \overload - * \param[in] val_solution - Pointer to the adjoint value (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \brief Constructor of the class. + * \param[in] psirho - Value of the adjoint density (initialization value). + * \param[in] phi - Value of the adjoint velocity (initialization value). + * \param[in] psie - Value of the adjoint energy (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CAdjEulerVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CAdjEulerVariable(su2double psirho, const su2double *phi, su2double psie, + unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - virtual ~CAdjEulerVariable(void); + virtual ~CAdjEulerVariable() = default; /*! * \brief Set all the primitive variables for compressible flows. */ - bool SetPrimVar(su2double SharpEdge_Distance, bool check, CConfig *config); + bool SetPrimVar(unsigned long iPoint, su2double SharpEdge_Distance, bool check, CConfig *config) final; /*! * \brief Set the value of the adjoint velocity. * \param[in] val_phi - Value of the adjoint velocity. */ - inline void SetPhi_Old(su2double *val_phi) {for (unsigned short iDim = 0; iDim < nDim; iDim++) Solution_Old[iDim+1]=val_phi[iDim]; }; + inline void SetPhi_Old(unsigned long iPoint, const su2double *val_phi) final { + for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution_Old(iPoint,iDim+1)=val_phi[iDim]; + } /*! * \brief Set the value of the force projection vector. * \param[in] val_ForceProj_Vector - Pointer to the force projection vector. */ - inline void SetForceProj_Vector(su2double *val_ForceProj_Vector) {for (unsigned short iDim = 0; iDim < nDim; iDim++) ForceProj_Vector[iDim] = val_ForceProj_Vector[iDim]; } + inline void SetForceProj_Vector(unsigned long iPoint, const su2double *val_ForceProj_Vector) final { + for (unsigned long iDim = 0; iDim < nDim; iDim++) ForceProj_Vector(iPoint,iDim) = val_ForceProj_Vector[iDim]; + } /*! * \brief Set the value of the objective function source. * \param[in] val_ObjFuncSource - Pointer to the objective function source. */ - inline void SetObjFuncSource(su2double *val_ObjFuncSource) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) ObjFuncSource[iVar] = val_ObjFuncSource[iVar]; + inline void SetObjFuncSource(unsigned long iPoint, const su2double *val_ObjFuncSource) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) ObjFuncSource(iPoint,iVar) = val_ObjFuncSource[iVar]; } /*! * \brief Set the value of the interior boundary jump vector vector. * \param[in] val_IntBoundary_Jump - Pointer to the interior boundary jump vector. */ - inline void SetIntBoundary_Jump(su2double *val_IntBoundary_Jump) {for (unsigned short iVar = 0; iVar < nVar; iVar++) IntBoundary_Jump[iVar] = val_IntBoundary_Jump[iVar]; } + inline void SetIntBoundary_Jump(unsigned long iPoint, const su2double *val_IntBoundary_Jump) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) IntBoundary_Jump(iPoint,iVar) = val_IntBoundary_Jump[iVar]; + } /*! * \brief Get the value of the force projection vector. * \return Pointer to the force projection vector. */ - inline su2double *GetForceProj_Vector(void) {return ForceProj_Vector; } + inline su2double *GetForceProj_Vector(unsigned long iPoint) final { return ForceProj_Vector[iPoint]; } /*! * \brief Get the value of the objective function source. * \param[in] val_SetObjFuncSource - Pointer to the objective function source. */ - inline su2double *GetObjFuncSource(void) {return ObjFuncSource; } + inline su2double *GetObjFuncSource(unsigned long iPoint) final { return ObjFuncSource[iPoint]; } /*! * \brief Get the value of the force projection vector. * \return Pointer to the force projection vector. */ - inline su2double *GetIntBoundary_Jump(void) {return IntBoundary_Jump; } + inline su2double *GetIntBoundary_Jump(unsigned long iPoint) final { return IntBoundary_Jump[iPoint]; } /*! * \brief Set the harmonic balance source term. - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the harmonic balance source term. for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] val_solution - Value of the harmonic balance source term. for the index iVar. */ - inline void SetHarmonicBalance_Source(unsigned short val_var, su2double val_source) {HB_Source[val_var] = val_source; } + inline void SetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar, su2double val_source) final { + HB_Source(iPoint,iVar) = val_source; + } /*! * \brief Get the harmonic balance source term. - * \param[in] val_var - Index of the variable. - * \return Value of the harmonic balance source term for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the harmonic balance source term for the index iVar. */ - inline su2double GetHarmonicBalance_Source(unsigned short val_var) {return HB_Source[val_var]; } - + inline su2double GetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar) const final { + return HB_Source(iPoint,iVar); + } + /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \return Value of the primitive variables gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \return Value of the reconstruction variables gradient at a node. */ - inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } - + inline su2double GetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final { + return Gradient_Reconstruction(iPoint,iVar,iDim); + } + /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] iDim - Index of the dimension. */ - inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } - + inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Reconstruction(iPoint,iVar,iDim) = value; + } + /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \return Value of the primitive variables gradient. + * \brief Get the array of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \return Array of the reconstruction variables gradient at a node. */ - inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } + inline su2double **GetGradient_Reconstruction(unsigned long iPoint) final { return Gradient_Reconstruction[iPoint]; } + }; diff --git a/SU2_CFD/include/variables/CAdjNSVariable.hpp b/SU2_CFD/include/variables/CAdjNSVariable.hpp index aaad126197e5..66e6f83e6a38 100644 --- a/SU2_CFD/include/variables/CAdjNSVariable.hpp +++ b/SU2_CFD/include/variables/CAdjNSVariable.hpp @@ -45,67 +45,31 @@ * \ingroup Navier_Stokes_Equations * \author F. Palacios */ -class CAdjNSVariable : public CAdjEulerVariable { -private: - +class CAdjNSVariable final : public CAdjEulerVariable { public: - /*! * \brief Constructor of the class. - */ - CAdjNSVariable(void); - - /*! - * \overload - * \param[in] val_psirho - Value of the adjoint density (initialization value). - * \param[in] val_phi - Value of the adjoint velocity (initialization value). - * \param[in] val_psie - Value of the adjoint energy (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] psirho - Value of the adjoint density (initialization value). + * \param[in] phi - Value of the adjoint velocity (initialization value). + * \param[in] psie - Value of the adjoint energy (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CAdjNSVariable(su2double val_psirho, su2double *val_phi, su2double val_psie, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); - - /*! - * \overload - * \param[in] val_solution - Pointer to the adjoint value (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CAdjNSVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CAdjNSVariable(su2double psirho, const su2double *phi, su2double psie, + unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - ~CAdjNSVariable(void); - - /*! - * \brief Set the value of the adjoint velocity. - * \param[in] val_phi - Value of the adjoint velocity. - */ - inline void SetPhi_Old(su2double *val_phi) {for (unsigned short iDim = 0; iDim < nDim; iDim++) Solution_Old[iDim+1] = val_phi[iDim]; }; - - /*! - * \brief Set the value of the force projection vector. - * \param[in] val_ForceProj_Vector - Pointer to the force projection vector. - */ - inline void SetForceProj_Vector(su2double *val_ForceProj_Vector) {for (unsigned short iDim = 0; iDim < nDim; iDim++) ForceProj_Vector[iDim] = val_ForceProj_Vector[iDim]; } - - /*! - * \brief Get the value of the force projection vector. - * \return Pointer to the force projection vector. - */ - inline su2double *GetForceProj_Vector(void) {return ForceProj_Vector; } - - /*! - * \brief Set the value of the force projection vector on the solution vector. - */ - inline void SetVelSolutionOldDVector(void) {for (unsigned short iDim = 0; iDim < nDim; iDim++) Solution_Old[iDim+1] = ForceProj_Vector[iDim]; }; + ~CAdjNSVariable() = default; /*! * \brief Set the value of the force projection vector on the old solution vector. */ - inline void SetVelSolutionDVector(void) {for (unsigned short iDim = 0; iDim < nDim; iDim++) Solution[iDim+1] = ForceProj_Vector[iDim]; }; + inline void SetVelSolutionDVector(unsigned long iPoint) override { + for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint,iDim+1) = ForceProj_Vector(iPoint,iDim); + } }; diff --git a/SU2_CFD/include/variables/CAdjTurbVariable.hpp b/SU2_CFD/include/variables/CAdjTurbVariable.hpp index 9aae546b341f..9f1e16a59d96 100644 --- a/SU2_CFD/include/variables/CAdjTurbVariable.hpp +++ b/SU2_CFD/include/variables/CAdjTurbVariable.hpp @@ -45,47 +45,42 @@ * \ingroup Turbulence_Model * \author A. Bueno. */ -class CAdjTurbVariable : public CVariable { +class CAdjTurbVariable final : public CVariable { protected: - su2double *dmuT_dUTvar; /*!< \brief Sensitivity of eddy viscosity to mean flow and turbulence vars. */ - su2double **dRTstar_dUTvar; /*!< \brief Sensitivity of modified turbulence residual (no boundary flux) - to mean flow and turbulence vars. */ - su2double **dFT_dUTvar; /*!< \brief Sensitivity of boundary flux - to mean flow and turbulence vars. */ - su2double *EddyViscSens; /*!< \brief Eddy Viscosity Sensitivity. */ + // ToDo: These variables were not being allocated... is this class used? + MatrixType dmuT_dUTvar; /*!< \brief Sensitivity of eddy viscosity to mean flow and turbulence vars. */ + VectorOfMatrix dRTstar_dUTvar; /*!< \brief Sensitivity of modified turbulence residual (no boundary flux) to mean flow and turbulence vars. */ + VectorOfMatrix dFT_dUTvar; /*!< \brief Sensitivity of boundary flux to mean flow and turbulence vars. */ + MatrixType EddyViscSens; /*!< \brief Eddy Viscosity Sensitivity. */ public: - /*! * \brief Constructor of the class. - */ - CAdjTurbVariable(void); - - /*! - * \overload - * \param[in] val_psinu_inf - Value of the adjoint turbulence variable at the infinity (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] psinu_inf - Value of the adjoint turbulence variable at the infinity (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CAdjTurbVariable(su2double val_psinu_inf, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CAdjTurbVariable(su2double psinu_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - ~CAdjTurbVariable(void); + ~CAdjTurbVariable() = default; /*! * \brief Set the Eddy Viscosity Sensitivity of the problem. * \param[in] val_EddyViscSens - Eddy Viscosity Sensitivity. */ - inline void SetEddyViscSens(su2double *val_EddyViscSens, unsigned short numTotalVar) { - for (unsigned short iVar = 0; iVar < numTotalVar; iVar++) EddyViscSens[iVar] = val_EddyViscSens[iVar]; + inline void SetEddyViscSens(unsigned long iPoint, const su2double *val_EddyViscSens, unsigned long numTotalVar) override { + for (unsigned long iVar = 0; iVar < numTotalVar; iVar++) + EddyViscSens(iPoint,iVar) = val_EddyViscSens[iVar]; } /*! * \brief Get the Eddy Viscosity Sensitivity of the problem. * \return Pointer to the Eddy Viscosity Sensitivity. */ - inline su2double *GetEddyViscSens(void) {return EddyViscSens; } + inline su2double *GetEddyViscSens(unsigned long iPoint) override { return EddyViscSens[iPoint]; } }; diff --git a/SU2_CFD/include/variables/CBaselineVariable.hpp b/SU2_CFD/include/variables/CBaselineVariable.hpp index 9f52d8c23e0b..921622e07788 100644 --- a/SU2_CFD/include/variables/CBaselineVariable.hpp +++ b/SU2_CFD/include/variables/CBaselineVariable.hpp @@ -44,25 +44,19 @@ * \brief Main class for defining the variables of a baseline solution from a restart file (for output). * \author F. Palacios, T. Economon. */ -class CBaselineVariable : public CVariable { +class CBaselineVariable final : public CVariable { public: - /*! * \brief Constructor of the class. - */ - CBaselineVariable(void); - - /*! - * \overload - * \param[in] val_solution - Pointer to the flow value (initialization value). - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CBaselineVariable(su2double *val_solution, unsigned short val_nvar, CConfig *config); + CBaselineVariable(unsigned long npoint, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - virtual ~CBaselineVariable(void); + ~CBaselineVariable() = default; }; diff --git a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp index f8b064d41992..1062a5feda06 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp @@ -38,6 +38,7 @@ #pragma once #include "CDiscAdjFEAVariable.hpp" +#include "../../../Common/include/toolboxes/CVertexMap.hpp" /*! * \class CDiscAdjFEABoundVariable @@ -46,55 +47,69 @@ * \author R. Sanchez. * \version 6.2.0 "Falcon" */ -class CDiscAdjFEABoundVariable : public CDiscAdjFEAVariable { -protected: +class CDiscAdjFEABoundVariable final : public CDiscAdjFEAVariable { +private: - su2double *FlowTraction_Sens; /*!< \brief Adjoint of the flow tractions. */ - su2double *SourceTerm_DispAdjoint; /*!< \brief Source term applied into the displacement adjoint - coming from external solvers. */ + MatrixType FlowTraction_Sens; /*!< \brief Adjoint of the flow tractions. */ + MatrixType SourceTerm_DispAdjoint; /*!< \brief Source term applied into the displacement + adjoint coming from external solvers. */ -public: - - /*! - * \brief Constructor of the class. - */ - CDiscAdjFEABoundVariable(void); + CVertexMap VertexMap; /*!< \brief Object that controls accesses to the variables of this class. */ +public: /*! * \overload - * \param[in] val_fea - Values of the fea solution (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] disp - Pointer to the adjoint value (initialization value). + * \param[in] vel - Pointer to the adjoint value (initialization value). + * \param[in] accel - Pointer to the adjoint value (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. + * \param[in] unsteady - Allocate velocity and acceleration. * \param[in] config - Definition of the particular problem. */ - CDiscAdjFEABoundVariable(su2double *val_fea, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CDiscAdjFEABoundVariable(const su2double *disp, const su2double *vel, const su2double *accel, + unsigned long npoint, unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config); /*! * \brief Destructor of the class. */ - ~CDiscAdjFEABoundVariable(void); + ~CDiscAdjFEABoundVariable() = default; + + /*! + * \brief Allocate member variables for points marked as vertex (via "Set_isVertex"). + * \param[in] config - Definition of the particular problem. + */ + void AllocateBoundaryVariables(CConfig *config); /*! * \brief Set the FSI force sensitivity at the node * \param[in] iDim - spacial component * \param[in] val - value of the Sensitivity */ - inline void SetFlowTractionSensitivity(unsigned short iDim, su2double val) { FlowTraction_Sens[iDim] = val; } + inline void SetFlowTractionSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + FlowTraction_Sens(iPoint,iDim) = val; + } /*! * \brief Get the FSI force sensitivity at the node * \param[in] iDim - spacial component * \return value of the Sensitivity */ - inline su2double GetFlowTractionSensitivity(unsigned short iDim) { return FlowTraction_Sens[iDim]; } + inline su2double GetFlowTractionSensitivity(unsigned long iPoint, unsigned long iDim) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return FlowTraction_Sens(iPoint,iDim); + } /*! * \brief Set the source term applied into the displacement adjoint coming from external solvers * \param[in] iDim - spacial component * \param[in] val - value of the source term */ - inline void SetSourceTerm_DispAdjoint(unsigned short iDim, su2double val){ - SourceTerm_DispAdjoint[iDim] = val; + inline void SetSourceTerm_DispAdjoint(unsigned long iPoint, unsigned long iDim, su2double val) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + SourceTerm_DispAdjoint(iPoint,iDim) = val; } /*! @@ -102,13 +117,23 @@ class CDiscAdjFEABoundVariable : public CDiscAdjFEAVariable { * \param[in] iDim - spacial component * \return value of the source term */ - inline su2double GetSourceTerm_DispAdjoint(unsigned short iDim){ - return SourceTerm_DispAdjoint[iDim]; + inline su2double GetSourceTerm_DispAdjoint(unsigned long iPoint, unsigned long iDim) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return SourceTerm_DispAdjoint(iPoint,iDim); } /*! - * \brief Get whether this node is on the boundary + * \brief Get whether a node is on the boundary */ - inline bool Get_isVertex(void) { return true; } + inline bool Get_isVertex(unsigned long iPoint) const override { + return VertexMap.GetIsVertex(iPoint); + } + + /*! + * \brief Set whether a node is on the boundary + */ + inline void Set_isVertex(unsigned long iPoint, bool isVertex) override { + VertexMap.SetIsVertex(iPoint,isVertex); + } }; diff --git a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp index 60e7a43b6b1d..b439fd7a87df 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp @@ -39,239 +39,255 @@ #include "CVariable.hpp" +/*! + * \class CDiscAdjFEAVariable + * \brief Main class for defining the variables of the adjoint solver. + * \ingroup Discrete_Adjoint + * \author T. Albring, R. Sanchez. + * \version 6.2.0 "Falcon" + */ class CDiscAdjFEAVariable : public CVariable { -private: - su2double* Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ - su2double* Solution_Direct; +protected: + MatrixType Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ + MatrixType Solution_Direct; - su2double* Dynamic_Derivative; - su2double* Dynamic_Derivative_n; - su2double* Dynamic_Derivative_Vel; - su2double* Dynamic_Derivative_Vel_n; - su2double* Dynamic_Derivative_Accel; - su2double* Dynamic_Derivative_Accel_n; + MatrixType Dynamic_Derivative; + MatrixType Dynamic_Derivative_n; + MatrixType Dynamic_Derivative_Vel; + MatrixType Dynamic_Derivative_Vel_n; + MatrixType Dynamic_Derivative_Accel; + MatrixType Dynamic_Derivative_Accel_n; - su2double* Solution_Vel; - su2double* Solution_Accel; + MatrixType Solution_Vel; + MatrixType Solution_Accel; - su2double* Solution_Vel_time_n; - su2double* Solution_Accel_time_n; + MatrixType Solution_Vel_time_n; + MatrixType Solution_Accel_time_n; - su2double* Solution_Old_Vel; - su2double* Solution_Old_Accel; + MatrixType Solution_Old_Vel; + MatrixType Solution_Old_Accel; - su2double* Solution_Direct_Vel; - su2double* Solution_Direct_Accel; + MatrixType Solution_Direct_Vel; + MatrixType Solution_Direct_Accel; - su2double* Cross_Term_Derivative; - su2double* Geometry_CrossTerm_Derivative; + MatrixType Cross_Term_Derivative; + MatrixType Geometry_CrossTerm_Derivative; - su2double* Solution_BGS; + MatrixType Solution_BGS; -public: /*! * \brief Constructor of the class. - */ - CDiscAdjFEAVariable(void); - - /*! - * \brief Destructor of the class. - */ - ~CDiscAdjFEAVariable(void); - - /*! - * \overload - * \param[in] val_solution - Pointer to the adjoint value (initialization value). - * \param[in] val_ndim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] disp - Pointer to the adjoint value (initialization value). + * \param[in] vel - Pointer to the adjoint value (initialization value). + * \param[in] accel - Pointer to the adjoint value (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. + * \param[in] unsteady - Allocate velocity and acceleration. * \param[in] config - Definition of the particular problem. */ - CDiscAdjFEAVariable(su2double *val_solution, unsigned short val_ndim, unsigned short val_nvar, CConfig *config); + CDiscAdjFEAVariable(const su2double *disp, const su2double *vel, const su2double *accel, + unsigned long npoint, unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config); +public: /*! - * \overload - * \param[in] val_solution - Pointer to the adjoint value (initialization value). - * \param[in] val_solution_accel - Pointer to the adjoint value (initialization value). - * \param[in] val_solution_vel - Pointer to the adjoint value (initialization value). - * \param[in] val_ndim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. + * \brief Destructor of the class. */ - CDiscAdjFEAVariable(su2double *val_solution, su2double *val_solution_accel, su2double *val_solution_vel, unsigned short val_ndim, unsigned short val_nvar, CConfig *config); + ~CDiscAdjFEAVariable() = default; /*! * \brief Set the sensitivity at the node * \param[in] iDim - spacial component * \param[in] val - value of the Sensitivity */ - inline void SetSensitivity(unsigned short iDim, su2double val) {Sensitivity[iDim] = val;} + inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity(iPoint,iDim) = val; } /*! * \brief Get the Sensitivity at the node * \param[in] iDim - spacial component * \return value of the Sensitivity */ - inline su2double GetSensitivity(unsigned short iDim) {return Sensitivity[iDim];} + inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity(iPoint,iDim);} - inline void SetDynamic_Derivative(unsigned short iVar, su2double der) {Dynamic_Derivative[iVar] = der; } + inline void SetDynamic_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) final { + Dynamic_Derivative(iPoint,iVar) = der; + } - inline void SetDynamic_Derivative_n(unsigned short iVar, su2double der) {Dynamic_Derivative_n[iVar] = der; } + inline void SetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) final { + Dynamic_Derivative_n(iPoint,iVar) = der; + } - inline su2double GetDynamic_Derivative(unsigned short iVar) {return Dynamic_Derivative[iVar]; } + inline su2double GetDynamic_Derivative(unsigned long iPoint, unsigned long iVar) const final { + return Dynamic_Derivative(iPoint,iVar); + } - inline su2double GetDynamic_Derivative_n(unsigned short iVar) {return Dynamic_Derivative_n[iVar]; } + inline su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const final { + return Dynamic_Derivative_n(iPoint,iVar); + } - inline void SetDynamic_Derivative_Vel(unsigned short iVar, su2double der) {Dynamic_Derivative_Vel[iVar] = der; } + inline void SetDynamic_Derivative_Vel(unsigned long iPoint, unsigned long iVar, su2double der) final { + Dynamic_Derivative_Vel(iPoint,iVar) = der; + } - inline void SetDynamic_Derivative_Vel_n(unsigned short iVar, su2double der) {Dynamic_Derivative_Vel_n[iVar] = der; } + inline void SetDynamic_Derivative_Vel_n(unsigned long iPoint, unsigned long iVar, su2double der) final { + Dynamic_Derivative_Vel_n(iPoint,iVar) = der; + } - inline su2double GetDynamic_Derivative_Vel(unsigned short iVar) {return Dynamic_Derivative_Vel[iVar]; } + inline su2double GetDynamic_Derivative_Vel(unsigned long iPoint, unsigned long iVar) const final { + return Dynamic_Derivative_Vel(iPoint,iVar); + } - inline su2double GetDynamic_Derivative_Vel_n(unsigned short iVar) {return Dynamic_Derivative_Vel_n[iVar]; } + inline su2double GetDynamic_Derivative_Vel_n(unsigned long iPoint, unsigned long iVar) const final { + return Dynamic_Derivative_Vel_n(iPoint,iVar); + } - inline void SetDynamic_Derivative_Accel(unsigned short iVar, su2double der) {Dynamic_Derivative_Accel[iVar] = der; } + inline void SetDynamic_Derivative_Accel(unsigned long iPoint, unsigned long iVar, su2double der) final { + Dynamic_Derivative_Accel(iPoint,iVar) = der; + } - inline void SetDynamic_Derivative_Accel_n(unsigned short iVar, su2double der) {Dynamic_Derivative_Accel_n[iVar] = der; } + inline void SetDynamic_Derivative_Accel_n(unsigned long iPoint, unsigned long iVar, su2double der) final { + Dynamic_Derivative_Accel_n(iPoint,iVar) = der; + } - inline su2double GetDynamic_Derivative_Accel(unsigned short iVar) {return Dynamic_Derivative_Accel[iVar]; } + inline su2double GetDynamic_Derivative_Accel(unsigned long iPoint, unsigned long iVar) const final { + return Dynamic_Derivative_Accel(iPoint,iVar); + } - inline su2double GetDynamic_Derivative_Accel_n(unsigned short iVar) {return Dynamic_Derivative_Accel_n[iVar]; } + inline su2double GetDynamic_Derivative_Accel_n(unsigned long iPoint, unsigned long iVar) const final { + return Dynamic_Derivative_Accel_n(iPoint,iVar); + } - inline void SetSolution_Direct(su2double *val_solution_direct) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Direct[iVar] = val_solution_direct[iVar]; + inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; } - inline void SetSolution_Vel_Direct(su2double *val_solution_direct) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Direct_Vel[iVar] = val_solution_direct[iVar]; + inline void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Vel(iPoint,iVar) = val_solution_direct[iVar]; } - inline void SetSolution_Accel_Direct(su2double *val_solution_direct) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Direct_Accel[iVar] = val_solution_direct[iVar]; + inline void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Accel(iPoint,iVar) = val_solution_direct[iVar]; } - inline su2double* GetSolution_Direct() {return Solution_Direct; } + inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } - inline su2double* GetSolution_Vel_Direct() {return Solution_Direct_Vel; } + inline su2double* GetSolution_Vel_Direct(unsigned long iPoint) final { return Solution_Direct_Vel[iPoint]; } - inline su2double* GetSolution_Accel_Direct() {return Solution_Direct_Accel; } + inline su2double* GetSolution_Accel_Direct(unsigned long iPoint) final { return Solution_Direct_Accel[iPoint]; } - inline su2double GetSolution_Old_Vel(unsigned short iVar) {return Solution_Old_Vel[iVar]; } + inline su2double GetSolution_Old_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Old_Vel(iPoint,iVar); } - inline su2double GetSolution_Old_Accel(unsigned short iVar) {return Solution_Old_Accel[iVar]; } + inline su2double GetSolution_Old_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Old_Accel(iPoint,iVar); } /*! * \brief Get the acceleration (Structural Analysis). - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_Accel(unsigned short val_var) {return Solution_Accel[val_var]; } + inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel(iPoint,iVar); } /*! * \brief Get the acceleration of the nodes (Structural Analysis) at time n. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_Accel_time_n(unsigned short val_var) {return Solution_Accel_time_n[val_var]; } + inline su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel_time_n(iPoint,iVar); } /*! * \brief Get the velocity (Structural Analysis). - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_Vel(unsigned short val_var) {return Solution_Vel[val_var]; } + inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel(iPoint,iVar); } /*! * \brief Get the velocity of the nodes (Structural Analysis) at time n. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_Vel_time_n(unsigned short val_var) {return Solution_Vel_time_n[val_var]; } + inline su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel_time_n(iPoint,iVar); } /*! * \brief Set the value of the acceleration (Structural Analysis - adjoint). * \param[in] val_solution - Solution of the problem (acceleration). */ - inline void SetSolution_Accel(su2double *val_solution_accel) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_Accel[iVar] = val_solution_accel[iVar]; + inline void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution_Accel(iPoint,iVar) = val_solution_accel[iVar]; } /*! * \brief Set the value of the velocity (Structural Analysis - adjoint). * \param[in] val_solution - Solution of the problem (velocity). */ - inline void SetSolution_Vel(su2double *val_solution_vel) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Vel[iVar] = val_solution_vel[iVar]; + inline void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel(iPoint,iVar) = val_solution_vel[iVar]; } /*! * \brief Set the value of the adjoint acceleration (Structural Analysis) at time n. * \param[in] val_solution_old - Pointer to the residual vector. */ - inline void SetSolution_Accel_time_n(su2double *val_solution_accel_time_n) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Accel_time_n[iVar] = val_solution_accel_time_n[iVar]; + inline void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar]; } /*! * \brief Set the value of the adjoint velocity (Structural Analysis) at time n. * \param[in] val_solution_old - Pointer to the residual vector. */ - inline void SetSolution_Vel_time_n(su2double *val_solution_vel_time_n) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n[iVar] = val_solution_vel_time_n[iVar]; + inline void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n[iVar]; } /*! * \brief Set the value of the old acceleration (Structural Analysis - adjoint). - * \param[in] val_solution - Old solution of the problem (acceleration). */ - inline void Set_OldSolution_Accel(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Old_Accel[iVar] = Solution_Accel[iVar]; - } + void Set_OldSolution_Accel() final; /*! * \brief Set the value of the old velocity (Structural Analysis - adjoint). - * \param[in] val_solution - Old solution of the problem (velocity). */ - inline void Set_OldSolution_Vel(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Old_Vel[iVar] = Solution_Vel[iVar]; - } + void Set_OldSolution_Vel() final; /*! * \brief Set the contribution of crossed terms into the derivative. */ - inline void SetCross_Term_Derivative(unsigned short iVar, su2double der) {Cross_Term_Derivative[iVar] = der; } + inline void SetCross_Term_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) final { + Cross_Term_Derivative(iPoint,iVar) = der; + } /*! * \brief Get the contribution of crossed terms into the derivative. */ - inline su2double GetCross_Term_Derivative(unsigned short iVar) {return Cross_Term_Derivative[iVar]; } + inline su2double GetCross_Term_Derivative(unsigned long iPoint, unsigned long iVar) const final { return Cross_Term_Derivative(iPoint,iVar); } /*! * \brief A virtual member. Get the geometry solution. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetGeometry_CrossTerm_Derivative(unsigned short val_var) {return Geometry_CrossTerm_Derivative[val_var];} + inline su2double GetGeometry_CrossTerm_Derivative(unsigned long iPoint, unsigned long iVar) const final { + return Geometry_CrossTerm_Derivative(iPoint,iVar); + } /*! * \brief A virtual member. Set the value of the mesh solution (adjoint). * \param[in] der - cross term derivative. */ - inline void SetGeometry_CrossTerm_Derivative(unsigned short iDim, su2double der) {Geometry_CrossTerm_Derivative[iDim] = der;} + inline void SetGeometry_CrossTerm_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) final { + Geometry_CrossTerm_Derivative(iPoint,iVar) = der; + } /*! * \brief Set the value of the adjoint solution in the current BGS subiteration. */ - inline void Set_BGSSolution(unsigned short iDim, su2double val_solution) {Solution_BGS[iDim] = val_solution;} + inline void Set_BGSSolution(unsigned long iPoint, unsigned long iDim, su2double val_solution) final { Solution_BGS(iPoint,iDim) = val_solution; } /*! * \brief Get the value of the adjoint solution in the previous BGS subiteration. * \param[out] val_solution - adjoint solution in the previous BGS subiteration. */ - inline su2double Get_BGSSolution(unsigned short iDim) {return Solution_BGS[iDim];} + inline su2double Get_BGSSolution(unsigned long iPoint, unsigned long iDim) const final { return Solution_BGS(iPoint,iDim); } - /*! - * \brief Get whether this node is on the boundary - */ - inline virtual bool Get_isVertex(void) { return false; } }; diff --git a/SU2_CFD/include/variables/CDiscAdjMeshBoundVariable.hpp b/SU2_CFD/include/variables/CDiscAdjMeshBoundVariable.hpp index 56eee21f8f58..ba2f0b82b022 100644 --- a/SU2_CFD/include/variables/CDiscAdjMeshBoundVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjMeshBoundVariable.hpp @@ -38,53 +38,67 @@ #pragma once -#include "CDiscAdjMeshVariable.hpp" +#include "CVariable.hpp" +#include "../../../Common/include/toolboxes/CVertexMap.hpp" -class CDiscAdjMeshBoundVariable : public CDiscAdjMeshVariable { -protected: +class CDiscAdjMeshBoundVariable final : public CVariable { +private: - su2double* Bound_Disp_Sens; /*!< \brief Store the reference coordinates of the mesh. */ - su2double* Bound_Disp_Direct; /*!< \brief Store the reference boundary displacements of the mesh. */ + MatrixType Bound_Disp_Sens; /*!< \brief Store the reference coordinates of the mesh. */ + MatrixType Bound_Disp_Direct; /*!< \brief Store the reference boundary displacements of the mesh. */ - su2double* Solution_BGS_k; /*!< \brief BGS solution to compute overall convergence. */ + MatrixType Solution_BGS_k; /*!< \brief BGS solution to compute overall convergence. */ + + CVertexMap VertexMap; /*!< \brief Object that controls accesses to the variables of this class. */ public: /*! * \brief Constructor of the class. - * \param[in] val_coor - Values of the coordinates (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. + * \param[in] npoint - Values of the coordinates (initialization value). + * \param[in] ndim - Number of dimensions of the problem. * \param[in] config - Definition of the particular problem. */ - CDiscAdjMeshBoundVariable(su2double *val_coor, unsigned short val_nDim, CConfig *config); + CDiscAdjMeshBoundVariable(unsigned long npoint, unsigned long ndim, CConfig *config); /*! * \brief Destructor of the class. */ - ~CDiscAdjMeshBoundVariable(void); + ~CDiscAdjMeshBoundVariable() = default; + + /*! + * \brief Allocate member variables for points marked as vertex (via "Set_isVertex"). + * \param[in] config - Definition of the particular problem. + */ + void AllocateBoundaryVariables(CConfig *config); /*! * \brief Get the value of the displacement imposed at the boundary. * \return Value of the boundary displacement. */ - inline su2double* GetBoundDisp_Direct(void) { return Bound_Disp_Direct; } + inline const su2double* GetBoundDisp_Direct(unsigned long iPoint) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return nullptr; + return Bound_Disp_Direct[iPoint]; + } /*! * \brief Set the solution for the boundary displacements. * \param[in] val_BoundDisp - Pointer to the boundary displacements. */ - inline void SetBoundDisp_Direct(const su2double *val_BoundDisp) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Bound_Disp_Direct[iDim] = val_BoundDisp[iDim]; + inline void SetBoundDisp_Direct(unsigned long iPoint, const su2double *val_BoundDisp) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Bound_Disp_Direct(iPoint,iDim) = val_BoundDisp[iDim]; } /*! * \brief Set the value of the sensitivity with respect to the undeformed coordinates. * \param[in] val_sens - Pointer to the sensitivities of the boundary displacements. */ - inline void SetBoundDisp_Sens(const su2double *val_sens) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Bound_Disp_Sens[iDim] = val_sens[iDim]; + inline void SetBoundDisp_Sens(unsigned long iPoint, const su2double *val_sens) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Bound_Disp_Sens(iPoint,iDim) = val_sens[iDim]; } /*! @@ -92,26 +106,37 @@ class CDiscAdjMeshBoundVariable : public CDiscAdjMeshVariable { * \param[in] iDim - Index of Mesh_Coord_Sens[nDim] * \return Value of the original Mesh_Coord_Sens iDim. */ - inline su2double GetBoundDisp_Sens(unsigned short iDim) const final { return Bound_Disp_Sens[iDim]; } + inline su2double GetBoundDisp_Sens(unsigned long iPoint, unsigned long iDim) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return Bound_Disp_Sens(iPoint,iDim); + } + + /*! + * \brief Get whether a node is on the boundary + */ + inline bool Get_isVertex(unsigned long iPoint) const override { + return VertexMap.GetIsVertex(iPoint); + } /*! - * \brief Determine whether the node is a moving vertex. - * \return True. The node is at the boundary. + * \brief Set whether a node is on the boundary */ - inline bool Get_isVertex(void) const final { return true; } + inline void Set_isVertex(unsigned long iPoint, bool isVertex) override { + VertexMap.SetIsVertex(iPoint,isVertex); + } /*! * \brief Set the value of the solution in the previous BGS subiteration. */ - inline void Set_BGSSolution_k(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_BGS_k[iVar] = Bound_Disp_Sens[iVar]; - } + void Set_BGSSolution_k() override; /*! * \brief Get the value of the solution in the previous BGS subiteration. * \param[out] val_solution - solution in the previous BGS subiteration. */ - inline su2double Get_BGSSolution_k(unsigned short iDim) { return Solution_BGS_k[iDim];} + inline su2double Get_BGSSolution_k(unsigned long iPoint, unsigned long iDim) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return Solution_BGS_k(iPoint,iDim); + } }; diff --git a/SU2_CFD/include/variables/CDiscAdjMeshVariable.hpp b/SU2_CFD/include/variables/CDiscAdjMeshVariable.hpp deleted file mode 100644 index 0bbe0aa29e53..000000000000 --- a/SU2_CFD/include/variables/CDiscAdjMeshVariable.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/*! - * \file CDiscAdjMeshVariable.hpp - * \brief Declaration and inlines of the class - * to define the adjoint variables of the mesh movement. - * \author Ruben Sanchez - * \version 6.2.0 "Falcon" - * - * The current SU2 release has been coordinated by the - * SU2 International Developers Society - * with selected contributions from the open-source community. - * - * The main research teams contributing to the current release are: - * - Prof. Juan J. Alonso's group at Stanford University. - * - Prof. Piero Colonna's group at Delft University of Technology. - * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. - * - Prof. Alberto Guardone's group at Polytechnic University of Milan. - * - Prof. Rafael Palacios' group at Imperial College London. - * - Prof. Vincent Terrapon's group at the University of Liege. - * - Prof. Edwin van der Weide's group at the University of Twente. - * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. - * - * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, - * Tim Albring, and the SU2 contributors. - * - * 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 . - */ - -#pragma once - -#include "CVariable.hpp" - -class CDiscAdjMeshVariable : public CVariable { -protected: - -public: - - /*! - * \brief Constructor of the class. - * \param[in] val_coor - Values of the coordinates (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] config - Definition of the particular problem. - */ - CDiscAdjMeshVariable(su2double *val_coor, unsigned short val_nDim, CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CDiscAdjMeshVariable(void); - - /*! - * \brief Determine whether the node is a moving vertex. - * \return False. The node is not at the boundary. - */ - inline virtual bool Get_isVertex(void) const override { return false; } - -}; diff --git a/SU2_CFD/include/variables/CDiscAdjVariable.hpp b/SU2_CFD/include/variables/CDiscAdjVariable.hpp index 8fe1a4a04821..1ad4ecc1a3a9 100644 --- a/SU2_CFD/include/variables/CDiscAdjVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjVariable.hpp @@ -45,192 +45,186 @@ * \ingroup Discrete_Adjoint * \author T. Albring. */ -class CDiscAdjVariable : public CVariable { +class CDiscAdjVariable final : public CVariable { private: - su2double* Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ - su2double* Solution_Direct; - su2double* DualTime_Derivative; - su2double* DualTime_Derivative_n; + MatrixType Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ + MatrixType Solution_Direct; + MatrixType DualTime_Derivative; + MatrixType DualTime_Derivative_n; - su2double* Cross_Term_Derivative; - su2double* Geometry_CrossTerm_Derivative; - su2double* Geometry_CrossTerm_Derivative_Flow; + MatrixType Cross_Term_Derivative; + MatrixType Geometry_CrossTerm_Derivative; + MatrixType Geometry_CrossTerm_Derivative_Flow; - su2double* Solution_Geometry; - su2double* Solution_Geometry_Old; - su2double* Geometry_Direct; + MatrixType Solution_Geometry; + MatrixType Solution_Geometry_Old; + MatrixType Geometry_Direct; - su2double* Solution_BGS; - su2double* Solution_Geometry_BGS_k; + MatrixType Solution_BGS; + MatrixType Solution_Geometry_BGS_k; public: /*! * \brief Constructor of the class. + * \param[in] sol - Pointer to the adjoint value (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. + * \param[in] config - Definition of the particular problem. */ - CDiscAdjVariable(void); + CDiscAdjVariable(const su2double* sol, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - ~CDiscAdjVariable(void); - - /*! - * \overload - * \param[in] val_solution - Pointer to the adjoint value (initialization value). - * \param[in] val_ndim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CDiscAdjVariable(su2double *val_solution, unsigned short val_ndim, unsigned short val_nvar, CConfig *config); + ~CDiscAdjVariable() = default; /*! * \brief Set the sensitivity at the node * \param[in] iDim - spacial component * \param[in] val - value of the Sensitivity */ - inline void SetSensitivity(unsigned short iDim, su2double val) {Sensitivity[iDim] = val;} + inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) override { Sensitivity(iPoint,iDim) = val;} /*! * \brief Get the Sensitivity at the node * \param[in] iDim - spacial component * \return value of the Sensitivity */ - inline su2double GetSensitivity(unsigned short iDim) {return Sensitivity[iDim];} + inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const override { return Sensitivity(iPoint,iDim); } - inline void SetDual_Time_Derivative(unsigned short iVar, su2double der) {DualTime_Derivative[iVar] = der;} + inline void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) override { DualTime_Derivative(iPoint,iVar) = der; } - inline void SetDual_Time_Derivative_n(unsigned short iVar, su2double der) {DualTime_Derivative_n[iVar] = der;} + inline void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) override { DualTime_Derivative_n(iPoint,iVar) = der; } - inline su2double GetDual_Time_Derivative(unsigned short iVar) {return DualTime_Derivative[iVar];} + inline su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const override { return DualTime_Derivative(iPoint,iVar); } - inline su2double GetDual_Time_Derivative_n(unsigned short iVar) {return DualTime_Derivative_n[iVar];} + inline su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const override { return DualTime_Derivative_n(iPoint,iVar); } - inline void SetSolution_Direct(su2double *val_solution_direct) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_Direct[iVar] = val_solution_direct[iVar]; + inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) override { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; } - inline su2double* GetSolution_Direct() {return Solution_Direct; } + inline su2double* GetSolution_Direct(unsigned long iPoint) override { return Solution_Direct[iPoint]; } /*! * \brief Set the restart geometry (coordinate of the converged solution) * \param[in] val_geometry_direct - Value of the restart coordinate. */ - inline void SetGeometry_Direct(su2double *val_geometry_direct) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Geometry_Direct[iDim] = val_geometry_direct[iDim]; + inline void SetGeometry_Direct(unsigned long iPoint, const su2double *val_geometry_direct) override { + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Geometry_Direct(iPoint,iDim) = val_geometry_direct[iDim]; } /*! * \brief Get the restart geometry (coordinate of the converged solution). * \return Pointer to the restart coordinate vector. */ - inline su2double *GetGeometry_Direct(void) {return Geometry_Direct;} + inline su2double *GetGeometry_Direct(unsigned long iPoint) override { return Geometry_Direct[iPoint]; } /*! * \brief Get the restart geometry (coordinate of the converged solution). - * \return Coordinate val_dim of the geometry_direct vector. + * \return Coordinate iDim of the geometry_direct vector. */ - inline su2double GetGeometry_Direct(unsigned short val_dim) {return Geometry_Direct[val_dim]; } + inline su2double GetGeometry_Direct(unsigned long iPoint, unsigned long iDim) const override { return Geometry_Direct(iPoint,iDim); } /*! * \brief Get the geometry solution. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iDim - Index of the coordinate. + * \return Value of the solution for the index iDim. */ - inline su2double GetSolution_Geometry(unsigned short val_var) {return Solution_Geometry[val_var];} + inline su2double GetSolution_Geometry(unsigned long iPoint, unsigned long iDim) const override { return Solution_Geometry(iPoint,iDim); } /*! * \brief Set the value of the mesh solution (adjoint). * \param[in] val_solution_geometry - Solution of the problem (acceleration). */ - inline void SetSolution_Geometry(su2double *val_solution_geometry) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Solution_Geometry[iDim] = val_solution_geometry[iDim]; + inline void SetSolution_Geometry(unsigned long iPoint, const su2double *val_solution_geometry) override { + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Solution_Geometry(iPoint,iDim) = val_solution_geometry[iDim]; } /*! * \brief A virtual member. Set the value of the mesh solution (adjoint). * \param[in] val_solution_geometry - Solution of the problem (acceleration). */ - inline void SetSolution_Geometry(unsigned short val_var, su2double val_solution_geometry) { - Solution_Geometry[val_var] = val_solution_geometry; + inline void SetSolution_Geometry(unsigned long iPoint, unsigned long iVar, su2double val_solution_geometry) override { + Solution_Geometry(iPoint,iVar) = val_solution_geometry; } /*! * \brief A virtual member. Get the geometry solution. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetGeometry_CrossTerm_Derivative(unsigned short val_var) {return Geometry_CrossTerm_Derivative[val_var];} + inline su2double GetGeometry_CrossTerm_Derivative(unsigned long iPoint, unsigned long iVar) const override { + return Geometry_CrossTerm_Derivative(iPoint,iVar); + } /*! * \brief A virtual member. Set the value of the mesh solution (adjoint). * \param[in] der - cross term derivative. */ - inline void SetGeometry_CrossTerm_Derivative(unsigned short iDim, su2double der) {Geometry_CrossTerm_Derivative[iDim] = der;} + inline void SetGeometry_CrossTerm_Derivative(unsigned long iPoint, unsigned long iDim, su2double der) override { + Geometry_CrossTerm_Derivative(iPoint,iDim) = der; + } /*! * \brief Get the mesh cross term derivative from the flow solution. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetGeometry_CrossTerm_Derivative_Flow(unsigned short val_var) {return Geometry_CrossTerm_Derivative_Flow[val_var];} + inline su2double GetGeometry_CrossTerm_Derivative_Flow(unsigned long iPoint, unsigned long iVar) const override { + return Geometry_CrossTerm_Derivative_Flow(iPoint,iVar); + } /*! * \brief Set the value of the mesh cross term derivative from the flow solution (adjoint). * \param[in] der - cross term derivative. */ - inline void SetGeometry_CrossTerm_Derivative_Flow(unsigned short iDim, su2double der) {Geometry_CrossTerm_Derivative_Flow[iDim] = der;} + inline void SetGeometry_CrossTerm_Derivative_Flow(unsigned long iPoint, unsigned long iDim, su2double der) override { + Geometry_CrossTerm_Derivative_Flow(iPoint,iDim) = der; + } /*! * \brief Set the value of the mesh solution (adjoint). - * \param[in] val_solution - Solution of the problem (acceleration). */ - inline void Set_OldSolution_Geometry(void) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Solution_Geometry_Old[iDim] = Solution_Geometry[iDim]; - } + void Set_OldSolution_Geometry() override; /*! * \brief Get the value of the old geometry solution (adjoint). * \param[out] val_solution - old adjoint solution for coordinate iDim */ - inline su2double Get_OldSolution_Geometry(unsigned short iDim) {return Solution_Geometry_Old[iDim];} + inline su2double Get_OldSolution_Geometry(unsigned long iPoint, unsigned long iDim) const override { + return Solution_Geometry_Old(iPoint,iDim); + } /*! * \brief Set the value of the adjoint solution in the current BGS subiteration. */ - inline void Set_BGSSolution(unsigned short iDim, su2double val_solution) {Solution_BGS[iDim] = val_solution;} + inline void Set_BGSSolution(unsigned long iPoint, unsigned long iDim, su2double val_solution) override { + Solution_BGS(iPoint,iDim) = val_solution; + } /*! * \brief Get the value of the adjoint solution in the previous BGS subiteration. * \param[out] val_solution - adjoint solution in the previous BGS subiteration. */ - inline su2double Get_BGSSolution(unsigned short iDim) {return Solution_BGS[iDim];} - - /*! - * \brief Set the value of the adjoint geometry solution in the previous BGS subiteration. - */ - inline void Set_BGSSolution_Geometry(void) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Solution_Geometry_BGS_k[iDim] = Solution_Geometry[iDim]; - } - - /*! - * \brief Get the value of the adjoint geometry solution in the previous BGS subiteration. - * \param[out] val_solution - geometrical adjoint solution in the previous BGS subiteration. - */ - inline su2double Get_BGSSolution_Geometry(unsigned short iDim) {return Solution_Geometry_BGS_k[iDim];} + inline su2double Get_BGSSolution(unsigned long iPoint, unsigned long iDim) const override { return Solution_BGS(iPoint,iDim);} /*! * \brief Set the contribution of crossed terms into the derivative. */ - inline void SetCross_Term_Derivative(unsigned short iVar, su2double der) {Cross_Term_Derivative[iVar] = der; } + inline void SetCross_Term_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) override { + Cross_Term_Derivative(iPoint,iVar) = der; + } /*! * \brief Get the contribution of crossed terms into the derivative. */ - inline su2double GetCross_Term_Derivative(unsigned short iVar) {return Cross_Term_Derivative[iVar]; } + inline su2double GetCross_Term_Derivative(unsigned long iPoint, unsigned long iVar) const override { + return Cross_Term_Derivative(iPoint,iVar); + } }; diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 3fc44974728c..822207394abb 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -47,263 +47,191 @@ */ class CEulerVariable : public CVariable { protected: - su2double Velocity2; /*!< \brief Square of the velocity vector. */ - su2double *HB_Source; /*!< \brief harmonic balance source term. */ - su2double Precond_Beta; /*!< \brief Low Mach number preconditioner value, Beta. */ - su2double *WindGust; /*! < \brief Wind gust value */ - su2double *WindGustDer; /*! < \brief Wind gust derivatives value */ + VectorType Velocity2; /*!< \brief Square of the velocity vector. */ + MatrixType HB_Source; /*!< \brief harmonic balance source term. */ + MatrixType WindGust; /*! < \brief Wind gust value */ + MatrixType WindGustDer; /*! < \brief Wind gust derivatives value */ /*--- Primitive variable definition ---*/ - - su2double *Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ - su2double **Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - su2double **Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term (T, vx, vy, vz, P, rho). */ - bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ - su2double *Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ + MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ + VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ + VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term (T, vx, vy, vz, P, rho). */ + MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ /*--- Secondary variable definition ---*/ + MatrixType Secondary; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ - su2double *Secondary; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ - su2double **Gradient_Secondary; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - su2double *Limiter_Secondary; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ - - /*--- New solution container for Classical RK4 ---*/ - - su2double *Solution_New; + MatrixType Solution_New; /*!< \brief New solution container for Classical RK4. */ public: - /*! * \brief Constructor of the class. - */ - CEulerVariable(void); - - /*! - * \overload - * \param[in] val_density - Value of the flow density (initialization value). - * \param[in] val_velocity - Value of the flow velocity (initialization value). - * \param[in] val_energy - Value of the flow energy (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CEulerVariable(su2double val_density, su2double *val_velocity, su2double val_energy, unsigned short val_nDim, - unsigned short val_nvar, CConfig *config); - - /*! - * \overload - * \param[in] val_solution - Pointer to the flow value (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] density - Value of the flow density (initialization value). + * \param[in] velocity - Value of the flow velocity (initialization value). + * \param[in] energy - Value of the flow energy (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CEulerVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CEulerVariable(su2double density, const su2double *velocity, su2double energy, + unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - virtual ~CEulerVariable(void); + virtual ~CEulerVariable() = default; /*! * \brief Get the new solution of the problem (Classical RK4). - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_New(unsigned short val_var) {return Solution_New[val_var]; } + inline su2double GetSolution_New(unsigned long iPoint, unsigned long iVar) const final { return Solution_New(iPoint,iVar); } /*! * \brief Set the new solution container for Classical RK4. */ - inline void SetSolution_New(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_New[iVar] = Solution[iVar]; - } + void SetSolution_New() final; /*! * \brief Add a value to the new solution container for Classical RK4. - * \param[in] val_var - Number of the variable. + * \param[in] iVar - Number of the variable. * \param[in] val_solution - Value that we want to add to the solution. */ - inline void AddSolution_New(unsigned short val_var, su2double val_solution) {Solution_New[val_var] += val_solution;} - - /*! - * \brief Set to zero the gradient of the primitive variables. - */ - void SetGradient_PrimitiveZero(unsigned short val_primvar); - - /*! - * \brief Add val_value to the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to add to the gradient of the primitive variables. - */ - inline void AddGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Primitive[val_var][val_dim] += val_value; } - - /*! - * \brief Subtract val_value to the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to subtract to the gradient of the primitive variables. - */ - inline void SubtractGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Primitive[val_var][val_dim] -= val_value; } - - /*! - * \brief Get the value of the primitive variables gradient. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \return Value of the primitive variables gradient. - */ - inline su2double GetGradient_Primitive(unsigned short val_var, unsigned short val_dim) {return Gradient_Primitive[val_var][val_dim]; } - - /*! - * \brief Get the value of the primitive variables gradient. - * \param[in] val_var - Index of the variable. - * \return Value of the primitive variables gradient. - */ - inline su2double GetLimiter_Primitive(unsigned short val_var) {return Limiter_Primitive[val_var]; } - - /*! - * \brief Set the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. - */ - inline void SetGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Primitive[val_var][val_dim] = val_value; } - - /*! - * \brief Set the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_value - Value of the gradient. - */ - inline void SetLimiter_Primitive(unsigned short val_var, su2double val_value) {Limiter_Primitive[val_var] = val_value; } - - /*! - * \brief Get the value of the primitive variables gradient. - * \return Value of the primitive variables gradient. - */ - inline su2double **GetGradient_Primitive(void) {return Gradient_Primitive; } - - /*! - * \brief Get the value of the primitive variables gradient. - * \return Value of the primitive variables gradient. - */ - inline su2double *GetLimiter_Primitive(void) {return Limiter_Primitive; } + inline void AddSolution_New(unsigned long iPoint, unsigned long iVar, su2double val_solution) final { + Solution_New(iPoint,iVar) += val_solution; + } /*! * \brief Set to zero the gradient of the primitive variables. */ - void SetGradient_SecondaryZero(unsigned short val_secondaryvar); + void SetGradient_PrimitiveZero() final; /*! - * \brief Add val_value to the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to add to the gradient of the primitive variables. + * \brief Add value to the gradient of the primitive variables. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value to add to the gradient of the primitive variables. */ - inline void AddGradient_Secondary(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Secondary[val_var][val_dim] += val_value; } + inline void AddGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Primitive(iPoint,iVar,iDim) += value; + } /*! - * \brief Subtract val_value to the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to subtract to the gradient of the primitive variables. + * \brief Subtract value to the gradient of the primitive variables. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value to subtract to the gradient of the primitive variables. */ - inline void SubtractGradient_Secondary(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Secondary[val_var][val_dim] -= val_value; } + inline void SubtractGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Primitive(iPoint,iVar,iDim) -= value; + } /*! * \brief Get the value of the primitive variables gradient. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. * \return Value of the primitive variables gradient. */ - inline su2double GetGradient_Secondary(unsigned short val_var, unsigned short val_dim) {return Gradient_Secondary[val_var][val_dim]; } + inline su2double GetGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final { + return Gradient_Primitive(iPoint,iVar,iDim); + } /*! * \brief Get the value of the primitive variables gradient. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. + * \param[in] iVar - Index of the variable. * \return Value of the primitive variables gradient. */ - inline su2double GetLimiter_Secondary(unsigned short val_var) {return Limiter_Secondary[val_var]; } + inline su2double GetLimiter_Primitive(unsigned long iPoint, unsigned long iVar) const final {return Limiter_Primitive(iPoint,iVar); } /*! * \brief Set the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value of the gradient. */ - inline void SetGradient_Secondary(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Secondary[val_var][val_dim] = val_value; } + inline void SetGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Primitive(iPoint,iVar,iDim) = value; + } /*! * \brief Set the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \param[in] iVar - Index of the variable. + * \param[in] value - Value of the gradient. */ - inline void SetLimiter_Secondary(unsigned short val_var, su2double val_value) {Limiter_Secondary[val_var] = val_value; } + inline void SetLimiter_Primitive(unsigned long iPoint, unsigned long iVar, su2double value) final { + Limiter_Primitive(iPoint,iVar) = value; + } /*! * \brief Get the value of the primitive variables gradient. * \return Value of the primitive variables gradient. */ - inline su2double **GetGradient_Secondary(void) {return Gradient_Secondary; } + inline su2double **GetGradient_Primitive(unsigned long iPoint) final { return Gradient_Primitive[iPoint]; } /*! * \brief Get the value of the primitive variables gradient. * \return Value of the primitive variables gradient. */ - inline su2double *GetLimiter_Secondary(void) {return Limiter_Secondary; } + inline su2double *GetLimiter_Primitive(unsigned long iPoint) final { return Limiter_Primitive[iPoint]; } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \return Value of the primitive variables gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \return Value of the reconstruction variables gradient at a node. */ - inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + inline su2double GetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final { + return Gradient_Reconstruction(iPoint,iVar,iDim); + } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] iDim - Index of the dimension. */ - inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Reconstruction(iPoint,iVar,iDim) = value; + } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \return Value of the primitive variables gradient. + * \brief Get the array of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \return Array of the reconstruction variables gradient at a node. */ - inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } + inline su2double **GetGradient_Reconstruction(unsigned long iPoint) final { return Gradient_Reconstruction[iPoint]; } /*! * \brief A virtual member. */ - inline void SetdPdrho_e(su2double dPdrho_e) {Secondary[0] = dPdrho_e;} + inline void SetdPdrho_e(unsigned long iPoint, su2double dPdrho_e) final { Secondary(iPoint,0) = dPdrho_e;} /*! * \brief A virtual member. */ - inline void SetdPde_rho(su2double dPde_rho) {Secondary[1] = dPde_rho;} + inline void SetdPde_rho(unsigned long iPoint, su2double dPde_rho) final { Secondary(iPoint,1) = dPde_rho;} /*! * \brief Set the value of the pressure. */ - inline bool SetPressure(su2double pressure) { - Primitive[nDim+1] = pressure; - if (Primitive[nDim+1] > 0.0) return false; - else return true; + inline bool SetPressure(unsigned long iPoint, su2double pressure) final { + Primitive(iPoint,nDim+1) = pressure; + return pressure <= 0.0; } /*! * \brief Set the value of the speed of the sound. * \param[in] soundspeed2 - Value of soundspeed^2. */ - bool SetSoundSpeed(su2double soundspeed2) { + bool SetSoundSpeed(unsigned long iPoint, su2double soundspeed2) final { su2double radical = soundspeed2; if (radical < 0.0) return true; else { - Primitive[nDim+4] = sqrt(radical); + Primitive(iPoint,nDim+4) = sqrt(radical); return false; } } @@ -311,164 +239,169 @@ class CEulerVariable : public CVariable { /*! * \brief Set the value of the enthalpy. */ - inline void SetEnthalpy(void) {Primitive[nDim+3] = (Solution[nVar-1] + Primitive[nDim+1]) / Solution[0]; } + inline void SetEnthalpy(unsigned long iPoint) final { + Primitive(iPoint,nDim+3) = (Solution(iPoint,nVar-1) + Primitive(iPoint,nDim+1)) / Solution(iPoint,0); + } /*! * \brief Set all the primitive variables for compressible flows. */ - bool SetPrimVar(CFluidModel *FluidModel); + bool SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) final; /*! * \brief A virtual member. */ - void SetSecondaryVar(CFluidModel *FluidModel); + void SetSecondaryVar(unsigned long iPoint, CFluidModel *FluidModel); /*! * \brief Get the primitive variables. - * \param[in] val_var - Index of the variable. - * \return Value of the primitive variable for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the primitive variable for the index iVar. */ - inline su2double GetPrimitive(unsigned short val_var) {return Primitive[val_var]; } + inline su2double GetPrimitive(unsigned long iPoint, unsigned long iVar) const final { return Primitive(iPoint,iVar); } /*! * \brief Set the value of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_var - Index of the variable. - * \return Set the value of the primitive variable for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] iVar - Index of the variable. + * \return Set the value of the primitive variable for the index iVar. */ - inline void SetPrimitive(unsigned short val_var, su2double val_prim) {Primitive[val_var] = val_prim; } + inline void SetPrimitive(unsigned long iPoint, unsigned long iVar, su2double val_prim) final { Primitive(iPoint,iVar) = val_prim; } /*! * \brief Set the value of the primitive variables. * \param[in] val_prim - Primitive variables. - * \return Set the value of the primitive variable for the index val_var. + * \return Set the value of the primitive variable for the index iVar. */ - inline void SetPrimitive(su2double *val_prim) { - for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) - Primitive[iVar] = val_prim[iVar]; + inline void SetPrimitive(unsigned long iPoint, const su2double *val_prim) final { + for (unsigned long iVar = 0; iVar < nPrimVar; iVar++) + Primitive(iPoint,iVar) = val_prim[iVar]; } /*! * \brief Get the primitive variables of the problem. * \return Pointer to the primitive variable vector. */ - inline su2double *GetPrimitive(void) {return Primitive; } + inline su2double *GetPrimitive(unsigned long iPoint) final {return Primitive[iPoint]; } /*! * \brief Get the primitive variables. - * \param[in] val_var - Index of the variable. - * \return Value of the primitive variable for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the primitive variable for the index iVar. */ - inline su2double GetSecondary(unsigned short val_var) {return Secondary[val_var]; } + inline su2double GetSecondary(unsigned long iPoint, unsigned long iVar) const final {return Secondary(iPoint,iVar); } /*! * \brief Set the value of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_var - Index of the variable. - * \return Set the value of the primitive variable for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] iVar - Index of the variable. + * \return Set the value of the primitive variable for the index iVar. */ - inline void SetSecondary(unsigned short val_var, su2double val_secondary) {Secondary[val_var] = val_secondary; } + inline void SetSecondary(unsigned long iPoint, unsigned long iVar, su2double val_secondary) final {Secondary(iPoint,iVar) = val_secondary; } /*! * \brief Set the value of the primitive variables. * \param[in] val_prim - Primitive variables. - * \return Set the value of the primitive variable for the index val_var. + * \return Set the value of the primitive variable for the index iVar. */ - inline void SetSecondary(su2double *val_secondary) { - for (unsigned short iVar = 0; iVar < nSecondaryVar; iVar++) - Secondary[iVar] = val_secondary[iVar]; + inline void SetSecondary(unsigned long iPoint, const su2double *val_secondary) final { + for (unsigned long iVar = 0; iVar < nSecondaryVar; iVar++) + Secondary(iPoint,iVar) = val_secondary[iVar]; } /*! * \brief Get the primitive variables of the problem. * \return Pointer to the primitive variable vector. */ - inline su2double *GetSecondary(void) {return Secondary; } + inline su2double *GetSecondary(unsigned long iPoint) final { return Secondary[iPoint]; } /*! * \brief Set the value of the density for the incompressible flows. */ - inline bool SetDensity(void) { - Primitive[nDim+2] = Solution[0]; - if (Primitive[nDim+2] > 0.0) return false; - else return true; + inline bool SetDensity(unsigned long iPoint) final { + Primitive(iPoint,nDim+2) = Solution(iPoint,0); + return Primitive(iPoint,nDim+2) <= 0.0; } /*! * \brief Set the value of the temperature. * \param[in] temperature - how agitated the particles are :) */ - inline bool SetTemperature(su2double temperature) { - Primitive[0] = temperature; - if (Primitive[0] > 0.0) return false; - else return true; + inline bool SetTemperature(unsigned long iPoint, su2double temperature) final { + Primitive(iPoint,0) = temperature; + return temperature <= 0.0; } /*! * \brief Get the norm 2 of the velocity. * \return Norm 2 of the velocity vector. */ - inline su2double GetVelocity2(void) {return Velocity2; } + inline su2double GetVelocity2(unsigned long iPoint) const final { return Velocity2(iPoint); } /*! * \brief Get the flow pressure. * \return Value of the flow pressure. */ - inline su2double GetPressure(void) {return Primitive[nDim+1]; } + inline su2double GetPressure(unsigned long iPoint) const final { return Primitive(iPoint,nDim+1); } /*! * \brief Get the speed of the sound. * \return Value of speed of the sound. */ - inline su2double GetSoundSpeed(void) {return Primitive[nDim+4]; } + inline su2double GetSoundSpeed(unsigned long iPoint) const final { return Primitive(iPoint,nDim+4); } /*! * \brief Get the enthalpy of the flow. * \return Value of the enthalpy of the flow. */ - inline su2double GetEnthalpy(void) {return Primitive[nDim+3]; } + inline su2double GetEnthalpy(unsigned long iPoint) const final { return Primitive(iPoint,nDim+3); } /*! * \brief Get the density of the flow. * \return Value of the density of the flow. */ - inline su2double GetDensity(void) {return Solution[0]; } + inline su2double GetDensity(unsigned long iPoint) const final { return Solution(iPoint,0); } /*! * \brief Get the energy of the flow. * \return Value of the energy of the flow. */ - inline su2double GetEnergy(void) {return Solution[nVar-1]/Solution[0]; }; + inline su2double GetEnergy(unsigned long iPoint) const final { return Solution(iPoint,nVar-1)/Solution(iPoint,0); } /*! * \brief Get the temperature of the flow. * \return Value of the temperature of the flow. */ - inline su2double GetTemperature(void) {return Primitive[0]; } + inline su2double GetTemperature(unsigned long iPoint) const final { return Primitive(iPoint,0); } /*! * \brief Get the velocity of the flow. - * \param[in] val_dim - Index of the dimension. - * \return Value of the velocity for the dimension val_dim. + * \param[in] iDim - Index of the dimension. + * \return Value of the velocity for the dimension iDim. */ - inline su2double GetVelocity(unsigned short val_dim) {return Primitive[val_dim+1]; } + inline su2double GetVelocity(unsigned long iPoint, unsigned long iDim) const final { return Primitive(iPoint,iDim+1); } /*! * \brief Get the projected velocity in a unitary vector direction (compressible solver). * \param[in] val_vector - Direction of projection. * \return Value of the projected velocity. */ - su2double GetProjVel(su2double *val_vector); + inline su2double GetProjVel(unsigned long iPoint, const su2double *val_vector) const final { + su2double ProjVel = 0.0; + for (unsigned long iDim = 0; iDim < nDim; iDim++) + ProjVel += Primitive(iPoint,iDim+1)*val_vector[iDim]; + return ProjVel; + } /*! * \brief Set the velocity vector from the solution. * \param[in] val_velocity - Pointer to the velocity. */ - inline void SetVelocity(void) { - Velocity2 = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - Primitive[iDim+1] = Solution[iDim+1] / Solution[0]; - Velocity2 += Primitive[iDim+1]*Primitive[iDim+1]; + inline void SetVelocity(unsigned long iPoint) final { + Velocity2(iPoint) = 0.0; + for (unsigned long iDim = 0; iDim < nDim; iDim++) { + Primitive(iPoint,iDim+1) = Solution(iPoint,iDim+1) / Solution(iPoint,0); + Velocity2(iPoint) += pow(Primitive(iPoint,iDim+1),2); } } @@ -476,65 +409,55 @@ class CEulerVariable : public CVariable { * \brief Set the velocity vector from the old solution. * \param[in] val_velocity - Pointer to the velocity. */ - inline void SetVelocity_Old(su2double *val_velocity) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Solution_Old[iDim+1] = val_velocity[iDim]*Solution[0]; + inline void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) final { + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Solution_Old(iPoint,iDim+1) = val_velocity[iDim]*Solution(iPoint,0); } /*! * \brief Set the harmonic balance source term. - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the harmonic balance source term. for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] val_solution - Value of the harmonic balance source term. for the index iVar. */ - inline void SetHarmonicBalance_Source(unsigned short val_var, su2double val_source) {HB_Source[val_var] = val_source; } + inline void SetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar, su2double val_source) final { + HB_Source(iPoint,iVar) = val_source; + } /*! * \brief Get the harmonic balance source term. - * \param[in] val_var - Index of the variable. - * \return Value of the harmonic balance source term for the index val_var. - */ - inline su2double GetHarmonicBalance_Source(unsigned short val_var) {return HB_Source[val_var]; } - - /*! - * \brief Get the value of the preconditioner Beta. - * \return Value of the low Mach preconditioner variable Beta - */ - inline su2double GetPreconditioner_Beta() {return Precond_Beta; } - - /*! - * \brief Set the value of the preconditioner Beta. - * \param[in] Value of the low Mach preconditioner variable Beta + * \param[in] iVar - Index of the variable. + * \return Value of the harmonic balance source term for the index iVar. */ - inline void SetPreconditioner_Beta(su2double val_Beta) {Precond_Beta = val_Beta; } + inline su2double GetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar) const final { return HB_Source(iPoint,iVar); } /*! * \brief Get the value of the wind gust * \return Value of the wind gust */ - inline su2double* GetWindGust() {return WindGust;} + inline su2double* GetWindGust(unsigned long iPoint) final { return WindGust[iPoint]; } /*! * \brief Set the value of the wind gust * \param[in] Value of the wind gust */ - inline void SetWindGust(su2double* val_WindGust) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - WindGust[iDim] = val_WindGust[iDim]; + inline void SetWindGust(unsigned long iPoint, const su2double* val_WindGust) final { + for (unsigned long iDim = 0; iDim < nDim; iDim++) + WindGust(iPoint,iDim) = val_WindGust[iDim]; } /*! * \brief Get the value of the derivatives of the wind gust * \return Value of the derivatives of the wind gust */ - inline su2double* GetWindGustDer() {return WindGustDer;} + inline su2double* GetWindGustDer(unsigned long iPoint) final { return WindGustDer[iPoint]; } /*! * \brief Set the value of the derivatives of the wind gust * \param[in] Value of the derivatives of the wind gust */ - inline void SetWindGustDer(su2double* val_WindGustDer) { - for (unsigned short iDim = 0; iDim < nDim+1; iDim++) - WindGustDer[iDim] = val_WindGustDer[iDim]; + inline void SetWindGustDer(unsigned long iPoint, const su2double* val_WindGustDer) final { + for (unsigned long iDim = 0; iDim < nDim+1; iDim++) + WindGustDer(iPoint,iDim) = val_WindGustDer[iDim]; } }; diff --git a/SU2_CFD/include/variables/CFEABoundVariable.hpp b/SU2_CFD/include/variables/CFEABoundVariable.hpp index 23c8625719ea..2c071bc829d4 100644 --- a/SU2_CFD/include/variables/CFEABoundVariable.hpp +++ b/SU2_CFD/include/variables/CFEABoundVariable.hpp @@ -38,80 +38,169 @@ #pragma once #include "CFEAVariable.hpp" +#include "../../../Common/include/toolboxes/CVertexMap.hpp" /*! * \class CFEABoundVariable - * \brief Class for defining the variables on the FEA boundaries for FSI applications. + * \brief Class that adds storage of boundary variables (tractions) to CFEAVariable. + * \note Member variables are allocated only for points marked as "vertex" i.e. on a boundary. + * A map is constructed so that variables can be referenced by iPoint instead of iVertex. * \ingroup Structural Finite Element Analysis Variables * \author R. Sanchez. * \version 6.2.0 "Falcon" */ -class CFEABoundVariable : public CFEAVariable { +class CFEABoundVariable final : public CFEAVariable { protected: - su2double *Residual_Ext_Surf; /*!< \brief Term of the residual due to external forces */ - su2double *Residual_Ext_Surf_n; /*!< \brief Term of the residual due to external forces at time n */ + MatrixType FlowTraction; /*!< \brief Traction from the fluid field. */ + MatrixType FlowTraction_n; /*!< \brief Traction from the fluid field at time n. */ -public: + MatrixType Residual_Ext_Surf; /*!< \brief Term of the residual due to external forces. */ + MatrixType Residual_Ext_Surf_n; /*!< \brief Term of the residual due to external forces at time n. */ - /*! - * \brief Constructor of the class. - */ - CFEABoundVariable(void); + CVertexMap VertexMap; /*!< \brief Object that controls accesses to the variables of this class. */ + + bool fsi_analysis = false; /*!< \brief If flow tractions are available. */ +public: /*! - * \overload + * \brief Constructor of the class. * \param[in] val_fea - Values of the fea solution (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEABoundVariable(su2double *val_fea, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CFEABoundVariable(const su2double *val_fea, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - ~CFEABoundVariable(void); + ~CFEABoundVariable() = default; + + /*! + * \brief Allocate member variables for points marked as vertex (via "Set_isVertex"). + * \param[in] config - Definition of the particular problem. + */ + void AllocateBoundaryVariables(CConfig *config); /*! * \brief Add surface load to the residual term */ - inline void Add_SurfaceLoad_Res(su2double *val_surfForce) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Residual_Ext_Surf[iVar] += val_surfForce[iVar]; + inline void Add_SurfaceLoad_Res(unsigned long iPoint, const su2double *val_surfForce) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + for (unsigned long iVar = 0; iVar < nVar; iVar++) Residual_Ext_Surf(iPoint,iVar) += val_surfForce[iVar]; } /*! * \brief Set surface load of the residual term (for dampers - deletes all the other loads) */ - inline void Set_SurfaceLoad_Res(unsigned short iVar, su2double val_surfForce) {Residual_Ext_Surf[iVar] = val_surfForce;} + inline void Set_SurfaceLoad_Res(unsigned long iPoint, unsigned long iVar, su2double val_surfForce) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + Residual_Ext_Surf(iPoint,iVar) = val_surfForce; + } /*! * \brief Get the residual term due to surface load */ - inline su2double Get_SurfaceLoad_Res(unsigned short iVar) {return Residual_Ext_Surf[iVar];} + inline su2double Get_SurfaceLoad_Res(unsigned long iPoint, unsigned long iVar) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return Residual_Ext_Surf(iPoint,iVar); + } /*! * \brief Clear the surface load residual */ - inline void Clear_SurfaceLoad_Res(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Residual_Ext_Surf[iVar] = 0.0; + inline void Clear_SurfaceLoad_Res(unsigned long iPoint) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + for (unsigned long iVar = 0; iVar < nVar; iVar++) Residual_Ext_Surf(iPoint,iVar) = 0.0; } /*! * \brief Store the surface load as the load for the previous time step. */ - inline void Set_SurfaceLoad_Res_n(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Residual_Ext_Surf_n[iVar] = Residual_Ext_Surf[iVar]; - } + void Set_SurfaceLoad_Res_n() override; /*! * \brief Get the surface load from the previous time step. */ - inline su2double Get_SurfaceLoad_Res_n(unsigned short iVar) {return Residual_Ext_Surf_n[iVar]; } + inline su2double Get_SurfaceLoad_Res_n(unsigned long iPoint, unsigned long iVar) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return Residual_Ext_Surf_n(iPoint,iVar); + } + + /*! + * \brief Set the flow traction at a node on the structural side + */ + inline void Set_FlowTraction(unsigned long iPoint, const su2double *val_flowTraction) override { + if (!fsi_analysis) return; + if (!VertexMap.GetVertexIndex(iPoint)) return; + for (unsigned long iVar = 0; iVar < nVar; iVar++) FlowTraction(iPoint,iVar) = val_flowTraction[iVar]; + } + + /*! + * \brief Add a value to the flow traction at a node on the structural side + */ + inline void Add_FlowTraction(unsigned long iPoint, const su2double *val_flowTraction) override { + if (!fsi_analysis) return; + if (!VertexMap.GetVertexIndex(iPoint)) return; + for (unsigned long iVar = 0; iVar < nVar; iVar++) FlowTraction(iPoint,iVar) += val_flowTraction[iVar]; + } + + /*! + * \brief Get the residual term due to the flow traction + */ + inline su2double Get_FlowTraction(unsigned long iPoint, unsigned long iVar) const override { + if (!fsi_analysis) return 0.0; + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return FlowTraction(iPoint,iVar); + } + + /*! + * \brief Set the value of the flow traction at the previous time step. + */ + void Set_FlowTraction_n() override; + + /*! + * \brief Retrieve the value of the flow traction from the previous time step. + */ + inline su2double Get_FlowTraction_n(unsigned long iPoint, unsigned long iVar) const override { + if (!fsi_analysis) return 0.0; + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return FlowTraction_n(iPoint,iVar); + } + + /*! + * \brief Clear the flow traction residual + */ + void Clear_FlowTraction() override; /*! - * \brief Get whether this node is on the boundary + * \brief Register the flow tractions as input variable. */ - inline bool Get_isVertex(void) {return true; } + void RegisterFlowTraction() override; + + /*! + * \brief Extract the flow traction derivatives. + */ + inline su2double ExtractFlowTraction_Sensitivity(unsigned long iPoint, unsigned long iDim) const override { + if (!fsi_analysis) return 0.0; + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return SU2_TYPE::GetDerivative(FlowTraction(iPoint,iDim)); + } + + /*! + * \brief Get whether a node is on the boundary + */ + inline bool Get_isVertex(unsigned long iPoint) const override { + return VertexMap.GetIsVertex(iPoint); + } + + /*! + * \brief Set whether a node is on the boundary + */ + inline void Set_isVertex(unsigned long iPoint, bool isVertex) override { + VertexMap.SetIsVertex(iPoint,isVertex); + } }; diff --git a/SU2_CFD/include/variables/CFEAFSIBoundVariable.hpp b/SU2_CFD/include/variables/CFEAFSIBoundVariable.hpp deleted file mode 100644 index 2a452c44dfbc..000000000000 --- a/SU2_CFD/include/variables/CFEAFSIBoundVariable.hpp +++ /dev/null @@ -1,132 +0,0 @@ -/*! - * \file CFEAFSIBoundVariable.hpp - * \brief Class for defining the variables on the FEA boundaries for FSI applications. - * \author R. Sanchez - * \version 6.2.0 "Falcon" - * - * The current SU2 release has been coordinated by the - * SU2 International Developers Society - * with selected contributions from the open-source community. - * - * The main research teams contributing to the current release are: - * - Prof. Juan J. Alonso's group at Stanford University. - * - Prof. Piero Colonna's group at Delft University of Technology. - * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. - * - Prof. Alberto Guardone's group at Polytechnic University of Milan. - * - Prof. Rafael Palacios' group at Imperial College London. - * - Prof. Vincent Terrapon's group at the University of Liege. - * - Prof. Edwin van der Weide's group at the University of Twente. - * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. - * - * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, - * Tim Albring, and the SU2 contributors. - * - * 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 . - */ - -#pragma once - -#include "CFEABoundVariable.hpp" - - -/*! - * \class CFEAFSIBoundVariable - * \brief Main class for defining the variables on the FEA boundaries for FSI applications. - * \ingroup Structural Finite Element Analysis Variables - * \author R. Sanchez. - * \version 6.2.0 "Falcon" - */ -class CFEAFSIBoundVariable : public CFEABoundVariable { -protected: - - su2double *FlowTraction; /*!< \brief Traction from the fluid field. */ - su2double *FlowTraction_n; /*!< \brief Traction from the fluid field at time n. */ - -public: - - /*! - * \brief Constructor of the class. - */ - CFEAFSIBoundVariable(void); - - /*! - * \overload - * \param[in] val_fea - Values of the fea solution (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CFEAFSIBoundVariable(su2double *val_fea, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config); - - /*! - * \brief Destructor of the class. - */ - ~CFEAFSIBoundVariable(void); - - /*! - * \brief Set the flow traction at a node on the structural side - */ - inline void Set_FlowTraction(su2double *val_flowTraction) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) FlowTraction[iVar] = val_flowTraction[iVar]; - } - - /*! - * \brief Add a value to the flow traction at a node on the structural side - */ - inline void Add_FlowTraction(su2double *val_flowTraction) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) FlowTraction[iVar] += val_flowTraction[iVar]; - } - - /*! - * \brief Get the residual term due to the flow traction - */ - inline su2double Get_FlowTraction(unsigned short iVar) {return FlowTraction[iVar]; } - - /*! - * \brief Set the value of the flow traction at the previous time step. - */ - void Set_FlowTraction_n(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) FlowTraction_n[iVar] = FlowTraction[iVar]; - } - - /*! - * \brief Retrieve the value of the flow traction from the previous time step. - */ - inline su2double Get_FlowTraction_n(unsigned short iVar) {return FlowTraction_n[iVar]; } - - /*! - * \brief Clear the flow traction residual - */ - inline void Clear_FlowTraction(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) FlowTraction[iVar] = 0.0; - } - - /*! - * \brief Register the flow tractions as input variable. - */ - inline void RegisterFlowTraction() { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(FlowTraction[iVar]); - } - - /*! - * \brief Extract the flow traction derivatives. - */ - inline su2double ExtractFlowTraction_Sensitivity(unsigned short iDim){ - su2double val_sens; val_sens = SU2_TYPE::GetDerivative(FlowTraction[iDim]); return val_sens; - } - - -}; diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index 7412420f93be..5108a20d522e 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -49,444 +49,441 @@ class CFEAVariable : public CVariable { protected: - su2double *Stress; /*!< \brief Stress tensor. */ + MatrixType Stress; /*!< \brief Stress tensor. */ - su2double *Residual_Ext_Body; /*!< \brief Term of the residual due to body forces */ + MatrixType Residual_Ext_Body; /*!< \brief Term of the residual due to body forces */ - su2double VonMises_Stress; /*!< \brief Von Mises stress. */ + VectorType VonMises_Stress; /*!< \brief Von Mises stress. */ - su2double *Solution_Vel, /*!< \brief Velocity of the nodes. */ - *Solution_Vel_time_n; /*!< \brief Velocity of the nodes at time n. */ + MatrixType Solution_Vel; /*!< \brief Velocity of the nodes. */ + MatrixType Solution_Vel_time_n; /*!< \brief Velocity of the nodes at time n. */ - su2double *Solution_Accel, /*!< \brief Acceleration of the nodes. */ - *Solution_Accel_time_n; /*!< \brief Acceleration of the nodes at time n. */ + MatrixType Solution_Accel; /*!< \brief Acceleration of the nodes. */ + MatrixType Solution_Accel_time_n; /*!< \brief Acceleration of the nodes at time n. */ - su2double *Solution_Pred, /*!< \brief Predictor of the solution for FSI purposes */ - *Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */ + MatrixType Solution_Pred; /*!< \brief Predictor of the solution for FSI purposes */ + MatrixType Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */ - su2double *Reference_Geometry; /*!< \brief Reference solution for optimization problems */ + MatrixType Reference_Geometry; /*!< \brief Reference solution for optimization problems */ - su2double *Prestretch; /*!< \brief Prestretch geometry */ - -public: + MatrixType Prestretch; /*!< \brief Prestretch geometry */ /*! * \brief Constructor of the class. - */ - CFEAVariable(void); - - /*! - * \overload + * \note This class is not supposed to be instantiated, it is only a building block for CFEABoundVariable * \param[in] val_fea - Values of the fea solution (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CFEAVariable(su2double *val_fea, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CFEAVariable(const su2double *val_fea, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); +public: /*! * \brief Destructor of the class. */ - ~CFEAVariable(void); + virtual ~CFEAVariable() = default; /*! * \brief Get the value of the stress. * \return Value of the stress. */ - inline su2double *GetStress_FEM(void) {return Stress; } + inline su2double *GetStress_FEM(unsigned long iPoint) final { return Stress[iPoint]; } /*! * \brief Set the value of the stress at the node * \param[in] iVar - index of the stress term * \param[in] val_stress - value of the stress */ - inline void SetStress_FEM(unsigned short iVar, su2double val_stress) {Stress[iVar] = val_stress; } + inline void SetStress_FEM(unsigned long iPoint, unsigned long iVar, su2double val_stress) final { Stress(iPoint,iVar) = val_stress; } /*! * \brief Add a certain value to the value of the stress at the node * \param[in] iVar - index of the stress term * \param[in] val_stress - value of the stress */ - inline void AddStress_FEM(unsigned short iVar, su2double val_stress) {Stress[iVar] += val_stress; } + inline void AddStress_FEM(unsigned long iPoint, unsigned long iVar, su2double val_stress) final { Stress(iPoint,iVar) += val_stress; } /*! * \brief Add body forces to the residual term. */ - inline void Add_BodyForces_Res(su2double *val_bodyForce) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Residual_Ext_Body[iVar] += val_bodyForce[iVar]; + inline void Add_BodyForces_Res(unsigned long iPoint, const su2double *val_bodyForce) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Residual_Ext_Body(iPoint,iVar) += val_bodyForce[iVar]; } /*! * \brief Clear the surface load residual */ - inline void Clear_BodyForces_Res(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Residual_Ext_Body[iVar] = 0.0; + inline void Clear_BodyForces_Res(unsigned long iPoint) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Residual_Ext_Body(iPoint,iVar) = 0.0; } /*! * \brief Get the body forces. */ - inline su2double Get_BodyForces_Res(unsigned short iVar) {return Residual_Ext_Body[iVar];} + inline su2double Get_BodyForces_Res(unsigned long iPoint, unsigned long iVar) const final { return Residual_Ext_Body(iPoint,iVar); } /*! * \brief Set the value of the velocity (Structural Analysis). - * \param[in] val_solution - Solution of the problem (velocity). + * \param[in] val_solution_vel - Solution of the problem (velocity). */ - void SetSolution_Vel(su2double *val_solution_vel) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Vel[iVar] = val_solution_vel[iVar]; + inline void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel(iPoint,iVar) = val_solution_vel[iVar]; } /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] val_solution_vel - Value of the solution for the index iVar. */ - inline void SetSolution_Vel(unsigned short val_var, su2double val_solution_vel) {Solution_Vel[val_var] = val_solution_vel; } + inline void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel) final { + Solution_Vel(iPoint,iVar) = val_solution_vel; + } /*! * \brief Set the value of the velocity (Structural Analysis) at time n. * \param[in] val_solution - Solution of the problem (acceleration). */ - void SetSolution_Vel_time_n(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n[iVar] = Solution_Vel[iVar]; - } + void SetSolution_Vel_time_n() final; /*! * \brief Set the value of the velocity (Structural Analysis) at time n. - * \param[in] val_solution_old - Pointer to the residual vector. + * \param[in] val_solution_vel_time_n - Pointer to the residual vector. */ - void SetSolution_Vel_time_n(su2double *val_solution_vel_time_n) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n[iVar] = val_solution_vel_time_n[iVar]; + inline void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n[iVar]; } /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution_old - Value of the old solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] val_solution_vel_time_n - Value of the old solution for the index iVar. */ - inline void SetSolution_Vel_time_n(unsigned short val_var, su2double val_solution_vel_time_n) {Solution_Vel_time_n[val_var] = val_solution_vel_time_n; } + inline void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel_time_n) final { + Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n; + } /*! * \brief Get the velocity (Structural Analysis). - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_Vel(unsigned short val_var) {return Solution_Vel[val_var]; } + inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel(iPoint,iVar); } /*! * \brief Get the solution of the problem. * \return Pointer to the solution vector. */ - inline su2double *GetSolution_Vel(void) {return Solution_Vel; } + inline su2double *GetSolution_Vel(unsigned long iPoint) final { return Solution_Vel[iPoint]; } /*! * \brief Get the velocity of the nodes (Structural Analysis) at time n. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_Vel_time_n(unsigned short val_var) {return Solution_Vel_time_n[val_var]; } + inline su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final { + return Solution_Vel_time_n(iPoint,iVar); + } /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline su2double *GetSolution_Vel_time_n(void) {return Solution_Vel_time_n; } + inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return Solution_Vel_time_n[iPoint]; } /*! * \brief Set the value of the acceleration (Structural Analysis). - * \param[in] val_solution - Solution of the problem (acceleration). + * \param[in] val_solution_accel - Solution of the problem (acceleration). */ - inline void SetSolution_Accel(su2double *val_solution_accel) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Accel[iVar] = val_solution_accel[iVar]; + inline void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Accel(iPoint,iVar) = val_solution_accel[iVar]; } /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] val_solution_accel - Value of the solution for the index iVar. */ - inline void SetSolution_Accel(unsigned short val_var, su2double val_solution_accel) {Solution_Accel[val_var] = val_solution_accel;} + inline void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel) final { + Solution_Accel(iPoint,iVar) = val_solution_accel; + } /*! * \brief Set the value of the acceleration (Structural Analysis) at time n. * \param[in] val_solution_old - Pointer to the residual vector. */ - inline void SetSolution_Accel_time_n(su2double *val_solution_accel_time_n) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Accel_time_n[iVar] = val_solution_accel_time_n[iVar]; + inline void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar]; } /*! * \brief Set the value of the acceleration (Structural Analysis) at time n. - * \param[in] val_solution - Solution of the problem (acceleration). */ - inline void SetSolution_Accel_time_n(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Accel_time_n[iVar] = Solution_Accel[iVar]; - } + void SetSolution_Accel_time_n() final; /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution_old - Value of the old solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] val_solution_accel_time_n - Value of the old solution for the index iVar. */ - inline void SetSolution_Accel_time_n(unsigned short val_var, su2double val_solution_accel_time_n) {Solution_Accel_time_n[val_var] = val_solution_accel_time_n; } + inline void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel_time_n) final { + Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n; + } /*! * \brief Get the acceleration (Structural Analysis). - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_Accel(unsigned short val_var) {return Solution_Accel[val_var]; } + inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel(iPoint,iVar); } /*! * \brief Get the solution of the problem. * \return Pointer to the solution vector. */ - inline su2double *GetSolution_Accel(void) {return Solution_Accel; } + inline su2double *GetSolution_Accel(unsigned long iPoint) final { return Solution_Accel[iPoint]; } /*! * \brief Get the acceleration of the nodes (Structural Analysis) at time n. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_Accel_time_n(unsigned short val_var) {return Solution_Accel_time_n[val_var]; } + inline su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final { + return Solution_Accel_time_n(iPoint,iVar); + } /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline su2double *GetSolution_Accel_time_n(void) {return Solution_Accel_time_n; } + inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return Solution_Accel_time_n[iPoint]; } /*! * \brief Set the value of the solution predictor. */ - inline void SetSolution_Pred(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Pred[iVar] = Solution[iVar]; + inline void SetSolution_Pred(unsigned long iPoint) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Pred(iPoint,iVar) = Solution(iPoint,iVar); } /*! * \brief Set the value of the old solution. - * \param[in] val_solution_old - Pointer to the residual vector. + * \param[in] val_solution_pred - Pointer to the residual vector. */ - inline void SetSolution_Pred(su2double *val_solution_pred) {Solution_Pred = val_solution_pred; } + inline void SetSolution_Pred(unsigned long iPoint, const su2double *val_solution_pred) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Pred(iPoint,iVar) = val_solution_pred[iVar]; + } /*! * \brief Set the value of the predicted solution. - * \param[in] val_var - Index of the variable + * \param[in] iVar - Index of the variable * \param[in] val_solution_pred - Value of the predicted solution. */ - inline void SetSolution_Pred(unsigned short val_var, su2double val_solution_pred) {Solution_Pred[val_var] = val_solution_pred; } + inline void SetSolution_Pred(unsigned long iPoint, unsigned long iVar, su2double val_solution_pred) final { + Solution_Pred(iPoint,iVar) = val_solution_pred; + } /*! * \brief Get the value of the solution predictor. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_Pred(unsigned short val_var) {return Solution_Pred[val_var]; } + inline su2double GetSolution_Pred(unsigned long iPoint, unsigned long iVar) const final { return Solution_Pred(iPoint,iVar); } /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline su2double *GetSolution_Pred(void) {return Solution_Pred; } + inline su2double *GetSolution_Pred(unsigned long iPoint) final { return Solution_Pred[iPoint]; } /*! * \brief Set the value of the solution predictor. */ - inline void SetSolution_Pred_Old(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution_Pred_Old[iVar] = Solution_Pred[iVar]; + inline void SetSolution_Pred_Old(unsigned long iPoint) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Pred_Old(iPoint,iVar) = Solution_Pred(iPoint,iVar); } /*! * \brief Set the value of the old solution. - * \param[in] val_solution_old - Pointer to the residual vector. + * \param[in] val_solution_pred_old - Pointer to the residual vector. */ - inline void SetSolution_Pred_Old(su2double *val_solution_pred_Old) {Solution_Pred_Old = val_solution_pred_Old; } + inline void SetSolution_Pred_Old(unsigned long iPoint, const su2double *val_solution_pred_old) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Pred_Old(iPoint,iVar) = val_solution_pred_old[iVar]; + } /*! * \brief A virtual member. Set the value of the old solution predicted. - * \param[in] val_var - Index of the variable + * \param[in] iVar - Index of the variable * \param[in] val_solution_pred_old - Value of the old predicted solution. */ - inline void SetSolution_Pred_Old(unsigned short val_var, su2double val_solution_pred_old) {Solution_Pred_Old[val_var] = val_solution_pred_old; } + inline void SetSolution_Pred_Old(unsigned long iPoint, unsigned long iVar, su2double val_solution_pred_old) final { + Solution_Pred_Old(iPoint,iVar) = val_solution_pred_old; + } /*! * \brief Get the value of the solution predictor. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_Pred_Old(unsigned short val_var) {return Solution_Pred_Old[val_var]; } + inline su2double GetSolution_Pred_Old(unsigned long iPoint, unsigned long iVar) const final { + return Solution_Pred_Old(iPoint,iVar); + } /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline su2double *GetSolution_Pred_Old(void) {return Solution_Pred_Old; } + inline su2double *GetSolution_Pred_Old(unsigned long iPoint) final { return Solution_Pred_Old[iPoint]; } /*! * \brief A virtual member. */ - inline void SetPrestretch(unsigned short iVar, su2double val_prestretch) {Prestretch[iVar] = val_prestretch;} + inline void SetPrestretch(unsigned long iPoint, unsigned long iVar, su2double val_prestretch) final { + Prestretch(iPoint,iVar) = val_prestretch; + } /*! * \brief A virtual member. */ - inline su2double *GetPrestretch(void) {return Prestretch; } + inline su2double *GetPrestretch(unsigned long iPoint) final { return Prestretch[iPoint]; } /*! * \brief A virtual member. */ - inline su2double GetPrestretch(unsigned short iVar) {return Prestretch[iVar]; } + inline su2double GetPrestretch(unsigned long iPoint, unsigned long iVar) const final { return Prestretch(iPoint,iVar); } /*! * \brief Set the value of the Von Mises stress. * \param[in] val_stress - Value of the Von Mises stress. */ - inline void SetVonMises_Stress(su2double val_stress) {VonMises_Stress = val_stress; } + inline void SetVonMises_Stress(unsigned long iPoint, su2double val_stress) final { VonMises_Stress(iPoint) = val_stress; } /*! * \brief Get the value of the Von Mises stress. * \return Value of the Von Mises stress. */ - inline su2double GetVonMises_Stress(void) {return VonMises_Stress; } + inline su2double GetVonMises_Stress(unsigned long iPoint) const final { return VonMises_Stress(iPoint); } /*! * \brief Set the reference geometry. * \return Pointer to the solution (at time n) vector. */ - inline void SetReference_Geometry(unsigned short iVar, su2double ref_geometry) {Reference_Geometry[iVar] = ref_geometry;} + inline void SetReference_Geometry(unsigned long iPoint, unsigned long iVar, su2double ref_geometry) final { + Reference_Geometry(iPoint,iVar) = ref_geometry; + } /*! * \brief Get the pointer to the reference geometry */ - inline su2double *GetReference_Geometry(void) {return Reference_Geometry; } + inline su2double *GetReference_Geometry(unsigned long iPoint) final { return Reference_Geometry[iPoint]; } /*! * \brief Get the value of the reference geometry for the coordinate iVar */ - inline su2double GetReference_Geometry(unsigned short iVar) {return Reference_Geometry[iVar]; } + inline su2double GetReference_Geometry(unsigned long iPoint, unsigned long iVar) const final { + return Reference_Geometry(iPoint,iVar); + } /*! * \brief Register the variables in the solution time_n array as input/output variable. * \param[in] input - input or output variables. */ - inline void Register_femSolution_time_n(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution_time_n[iVar]); - } + void Register_femSolution_time_n() final; /*! * \brief Register the variables in the velocity array as input/output variable. * \param[in] input - input or output variables. */ - inline void RegisterSolution_Vel(bool input) { - if (input) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution_Vel[iVar]); - } - else { for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterOutput(Solution_Vel[iVar]);} - } + void RegisterSolution_Vel(bool input) final; /*! * \brief Register the variables in the velocity time_n array as input/output variable. */ - inline void RegisterSolution_Vel_time_n(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution_Vel_time_n[iVar]); - } + void RegisterSolution_Vel_time_n() final; /*! * \brief Register the variables in the acceleration array as input/output variable. * \param[in] input - input or output variables. */ - inline void RegisterSolution_Accel(bool input) { - if (input) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution_Accel[iVar]); - } - else { for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterOutput(Solution_Accel[iVar]);} - } + void RegisterSolution_Accel(bool input) final; /*! * \brief Register the variables in the acceleration time_n array as input/output variable. */ - inline void RegisterSolution_Accel_time_n(void){ - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution_Accel_time_n[iVar]); - } + void RegisterSolution_Accel_time_n() final; /*! * \brief Set the velocity adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void SetAdjointSolution_Vel(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_Vel[iVar], SU2_TYPE::GetValue(adj_sol[iVar])); + inline void SetAdjointSolution_Vel(unsigned long iPoint, const su2double *adj_sol) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + SU2_TYPE::SetDerivative(Solution_Vel(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } /*! * \brief Get the velocity adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void GetAdjointSolution_Vel(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Vel[iVar]); + inline void GetAdjointSolution_Vel(unsigned long iPoint, su2double *adj_sol) const final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Vel(iPoint,iVar)); } /*! * \brief Set the velocity adjoint values of the solution at time n. * \param[in] adj_sol - The adjoint values of the solution. */ - void SetAdjointSolution_Vel_time_n(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_Vel_time_n[iVar], SU2_TYPE::GetValue(adj_sol[iVar])); + void SetAdjointSolution_Vel_time_n(unsigned long iPoint, const su2double *adj_sol) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + SU2_TYPE::SetDerivative(Solution_Vel_time_n(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } /*! * \brief Get the velocity adjoint values of the solution at time n. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void GetAdjointSolution_Vel_time_n(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Vel_time_n[iVar]); + inline void GetAdjointSolution_Vel_time_n(unsigned long iPoint, su2double *adj_sol) const final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Vel_time_n(iPoint,iVar)); } /*! * \brief Set the acceleration adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void SetAdjointSolution_Accel(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_Accel[iVar], SU2_TYPE::GetValue(adj_sol[iVar])); + inline void SetAdjointSolution_Accel(unsigned long iPoint, const su2double *adj_sol) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + SU2_TYPE::SetDerivative(Solution_Accel(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } /*! * \brief Get the acceleration adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void GetAdjointSolution_Accel(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Accel[iVar]); + inline void GetAdjointSolution_Accel(unsigned long iPoint, su2double *adj_sol) const final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Accel(iPoint,iVar)); } /*! * \brief Set the acceleration adjoint values of the solution at time n. * \param[in] adj_sol - The adjoint values of the solution. */ - void SetAdjointSolution_Accel_time_n(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_Accel_time_n[iVar], SU2_TYPE::GetValue(adj_sol[iVar])); + void SetAdjointSolution_Accel_time_n(unsigned long iPoint, const su2double *adj_sol) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + SU2_TYPE::SetDerivative(Solution_Accel_time_n(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } /*! * \brief Get the acceleration adjoint values of the solution at time n. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void GetAdjointSolution_Accel_time_n(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Accel_time_n[iVar]); + inline void GetAdjointSolution_Accel_time_n(unsigned long iPoint, su2double *adj_sol) const final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Accel_time_n(iPoint,iVar)); } }; diff --git a/SU2_CFD/include/variables/CHeatFVMVariable.hpp b/SU2_CFD/include/variables/CHeatFVMVariable.hpp index 94f96860d085..306b6178659c 100644 --- a/SU2_CFD/include/variables/CHeatFVMVariable.hpp +++ b/SU2_CFD/include/variables/CHeatFVMVariable.hpp @@ -45,53 +45,55 @@ * \author O. Burghardt * \version 6.2.0 "Falcon" */ -class CHeatFVMVariable : public CVariable { +class CHeatFVMVariable final : public CVariable { protected: - su2double* Solution_Direct; /*!< \brief Direct solution container for use in the adjoint Heat solver. */ - su2double **Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term. */ - bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ - -public: + MatrixType Solution_Direct; /*!< \brief Direct solution container for use in the adjoint Heat solver. */ - /*! - * \brief Constructor of the class. - */ - CHeatFVMVariable(void); + VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ +public: /*! - * \overload - * \param[in] val_Heat - Values of the Heat solution (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \brief Constructor of the class. + * \param[in] heat - Values of the Heat solution (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CHeatFVMVariable(su2double val_Heat, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CHeatFVMVariable(su2double heat, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - ~CHeatFVMVariable(void); + ~CHeatFVMVariable() = default; /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \return Value of the primitive variables gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \return Value of the reconstruction variables gradient at a node. */ - inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + inline su2double GetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final { + return Gradient_Reconstruction(iPoint,iVar,iDim); + } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] iDim - Index of the dimension. */ - inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Reconstruction(iPoint,iVar,iDim) = value; + } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \return Value of the primitive variables gradient. + * \brief Get the array of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \return Array of the reconstruction variables gradient at a node. */ - inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } + inline su2double **GetGradient_Reconstruction(unsigned long iPoint) final { return Gradient_Reconstruction[iPoint]; } }; diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index da05fb11f3e7..51af4b4e32cf 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -47,293 +47,310 @@ */ class CIncEulerVariable : public CVariable { protected: - su2double Velocity2; /*!< \brief Square of the velocity vector. */ - - /*--- Primitive variable definition ---*/ - - su2double *Primitive; /*!< \brief Primitive variables (P, vx, vy, vz, T, rho ...) for incompressible flows. */ - su2double **Gradient_Primitive; /*!< \brief Gradient of the primitive variables */ - su2double **Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term */ - bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ - - su2double *Limiter_Primitive; /*!< \brief Limiter of the primitive variables */ - - /*--- Old density for variable density turbulent flows (SST). ---*/ - - su2double Density_Old; + VectorType Velocity2; /*!< \brief Square of the velocity vector. */ + MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ + VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ + VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term */ + MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ + VectorType Density_Old; /*!< \brief Old density for variable density turbulent flows (SST). */ public: - /*! * \brief Constructor of the class. - */ - CIncEulerVariable(void); - - /*! - * \overload * \param[in] val_pressure - value of the pressure. - * \param[in] val_velocity - Value of the flow velocity (initialization value). - * \param[in] val_temperature - Value of the temperature (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] velocity - Value of the flow velocity (initialization value). + * \param[in] temperature - Value of the temperature (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CIncEulerVariable(su2double val_pressure, su2double *val_velocity, su2double val_temperature, unsigned short val_nDim, - unsigned short val_nvar, CConfig *config); - - /*! - * \overload - * \param[in] val_solution - Pointer to the flow value (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CIncEulerVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature, + unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - virtual ~CIncEulerVariable(void); + virtual ~CIncEulerVariable() = default; /*! * \brief Set to zero the gradient of the primitive variables. */ - void SetGradient_PrimitiveZero(unsigned short val_primvar); + void SetGradient_PrimitiveZero() final; /*! - * \brief Add val_value to the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to add to the gradient of the primitive variables. + * \brief Add value to the gradient of the primitive variables. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value to add to the gradient of the primitive variables. */ - inline void AddGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Primitive[val_var][val_dim] += val_value; } + inline void AddGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Primitive(iPoint,iVar,iDim) += value; + } /*! - * \brief Subtract val_value to the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to subtract to the gradient of the primitive variables. + * \brief Subtract value to the gradient of the primitive variables. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value to subtract to the gradient of the primitive variables. */ - inline void SubtractGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Primitive[val_var][val_dim] -= val_value; } + inline void SubtractGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Primitive(iPoint,iVar,iDim) -= value; + } /*! * \brief Get the value of the primitive variables gradient. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. * \return Value of the primitive variables gradient. */ - inline su2double GetGradient_Primitive(unsigned short val_var, unsigned short val_dim) {return Gradient_Primitive[val_var][val_dim]; } + inline su2double GetGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final { + return Gradient_Primitive(iPoint,iVar,iDim); + } /*! * \brief Get the value of the primitive variables gradient. - * \param[in] val_var - Index of the variable. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. * \return Value of the primitive variables gradient. */ - inline su2double GetLimiter_Primitive(unsigned short val_var) {return Limiter_Primitive[val_var]; } + inline su2double GetLimiter_Primitive(unsigned long iPoint, unsigned long iVar) const final { + return Limiter_Primitive(iPoint,iVar); + } /*! * \brief Set the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value of the gradient. */ - inline void SetGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Primitive[val_var][val_dim] = val_value; } + inline void SetGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Primitive(iPoint,iVar,iDim) = value; + } /*! * \brief Set the gradient of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_value - Value of the gradient. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] value - Value of the gradient. */ - inline void SetLimiter_Primitive(unsigned short val_var, su2double val_value) {Limiter_Primitive[val_var] = val_value; } + inline void SetLimiter_Primitive(unsigned long iPoint, unsigned long iVar, su2double value) final { + Limiter_Primitive(iPoint,iVar) = value; + } /*! * \brief Get the value of the primitive variables gradient. + * \param[in] iPoint - Point index. * \return Value of the primitive variables gradient. */ - inline su2double **GetGradient_Primitive(void) {return Gradient_Primitive; } + inline su2double **GetGradient_Primitive(unsigned long iPoint) final { return Gradient_Primitive[iPoint]; } /*! * \brief Get the value of the primitive variables gradient. + * \param[in] iPoint - Point index. * \return Value of the primitive variables gradient. */ - inline su2double *GetLimiter_Primitive(void) {return Limiter_Primitive; } - + inline su2double *GetLimiter_Primitive(unsigned long iPoint) final { return Limiter_Primitive[iPoint]; } + /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \return Value of the primitive variables gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \return Value of the reconstruction variables gradient at a node. */ - inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + inline su2double GetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final { + return Gradient_Reconstruction(iPoint,iVar,iDim); + } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] iDim - Index of the dimension. */ - inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Reconstruction(iPoint,iVar,iDim) = value; + } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \return Value of the primitive variables gradient. + * \brief Get the array of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \return Array of the reconstruction variables gradient at a node. */ - inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } - + inline su2double **GetGradient_Reconstruction(unsigned long iPoint) final { return Gradient_Reconstruction[iPoint]; } /*! * \brief Set the value of the pressure. + * \param[in] iPoint - Point index. */ - inline void SetPressure(void) {Primitive[0] = Solution[0];} + inline void SetPressure(unsigned long iPoint) final { Primitive(iPoint,0) = Solution(iPoint,0); } /*! * \brief Get the primitive variables. - * \param[in] val_var - Index of the variable. - * \return Value of the primitive variable for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \return Value of the primitive variable for the index iVar. */ - inline su2double GetPrimitive(unsigned short val_var) {return Primitive[val_var]; } + inline su2double GetPrimitive(unsigned long iPoint, unsigned long iVar) const final { return Primitive(iPoint,iVar); } /*! * \brief Set the value of the primitive variables. - * \param[in] val_var - Index of the variable. - * \param[in] val_var - Index of the variable. - * \return Set the value of the primitive variable for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iVar - Index of the variable. + * \return Set the value of the primitive variable for the index iVar. */ - inline void SetPrimitive(unsigned short val_var, su2double val_prim) {Primitive[val_var] = val_prim; } + inline void SetPrimitive(unsigned long iPoint, unsigned long iVar, su2double val_prim) final { Primitive(iPoint,iVar) = val_prim; } /*! * \brief Set the value of the primitive variables. + * \param[in] iPoint - Point index. * \param[in] val_prim - Primitive variables. - * \return Set the value of the primitive variable for the index val_var. + * \return Set the value of the primitive variable for the index iVar. */ - inline void SetPrimitive(su2double *val_prim) { - for (unsigned short iVar = 0; iVar < nPrimVar; iVar++) - Primitive[iVar] = val_prim[iVar]; + inline void SetPrimitive(unsigned long iPoint, const su2double *val_prim) final { + for (unsigned long iVar = 0; iVar < nPrimVar; iVar++) Primitive(iPoint,iVar) = val_prim[iVar]; } /*! * \brief Get the primitive variables of the problem. + * \param[in] iPoint - Point index. * \return Pointer to the primitive variable vector. */ - inline su2double *GetPrimitive(void) {return Primitive; } + inline su2double *GetPrimitive(unsigned long iPoint) final { return Primitive[iPoint]; } /*! * \brief Set the value of the density for the incompressible flows. + * \param[in] iPoint - Point index. */ - inline bool SetDensity(su2double val_density) { - Primitive[nDim+2] = val_density; - if (Primitive[nDim+2] > 0.0) return false; + inline bool SetDensity(unsigned long iPoint, su2double val_density) final { + Primitive(iPoint,nDim+2) = val_density; + if (Primitive(iPoint,nDim+2) > 0.0) return false; else return true; } /*! * \brief Set the value of the density for the incompressible flows. + * \param[in] iPoint - Point index. */ - inline void SetVelocity(void) { - Velocity2 = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - Primitive[iDim+1] = Solution[iDim+1]; - Velocity2 += Primitive[iDim+1]*Primitive[iDim+1]; + inline void SetVelocity(unsigned long iPoint) final { + Velocity2(iPoint) = 0.0; + for (unsigned long iDim = 0; iDim < nDim; iDim++) { + Primitive(iPoint,iDim+1) = Solution(iPoint,iDim+1); + Velocity2(iPoint) += pow(Primitive(iPoint,iDim+1),2); } } /*! * \brief Set the value of the temperature for incompressible flows with energy equation. + * \param[in] iPoint - Point index. */ - inline bool SetTemperature(su2double val_temperature) { - Primitive[nDim+1] = val_temperature; - if (Primitive[nDim+1] > 0.0) return false; + inline bool SetTemperature(unsigned long iPoint, su2double val_temperature) final { + Primitive(iPoint,nDim+1) = val_temperature; + if (Primitive(iPoint,nDim+1) > 0.0) return false; else return true; } /*! * \brief Set the value of the beta coeffient for incompressible flows. + * \param[in] iPoint - Point index. */ - inline void SetBetaInc2(su2double val_betainc2) {Primitive[nDim+3] = val_betainc2; } + inline void SetBetaInc2(unsigned long iPoint, su2double val_betainc2) final { Primitive(iPoint,nDim+3) = val_betainc2; } /*! * \brief Get the norm 2 of the velocity. * \return Norm 2 of the velocity vector. */ - inline su2double GetVelocity2(void) {return Velocity2; } + inline su2double GetVelocity2(unsigned long iPoint) const final { return Velocity2(iPoint); } /*! * \brief Get the flow pressure. * \return Value of the flow pressure. */ - inline su2double GetPressure(void) {return Primitive[0]; } + inline su2double GetPressure(unsigned long iPoint) const final { return Primitive(iPoint,0); } /*! * \brief Get the value of beta squared for the incompressible flow * \return Value of beta squared. */ - inline su2double GetBetaInc2(void) {return Primitive[nDim+3]; } + inline su2double GetBetaInc2(unsigned long iPoint) const final { return Primitive(iPoint,nDim+3); } /*! * \brief Get the density of the flow. * \return Value of the density of the flow. */ - inline su2double GetDensity(void) {return Primitive[nDim+2]; } + inline su2double GetDensity(unsigned long iPoint) const final { return Primitive(iPoint,nDim+2); } /*! * \brief Get the density of the flow from the previous iteration. * \return Old value of the density of the flow. */ - inline su2double GetDensity_Old(void) {return Density_Old; } + inline su2double GetDensity_Old(unsigned long iPoint) const final { return Density_Old(iPoint); } /*! * \brief Get the temperature of the flow. * \return Value of the temperature of the flow. */ - inline su2double GetTemperature(void) {return Primitive[nDim+1]; } + inline su2double GetTemperature(unsigned long iPoint) const final { return Primitive(iPoint,nDim+1); } /*! * \brief Get the velocity of the flow. - * \param[in] val_dim - Index of the dimension. - * \return Value of the velocity for the dimension val_dim. + * \param[in] iDim - Index of the dimension. + * \return Value of the velocity for the dimension iDim. */ - inline su2double GetVelocity(unsigned short val_dim) {return Primitive[val_dim+1]; } + inline su2double GetVelocity(unsigned long iPoint, unsigned long iDim) const final { return Primitive(iPoint,iDim+1); } /*! * \brief Get the projected velocity in a unitary vector direction (compressible solver). * \param[in] val_vector - Direction of projection. * \return Value of the projected velocity. */ - su2double GetProjVel(su2double *val_vector); + inline su2double GetProjVel(unsigned long iPoint, const su2double *val_vector) const final { + su2double ProjVel = 0.0; + for (unsigned long iDim = 0; iDim < nDim; iDim++) + ProjVel += Primitive(iPoint,iDim+1)*val_vector[iDim]; + return ProjVel; + } /*! * \brief Set the velocity vector from the old solution. * \param[in] val_velocity - Pointer to the velocity. */ - inline void SetVelocity_Old(su2double *val_velocity) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Solution_Old[iDim+1] = val_velocity[iDim]; + inline void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) final { + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Solution_Old(iPoint,iDim+1) = val_velocity[iDim]; } /*! * \brief Set all the primitive variables for incompressible flows. */ - bool SetPrimVar(CFluidModel *FluidModel); + bool SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) final; /*! * \brief Set the specific heat Cp. */ - inline void SetSpecificHeatCp(su2double val_Cp) {Primitive[nDim+7] = val_Cp;} + inline void SetSpecificHeatCp(unsigned long iPoint, su2double val_Cp) final { Primitive(iPoint, nDim+7) = val_Cp; } /*! * \brief Set the specific heat Cv. */ - inline void SetSpecificHeatCv(su2double val_Cv) {Primitive[nDim+8] = val_Cv;} + inline void SetSpecificHeatCv(unsigned long iPoint, su2double val_Cv) final { Primitive(iPoint, nDim+8) = val_Cv; } /*! * \brief Get the specific heat at constant P of the flow. * \return Value of the specific heat at constant P of the flow. */ - inline su2double GetSpecificHeatCp(void) {return Primitive[nDim+7]; } + inline su2double GetSpecificHeatCp(unsigned long iPoint) const final { return Primitive(iPoint, nDim+7); } /*! * \brief Get the specific heat at constant V of the flow. * \return Value of the specific heat at constant V of the flow. */ - inline su2double GetSpecificHeatCv(void) {return Primitive[nDim+8]; } + inline su2double GetSpecificHeatCv(unsigned long iPoint) const final { return Primitive(iPoint, nDim+8); } }; diff --git a/SU2_CFD/include/variables/CIncNSVariable.hpp b/SU2_CFD/include/variables/CIncNSVariable.hpp index 7f89a5e024da..1992b9f702fd 100644 --- a/SU2_CFD/include/variables/CIncNSVariable.hpp +++ b/SU2_CFD/include/variables/CIncNSVariable.hpp @@ -46,116 +46,106 @@ * \ingroup Navier_Stokes_Equations * \author F. Palacios, T. Economon, T. Albring */ -class CIncNSVariable : public CIncEulerVariable { +class CIncNSVariable final : public CIncEulerVariable { private: - su2double Vorticity[3]; /*!< \brief Vorticity of the fluid. */ - su2double StrainMag; /*!< \brief Magnitude of rate of strain tensor. */ + MatrixType Vorticity; /*!< \brief Vorticity of the fluid. */ + VectorType StrainMag; /*!< \brief Magnitude of rate of strain tensor. */ - su2double DES_LengthScale; -public: + VectorType DES_LengthScale; +public: /*! * \brief Constructor of the class. - */ - CIncNSVariable(void); - - /*! - * \overload - * \param[in] val_pressure - value of the pressure. - * \param[in] val_velocity - Value of the flow velocity (initialization value). - * \param[in] val_temperature - Value of the temperature (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CIncNSVariable(su2double val_pressure, su2double *val_velocity, su2double val_temperature, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); - - /*! - * \overload - * \param[in] val_solution - Pointer to the flow value (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] pressure - value of the pressure. + * \param[in] velocity - Value of the flow velocity (initialization value). + * \param[in] temperature - Value of the temperature (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CIncNSVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CIncNSVariable(su2double pressure, const su2double *velocity, su2double temperature, + unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - ~CIncNSVariable(void); + ~CIncNSVariable() = default; /*! * \brief Set the laminar viscosity. */ - inline void SetLaminarViscosity(su2double laminarViscosity) {Primitive[nDim+4] = laminarViscosity;} + inline void SetLaminarViscosity(unsigned long iPoint, su2double laminarViscosity) override { + Primitive(iPoint,nDim+4) = laminarViscosity; + } /*! * \brief Set the vorticity value. */ - bool SetVorticity(void); - - /*! - * \brief Set the rate of strain magnitude. - */ - bool SetStrainMag(void); + bool SetVorticity_StrainMag() override; /*! * \overload * \param[in] eddy_visc - Value of the eddy viscosity. */ - inline void SetEddyViscosity(su2double eddy_visc) {Primitive[nDim+5] = eddy_visc; } + inline void SetEddyViscosity(unsigned long iPoint, su2double eddy_visc) override { + Primitive(iPoint,nDim+5) = eddy_visc; + } /*! * \brief Get the laminar viscosity of the flow. * \return Value of the laminar viscosity of the flow. */ - inline su2double GetLaminarViscosity(void) {return Primitive[nDim+4]; } + inline su2double GetLaminarViscosity(unsigned long iPoint) const override { return Primitive(iPoint,nDim+4); } /*! * \brief Get the eddy viscosity of the flow. * \return The eddy viscosity of the flow. */ - inline su2double GetEddyViscosity(void) {return Primitive[nDim+5]; } + inline su2double GetEddyViscosity(unsigned long iPoint) const override { return Primitive(iPoint,nDim+5); } /*! * \brief Set the thermal conductivity. */ - inline void SetThermalConductivity(su2double thermalConductivity) {Primitive[nDim+6] = thermalConductivity;} + inline void SetThermalConductivity(unsigned long iPoint, su2double thermalConductivity) override { + Primitive(iPoint,nDim+6) = thermalConductivity; + } /*! * \brief Get the thermal conductivity of the flow. * \return Value of the laminar viscosity of the flow. */ - inline su2double GetThermalConductivity(void) {return Primitive[nDim+6]; } + inline su2double GetThermalConductivity(unsigned long iPoint) const override { return Primitive(iPoint,nDim+6); } /*! * \brief Get the value of the vorticity. - * \param[in] val_dim - Index of the dimension. * \return Value of the vorticity. */ - inline su2double *GetVorticity(void) {return Vorticity; } + inline su2double *GetVorticity(unsigned long iPoint) override { return Vorticity[iPoint]; } /*! * \brief Get the value of the magnitude of rate of strain. * \return Value of the rate of strain magnitude. */ - inline su2double GetStrainMag(void) {return StrainMag; } + inline su2double GetStrainMag(unsigned long iPoint) const override { return StrainMag(iPoint); } /*! * \brief Set all the primitive variables for incompressible flows */ - bool SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel); + bool SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel) override; using CVariable::SetPrimVar; /*! * \brief Set the DES Length Scale. */ - inline void SetDES_LengthScale(su2double val_des_lengthscale) {DES_LengthScale = val_des_lengthscale; } + inline void SetDES_LengthScale(unsigned long iPoint, su2double val_des_lengthscale) override { + DES_LengthScale(iPoint) = val_des_lengthscale; + } /*! * \brief Get the DES length scale * \return Value of the DES length Scale. */ - inline su2double GetDES_LengthScale(void) {return DES_LengthScale; } + inline su2double GetDES_LengthScale(unsigned long iPoint) const override { return DES_LengthScale(iPoint); } }; diff --git a/SU2_CFD/include/variables/CMeshBoundVariable.hpp b/SU2_CFD/include/variables/CMeshBoundVariable.hpp index 3487bc6b27f4..e7395ebbdcaa 100644 --- a/SU2_CFD/include/variables/CMeshBoundVariable.hpp +++ b/SU2_CFD/include/variables/CMeshBoundVariable.hpp @@ -39,39 +39,52 @@ #pragma once #include "CMeshVariable.hpp" +#include "../../../Common/include/toolboxes/CVertexMap.hpp" -class CMeshBoundVariable : public CMeshVariable { -protected: +class CMeshBoundVariable final : public CMeshVariable { +private: - su2double *Boundary_Displacement; /*!< \brief Store the reference coordinates of the mesh. */ + MatrixType Boundary_Displacement; /*!< \brief Store the reference coordinates of the mesh. */ + + CVertexMap VertexMap; /*!< \brief Object that controls accesses to the variables of this class. */ public: /*! * \brief Constructor of the class. * \param[in] val_coor - Values of the coordinates (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. + * \param[in] ndim - Number of dimensions of the problem. * \param[in] config - Definition of the particular problem. */ - CMeshBoundVariable(su2double *val_coor, unsigned short val_nDim, CConfig *config); + CMeshBoundVariable(unsigned long npoint, unsigned long ndim, CConfig *config); /*! * \brief Destructor of the class. */ - ~CMeshBoundVariable(void); + ~CMeshBoundVariable() = default; + + /*! + * \brief Allocate member variables for points marked as vertex (via "Set_isVertex"). + * \param[in] config - Definition of the particular problem. + */ + void AllocateBoundaryVariables(CConfig *config); /*! * \brief Get the value of the displacement imposed at the boundary. * \return Value of the boundary displacement. */ - inline su2double GetBound_Disp(unsigned short iDim) const final { return Boundary_Displacement[iDim]; } + inline su2double GetBound_Disp(unsigned long iPoint, unsigned long iDim) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return Boundary_Displacement(iPoint,iDim); + } /*! * \brief Set the boundary displacements. * \param[in] val_BoundDisp - Pointer to the boundary displacements. */ - inline void SetBound_Disp(const su2double *val_BoundDisp) final { - for (unsigned short iDim = 0; iDim < nDim; iDim++) Boundary_Displacement[iDim] = val_BoundDisp[iDim]; + inline void SetBound_Disp(unsigned long iPoint, const su2double *val_BoundDisp) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + for (unsigned long iDim = 0; iDim < nDim; iDim++) Boundary_Displacement(iPoint,iDim) = val_BoundDisp[iDim]; } /*! @@ -79,37 +92,39 @@ class CMeshBoundVariable : public CMeshVariable { * \param[in] iDim - Index of the dimension of interest. * \param[in] val_BoundDisp - Value of the boundary displacements. */ - inline void SetBound_Disp(unsigned short iDim, const su2double val_BoundDisp) final { - Boundary_Displacement[iDim] = val_BoundDisp; + inline void SetBound_Disp(unsigned long iPoint, unsigned long iDim, su2double val_BoundDisp) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + Boundary_Displacement(iPoint,iDim) = val_BoundDisp; } /*! - * \brief Determine whether the node is a moving vertex. - * \return True. The node is at the boundary. + * \brief Register the boundary displacements of the mesh. + * \param[in] input - Defines whether we are registering the variable as input or as output. */ - inline bool Get_isVertex(void) const final { return true; } + void Register_BoundDisp(bool input) override; /*! - * \brief Register the boundary displacements of the mesh. - * \param[in] input - Defines whether we are registering the variable as input or as output. + * \brief Recover the value of the adjoint of the boundary displacements. */ - inline void Register_BoundDisp(bool input) final { - if (input) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Boundary_Displacement[iVar]); - } - else { for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterOutput(Boundary_Displacement[iVar]); + inline void GetAdjoint_BoundDisp(unsigned long iPoint, su2double *adj_disp) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + for (unsigned long iVar = 0; iVar < nVar; iVar++) { + adj_disp[iVar] = SU2_TYPE::GetDerivative(Boundary_Displacement(iPoint,iVar)); } } /*! - * \brief Recover the value of the adjoint of the boundary displacements. + * \brief Get whether a node is on the boundary */ - inline void GetAdjoint_BoundDisp(su2double *adj_disp) final { - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - adj_disp[iVar] = SU2_TYPE::GetDerivative(Boundary_Displacement[iVar]); - } + inline bool Get_isVertex(unsigned long iPoint) const override { + return VertexMap.GetIsVertex(iPoint); + } + + /*! + * \brief Set whether a node is on the boundary + */ + inline void Set_isVertex(unsigned long iPoint, bool isVertex) override { + VertexMap.SetIsVertex(iPoint,isVertex); } }; diff --git a/SU2_CFD/include/variables/CMeshElement.hpp b/SU2_CFD/include/variables/CMeshElement.hpp index 0e49bd0c8b1b..ee6ea355eb98 100644 --- a/SU2_CFD/include/variables/CMeshElement.hpp +++ b/SU2_CFD/include/variables/CMeshElement.hpp @@ -67,7 +67,7 @@ class CMeshElement { /*! * \brief Destructor of the class. */ - ~CMeshElement(void); + ~CMeshElement(void) = default; /*! * \brief Get the value of the element volume with undeformed coordinates. diff --git a/SU2_CFD/include/variables/CMeshVariable.hpp b/SU2_CFD/include/variables/CMeshVariable.hpp index 08c46c626d1a..4d38a9f3f340 100644 --- a/SU2_CFD/include/variables/CMeshVariable.hpp +++ b/SU2_CFD/include/variables/CMeshVariable.hpp @@ -43,54 +43,43 @@ class CMeshVariable : public CVariable { protected: - unsigned short nDim; - - su2double WallDistance; /*!< \brief Store the wall distance in reference coordinates. */ - - su2double *Mesh_Coord; /*!< \brief Store the reference coordinates of the mesh. */ - - -public: + VectorType WallDistance; /*!< \brief Store the wall distance in reference coordinates. */ + MatrixType Mesh_Coord; /*!< \brief Store the reference coordinates of the mesh. */ /*! * \brief Constructor of the class. - * \param[in] val_coor - Values of the coordinates (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. * \param[in] config - Definition of the particular problem. */ - CMeshVariable(const su2double *val_coor, unsigned short val_nDim, CConfig *config); + CMeshVariable(unsigned long npoint, unsigned long ndim, CConfig *config); +public: /*! * \brief Destructor of the class. */ - ~CMeshVariable(void); + ~CMeshVariable() = default; /*! * \brief Get the value of the undeformed coordinates. * \param[in] iDim - Index of Mesh_Coord[nDim] * \return Value of the original coordinate iDim. */ - inline su2double GetMesh_Coord(unsigned short iDim) const final { return Mesh_Coord[iDim]; } + inline su2double GetMesh_Coord(unsigned long iPoint, unsigned long iDim) const final { return Mesh_Coord(iPoint,iDim); } /*! * \brief Get the undeformed coordinates. * \return Pointer to the reference coordinates. */ - inline su2double *GetMesh_Coord() final { return Mesh_Coord; } + inline const su2double *GetMesh_Coord(unsigned long iPoint) const final { return Mesh_Coord[iPoint]; } /*! * \brief Set the value of the undeformed coordinates. * \param[in] iDim - Index of Mesh_Coord[nDim] * \param[in] val_coord - Value of Mesh_Coord[nDim] */ - inline void SetMesh_Coord(unsigned short iDim, const su2double val_coord) final { Mesh_Coord[iDim] = val_coord;} - - /*! - * \brief Move Displacement into Displacement_Old. - */ - inline void SetSolution_Old(void){ - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Solution_Old[iDim] = Solution[iDim]; + inline void SetMesh_Coord(unsigned long iPoint, unsigned long iDim, su2double val_coord) final { + Mesh_Coord(iPoint,iDim) = val_coord; } /*! @@ -98,41 +87,26 @@ class CMeshVariable : public CVariable { * \param[in] iDim - Index of Mesh_Coord[nDim] * \return Value of the wall distance in reference coordinates. */ - inline su2double GetWallDistance(void) const final { return WallDistance; } + inline su2double GetWallDistance(unsigned long iPoint) const final { return WallDistance(iPoint); } /*! * \brief Set the value of the wall distance in reference coordinates. * \param[in] val_dist - Value of wall distance. */ - inline void SetWallDistance(const su2double val_dist) final { WallDistance = val_dist; } - - /*! - * \brief Determine whether the node is a moving vertex. - * \return False. The node is not at the boundary. - */ - inline virtual bool Get_isVertex(void) const override { return false; } + inline void SetWallDistance(unsigned long iPoint, su2double val_dist) final { WallDistance(iPoint) = val_dist; } /*! * \brief Register the reference coordinates of the mesh. * \param[in] input - Defines whether we are registering the variable as input or as output. */ - inline void Register_MeshCoord(bool input) final { - if (input) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Mesh_Coord[iVar]); - } - else { for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterOutput(Mesh_Coord[iVar]); - } - } + void Register_MeshCoord(bool input) final; /*! * \brief Recover the value of the adjoint of the mesh coordinates. */ - inline void GetAdjoint_MeshCoord(su2double *adj_mesh) const final{ - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - adj_mesh[iVar] = SU2_TYPE::GetDerivative(Mesh_Coord[iVar]); - } + inline void GetAdjoint_MeshCoord(unsigned long iPoint, su2double *adj_mesh) const final { + for (unsigned long iDim = 0; iDim < nDim; iDim++) + adj_mesh[iDim] = SU2_TYPE::GetDerivative(Mesh_Coord(iPoint,iDim)); } }; diff --git a/SU2_CFD/include/variables/CNSVariable.hpp b/SU2_CFD/include/variables/CNSVariable.hpp index 692f5acea912..9efee442d51a 100644 --- a/SU2_CFD/include/variables/CNSVariable.hpp +++ b/SU2_CFD/include/variables/CNSVariable.hpp @@ -45,212 +45,198 @@ * \ingroup Navier_Stokes_Equations * \author F. Palacios, T. Economon */ -class CNSVariable : public CEulerVariable { +class CNSVariable final : public CEulerVariable { private: - su2double Prandtl_Lam; /*!< \brief Laminar Prandtl number. */ - su2double Prandtl_Turb; /*!< \brief Turbulent Prandtl number. */ - su2double Temperature_Ref; /*!< \brief Reference temperature of the fluid. */ - su2double Viscosity_Ref; /*!< \brief Reference viscosity of the fluid. */ - su2double Viscosity_Inf; /*!< \brief Viscosity of the fluid at the infinity. */ - su2double Vorticity[3]; /*!< \brief Vorticity of the fluid. */ - su2double StrainMag; /*!< \brief Magnitude of rate of strain tensor. */ - su2double Tau_Wall; /*!< \brief Magnitude of the wall shear stress from a wall function. */ - su2double DES_LengthScale; /*!< \brief DES Length Scale. */ su2double inv_TimeScale; /*!< \brief Inverse of the reference time scale. */ - su2double Roe_Dissipation; /*!< \brief Roe low dissipation coefficient. */ - su2double Vortex_Tilting; /*!< \brief Value of the vortex tilting variable for DES length scale computation. */ -public: + MatrixType Vorticity; /*!< \brief Vorticity of the fluid. */ + VectorType StrainMag; /*!< \brief Magnitude of rate of strain tensor. */ + VectorType Tau_Wall; /*!< \brief Magnitude of the wall shear stress from a wall function. */ + VectorType DES_LengthScale; /*!< \brief DES Length Scale. */ + VectorType Roe_Dissipation; /*!< \brief Roe low dissipation coefficient. */ + VectorType Vortex_Tilting; /*!< \brief Value of the vortex tilting variable for DES length scale computation. */ +public: /*! * \brief Constructor of the class. - */ - CNSVariable(void); - - /*! - * \overload - * \param[in] val_density - Value of the flow density (initialization value). - * \param[in] val_velocity - Value of the flow velocity (initialization value). - * \param[in] val_energy - Value of the flow energy (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. - * \param[in] config - Definition of the particular problem. - */ - CNSVariable(su2double val_density, su2double *val_velocity, - su2double val_energy, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); - - /*! - * \overload - * \param[in] val_solution - Pointer to the flow value (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] density - Value of the flow density (initialization value). + * \param[in] velocity - Value of the flow velocity (initialization value). + * \param[in] energy - Value of the flow energy (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CNSVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CNSVariable(su2double density, const su2double *velocity, su2double energy, + unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - ~CNSVariable(void); + ~CNSVariable() = default; /*! * \brief Set the laminar viscosity. */ - inline void SetLaminarViscosity(su2double laminarViscosity) {Primitive[nDim+5] = laminarViscosity;} + inline void SetLaminarViscosity(unsigned long iPoint, su2double laminarViscosity) override { + Primitive(iPoint,nDim+5) = laminarViscosity; + } /*! * \brief Set the laminar viscosity. */ - inline void SetThermalConductivity(su2double thermalConductivity) {Primitive[nDim+7] = thermalConductivity;} + inline void SetThermalConductivity(unsigned long iPoint, su2double thermalConductivity) override { + Primitive(iPoint,nDim+7) = thermalConductivity; + } /*! * \brief Set the specific heat Cp. */ - inline void SetSpecificHeatCp(su2double val_Cp) {Primitive[nDim+8] = val_Cp;} + inline void SetSpecificHeatCp(unsigned long iPoint, su2double val_Cp) override { Primitive(iPoint,nDim+8) = val_Cp; } /*! * \brief Set the vorticity value. */ - bool SetVorticity(void); - - /*! - * \brief Set the rate of strain magnitude. - */ - bool SetStrainMag(void); + bool SetVorticity_StrainMag() override; /*! * \overload * \param[in] eddy_visc - Value of the eddy viscosity. */ - inline void SetEddyViscosity(su2double eddy_visc) {Primitive[nDim+6] = eddy_visc; } + inline void SetEddyViscosity(unsigned long iPoint, su2double eddy_visc) override { Primitive(iPoint,nDim+6) = eddy_visc; } /*! * \brief Get the laminar viscosity of the flow. * \return Value of the laminar viscosity of the flow. */ - inline su2double GetLaminarViscosity(void) {return Primitive[nDim+5]; } + inline su2double GetLaminarViscosity(unsigned long iPoint) const override { return Primitive(iPoint,nDim+5); } /*! * \brief Get the thermal conductivity of the flow. * \return Value of the laminar viscosity of the flow. */ - inline su2double GetThermalConductivity(void) {return Primitive[nDim+7]; } + inline su2double GetThermalConductivity(unsigned long iPoint) const override { return Primitive(iPoint,nDim+7); } /*! * \brief Get the eddy viscosity of the flow. * \return The eddy viscosity of the flow. */ - inline su2double GetEddyViscosity(void) {return Primitive[nDim+6]; } + inline su2double GetEddyViscosity(unsigned long iPoint) const override { return Primitive(iPoint,nDim+6); } /*! * \brief Get the specific heat at constant P of the flow. * \return Value of the specific heat at constant P of the flow. */ - inline su2double GetSpecificHeatCp(void) {return Primitive[nDim+8]; } + inline su2double GetSpecificHeatCp(unsigned long iPoint) const override { return Primitive(iPoint,nDim+8); } /*! * \brief Set the temperature at the wall */ - inline void SetWallTemperature(su2double temperature_wall) { Primitive[0] = temperature_wall; } + inline void SetWallTemperature(unsigned long iPoint, su2double temperature_wall) override { + Primitive(iPoint,0) = temperature_wall; + } /*! * \brief Get the value of the vorticity. - * \param[in] val_dim - Index of the dimension. * \return Value of the vorticity. */ - inline su2double *GetVorticity(void) {return Vorticity; } + inline su2double *GetVorticity(unsigned long iPoint) override { return Vorticity[iPoint]; } /*! * \brief Get the value of the magnitude of rate of strain. * \return Value of the rate of strain magnitude. */ - inline su2double GetStrainMag(void) {return StrainMag; } + inline su2double GetStrainMag(unsigned long iPoint) const override { return StrainMag(iPoint); } /*! * \brief Set the derivative of temperature with respect to density (at constant internal energy). */ - inline void SetdTdrho_e(su2double dTdrho_e) {Secondary[2] = dTdrho_e;} + inline void SetdTdrho_e(unsigned long iPoint, su2double dTdrho_e) override { Secondary(iPoint,2) = dTdrho_e;} /*! * \brief Set the derivative of temperature with respect to internal energy (at constant density). */ - inline void SetdTde_rho(su2double dTde_rho) {Secondary[3] = dTde_rho;} + inline void SetdTde_rho(unsigned long iPoint, su2double dTde_rho) override { Secondary(iPoint,3) = dTde_rho;} /*! * \brief Set the derivative of laminar viscosity with respect to density (at constant temperature). */ - inline void Setdmudrho_T(su2double dmudrho_T) {Secondary[4] = dmudrho_T;} + inline void Setdmudrho_T(unsigned long iPoint, su2double dmudrho_T) override { Secondary(iPoint,4) = dmudrho_T;} /*! * \brief Set the derivative of laminar viscosity with respect to temperature (at constant density). */ - inline void SetdmudT_rho(su2double dmudT_rho) {Secondary[5] = dmudT_rho;} + inline void SetdmudT_rho(unsigned long iPoint, su2double dmudT_rho) override { Secondary(iPoint,5) = dmudT_rho;} /*! * \brief Set the derivative of thermal conductivity with respect to density (at constant temperature). */ - inline void Setdktdrho_T(su2double dktdrho_T) {Secondary[6] = dktdrho_T;} + inline void Setdktdrho_T(unsigned long iPoint, su2double dktdrho_T) override { Secondary(iPoint,6) = dktdrho_T;} /*! * \brief Set the derivative of thermal conductivity with respect to temperature (at constant density). */ - inline void SetdktdT_rho(su2double dktdT_rho) {Secondary[7] = dktdT_rho;} + inline void SetdktdT_rho(unsigned long iPoint, su2double dktdT_rho) override { Secondary(iPoint,7) = dktdT_rho;} /*! * \brief Set all the primitive variables for compressible flows */ - bool SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel); + bool SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel) override; using CVariable::SetPrimVar; /*! * \brief Set all the secondary variables (partial derivatives) for compressible flows */ - void SetSecondaryVar(CFluidModel *FluidModel); + void SetSecondaryVar(unsigned long iPoint, CFluidModel *FluidModel) override; /*! * \brief Set the value of the wall shear stress computed by a wall function. */ - inline void SetTauWall(su2double val_tau_wall) {Tau_Wall = val_tau_wall; } + inline void SetTauWall(unsigned long iPoint, su2double val_tau_wall) override { Tau_Wall(iPoint) = val_tau_wall; } /*! * \brief Get the value of the wall shear stress computed by a wall function. * \return Value of the wall shear stress computed by a wall function. */ - inline su2double GetTauWall(void) {return Tau_Wall; } + inline su2double GetTauWall(unsigned long iPoint) const override { return Tau_Wall(iPoint); } /*! * \brief Get the DES length scale * \return Value of the DES length Scale. */ - inline su2double GetDES_LengthScale(void) {return DES_LengthScale; } + inline su2double GetDES_LengthScale(unsigned long iPoint) const override { return DES_LengthScale(iPoint); } /*! * \brief Set the DES Length Scale. */ - inline void SetDES_LengthScale(su2double val_des_lengthscale) {DES_LengthScale = val_des_lengthscale; } + inline void SetDES_LengthScale(unsigned long iPoint, su2double val_des_lengthscale) override { + DES_LengthScale(iPoint) = val_des_lengthscale; + } /*! * \brief Set the new solution for Roe Dissipation. * \param[in] val_delta - A scalar measure of the grid size * \param[in] val_const_DES - The DES constant (C_DES) */ - void SetRoe_Dissipation_NTS(su2double val_delta, su2double val_const_DES); + void SetRoe_Dissipation_NTS(unsigned long iPoint, su2double val_delta, su2double val_const_DES) override; /*! * \brief Set the new solution for Roe Dissipation. */ - void SetRoe_Dissipation_FD(su2double wall_distance); + void SetRoe_Dissipation_FD(unsigned long iPoint, su2double wall_distance) override; /*! * \brief Get the Roe Dissipation Coefficient. * \return Value of the Roe Dissipation. */ - inline su2double GetRoe_Dissipation(void) {return Roe_Dissipation; } + inline su2double GetRoe_Dissipation(unsigned long iPoint) const override { return Roe_Dissipation(iPoint); } /*! * \brief Set the Roe Dissipation Coefficient. * \param[in] val_dissipation - Value of the Roe dissipation factor. */ - inline void SetRoe_Dissipation(su2double val_dissipation) {Roe_Dissipation = val_dissipation; } + inline void SetRoe_Dissipation(unsigned long iPoint, su2double val_dissipation) override { + Roe_Dissipation(iPoint) = val_dissipation; + } }; diff --git a/SU2_CFD/include/variables/CTransLMVariable.hpp b/SU2_CFD/include/variables/CTransLMVariable.hpp index a90141f9adc6..43a900f71161 100644 --- a/SU2_CFD/include/variables/CTransLMVariable.hpp +++ b/SU2_CFD/include/variables/CTransLMVariable.hpp @@ -46,46 +46,41 @@ * \author A. Bueno. */ -class CTransLMVariable : public CTurbVariable { +class CTransLMVariable final : public CTurbVariable { protected: - su2double gamma_sep; + VectorType gamma_sep; public: - /*! * \brief Constructor of the class. - */ - CTransLMVariable(void); - - /*! - * \overload - * \param[in] val_nu_tilde - Turbulent variable value (initialization value). * \param[in] val_intermittency * \param[in] val_REth - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. + * \param[in] constants - * \param[in] config - Definition of the particular problem. */ - CTransLMVariable(su2double val_nu_tilde, su2double val_intermittency, su2double val_REth, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CTransLMVariable(su2double intermittency, su2double REth, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - ~CTransLMVariable(void); + ~CTransLMVariable() = default; /*! * \brief ________________. */ - inline su2double GetIntermittency(void) { return Solution[0]; } + inline su2double GetIntermittency(unsigned long iPoint) const override { return Solution(iPoint,0); } /*! * \brief ________________. * \param[in] gamma_sep_in */ - inline void SetGammaSep(su2double gamma_sep_in) {gamma_sep = gamma_sep_in;} + inline void SetGammaSep(unsigned long iPoint, su2double gamma_sep_in) override { gamma_sep(iPoint) = gamma_sep_in; } /*! * \brief Correction for separation-induced transition. */ - inline void SetGammaEff(void) {Solution[0] = max(Solution[0], gamma_sep);} + inline void SetGammaEff(unsigned long iPoint) override { Solution(iPoint,0) = max(Solution(iPoint,0), gamma_sep(iPoint)); } }; diff --git a/SU2_CFD/include/variables/CTurbSAVariable.hpp b/SU2_CFD/include/variables/CTurbSAVariable.hpp index b65178f24f78..1dc15995f0c9 100644 --- a/SU2_CFD/include/variables/CTurbSAVariable.hpp +++ b/SU2_CFD/include/variables/CTurbSAVariable.hpp @@ -46,80 +46,85 @@ * \author A. Bueno. */ -class CTurbSAVariable : public CTurbVariable { +class CTurbSAVariable final : public CTurbVariable { private: - su2double gamma_BC; /*!< \brief Value of the intermittency for the BC trans. model. */ - su2double DES_LengthScale; - su2double Vortex_Tilting; + VectorType gamma_BC; /*!< \brief Value of the intermittency for the BC trans. model. */ + VectorType DES_LengthScale; + VectorType Vortex_Tilting; public: /*! * \brief Constructor of the class. - */ - CTurbSAVariable(void); - - /*! - * \overload * \param[in] val_nu_tilde - Turbulent variable value (initialization value). * \param[in] val_muT - The eddy viscosity - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. + * \param[in] constants - * \param[in] config - Definition of the particular problem. */ - CTurbSAVariable(su2double val_nu_tilde, su2double val_muT, unsigned short val_nDim, unsigned short val_nvar, CConfig *config); - + CTurbSAVariable(su2double val_nu_tilde, su2double val_muT, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); + /*! * \brief Destructor of the class. */ - ~CTurbSAVariable(void); + ~CTurbSAVariable() = default; /*! * \brief Set the harmonic balance source term. - * \param[in] val_var - Index of the variable. - * \param[in] val_source - Value of the harmonic balance source term. for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] source - Value of the harmonic balance source term. for the index iVar. */ - inline void SetHarmonicBalance_Source(unsigned short val_var, su2double val_source) {HB_Source[val_var] = val_source; } + inline void SetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar, su2double source) override { HB_Source(iPoint,iVar) = source; } /*! * \brief Get the harmonic balance source term. - * \param[in] val_var - Index of the variable. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. * \return Value of the harmonic balance source term for the index val_var. */ - inline su2double GetHarmonicBalance_Source(unsigned short val_var) {return HB_Source[val_var]; } + inline su2double GetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar) const override { return HB_Source(iPoint,iVar); } /*! * \brief Get the intermittency of the BC transition model. + * \param[in] iPoint - Point index. * \return Value of the intermittency of the BC transition model. */ - inline su2double GetGammaBC(void) {return gamma_BC; } + inline su2double GetGammaBC(unsigned long iPoint) const override { return gamma_BC(iPoint); } /*! * \brief Set the intermittency of the BC transition model. + * \param[in] iPoint - Point index. * \param[in] val_gamma - New value of the intermittency. */ - inline void SetGammaBC(su2double val_gamma) {gamma_BC = val_gamma; } + inline void SetGammaBC(unsigned long iPoint, su2double val_gamma) override { gamma_BC(iPoint) = val_gamma; } /*! * \brief Get the DES length scale + * \param[in] iPoint - Point index. * \return Value of the DES length Scale. */ - inline su2double GetDES_LengthScale(void) {return DES_LengthScale; } + inline su2double GetDES_LengthScale(unsigned long iPoint) const override { return DES_LengthScale(iPoint); } /*! * \brief Set the DES Length Scale. + * \param[in] iPoint - Point index. */ - inline void SetDES_LengthScale(su2double val_des_lengthscale) {DES_LengthScale = val_des_lengthscale; } + inline void SetDES_LengthScale(unsigned long iPoint, su2double val_des_lengthscale) override { DES_LengthScale(iPoint) = val_des_lengthscale; } /*! * \brief Set the vortex tilting measure for computation of the EDDES length scale + * \param[in] iPoint - Point index. */ - void SetVortex_Tilting(su2double **PrimGrad_Flow, su2double* Vorticity, su2double LaminarViscosity); + void SetVortex_Tilting(unsigned long iPoint, su2double **PrimGrad_Flow, su2double* Vorticity, su2double LaminarViscosity) override; /*! * \brief Get the vortex tilting measure for computation of the EDDES length scale + * \param[in] iPoint - Point index. * \return Value of the DES length Scale */ - inline su2double GetVortex_Tilting() {return Vortex_Tilting; } + inline su2double GetVortex_Tilting(unsigned long iPoint) const override { return Vortex_Tilting(iPoint); } }; diff --git a/SU2_CFD/include/variables/CTurbSSTVariable.hpp b/SU2_CFD/include/variables/CTurbSSTVariable.hpp index 9168414b8657..7b3ae7b7dfd7 100644 --- a/SU2_CFD/include/variables/CTurbSSTVariable.hpp +++ b/SU2_CFD/include/variables/CTurbSSTVariable.hpp @@ -46,37 +46,33 @@ * \author A. Bueno. */ -class CTurbSSTVariable : public CTurbVariable { +class CTurbSSTVariable final : public CTurbVariable { protected: - su2double sigma_om2, - beta_star; - su2double F1, /*!< \brief Menter blending function for blending of k-w and k-eps. */ - F2, /*!< \brief Menter blending function for stress limiter. */ - CDkw; /*!< \brief Cross-diffusion. */ + su2double sigma_om2; + su2double beta_star; + VectorType F1; + VectorType F2; /*!< \brief Menter blending function for blending of k-w and k-eps. */ + VectorType CDkw; /*!< \brief Cross-diffusion. */ public: /*! * \brief Constructor of the class. - */ - CTurbSSTVariable(void); - - /*! - * \overload - * \param[in] val_rho_kine - Turbulent variable value (initialization value). - * \param[in] val_rho_omega - Turbulent variable value (initialization value). - * \param[in] val_muT - Turbulent variable value (initialization value). - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] kine - Turbulence kinetic energy (k) (initialization value). + * \param[in] omega - Turbulent variable value (initialization value). + * \param[in] mut - Eddy viscosity (initialization value). + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] constants - * \param[in] config - Definition of the particular problem. */ - CTurbSSTVariable(su2double val_rho_kine, su2double val_rho_omega, su2double val_muT, unsigned short val_nDim, unsigned short val_nvar, - su2double *constants, CConfig *config); - + CTurbSSTVariable(su2double kine, su2double omega, su2double mut, unsigned long npoint, + unsigned long ndim, unsigned long nvar, const su2double* constants, CConfig *config); + /*! * \brief Destructor of the class. */ - ~CTurbSSTVariable(void); + ~CTurbSSTVariable() = default; /*! * \brief Set the blending function for the blending of k-w and k-eps. @@ -84,20 +80,20 @@ class CTurbSSTVariable : public CTurbVariable { * \param[in] val_dist - Value of the distance to the wall. * \param[in] val_density - Value of the density. */ - void SetBlendingFunc(su2double val_viscosity, su2double val_dist, su2double val_density); + void SetBlendingFunc(unsigned long iPoint, su2double val_viscosity, su2double val_dist, su2double val_density) override; /*! * \brief Get the first blending function. */ - inline su2double GetF1blending(void) { return F1; } + inline su2double GetF1blending(unsigned long iPoint) const override { return F1(iPoint); } /*! * \brief Get the second blending function. */ - inline su2double GetF2blending(void) { return F2; } + inline su2double GetF2blending(unsigned long iPoint) const override { return F2(iPoint); } /*! * \brief Get the value of the cross diffusion of tke and omega. */ - inline su2double GetCrossDiff(void) { return CDkw; } + inline su2double GetCrossDiff(unsigned long iPoint) const override { return CDkw(iPoint); } }; diff --git a/SU2_CFD/include/variables/CTurbVariable.hpp b/SU2_CFD/include/variables/CTurbVariable.hpp index 28e0152be71e..ae2528af61e4 100644 --- a/SU2_CFD/include/variables/CTurbVariable.hpp +++ b/SU2_CFD/include/variables/CTurbVariable.hpp @@ -47,63 +47,68 @@ */ class CTurbVariable : public CVariable { protected: - su2double muT; /*!< \brief Eddy viscosity. */ - su2double *HB_Source; /*!< \brief Harmonic Balance source term. */ - su2double **Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ - bool GradReconAllocated; /*!< \brief Flag indicating that separate memory was allocated for the MUSCL reconstruction gradient. */ + VectorType muT; /*!< \brief Eddy viscosity. */ + MatrixType HB_Source; /*!< \brief Harmonic Balance source term. */ + + VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ public: /*! * \brief Constructor of the class. - */ - CTurbVariable(void); - - /*! - * \overload - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CTurbVariable(unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - virtual ~CTurbVariable(void); + virtual ~CTurbVariable() = default; /*! * \brief Get the value of the eddy viscosity. + * \param[in] iPoint - Point index. * \return the value of the eddy viscosity. */ - inline su2double GetmuT() { return muT; } + inline su2double GetmuT(unsigned long iPoint) const final { return muT(iPoint); } /*! * \brief Set the value of the eddy viscosity. + * \param[in] iPoint - Point index. * \param[in] val_muT - Value of the eddy viscosity. */ - inline void SetmuT(su2double val_muT) { muT = val_muT; } - + inline void SetmuT(unsigned long iPoint, su2double val_muT) final { muT(iPoint) = val_muT; } + /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \return Value of the primitive variables gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \return Value of the reconstruction variables gradient at a node. */ - inline su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) {return Gradient_Reconstruction[val_var][val_dim]; } + inline su2double GetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const final { + return Gradient_Reconstruction(iPoint,iVar,iDim); + } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \brief Get the value of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] iDim - Index of the dimension. */ - inline void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient_Reconstruction[val_var][val_dim] = val_value; } + inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { + Gradient_Reconstruction(iPoint,iVar,iDim) = value; + } /*! - * \brief Get the value of the primitive gradient for MUSCL reconstruction. - * \return Value of the primitive variables gradient. + * \brief Get the array of the reconstruction variables gradient at a node. + * \param[in] iPoint - Index of the current node. + * \return Array of the reconstruction variables gradient at a node. */ - inline su2double **GetGradient_Reconstruction(void) {return Gradient_Reconstruction; } + inline su2double **GetGradient_Reconstruction(unsigned long iPoint) final { return Gradient_Reconstruction[iPoint]; } }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 3189ca4c0408..5db48fd77754 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -47,6 +47,7 @@ #include "../../../Common/include/config_structure.hpp" #include "../fluid_model.hpp" +#include "../../../Common/include/toolboxes/C2DContainer.hpp" using namespace std; @@ -58,1434 +59,1580 @@ using namespace std; */ class CVariable { protected: + using VectorType = C2DContainer; + using MatrixType = C2DContainer; + + /*--- This contrived container is used to store matrices in a contiguous manner but still present the + "su2double**" interface to the outside world, it will be replaced by something more efficient. ---*/ + struct VectorOfMatrix { + su2activevector storage; + su2matrix interface; + unsigned long M, N; + + void resize(unsigned long length, unsigned long rows, unsigned long cols, su2double value) { + M = rows; + N = cols; + storage.resize(length*rows*cols) = value; + interface.resize(length,rows); + + for(unsigned long i=0; i Non_Physical; /*!< \brief Non-physical points in the solution (force first order). */ + su2vector Non_Physical_Counter; /*!< \brief Number of consecutive iterations that a point has been treated first-order. After a specified number of successful reconstructions, the point can be returned to second-order. */ + + VectorType UnderRelaxation; /*!< \brief Value of the under-relxation parameter local to the control volume. */ + VectorType LocalCFL; /*!< \brief Value of the CFL number local to the control volume. */ + + MatrixType Solution_time_n; /*!< \brief Solution of the problem at time n for dual-time stepping technique. */ + MatrixType Solution_time_n1; /*!< \brief Solution of the problem at time n-1 for dual-time stepping technique. */ + VectorType Delta_Time; /*!< \brief Time step. */ + + VectorOfMatrix Gradient; /*!< \brief Gradient of the solution of the problem. */ + VectorOfMatrix Rmatrix; /*!< \brief Geometry-based matrix for weighted least squares gradient calculations. */ + + MatrixType Limiter; /*!< \brief Limiter of the solution of the problem. */ + MatrixType Solution_Max; /*!< \brief Max solution for limiter computation. */ + MatrixType Solution_Min; /*!< \brief Min solution for limiter computation. */ + + VectorType AuxVar; /*!< \brief Auxiliar variable for gradient computation. */ + MatrixType Grad_AuxVar; /*!< \brief Gradient of the auxiliar variable. */ + + VectorType Max_Lambda_Inv; /*!< \brief Maximun inviscid eingenvalue. */ + VectorType Max_Lambda_Visc; /*!< \brief Maximun viscous eingenvalue. */ + VectorType Lambda; /*!< \brief Value of the eingenvalue. */ + + VectorType Sensor; /*!< \brief Pressure sensor for high order central scheme and Roe dissipation. */ + MatrixType Undivided_Laplacian; /*!< \brief Undivided laplacian of the solution. */ + + MatrixType Res_TruncError; /*!< \brief Truncation error for multigrid cycle. */ + MatrixType Residual_Old; /*!< \brief Auxiliar structure for residual smoothing. */ + MatrixType Residual_Sum; /*!< \brief Auxiliar structure for residual smoothing. */ + + MatrixType Solution_Adj_Old; /*!< \brief Solution of the problem in the previous AD-BGS iteration. */ - su2double *Solution, /*!< \brief Solution of the problem. */ - *Solution_Old; /*!< \brief Old solution of the problem R-K. */ - bool Non_Physical; /*!< \brief Non-physical points in the solution (force first order). */ - unsigned short Non_Physical_Counter; /*!< \brief Number of consecutive iterations that a point has been treated first-order. After a specified number of successful reconstructions, the point can be returned to second-order. */ - su2double *Solution_time_n, /*!< \brief Solution of the problem at time n for dual-time stepping technique. */ - *Solution_time_n1; /*!< \brief Solution of the problem at time n-1 for dual-time stepping technique. */ - su2double **Gradient; /*!< \brief Gradient of the solution of the problem. */ - su2double **Rmatrix; /*!< \brief Geometry-based matrix for weighted least squares gradient calculations. */ - su2double *Limiter; /*!< \brief Limiter of the solution of the problem. */ - su2double *Solution_Max; /*!< \brief Max solution for limiter computation. */ - su2double *Solution_Min; /*!< \brief Min solution for limiter computation. */ - su2double AuxVar; /*!< \brief Auxiliar variable for gradient computation. */ - su2double *Grad_AuxVar; /*!< \brief Gradient of the auxiliar variable. */ - su2double Delta_Time; /*!< \brief Time step. */ - su2double Max_Lambda, /*!< \brief Maximun eingenvalue. */ - Max_Lambda_Inv, /*!< \brief Maximun inviscid eingenvalue. */ - Max_Lambda_Visc, /*!< \brief Maximun viscous eingenvalue. */ - Lambda; /*!< \brief Value of the eingenvalue. */ - su2double Sensor; /*!< \brief Pressure sensor for high order central scheme and Roe dissipation. */ - su2double *Undivided_Laplacian; /*!< \brief Undivided laplacian of the solution. */ - su2double *Res_TruncError, /*!< \brief Truncation error for multigrid cycle. */ - *Residual_Old, /*!< \brief Auxiliar structure for residual smoothing. */ - *Residual_Sum; /*!< \brief Auxiliar structure for residual smoothing. */ - su2double UnderRelaxation; /*!< \brief Value of the under-relxation parameter local to the control volume. */ - su2double LocalCFL; /*!< \brief Value of the CFL number local to the control volume. */ - - static unsigned short nDim; /*!< \brief Number of dimension of the problem. */ - unsigned short nVar; /*!< \brief Number of variables of the problem, - note that this variable cannnot be static, it is possible to - have different number of nVar in the same problem. */ - unsigned short nPrimVar, nPrimVarGrad; /*!< \brief Number of variables of the problem, - note that this variable cannnot be static, it is possible to - have different number of nVar in the same problem. */ - unsigned short nSecondaryVar, nSecondaryVarGrad; /*!< \brief Number of variables of the problem, - note that this variable cannnot be static, it is possible to - have different number of nVar in the same problem. */ - su2double *Solution_Adj_Old; /*!< \brief Solution of the problem in the previous AD-BGS iteration. */ - - su2double *Solution_BGS_k; + MatrixType Solution_BGS_k; /*!< \brief Old solution container for BGS iterations. */ + + su2matrix Input_AdjIndices; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix Output_AdjIndices; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + + unsigned long nPoint = {0}; /*!< \brief Number of points in the domain. */ + unsigned long nDim = {0}; /*!< \brief Number of dimension of the problem. */ + unsigned long nVar = {0}; /*!< \brief Number of variables of the problem. */ + unsigned long nPrimVar = {0}; /*!< \brief Number of primitive variables. */ + unsigned long nPrimVarGrad = {0}; /*!< \brief Number of primitives for which a gradient is computed. */ + unsigned long nSecondaryVar = {0}; /*!< \brief Number of secondary variables. */ + unsigned long nSecondaryVarGrad = {0}; /*!< \brief Number of secondaries for which a gradient is computed. */ public: - /*! - * \brief Constructor of the class. - */ - CVariable(void); + /*--- Disable default construction copy and assignment. ---*/ + CVariable() = delete; + CVariable(const CVariable&) = delete; + CVariable(CVariable&&) = delete; + CVariable& operator= (const CVariable&) = delete; + CVariable& operator= (CVariable&&) = delete; /*! * \overload - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CVariable(unsigned short val_nvar, CConfig *config); + CVariable(unsigned long npoint, unsigned long nvar, CConfig *config); /*! * \overload - * \param[in] val_nDim - Number of dimensions of the problem. - * \param[in] val_nvar - Number of variables of the problem. + * \param[in] npoint - Number of points/nodes/vertices in the domain. + * \param[in] ndim - Number of dimensions of the problem. + * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. */ - CVariable(unsigned short val_nDim, unsigned short val_nvar, CConfig *config); + CVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. */ - virtual ~CVariable(void); + virtual ~CVariable() = default; /*! - * \brief Set the value of the solution. - * \param[in] val_solution - Solution of the problem. + * \brief Set the value of the solution, all variables. + * \param[in] iPoint - Point index. + * \param[in] solution - Solution of the problem. */ - inline void SetSolution(su2double *val_solution) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = val_solution[iVar]; + inline void SetSolution(unsigned long iPoint, const su2double *solution) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar) = solution[iVar]; } /*! - * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the solution for the index val_var. + * \brief Set the value of the solution, one variable. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] solution - Value of the solution for the index iVar. */ - inline void SetSolution(unsigned short val_var, su2double val_solution) {Solution[val_var] = val_solution;} + inline void SetSolution(unsigned long iPoint, unsigned long iVar, su2double solution) { Solution(iPoint,iVar) = solution; } /*! * \brief Add the value of the solution vector to the previous solution (incremental approach). - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the solution for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] solution - Value of the solution for the index iVar. */ - inline void Add_DeltaSolution(unsigned short val_var, su2double val_solution) {Solution[val_var] += val_solution;} + inline void Add_DeltaSolution(unsigned long iPoint, unsigned long iVar, su2double solution) { Solution(iPoint,iVar) += solution; } /*! * \brief Set the value of the non-physical point. - * \param[in] val_value - identification of the non-physical point. + * \param[in] iPoint - Point index. + * \param[in] value - identification of the non-physical point. */ - inline void SetNon_Physical(bool val_value) { + inline void SetNon_Physical(unsigned long iPoint, bool val_value) { if (val_value) { - Non_Physical = val_value; - Non_Physical_Counter = 0; + Non_Physical(iPoint) = val_value; + Non_Physical_Counter(iPoint) = 0; } else { - Non_Physical_Counter++; - if (Non_Physical_Counter > 20) { - Non_Physical = val_value; + Non_Physical_Counter(iPoint)++; + if (Non_Physical_Counter(iPoint) > 20) { + Non_Physical(iPoint) = val_value; } } } /*! - * \brief Get the value of the non-physical point. + * \brief Get the value of the non-physical boolean at a point. + * \param[in] iPoint - Point index. * \return Value of the Non-physical point. */ - inline bool GetNon_Physical(void) { return Non_Physical; } + inline bool GetNon_Physical(unsigned long iPoint) { return Non_Physical(iPoint); } /*! * \brief Get the solution. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetSolution(unsigned short val_var) {return Solution[val_var]; } + inline su2double GetSolution(unsigned long iPoint, unsigned long iVar) const { return Solution(iPoint,iVar); } /*! * \brief Get the old solution of the problem (Runge-Kutta method) - * \param[in] val_var - Index of the variable. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_Old(unsigned short val_var) {return Solution_Old[val_var]; } + inline su2double GetSolution_Old(unsigned long iPoint, unsigned long iVar) const { return Solution_Old(iPoint,iVar); } /*! - * \brief Get the old solution of the discrete adjoint problem (for multiphysics subiterations= - * \param[in] val_var - Index of the variable. + * \brief Get the old solution of the discrete adjoint problem (for multiphysics subiterations) + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline su2double GetSolution_Old_Adj(unsigned short val_var) {return Solution_Adj_Old[val_var]; } + inline su2double GetSolution_Old_Adj(unsigned long iPoint, unsigned long iVar) const { return Solution_Adj_Old(iPoint,iVar); } /*! * \brief Set the value of the old solution. - * \param[in] val_solution_old - Pointer to the residual vector. + * \param[in] iPoint - Point index. + * \param[in] solution_old - Pointer to the residual vector. */ - inline void SetSolution_Old(su2double *val_solution_old) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_Old[iVar] = val_solution_old[iVar]; + inline void SetSolution_Old(unsigned long iPoint, const su2double *solution_old) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution_Old(iPoint,iVar) = solution_old[iVar]; } /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution_old - Value of the old solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] iPoint - Point index. + * \param[in] solution_old - Value of the old solution for the index iVar. */ - inline void SetSolution_Old(unsigned short val_var, su2double val_solution_old) {Solution_Old[val_var] = val_solution_old; } + inline void SetSolution_Old(unsigned long iPoint, unsigned long iVar, su2double solution_old) { Solution_Old(iPoint,iVar) = solution_old; } /*! * \brief Set old variables to the value of the current variables. */ - inline void Set_OldSolution(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_Old[iVar] = Solution[iVar]; - } + void Set_OldSolution(); /*! * \brief Set variables to the value of the old variables. */ - inline void Set_Solution(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = Solution_Old[iVar]; - } - - /*! - * \brief Set old discrete adjoint variables to the current value of the adjoint variables. - */ - inline void Set_OldSolution_Adj(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_Adj_Old[iVar] = Solution[iVar]; - } + void Set_Solution(); /*! * \brief Set the variable solution at time n. */ - inline void Set_Solution_time_n(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_time_n[iVar] = Solution[iVar]; - } + void Set_Solution_time_n(); /*! * \brief Set the variable solution at time n-1. */ - inline void Set_Solution_time_n1(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_time_n1[iVar] = Solution_time_n[iVar]; - } + void Set_Solution_time_n1(); /*! * \brief Set the variable solution at time n. + * \param[in] iPoint - Point index. */ - inline void Set_Solution_time_n(su2double* val_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_time_n[iVar] = val_sol[iVar]; + inline void Set_Solution_time_n(unsigned long iPoint, const su2double* val_sol) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_time_n(iPoint,iVar) = val_sol[iVar]; } /*! * \brief Set the variable solution at time n-1. + * \param[in] iPoint - Point index. */ - inline void Set_Solution_time_n1(su2double* val_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_time_n1[iVar] = val_sol[iVar]; + inline void Set_Solution_time_n1(unsigned long iPoint, const su2double* val_sol) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution_time_n1(iPoint,iVar) = val_sol[iVar]; } /*! - * \brief Set the variable solution at time n-1. + * \brief Set the variable solution at time n. */ - inline void Set_Solution_time_n(unsigned short iVar, su2double val_sol) { - Solution_time_n[iVar] = val_sol; + inline void Set_Solution_time_n(unsigned long iPoint, unsigned long iVar, su2double val_sol) { + Solution_time_n(iPoint,iVar) = val_sol; } /*! * \brief Set the variable solution at time n-1. */ - inline void Set_Solution_time_n1(unsigned short iVar, su2double val_sol) { - Solution_time_n1[iVar] = val_sol; + inline void Set_Solution_time_n1(unsigned long iPoint, unsigned long iVar, su2double val_sol) { + Solution_time_n1(iPoint,iVar) = val_sol; } /*! * \brief Set to zero the velocity components of the solution. + * \param[in] iPoint - Point index. */ - inline void SetVelSolutionZero(void) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) Solution[iDim+1] = 0.0; + inline void SetVelSolutionZero(unsigned long iPoint) { + for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint,iDim+1) = 0.0; } /*! * \brief Specify a vector to set the velocity components of the solution. + * \param[in] iPoint - Point index. * \param[in] val_vector - Pointer to the vector. */ - inline void SetVelSolutionVector(su2double *val_vector) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Solution[iDim+1] = val_vector[iDim]; + inline void SetVelSolutionVector(unsigned long iPoint, const su2double *val_vector) { + for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution(iPoint, iDim+1) = val_vector[iDim]; } /*! * \brief Set to zero velocity components of the solution. */ - inline void SetVelSolutionOldZero(void) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) Solution_Old[iDim+1] = 0.0; + inline void SetVelSolutionOldZero(unsigned long iPoint) { + for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution_Old(iPoint, iDim+1) = 0.0; } /*! - * \brief Specify a vector to set the velocity components of the old solution. - * \param[in] val_vector - Pointer to the vector. - */ - inline void SetVelSolutionOldVector(su2double *val_vector) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Solution_Old[iDim+1] = val_vector[iDim]; - } - - /*! - * \brief Set to zero the solution. + * \brief Add a value to the solution. + * \param[in] iPoint - Point index. + * \param[in] iVar - Number of the variable. + * \param[in] solution - Value that we want to add to the solution. */ - inline void SetSolutionZero(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; + inline void AddSolution(unsigned long iPoint, unsigned long iVar, su2double solution) { + Solution(iPoint, iVar) = Solution_Old(iPoint, iVar) + solution; } - /*! - * \brief Set to zero a particular solution. - */ - inline void SetSolutionZero(unsigned short val_var) {Solution[val_var] = 0.0;} - /*! * \brief Add a value to the solution. - * \param[in] val_var - Number of the variable. - * \param[in] val_solution - Value that we want to add to the solution. + * \param[in] iPoint - Point index. + * \param[in] solution - Value that we want to add to the solution. */ - inline void AddSolution(unsigned short val_var, su2double val_solution) { - Solution[val_var] = Solution_Old[val_var] + val_solution; + inline void AddSolution(unsigned long iPoint, const su2double *solution) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint, iVar) += solution[iVar]; } /*! * \brief A virtual member. - * \param[in] val_var - Index of the variable. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline virtual su2double GetSolution_New(unsigned short val_var) {return 0.0; } + inline virtual su2double GetSolution_New(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual su2double GetRoe_Dissipation(void) {return 0.0; } + inline virtual su2double GetRoe_Dissipation(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual void SetRoe_Dissipation(su2double val_dissipation) {} + inline virtual void SetRoe_Dissipation(unsigned long iPoint, su2double val_dissipation) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual void SetRoe_Dissipation_FD(su2double val_wall_dist) {} + inline virtual void SetRoe_Dissipation_FD(unsigned long iPoint, su2double val_wall_dist) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \param[in] val_delta - A scalar measure of the grid size * \param[in] val_const_DES - The DES constant (C_DES) */ - inline virtual void SetRoe_Dissipation_NTS(su2double val_delta, su2double val_const_DES) {} + inline virtual void SetRoe_Dissipation_NTS(unsigned long iPoint, su2double val_delta, su2double val_const_DES) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual su2double GetDES_LengthScale(void) {return 0.0; } + inline virtual su2double GetDES_LengthScale(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual void SetDES_LengthScale(su2double val_des_lengthscale) {} + inline virtual void SetDES_LengthScale(unsigned long iPoint, su2double val_des_lengthscale) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. + */ + virtual void SetSolution_New() {} + + /*! + * \brief Set external contributions to zero. */ - inline virtual void SetSolution_New(void) {} + void SetExternalZero(); + + /*! + * \brief Set old External to the value of the current variables. + */ + void Set_OldExternal(); /*! * \brief A virtual member. * \param[in] val_var - Number of the variable. * \param[in] val_solution - Value that we want to add to the solution. + * \param[in] iPoint - Point index. + * \param[in] iVar - Number of the variable. + * \param[in] solution - Value that we want to add to the solution. + */ + inline virtual void AddSolution_New(unsigned long iPoint, unsigned long iVar, su2double solution) {} + + /*! + * \brief Add a value to the External vector. + * \param[in] iPoint - Point index. + * \param[in] val_sol - vector that has to be added component-wise + */ + inline void Add_External(unsigned long iPoint, const su2double* val_sol) { + for(unsigned long iVar = 0; iVar < nVar; iVar++) External(iPoint,iVar) += val_sol[iVar]; + } + + /*! + * \brief Add a valaue to the old External vector. + * \param[in] iPoint - Point index. + * \param[in] val_solution - Value that we want to add to the solution. */ - inline virtual void AddSolution_New(unsigned short val_var, su2double val_solution) {} + inline void Add_ExternalOld(unsigned long iPoint, const su2double* val_sol) { + for(unsigned long iVar = 0; iVar < nVar; iVar++) External_Old(iPoint,iVar) += val_sol[iVar]; + } /*! * \brief Add a value to the solution, clipping the values. - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the solution change. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] solution - Value of the solution change. * \param[in] lowerlimit - Lower value. * \param[in] upperlimit - Upper value. */ - inline void AddClippedSolution(unsigned short val_var, su2double val_solution, + inline void AddClippedSolution(unsigned long iPoint, unsigned long iVar, su2double solution, su2double lowerlimit, su2double upperlimit) { - su2double val_new = Solution_Old[val_var] + val_solution; - Solution[val_var] = min(max(val_new, lowerlimit), upperlimit); + su2double val_new = Solution_Old(iPoint, iVar) + solution; + Solution(iPoint,iVar) = min(max(val_new, lowerlimit), upperlimit); } /*! * \brief Update the variables using a conservative format. - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the solution change. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] solution - Value of the solution change. * \param[in] val_density - Value of the density. * \param[in] val_density_old - Value of the old density. * \param[in] lowerlimit - Lower value. * \param[in] upperlimit - Upper value. */ - inline void AddConservativeSolution(unsigned short val_var, su2double val_solution, + inline void AddConservativeSolution(unsigned long iPoint, unsigned long iVar, su2double solution, su2double val_density, su2double val_density_old, su2double lowerlimit, su2double upperlimit) { - su2double val_new = (Solution_Old[val_var]*val_density_old + val_solution)/val_density; - Solution[val_var] = min(max(val_new, lowerlimit), upperlimit); + su2double val_new = (Solution_Old(iPoint,iVar)*val_density_old + solution)/val_density; + Solution(iPoint,iVar) = min(max(val_new, lowerlimit), upperlimit); } /*! * \brief Get the solution of the problem. * \return Pointer to the solution vector. */ - inline su2double *GetSolution(void) {return Solution; } + inline su2double *GetSolution(unsigned long iPoint) { return Solution[iPoint]; } /*! * \brief Get the old solution of the problem (Runge-Kutta method) * \return Pointer to the old solution vector. */ - inline su2double *GetSolution_Old(void) {return Solution_Old; } + inline su2double *GetSolution_Old(unsigned long iPoint) { return Solution_Old[iPoint]; } + + /*! + * \brief Get the external contributions of the problem. + * \param[in] iPoint - Point index. + * \return Pointer to the External row for iPoint. + */ + inline const su2double *Get_External(unsigned long iPoint) const { return External[iPoint]; } + + /*! + * \brief Get the old external contributions of the problem. + * \param[in] iPoint - Point index. + * \return Pointer to the External_Old row for iPoint. + */ + inline const su2double *Get_ExternalOld(unsigned long iPoint) const { return External_Old[iPoint]; } /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline su2double *GetSolution_time_n(void) {return Solution_time_n; } + inline su2double *GetSolution_time_n(unsigned long iPoint) { return Solution_time_n[iPoint]; } /*! * \brief Get the solution at time n-1. * \return Pointer to the solution (at time n-1) vector. */ - inline su2double *GetSolution_time_n1(void) {return Solution_time_n1; } + inline su2double *GetSolution_time_n1(unsigned long iPoint) { return Solution_time_n1[iPoint]; } /*! * \brief Set the value of the old residual. + * \param[in] iPoint - Point index. * \param[in] val_residual_old - Pointer to the residual vector. */ - inline void SetResidual_Old(su2double *val_residual_old) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Residual_Old[iVar] = val_residual_old[iVar]; + inline void SetResidual_Old(unsigned long iPoint, const su2double *val_residual_old) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Residual_Old(iPoint,iVar) = val_residual_old[iVar]; } /*! * \brief Add a value to the summed residual vector. + * \param[in] iPoint - Point index. * \param[in] val_residual - Pointer to the residual vector. */ - inline void AddResidual_Sum(su2double *val_residual) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Residual_Sum[iVar] += val_residual[iVar]; + inline void AddResidual_Sum(unsigned long iPoint, const su2double *val_residual) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Residual_Sum(iPoint,iVar) += val_residual[iVar]; } /*! * \brief Set summed residual vector to zero value. */ - inline void SetResidualSumZero(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Residual_Sum[iVar] = 0.0; - } + void SetResidualSumZero(); /*! * \brief Set the velocity of the truncation error to zero. + * \param[in] iPoint - Point index. */ - inline virtual void SetVel_ResTruncError_Zero(unsigned short iSpecies) {} + inline virtual void SetVel_ResTruncError_Zero(unsigned long iPoint, unsigned long iSpecies) {} /*! * \brief Get the value of the summed residual. + * \param[in] iPoint - Point index. * \return Pointer to the summed residual. */ - inline su2double *GetResidual_Sum(void) {return Residual_Sum; } + inline su2double *GetResidual_Sum(unsigned long iPoint) { return Residual_Sum[iPoint]; } /*! * \brief Get the value of the old residual. + * \param[in] iPoint - Point index. * \return Pointer to the old residual. */ - inline su2double *GetResidual_Old(void) {return Residual_Old; } + inline su2double *GetResidual_Old(unsigned long iPoint) { return Residual_Old[iPoint]; } /*! * \brief Get the value of the summed residual. + * \param[in] iPoint - Point index. * \param[in] val_residual - Pointer to the summed residual. */ - inline void GetResidual_Sum(su2double *val_residual) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - val_residual[iVar] = Residual_Sum[iVar]; + inline void GetResidual_Sum(unsigned long iPoint, su2double *val_residual) const { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + val_residual[iVar] = Residual_Sum(iPoint,iVar); } /*! * \brief Set the value of the under-relaxation parameter for the current control volume (CV). * \param[in] val_under_relaxation - the input value of the under-relaxation parameter for this CV. */ - inline void SetUnderRelaxation(su2double val_under_relaxation) { UnderRelaxation = val_under_relaxation; } + inline void SetUnderRelaxation(unsigned long iPoint, su2double val_under_relaxation) { UnderRelaxation(iPoint) = val_under_relaxation; } /*! * \brief Get the value of the under-relaxation parameter for the current control volume (CV). * \return Value of the under-relaxation parameter for this CV. */ - inline su2double GetUnderRelaxation(void) { return UnderRelaxation; } + inline su2double GetUnderRelaxation(unsigned long iPoint) { return UnderRelaxation(iPoint); } /*! * \brief Set the value of the local CFL number for the current control volume (CV). * \param[in] val_cfl - the input value of the local CFL number for this CV. */ - inline void SetLocalCFL(su2double val_cfl) { LocalCFL = val_cfl; } + inline void SetLocalCFL(unsigned long iPoint, su2double val_cfl) { LocalCFL(iPoint) = val_cfl; } /*! * \brief Get the value of the local CFL number for the current control volume (CV). * \return Value of the local CFL number for this CV. */ - inline su2double GetLocalCFL(void) { return LocalCFL; } + inline su2double GetLocalCFL(unsigned long iPoint) { return LocalCFL(iPoint); } /*! * \brief Set auxiliar variables, we are looking for the gradient of that variable. + * \param[in] iPoint - Point index. * \param[in] val_auxvar - Value of the auxiliar variable. */ - inline void SetAuxVar(su2double val_auxvar) {AuxVar = val_auxvar; } + inline void SetAuxVar(unsigned long iPoint, su2double val_auxvar) { AuxVar(iPoint) = val_auxvar; } /*! * \brief Get the value of the auxiliary variable. + * \param[in] iPoint - Point index. * \return Value of the auxiliary variable. */ - inline su2double GetAuxVar(void) {return AuxVar; } + inline su2double GetAuxVar(unsigned long iPoint) const { return AuxVar(iPoint); } /*! * \brief Set the auxiliary variable gradient to zero value. */ - inline void SetAuxVarGradientZero(void) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) Grad_AuxVar[iDim] = 0.0; - } + void SetAuxVarGradientZero(); /*! * \brief Set the value of the auxiliary variable gradient. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_gradient - Value of the gradient for the index val_dim. + * \param[in] iPoint - Point index. + * \param[in] iDim - Index of the dimension. + * \param[in] val_gradient - Value of the gradient for the index iDim. */ - inline void SetAuxVarGradient(unsigned short val_dim, su2double val_gradient) {Grad_AuxVar[val_dim] = val_gradient;} + inline void SetAuxVarGradient(unsigned long iPoint, unsigned long iDim, su2double val_gradient) { Grad_AuxVar(iPoint,iDim) = val_gradient; } /*! * \brief Add a value to the auxiliary variable gradient. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient to be added for the index val_dim. + * \param[in] iPoint - Point index. + * \param[in] iDim - Index of the dimension. + * \param[in] val_value - Value of the gradient to be added for the index iDim. */ - inline void AddAuxVarGradient(unsigned short val_dim, su2double val_value) {Grad_AuxVar[val_dim] += val_value;} + inline void AddAuxVarGradient(unsigned long iPoint, unsigned long iDim, su2double val_value) { Grad_AuxVar(iPoint,iDim) += val_value;} /*! * \brief Subtract a value to the auxiliary variable gradient. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient to be subtracted for the index val_dim. + * \param[in] iPoint - Point index. + * \param[in] iDim - Index of the dimension. + * \param[in] val_value - Value of the gradient to be subtracted for the index iDim. */ - inline void SubtractAuxVarGradient(unsigned short val_dim, su2double val_value) {Grad_AuxVar[val_dim] -= val_value; } + inline void SubtractAuxVarGradient(unsigned long iPoint, unsigned long iDim, su2double val_value) { Grad_AuxVar(iPoint,iDim) -= val_value; } /*! * \brief Get the gradient of the auxiliary variable. + * \param[in] iPoint - Point index. * \return Value of the gradient of the auxiliary variable. */ - inline su2double *GetAuxVarGradient(void) {return Grad_AuxVar; } + inline su2double *GetAuxVarGradient(unsigned long iPoint) { return Grad_AuxVar[iPoint]; } /*! * \brief Get the gradient of the auxiliary variable. - * \param[in] val_dim - Index of the dimension. - * \return Value of the gradient of the auxiliary variable for the dimension val_dim. + * \param[in] iPoint - Point index. + * \param[in] iDim - Index of the dimension. + * \return Value of the gradient of the auxiliary variable for the dimension iDim. */ - inline su2double GetAuxVarGradient(unsigned short val_dim) {return Grad_AuxVar[val_dim]; } + inline su2double GetAuxVarGradient(unsigned long iPoint, unsigned long iDim) const { return Grad_AuxVar(iPoint,iDim); } /*! * \brief Add a value to the truncation error. + * \param[in] iPoint - Point index. * \param[in] val_truncation_error - Value that we want to add to the truncation error. */ - inline void AddRes_TruncError(su2double *val_truncation_error) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Res_TruncError[iVar] += val_truncation_error[iVar]; + inline void AddRes_TruncError(unsigned long iPoint, const su2double *val_truncation_error) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Res_TruncError(iPoint, iVar) += val_truncation_error[iVar]; } /*! * \brief Subtract a value to the truncation error. + * \param[in] iPoint - Point index. * \param[in] val_truncation_error - Value that we want to subtract to the truncation error. */ - inline void SubtractRes_TruncError(su2double *val_truncation_error) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Res_TruncError[iVar] -= val_truncation_error[iVar]; + inline void SubtractRes_TruncError(unsigned long iPoint, const su2double *val_truncation_error) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Res_TruncError(iPoint, iVar) -= val_truncation_error[iVar]; } /*! * \brief Set the truncation error to zero. + * \param[in] iPoint - Point index. */ - inline void SetRes_TruncErrorZero(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) Res_TruncError[iVar] = 0.0; + inline void SetRes_TruncErrorZero(unsigned long iPoint) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Res_TruncError(iPoint, iVar) = 0.0; } /*! * \brief Set the truncation error to zero. + * \param[in] iPoint - Point index. */ - inline void SetVal_ResTruncError_Zero(unsigned short val_var) {Res_TruncError[val_var] = 0.0;} + inline void SetVal_ResTruncError_Zero(unsigned long iPoint, unsigned long iVar) {Res_TruncError(iPoint, iVar) = 0.0;} /*! * \brief Set the velocity of the truncation error to zero. + * \param[in] iPoint - Point index. */ - inline void SetVel_ResTruncError_Zero(void) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) Res_TruncError[iDim+1] = 0.0; + inline void SetVel_ResTruncError_Zero(unsigned long iPoint) { + for (unsigned long iDim = 0; iDim < nDim; iDim++) Res_TruncError(iPoint,iDim+1) = 0.0; } /*! * \brief Set the velocity of the truncation error to zero. + * \param[in] iPoint - Point index. */ - inline void SetEnergy_ResTruncError_Zero(void) {Res_TruncError[nDim+1] = 0.0;} + inline void SetEnergy_ResTruncError_Zero(unsigned long iPoint) { Res_TruncError(iPoint,nDim+1) = 0.0;} /*! * \brief Get the truncation error. + * \param[in] iPoint - Point index. * \return Pointer to the truncation error. */ - inline su2double *GetResTruncError(void) {return Res_TruncError; } + inline su2double *GetResTruncError(unsigned long iPoint) { return Res_TruncError[iPoint]; } /*! * \brief Get the truncation error. + * \param[in] iPoint - Point index. * \param[in] val_trunc_error - Pointer to the truncation error. */ - inline void GetResTruncError(su2double *val_trunc_error) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - val_trunc_error[iVar] = Res_TruncError[iVar]; + inline void GetResTruncError(unsigned long iPoint, su2double *val_trunc_error) const { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + val_trunc_error[iVar] = Res_TruncError(iPoint, iVar); } /*! * \brief Set the gradient of the solution. - * \param[in] val_gradient - Gradient of the solution. + * \param[in] iPoint - Point index. + * \param[in] gradient - Gradient of the solution. */ - inline void SetGradient(su2double **val_gradient) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Gradient[iVar][iDim] = val_gradient[iVar][iDim]; + inline void SetGradient(unsigned long iPoint, su2double **gradient) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Gradient(iPoint,iVar,iDim) = gradient[iVar][iDim]; } /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value of the gradient. */ - inline void SetGradient(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient[val_var][val_dim] = val_value; } + inline void SetGradient(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) { Gradient(iPoint,iVar,iDim) = value; } /*! * \brief Set to zero the gradient of the solution. */ - inline void SetGradientZero(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - for (unsigned short iDim = 0; iDim < nDim; iDim++) - Gradient[iVar][iDim] = 0.0; - } + void SetGradientZero(); /*! - * \brief Add val_value to the solution gradient. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to add to the solution gradient. + * \brief Add value to the solution gradient. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value to add to the solution gradient. */ - inline void AddGradient(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient[val_var][val_dim] += val_value; } + inline void AddGradient(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) { Gradient(iPoint,iVar,iDim) += value; } /*! - * \brief Subtract val_value to the solution gradient. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to subtract to the solution gradient. + * \brief Subtract value to the solution gradient. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. + * \param[in] value - Value to subtract to the solution gradient. */ - inline void SubtractGradient(unsigned short val_var, unsigned short val_dim, su2double val_value) {Gradient[val_var][val_dim] -= val_value; } + inline void SubtractGradient(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) { Gradient(iPoint,iVar,iDim) -= value; } /*! * \brief Get the value of the solution gradient. + * \param[in] iPoint - Point index. * \return Value of the gradient solution. */ - inline su2double **GetGradient(void) {return Gradient; } + inline su2double **GetGradient(unsigned long iPoint) { return Gradient[iPoint]; } /*! * \brief Get the value of the solution gradient. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. * \return Value of the solution gradient. */ - inline su2double GetGradient(unsigned short val_var, unsigned short val_dim) {return Gradient[val_var][val_dim]; } + inline su2double GetGradient(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const { return Gradient(iPoint,iVar,iDim); } /*! * \brief Set the value of an entry in the Rmatrix for least squares gradient calculations. - * \param[in] val_iDim - Index of the dimension. - * \param[in] val_jDim - Index of the dimension. - * \param[in] val_value - Value of the Rmatrix entry. + * \param[in] iPoint - Point index. + * \param[in] iDim - Index of the dimension. + * \param[in] jDim - Index of the dimension. + * \param[in] value - Value of the Rmatrix entry. */ - inline void SetRmatrix(unsigned short val_iDim, unsigned short val_jDim, su2double val_value) {Rmatrix[val_iDim][val_jDim] = val_value; } + inline void SetRmatrix(unsigned long iPoint, unsigned long iDim, unsigned long jDim, su2double value) { Rmatrix(iPoint,iDim,jDim) = value; } /*! * \brief Set to zero the Rmatrix for least squares gradient calculations. */ - inline void SetRmatrixZero(void) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) - for (unsigned short jDim = 0; jDim < nDim; jDim++) - Rmatrix[iDim][jDim] = 0.0; - } + void SetRmatrixZero(); /*! - * \brief Add val_value to the Rmatrix for least squares gradient calculations. - * \param[in] val_iDim - Index of the dimension. - * \param[in] val_jDim - Index of the dimension. - * \param[in] val_value - Value to add to the Rmatrix entry. + * \brief Add value to the Rmatrix for least squares gradient calculations. + * \param[in] iPoint - Point index. + * \param[in] iDim - Index of the dimension. + * \param[in] jDim - Index of the dimension. + * \param[in] value - Value of the Rmatrix entry. */ - inline void AddRmatrix(unsigned short val_iDim, unsigned short val_jDim, su2double val_value) {Rmatrix[val_iDim][val_jDim] += val_value; } + inline void AddRmatrix(unsigned long iPoint, unsigned long iDim, unsigned long jDim, su2double value) { Rmatrix(iPoint,iDim,jDim) += value; } /*! * \brief Get the value of the Rmatrix entry for least squares gradient calculations. - * \param[in] val_iDim - Index of the dimension. - * \param[in] val_jDim - Index of the dimension. + * \param[in] iPoint - Point index. + * \param[in] iDim - Index of the dimension. + * \param[in] jDim - Index of the dimension. * \return Value of the Rmatrix entry. */ - inline su2double GetRmatrix(unsigned short val_iDim, unsigned short val_jDim) {return Rmatrix[val_iDim][val_jDim]; } + inline su2double GetRmatrix(unsigned long iPoint, unsigned long iDim, unsigned long jDim) const { return Rmatrix(iPoint,iDim,jDim); } /*! * \brief Get the value of the Rmatrix entry for least squares gradient calculations. - * \param[in] val_iDim - Index of the dimension. - * \param[in] val_jDim - Index of the dimension. + * \param[in] iPoint - Point index. * \return Value of the Rmatrix entry. */ - inline su2double **GetRmatrix(void) {return Rmatrix; } + inline su2double **GetRmatrix(unsigned long iPoint) { return Rmatrix[iPoint]; } /*! * \brief Set the value of the limiter. - * \param[in] val_var - Index of the variable. - * \param[in] val_limiter - Value of the limiter for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] val_limiter - Value of the limiter for the index iVar. */ - inline void SetLimiter(unsigned short val_var, su2double val_limiter) {Limiter[val_var] = val_limiter; } + inline void SetLimiter(unsigned long iPoint, unsigned long iVar, su2double val_limiter) { Limiter(iPoint,iVar) = val_limiter; } /*! * \brief Set the value of the limiter. + * \param[in] iPoint - Point index. * \param[in] val_species - Index of the species . - * \param[in] val_var - Index of the variable. - * \param[in] val_limiter - Value of the limiter for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] val_limiter - Value of the limiter for the index iVar. */ - inline virtual void SetLimiterPrimitive(unsigned short val_species, unsigned short val_var, su2double val_limiter) {} + inline virtual void SetLimiterPrimitive(unsigned long iPoint, unsigned long val_species, unsigned long iVar, su2double val_limiter) {} /*! * \brief Set the value of the limiter. + * \param[in] iPoint - Point index. * \param[in] val_species - Index of the species . - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. */ - inline virtual su2double GetLimiterPrimitive(unsigned short val_species, unsigned short val_var) {return 0.0; } + inline virtual su2double GetLimiterPrimitive(unsigned long iPoint, unsigned long val_species, unsigned long iVar) const { return 0.0; } /*! * \brief Set the value of the max solution. - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the max solution for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] solution - Value of the max solution for the index iVar. */ - inline void SetSolution_Max(unsigned short val_var, su2double val_solution) {Solution_Max[val_var] = val_solution; } + inline void SetSolution_Max(unsigned long iPoint, unsigned long iVar, su2double solution) { Solution_Max(iPoint,iVar) = solution; } /*! * \brief Set the value of the min solution. - * \param[in] val_var - Index of the variable. - * \param[in] val_solution - Value of the min solution for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] solution - Value of the min solution for the index iVar. */ - inline void SetSolution_Min(unsigned short val_var, su2double val_solution) {Solution_Min[val_var] = val_solution; } + inline void SetSolution_Min(unsigned long iPoint, unsigned long iVar, su2double solution) { Solution_Min(iPoint,iVar) = solution; } /*! * \brief Get the value of the slope limiter. + * \param[in] iPoint - Point index. * \return Pointer to the limiters vector. */ - inline su2double *GetLimiter(void) {return Limiter; } + inline su2double *GetLimiter(unsigned long iPoint) { return Limiter[iPoint]; } /*! * \brief Get the value of the slope limiter. - * \param[in] val_var - Index of the variable. - * \return Value of the limiter vector for the variable val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \return Value of the limiter vector for the variable iVar. */ - inline su2double GetLimiter(unsigned short val_var) {return Limiter[val_var]; } + inline su2double GetLimiter(unsigned long iPoint, unsigned long iVar) const { return Limiter(iPoint,iVar); } /*! * \brief Get the value of the min solution. - * \param[in] val_var - Index of the variable. - * \return Value of the min solution for the variable val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \return Value of the min solution for the variable iVar. */ - inline su2double GetSolution_Max(unsigned short val_var) {return Solution_Max[val_var]; } - - /*! - * \brief Get the value of the min solution. - * \param[in] val_var - Index of the variable. - * \return Value of the min solution for the variable val_var. - */ - inline su2double GetSolution_Min(unsigned short val_var) {return Solution_Min[val_var]; } - - /*! - * \brief Get the value of the preconditioner Beta. - * \return Value of the low Mach preconditioner variable Beta - */ - inline virtual su2double GetPreconditioner_Beta() {return 0; } + inline su2double GetSolution_Max(unsigned long iPoint, unsigned long iVar) const { return Solution_Max(iPoint,iVar); } /*! * \brief Set the value of the preconditioner Beta. * \param[in] val_Beta - Value of the low Mach preconditioner variable Beta + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \return Value of the min solution for the variable iVar. */ - inline virtual void SetPreconditioner_Beta(su2double val_Beta) {} + inline su2double GetSolution_Min(unsigned long iPoint, unsigned long iVar) const { return Solution_Min(iPoint,iVar); } /*! * \brief Get the value of the wind gust + * \param[in] iPoint - Point index. * \return Value of the wind gust */ - inline virtual su2double* GetWindGust() {return 0; } + inline virtual su2double* GetWindGust(unsigned long iPoint) { return nullptr; } /*! * \brief Set the value of the wind gust + * \param[in] iPoint - Point index. * \param[in] val_WindGust - Value of the wind gust */ - inline virtual void SetWindGust(su2double* val_WindGust) {} + inline virtual void SetWindGust(unsigned long iPoint, const su2double* val_WindGust) {} /*! * \brief Get the value of the derivatives of the wind gust * \return Value of the derivatives of the wind gust */ - inline virtual su2double* GetWindGustDer() {return NULL;} + inline virtual su2double* GetWindGustDer(unsigned long iPoint) { return nullptr;} /*! * \brief Set the value of the derivatives of the wind gust + * \param[in] iPoint - Point index. * \param[in] val_WindGust - Value of the derivatives of the wind gust */ - inline virtual void SetWindGustDer(su2double* val_WindGust) {} + inline virtual void SetWindGustDer(unsigned long iPoint, const su2double* val_WindGust) {} /*! * \brief Set the value of the time step. + * \param[in] iPoint - Point index. * \param[in] val_delta_time - Value of the time step. */ - inline void SetDelta_Time(su2double val_delta_time) {Delta_Time = val_delta_time; } + inline void SetDelta_Time(unsigned long iPoint, su2double val_delta_time) { Delta_Time(iPoint) = val_delta_time; } /*! * \brief Set the value of the time step. + * \param[in] iPoint - Point index. * \param[in] val_delta_time - Value of the time step. - * \param[in] iSpecies - Index of the Species . + * \param[in] iSpecies - Index of the Species. */ - inline virtual void SetDelta_Time(su2double val_delta_time, unsigned short iSpecies) {} + inline virtual void SetDelta_Time(unsigned long iPoint, su2double val_delta_time, unsigned long iSpecies) {} /*! * \brief Get the value of the time step. + * \param[in] iPoint - Point index. * \return Value of the time step. */ - inline su2double GetDelta_Time(void) {return Delta_Time; } + inline su2double GetDelta_Time(unsigned long iPoint) const {return Delta_Time(iPoint); } /*! * \brief Get the value of the time step. + * \param[in] iPoint - Point index. * \param[in] iSpecies - Index of the Species * \return Value of the time step. */ - inline virtual su2double GetDelta_Time(unsigned short iSpecies) {return 0;} - - /*! - * \brief Set the value of the maximum eigenvalue. - * \param[in] val_max_lambda - Value of the maximum eigenvalue. - */ - inline void SetMax_Lambda(su2double val_max_lambda) {Max_Lambda = val_max_lambda; } + inline virtual su2double GetDelta_Time(unsigned long iPoint, unsigned long iSpecies) { return 0.0; } /*! * \brief Set the value of the maximum eigenvalue for the inviscid terms of the PDE. + * \param[in] iPoint - Point index. * \param[in] val_max_lambda - Value of the maximum eigenvalue for the inviscid terms of the PDE. */ - inline void SetMax_Lambda_Inv(su2double val_max_lambda) {Max_Lambda_Inv = val_max_lambda; } + inline void SetMax_Lambda_Inv(unsigned long iPoint, su2double val_max_lambda) { Max_Lambda_Inv(iPoint) = val_max_lambda; } /*! * \brief Set the value of the maximum eigenvalue for the inviscid terms of the PDE. + * \param[in] iPoint - Point index. * \param[in] val_max_lambda - Value of the maximum eigenvalue for the inviscid terms of the PDE. * \param[in] val_species - Value of the species index to set the maximum eigenvalue. */ - inline virtual void SetMax_Lambda_Inv(su2double val_max_lambda, unsigned short val_species) {} + inline virtual void SetMax_Lambda_Inv(unsigned long iPoint, su2double val_max_lambda, unsigned long val_species) {} /*! * \brief Set the value of the maximum eigenvalue for the viscous terms of the PDE. + * \param[in] iPoint - Point index. * \param[in] val_max_lambda - Value of the maximum eigenvalue for the viscous terms of the PDE. */ - inline void SetMax_Lambda_Visc(su2double val_max_lambda) {Max_Lambda_Visc = val_max_lambda; } + inline void SetMax_Lambda_Visc(unsigned long iPoint, su2double val_max_lambda) { Max_Lambda_Visc(iPoint) = val_max_lambda; } /*! * \brief Set the value of the maximum eigenvalue for the viscous terms of the PDE. + * \param[in] iPoint - Point index. * \param[in] val_max_lambda - Value of the maximum eigenvalue for the viscous terms of the PDE. * \param[in] val_species - Index of the species to set the maximum eigenvalue of the viscous terms. */ - inline virtual void SetMax_Lambda_Visc(su2double val_max_lambda, unsigned short val_species) {} - - /*! - * \brief Add a value to the maximum eigenvalue. - * \param[in] val_max_lambda - Value of the maximum eigenvalue. - */ - inline void AddMax_Lambda(su2double val_max_lambda) {Max_Lambda += val_max_lambda; } + inline virtual void SetMax_Lambda_Visc(unsigned long iPoint, su2double val_max_lambda, unsigned long val_species) {} /*! * \brief Add a value to the maximum eigenvalue for the inviscid terms of the PDE. + * \param[in] iPoint - Point index. * \param[in] val_max_lambda - Value of the maximum eigenvalue for the inviscid terms of the PDE. */ - inline void AddMax_Lambda_Inv(su2double val_max_lambda) {Max_Lambda_Inv += val_max_lambda; } + inline void AddMax_Lambda_Inv(unsigned long iPoint, su2double val_max_lambda) { Max_Lambda_Inv(iPoint) += val_max_lambda; } /*! * \brief Add a value to the maximum eigenvalue for the viscous terms of the PDE. + * \param[in] iPoint - Point index. * \param[in] val_max_lambda - Value of the maximum eigenvalue for the viscous terms of the PDE. */ - inline void AddMax_Lambda_Visc(su2double val_max_lambda) {Max_Lambda_Visc += val_max_lambda; } - - /*! - * \brief Get the value of the maximum eigenvalue. - * \return the value of the maximum eigenvalue. - */ - inline su2double GetMax_Lambda(void) {return Max_Lambda; } + inline void AddMax_Lambda_Visc(unsigned long iPoint, su2double val_max_lambda) { Max_Lambda_Visc(iPoint) += val_max_lambda; } /*! * \brief Get the value of the maximum eigenvalue for the inviscid terms of the PDE. + * \param[in] iPoint - Point index. * \return the value of the maximum eigenvalue for the inviscid terms of the PDE. */ - inline su2double GetMax_Lambda_Inv(void) {return Max_Lambda_Inv; } + inline su2double GetMax_Lambda_Inv(unsigned long iPoint) const { return Max_Lambda_Inv(iPoint); } /*! * \brief Get the value of the maximum eigenvalue for the viscous terms of the PDE. + * \param[in] iPoint - Point index. * \return the value of the maximum eigenvalue for the viscous terms of the PDE. */ - inline su2double GetMax_Lambda_Visc(void) {return Max_Lambda_Visc; } + inline su2double GetMax_Lambda_Visc(unsigned long iPoint) const { return Max_Lambda_Visc(iPoint); } /*! * \brief Set the value of the spectral radius. + * \param[in] iPoint - Point index. * \param[in] val_lambda - Value of the spectral radius. */ - inline void SetLambda(su2double val_lambda) {Lambda = val_lambda; } + inline void SetLambda(unsigned long iPoint, su2double val_lambda) { Lambda(iPoint) = val_lambda; } /*! * \brief Set the value of the spectral radius. + * \param[in] iPoint - Point index. * \param[in] val_lambda - Value of the spectral radius. * \param[in] val_iSpecies -Index of species */ - inline virtual void SetLambda(su2double val_lambda, unsigned short val_iSpecies) {} + inline virtual void SetLambda(unsigned long iPoint, su2double val_lambda, unsigned long val_iSpecies) {} /*! * \brief Add the value of the spectral radius. + * \param[in] iPoint - Point index. * \param[in] val_lambda - Value of the spectral radius. */ - inline void AddLambda(su2double val_lambda) {Lambda += val_lambda; } + inline void AddLambda(unsigned long iPoint, su2double val_lambda) { Lambda(iPoint) += val_lambda; } /*! * \brief Add the value of the spectral radius. + * \param[in] iPoint - Point index. * \param[in] val_iSpecies -Index of species * \param[in] val_lambda - Value of the spectral radius. */ - inline virtual void AddLambda(su2double val_lambda, unsigned short val_iSpecies) {} + inline virtual void AddLambda(unsigned long iPoint, su2double val_lambda, unsigned long val_iSpecies) {} /*! * \brief Get the value of the spectral radius. + * \param[in] iPoint - Point index. * \return Value of the spectral radius. */ - inline su2double GetLambda(void) {return Lambda; } + inline su2double GetLambda(unsigned long iPoint) const { return Lambda(iPoint); } /*! * \brief Get the value of the spectral radius. + * \param[in] iPoint - Point index. * \param[in] val_iSpecies -Index of species * \return Value of the spectral radius. */ - inline virtual su2double GetLambda(unsigned short val_iSpecies) {return 0.0;} + inline virtual su2double GetLambda(unsigned long iPoint, unsigned long val_iSpecies) { return 0.0; } /*! * \brief Set pressure sensor. + * \param[in] iPoint - Point index. * \param[in] val_sensor - Value of the pressure sensor. */ - inline void SetSensor(su2double val_sensor) {Sensor = val_sensor; } + inline void SetSensor(unsigned long iPoint, su2double val_sensor) { Sensor(iPoint) = val_sensor; } /*! * \brief Set pressure sensor. + * \param[in] iPoint - Point index. * \param[in] val_sensor - Value of the pressure sensor. * \param[in] iSpecies - Index of the species. */ - inline virtual void SetSensor(su2double val_sensor, unsigned short iSpecies) {} + inline virtual void SetSensor(unsigned long iPoint, su2double val_sensor, unsigned long iSpecies) {} /*! * \brief Get the pressure sensor. + * \param[in] iPoint - Point index. * \return Value of the pressure sensor. */ - inline su2double GetSensor(void) {return Sensor; } + inline su2double GetSensor(unsigned long iPoint) const { return Sensor(iPoint); } /*! * \brief Get the pressure sensor. + * \param[in] iPoint - Point index. * \param[in] iSpecies - index of species * \return Value of the pressure sensor. */ - inline virtual su2double GetSensor(unsigned short iSpecies) {return 0;} + inline virtual su2double GetSensor(unsigned long iPoint, unsigned long iSpecies) const { return 0.0; } /*! * \brief Set the value of the undivided laplacian of the solution. - * \param[in] val_var - Index of the variable. - * \param[in] val_undivided_laplacian - Value of the undivided solution for the index val_var. + * \param[in] iPoint - Point index. + * \param[in] iVar - Index of the variable. + * \param[in] val_undivided_laplacian - Value of the undivided solution for the index iVar. */ - inline void SetUndivided_Laplacian(unsigned short val_var, su2double val_undivided_laplacian) { - Undivided_Laplacian[val_var] = val_undivided_laplacian; + inline void SetUndivided_Laplacian(unsigned long iPoint, unsigned long iVar, su2double val_undivided_laplacian) { + Undivided_Laplacian(iPoint,iVar) = val_undivided_laplacian; } /*! * \brief Add the value of the undivided laplacian of the solution. + * \param[in] iPoint - Point index. * \param[in] val_und_lapl - Value of the undivided solution. */ - inline void AddUnd_Lapl(su2double *val_und_lapl) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Undivided_Laplacian[iVar] += val_und_lapl[iVar]; + inline void AddUnd_Lapl(unsigned long iPoint, const su2double *val_und_lapl) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Undivided_Laplacian(iPoint, iVar) += val_und_lapl[iVar]; } /*! * \brief Subtract the value of the undivided laplacian of the solution. + * \param[in] iPoint - Point index. * \param[in] val_und_lapl - Value of the undivided solution. */ - inline void SubtractUnd_Lapl(su2double *val_und_lapl) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Undivided_Laplacian[iVar] -= val_und_lapl[iVar]; + inline void SubtractUnd_Lapl(unsigned long iPoint, const su2double *val_und_lapl) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Undivided_Laplacian(iPoint, iVar) -= val_und_lapl[iVar]; } /*! * \brief Subtract the value of the undivided laplacian of the solution. - * \param[in] val_var - Variable of the undivided laplacian. + * \param[in] iPoint - Point index. + * \param[in] iVar - Variable of the undivided laplacian. * \param[in] val_und_lapl - Value of the undivided solution. */ - inline void SubtractUnd_Lapl(unsigned short val_var, su2double val_und_lapl) { - Undivided_Laplacian[val_var] -= val_und_lapl; + inline void SubtractUnd_Lapl(unsigned long iPoint, unsigned long iVar, su2double val_und_lapl) { + Undivided_Laplacian(iPoint, iVar) -= val_und_lapl; } /*! * \brief Set the undivided laplacian of the solution to zero. */ - inline void SetUnd_LaplZero(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Undivided_Laplacian[iVar] = 0.0; - } + void SetUnd_LaplZero(); /*! * \brief Set a value to the undivided laplacian. - * \param[in] val_var - Variable of the undivided laplacian. + * \param[in] iPoint - Point index. + * \param[in] iVar - Variable of the undivided laplacian. * \param[in] val_und_lapl - Value of the undivided laplacian. */ - inline void SetUnd_Lapl(unsigned short val_var, su2double val_und_lapl) { - Undivided_Laplacian[val_var] = val_und_lapl; + inline void SetUnd_Lapl(unsigned long iPoint, unsigned long iVar, su2double val_und_lapl) { + Undivided_Laplacian(iPoint, iVar) = val_und_lapl; } /*! * \brief Get the undivided laplacian of the solution. + * \param[in] iPoint - Point index. * \return Pointer to the undivided laplacian vector. */ - inline su2double *GetUndivided_Laplacian(void) {return Undivided_Laplacian; } + inline su2double *GetUndivided_Laplacian(unsigned long iPoint) { return Undivided_Laplacian[iPoint]; } /*! * \brief Get the undivided laplacian of the solution. - * \param[in] val_var - Variable of the undivided laplacian. + * \param[in] iPoint - Point index. + * \param[in] iVar - Variable of the undivided laplacian. * \return Value of the undivided laplacian vector. */ - inline su2double GetUndivided_Laplacian(unsigned short val_var) {return Undivided_Laplacian[val_var]; } + inline su2double GetUndivided_Laplacian(unsigned long iPoint, unsigned long iVar) const { return Undivided_Laplacian(iPoint, iVar); } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the flow density. */ - inline virtual su2double GetDensity(void) {return 0; } + inline virtual su2double GetDensity(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Old value of the flow density. */ - inline virtual su2double GetDensity_Old(void) {return 0; } + inline virtual su2double GetDensity_Old(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the flow density. */ - inline virtual su2double GetDensity(unsigned short val_iSpecies) {return 0; } + inline virtual su2double GetDensity(unsigned long iPoint, unsigned long val_iSpecies) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \param[in] val_Species - Index of species s. * \return Value of the mass fraction of species s. */ - inline virtual su2double GetMassFraction(unsigned short val_Species) {return 0.0;} + inline virtual su2double GetMassFraction(unsigned long iPoint, unsigned long val_Species) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the flow energy. */ - inline virtual su2double GetEnergy(void) {return 0; } + inline virtual su2double GetEnergy(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Pointer to the force projection vector. */ - inline virtual su2double *GetForceProj_Vector(void) {return NULL; } + inline virtual su2double *GetForceProj_Vector(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Pointer to the objective function source. */ - inline virtual su2double *GetObjFuncSource(void) {return NULL; } + inline virtual su2double *GetObjFuncSource(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Pointer to the internal boundary vector. */ - inline virtual su2double *GetIntBoundary_Jump(void) {return NULL; } + inline virtual su2double *GetIntBoundary_Jump(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the eddy viscosity. */ - inline virtual su2double GetEddyViscosity(void) {return 0; } + inline virtual su2double GetEddyViscosity(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the flow enthalpy. */ - inline virtual su2double GetEnthalpy(void) {return 0; } + inline virtual su2double GetEnthalpy(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the flow pressure. */ - inline virtual su2double GetPressure(void) {return 0; } + inline virtual su2double GetPressure(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \param[in] val_vector - Direction of projection. * \return Value of the projected velocity. */ - inline virtual su2double GetProjVel(su2double *val_vector) {return 0; } + inline virtual su2double GetProjVel(unsigned long iPoint, const su2double *val_vector) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \param[in] val_vector - Direction of projection. * \param[in] val_species - Index of the desired species. * \return Value of the projected velocity. */ - inline virtual su2double GetProjVel(su2double *val_vector, unsigned short val_species) {return 0; } + inline virtual su2double GetProjVel(unsigned long iPoint, su2double *val_vector, unsigned long val_species) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the sound speed. */ - inline virtual su2double GetSoundSpeed(void) {return 0; } + inline virtual su2double GetSoundSpeed(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the beta for the incompressible flow. */ - inline virtual su2double GetBetaInc2(void) { return 0.0; } + inline virtual su2double GetBetaInc2(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. * \return Value of the temperature. */ - inline virtual su2double GetTemperature(void) {return 0.0; } + inline virtual su2double GetTemperature(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the vibrational-electronic temperature. */ - inline virtual su2double GetTemperature_ve(void) {return 0; } + inline virtual su2double GetTemperature_ve(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member -- Get the mixture specific heat at constant volume (trans.-rot.). + * \param[in] iPoint - Point index. * \return \f$\rho C^{t-r}_{v} \f$ */ - inline virtual su2double GetRhoCv_tr(void) {return 0; } + inline virtual su2double GetRhoCv_tr(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member -- Get the mixture specific heat at constant volume (vib.-el.). + * \param[in] iPoint - Point index. * \return \f$\rho C^{v-e}_{v} \f$ */ - inline virtual su2double GetRhoCv_ve(void) {return 0; } + inline virtual su2double GetRhoCv_ve(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. - * \param[in] val_dim - Index of the dimension. - * \return Value of the velocity for the dimension val_dim. + * \param[in] iPoint - Point index. + * \param[in] iDim - Index of the dimension. + * \return Value of the velocity for the dimension iDim. */ - inline virtual su2double GetVelocity(unsigned short val_dim) {return 0; } + inline virtual su2double GetVelocity(unsigned long iPoint, unsigned long iDim) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Norm 2 of the velocity vector. */ - inline virtual su2double GetVelocity2(void) {return 0; } + inline virtual su2double GetVelocity2(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Norm 2 of the velocity vector of Fluid val_species. */ - inline virtual su2double GetVelocity2(unsigned short val_species) {return 0;} + inline virtual su2double GetVelocity2(unsigned long iPoint, unsigned long val_species) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return The laminar viscosity of the flow. */ - inline virtual su2double GetLaminarViscosity(void) {return 0; } + inline virtual su2double GetLaminarViscosity(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return The laminar viscosity of the flow. */ - inline virtual su2double GetLaminarViscosity(unsigned short iSpecies) {return 0; } + inline virtual su2double GetLaminarViscosity(unsigned long iPoint, unsigned long iSpecies) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the species diffusion coefficient. */ - inline virtual su2double* GetDiffusionCoeff(void) {return NULL; } + inline virtual su2double* GetDiffusionCoeff(unsigned long iPoint) {return nullptr; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the thermal conductivity (translational/rotational) */ - inline virtual su2double GetThermalConductivity(void) {return 0; } + inline virtual su2double GetThermalConductivity(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the specific heat at constant P */ - inline virtual su2double GetSpecificHeatCp(void) {return 0; } + inline virtual su2double GetSpecificHeatCp(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the specific heat at constant V */ - inline virtual su2double GetSpecificHeatCv(void) {return 0; } + inline virtual su2double GetSpecificHeatCv(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the thermal conductivity (vibrational) */ - inline virtual su2double GetThermalConductivity_ve(void) {return 0; } + inline virtual su2double GetThermalConductivity_ve(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Sets separation intermittency */ - inline virtual void SetGammaSep(su2double gamma_sep) {} + inline virtual void SetGammaSep(unsigned long iPoint, su2double gamma_sep) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Sets separation intermittency */ - inline virtual void SetGammaEff(void) {} + inline virtual void SetGammaEff(unsigned long iPoint) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Returns intermittency */ - inline virtual su2double GetIntermittency() { return 0.0; } + inline virtual su2double GetIntermittency(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the vorticity. */ - inline virtual su2double *GetVorticity(void) {return 0; } + inline virtual su2double *GetVorticity(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the rate of strain magnitude. */ - inline virtual su2double GetStrainMag(void) {return 0; } + inline virtual su2double GetStrainMag(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \param[in] val_ForceProj_Vector - Pointer to the force projection vector. */ - inline virtual void SetForceProj_Vector(su2double *val_ForceProj_Vector) {} + inline virtual void SetForceProj_Vector(unsigned long iPoint, const su2double *val_ForceProj_Vector) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \param[in] val_SetObjFuncSource - Pointer to the objective function source. */ - inline virtual void SetObjFuncSource(su2double *val_SetObjFuncSource) {} + inline virtual void SetObjFuncSource(unsigned long iPoint, const su2double *val_SetObjFuncSource) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \param[in] val_IntBoundary_Jump - Pointer to the interior boundary jump. */ - inline virtual void SetIntBoundary_Jump(su2double *val_IntBoundary_Jump) {} + inline virtual void SetIntBoundary_Jump(unsigned long iPoint, const su2double *val_IntBoundary_Jump) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \return Value of the gamma_BC of B-C transition model. */ - inline virtual su2double GetGammaBC(void) {return 0; } + inline virtual su2double GetGammaBC(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual void SetGammaBC(su2double val_gamma) {} + inline virtual void SetGammaBC(unsigned long iPoint, su2double val_gamma) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. * \param[in] eddy_visc - Value of the eddy viscosity. */ - inline virtual void SetEddyViscosity(su2double eddy_visc) {} + inline virtual void SetEddyViscosity(unsigned long iPoint, su2double eddy_visc) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual void SetEnthalpy(void) {} + inline virtual void SetEnthalpy(unsigned long iPoint) {} /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual bool SetPrimVar(CConfig *config) {return true; } + inline virtual bool SetPrimVar(unsigned long iPoint, CConfig *config) { return true; } /*! * \brief A virtual member. + * \param[in] iPoint - Point index. */ - inline virtual bool SetPrimVar(CFluidModel *FluidModel) {return true; } + inline virtual bool SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { return true; } /*! * \brief A virtual member. */ - inline virtual void SetSecondaryVar(CFluidModel *FluidModel) {} + inline virtual void SetSecondaryVar(unsigned long iPoint, CFluidModel *FluidModel) {} /*! * \brief A virtual member. */ - inline virtual bool Cons2PrimVar(CConfig *config, su2double *U, su2double *V, su2double *dPdU, + inline virtual bool Cons2PrimVar(CConfig *config, unsigned long iPoint, su2double *U, su2double *V, su2double *dPdU, su2double *dTdU, su2double *dTvedU) { return false; } /*! * \brief A virtual member. */ - inline virtual void Prim2ConsVar(CConfig *config, su2double *V, su2double *U) {return; } + inline virtual void Prim2ConsVar(CConfig *config, unsigned long iPoint, su2double *V, su2double *U) { } /*! * \brief A virtual member. */ - inline virtual bool SetPrimVar(su2double SharpEdge_Distance, bool check, CConfig *config) {return true; } + inline virtual bool SetPrimVar(unsigned long iPoint, su2double SharpEdge_Distance, bool check, CConfig *config) { return true; } /*! * \brief A virtual member. */ - inline virtual bool SetPrimVar(su2double eddy_visc, su2double turb_ke, CConfig *config) {return true; } + inline virtual bool SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2double turb_ke, CConfig *config) { return true; } /*! * \brief A virtual member. */ - inline virtual bool SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel) {return true; } + inline virtual bool SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel) { return true; } /*! * \brief A virtual member. */ - inline virtual bool SetPrimVar(su2double Density_Inf, CConfig *config) {return true; } + inline virtual bool SetPrimVar(unsigned long iPoint, su2double Density_Inf, CConfig *config) { return true; } /*! * \brief A virtual member. */ - inline virtual bool SetPrimVar(su2double Density_Inf, su2double Viscosity_Inf, su2double eddy_visc, su2double turb_ke, CConfig *config) {return true; } + inline virtual bool SetPrimVar(unsigned long iPoint, su2double Density_Inf, su2double Viscosity_Inf, + su2double eddy_visc, su2double turb_ke, CConfig *config) {return true; } /*! * \brief A virtual member. */ - inline virtual su2double GetPrimitive(unsigned short val_var) {return 0; } + inline virtual su2double GetPrimitive(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void SetPrimitive(unsigned short val_var, su2double val_prim) {} + inline virtual void SetPrimitive(unsigned long iPoint, unsigned long iVar, su2double val_prim) {} /*! * \brief A virtual member. */ - inline virtual void SetPrimitive(su2double *val_prim) {} + inline virtual void SetPrimitive(unsigned long iPoint, const su2double *val_prim) {} /*! * \brief A virtual member. */ - inline virtual su2double *GetPrimitive(void) {return NULL; } + inline virtual su2double *GetPrimitive(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. */ - inline virtual su2double GetSecondary(unsigned short val_var) {return 0; } + inline virtual su2double GetSecondary(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void SetSecondary(unsigned short val_var, su2double val_secondary) {} + inline virtual void SetSecondary(unsigned long iPoint, unsigned long iVar, su2double val_secondary) {} /*! * \brief A virtual member. */ - inline virtual void SetSecondary(su2double *val_secondary) {} + inline virtual void SetSecondary(unsigned long iPoint, const su2double *val_secondary) {} /*! * \brief A virtual member. */ - inline virtual void SetdPdrho_e(su2double dPdrho_e) {} + inline virtual void SetdPdrho_e(unsigned long iPoint, su2double dPdrho_e) {} /*! * \brief A virtual member. */ - inline virtual void SetdPde_rho(su2double dPde_rho) {} + inline virtual void SetdPde_rho(unsigned long iPoint, su2double dPde_rho) {} /*! * \brief A virtual member. */ - inline virtual void SetdTdrho_e(su2double dTdrho_e) {} + inline virtual void SetdTdrho_e(unsigned long iPoint, su2double dTdrho_e) {} /*! * \brief A virtual member. */ - inline virtual void SetdTde_rho(su2double dTde_rho) {} + inline virtual void SetdTde_rho(unsigned long iPoint, su2double dTde_rho) {} /*! * \brief A virtual member. */ - inline virtual void Setdmudrho_T(su2double dmudrho_T) {} + inline virtual void Setdmudrho_T(unsigned long iPoint, su2double dmudrho_T) {} /*! * \brief A virtual member. */ - inline virtual void SetdmudT_rho(su2double dmudT_rho) {} + inline virtual void SetdmudT_rho(unsigned long iPoint, su2double dmudT_rho) {} /*! * \brief A virtual member. */ - inline virtual void Setdktdrho_T(su2double dktdrho_T) {} + inline virtual void Setdktdrho_T(unsigned long iPoint, su2double dktdrho_T) {} /*! * \brief A virtual member. */ - inline virtual void SetdktdT_rho(su2double dktdT_rho) {} + inline virtual void SetdktdT_rho(unsigned long iPoint, su2double dktdT_rho) {} /*! * \brief A virtual member. */ - inline virtual su2double *GetSecondary(void) {return NULL; } + inline virtual su2double *GetSecondary(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. */ - inline virtual bool SetDensity(su2double val_density) { return false; } + inline virtual bool SetDensity(unsigned long iPoint, su2double val_density) { return false; } /*! * \brief A virtual member. */ - inline virtual bool SetDensity(void) { return false; } + inline virtual bool SetDensity(unsigned long iPoint) { return false; } /*! * \brief A virtual member. */ - inline virtual void SetPressure(void) {} + inline virtual void SetPressure(unsigned long iPoint) {} /*! * \brief A virtual member. */ - inline virtual void SetVelocity(void) {} + inline virtual void SetVelocity(unsigned long iPoint) {} /*! * \brief A virtual member. */ - inline virtual void SetBetaInc2(su2double val_betainc2) {} + inline virtual void SetBetaInc2(unsigned long iPoint, su2double val_betainc2) {} /*! * \brief A virtual member. * \param[in] val_phi - Value of the adjoint velocity. */ - inline virtual void SetPhi_Old(su2double *val_phi) {} + inline virtual void SetPhi_Old(unsigned long iPoint, const su2double *val_phi) {} /*! * \brief A virtual member. * \param[in] Gamma - Ratio of Specific heats */ - inline virtual bool SetPressure(su2double Gamma) {return false; } + inline virtual bool SetPressure(unsigned long iPoint, su2double Gamma) { return false; } /*! * \brief A virtual member. * \param[in] config */ - inline virtual bool SetPressure(CConfig *config) {return false; } + inline virtual bool SetPressure(unsigned long iPoint, CConfig *config) { return false; } /*! * \brief A virtual member. */ - inline virtual bool SetPressure(su2double Gamma, su2double turb_ke) {return false; } + inline virtual bool SetPressure(unsigned long iPoint, su2double Gamma, su2double turb_ke) { return false; } /*! * \brief Calculates vib.-el. energy per mass, \f$e^{vib-el}_s\f$, for input species (not including KE) */ - inline virtual su2double CalcEve(su2double *V, CConfig *config, unsigned short val_Species) {return 0; } + inline virtual su2double CalcEve(unsigned long iPoint, su2double *V, CConfig *config, unsigned long val_Species) { return 0.0; } /*! * \brief Calculates enthalpy per mass, \f$h_s\f$, for input species (not including KE) */ - inline virtual su2double CalcHs(su2double *V, CConfig *config, unsigned short val_Species) {return 0; } + inline virtual su2double CalcHs(unsigned long iPoint, su2double *V, CConfig *config, unsigned long val_Species) { return 0.0; } /*! * \brief Calculates enthalpy per mass, \f$Cv_s\f$, for input species (not including KE) */ - inline virtual su2double CalcCvve(su2double val_Tve, CConfig *config, unsigned short val_Species) {return 0; } + inline virtual su2double CalcCvve(unsigned long iPoint, su2double val_Tve, CConfig *config, unsigned long val_Species) { return 0.0; } /*! * \brief A virtual member. @@ -1493,7 +1640,7 @@ class CVariable { * \param[in] config - Configuration settings * \param[in] dPdU */ - inline virtual void CalcdPdU(su2double *V, CConfig *config, su2double *dPdU) {} + inline virtual void CalcdPdU(unsigned long iPoint, su2double *V, CConfig *config, su2double *dPdU) {} /*! * \brief Set partial derivative of temperature w.r.t. density \f$\frac{\partial P}{\partial \rho_s}\f$ @@ -1501,7 +1648,7 @@ class CVariable { * \param[in] config - Configuration settings * \param[in] dTdU */ - inline virtual void CalcdTdU(su2double *V, CConfig *config, su2double *dTdU) {} + inline virtual void CalcdTdU(unsigned long iPoint, su2double *V, CConfig *config, su2double *dTdU) {} /*! * \brief Set partial derivative of temperature w.r.t. density \f$\frac{\partial P}{\partial \rho_s}\f$ @@ -1509,394 +1656,326 @@ class CVariable { * \param[in] config - Configuration settings * \param[in] dTdU */ - inline virtual void CalcdTvedU(su2double *V, CConfig *config, su2double *dTdU) {} + inline virtual void CalcdTvedU(unsigned long iPoint, su2double *V, CConfig *config, su2double *dTdU) {} /*! * \brief A virtual member. */ - inline virtual su2double *GetdPdU(void) { return NULL; } + inline virtual su2double *GetdPdU(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. */ - inline virtual su2double *GetdTdU(void) { return NULL; } + inline virtual su2double *GetdTdU(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. */ - inline virtual su2double *GetdTvedU(void) { return NULL; } + inline virtual su2double *GetdTvedU(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. * \param[in] val_velocity - Value of the velocity. * \param[in] Gamma - Ratio of Specific heats */ - inline virtual void SetDeltaPressure(su2double *val_velocity, su2double Gamma) {} + inline virtual void SetDeltaPressure(unsigned long iPoint, const su2double *val_velocity, su2double Gamma) {} /*! * \brief A virtual member. * \param[in] Gamma - Ratio of specific heats. */ - inline virtual bool SetSoundSpeed(su2double Gamma) {return false; } + inline virtual bool SetSoundSpeed(unsigned long iPoint, su2double Gamma) { return false; } /*! * \brief A virtual member. * \param[in] config - Configuration parameters. */ - inline virtual bool SetSoundSpeed(CConfig *config) {return false; } + inline virtual bool SetSoundSpeed(unsigned long iPoint, CConfig *config) { return false; } /*! * \brief A virtual member. */ - inline virtual bool SetSoundSpeed(void) { return false; } + inline virtual bool SetSoundSpeed(unsigned long iPoint) { return false; } /*! * \brief A virtual member. * \param[in] Gas_Constant - Value of the Gas Constant */ - inline virtual bool SetTemperature(su2double Gas_Constant) {return false; } + inline virtual bool SetTemperature(unsigned long iPoint, su2double Gas_Constant) { return false; } /*! * \brief Sets the vibrational electronic temperature of the flow. * \return Value of the temperature of the flow. */ - inline virtual bool SetTemperature_ve(su2double val_Tve) {return false; } + inline virtual bool SetTemperature_ve(unsigned long iPoint, su2double val_Tve) { return false; } /*! * \brief A virtual member. * \param[in] config - Configuration parameters. */ - inline virtual bool SetTemperature(CConfig *config) {return false; } + inline virtual bool SetTemperature(unsigned long iPoint, CConfig *config) { return false; } /*! * \brief A virtual member. * \param[in] config - Configuration parameters. */ - inline virtual void SetPrimitive(CConfig *config) {} + inline virtual void SetPrimitive(unsigned long iPoint, CConfig *config) {} /*! * \brief A virtual member. * \param[in] config - Configuration parameters. * \param[in] Coord - Physical coordinates. */ - inline virtual void SetPrimitive(CConfig *config, su2double *Coord) {} + inline virtual void SetPrimitive(unsigned long iPoint, CConfig *config, su2double *Coord) {} /*! * \brief A virtual member. * \param[in] Temperature_Wall - Value of the Temperature at the wall */ - inline virtual void SetWallTemperature(su2double Temperature_Wall) {} + inline virtual void SetWallTemperature(unsigned long iPoint, su2double Temperature_Wall) {} /*! * \brief A virtual member. * \param[in] Temperature_Wall - Value of the Temperature at the wall */ - inline virtual void SetWallTemperature(su2double* Temperature_Wall) {} + inline virtual void SetWallTemperature(unsigned long iPoint, su2double* Temperature_Wall) {} /*! * \brief Set the thermal coefficient. * \param[in] config - Configuration parameters. */ - inline virtual void SetThermalCoeff(CConfig *config) {} + inline virtual void SetThermalCoeff(unsigned long iPoint, CConfig *config) {} /*! * \brief A virtual member. */ - inline virtual void SetStress_FEM(unsigned short iVar, su2double val_stress) {} + inline virtual void SetStress_FEM(unsigned long iPoint, unsigned long iVar, su2double val_stress) {} /*! * \brief A virtual member. */ - inline virtual void AddStress_FEM(unsigned short iVar, su2double val_stress) {} + inline virtual void AddStress_FEM(unsigned long iPoint, unsigned long iVar, su2double val_stress) {} /*! * \brief A virtual member. */ - inline virtual su2double *GetStress_FEM(void) {return NULL;} + inline virtual su2double *GetStress_FEM(unsigned long iPoint) {return nullptr;} /*! * \brief A virtual member. */ - inline virtual void SetVonMises_Stress(su2double val_stress) {} + inline virtual void SetVonMises_Stress(unsigned long iPoint, su2double val_stress) {} /*! * \brief A virtual member. */ - inline virtual su2double GetVonMises_Stress(void) {return 0.0;} + inline virtual su2double GetVonMises_Stress(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void Add_SurfaceLoad_Res(su2double *val_surfForce) {} + inline virtual void Add_SurfaceLoad_Res(unsigned long iPoint, const su2double *val_surfForce) {} /*! * \brief A virtual member. */ - inline virtual void Set_SurfaceLoad_Res(unsigned short iVar, su2double val_surfForce) {} + inline virtual void Set_SurfaceLoad_Res(unsigned long iPoint, unsigned long iVar, su2double val_surfForce) {} /*! * \brief A virtual member. */ - inline virtual su2double Get_SurfaceLoad_Res(unsigned short iVar) {return 0.0;} + inline virtual su2double Get_SurfaceLoad_Res(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void Clear_SurfaceLoad_Res(void) {} + inline virtual void Clear_SurfaceLoad_Res(unsigned long iPoint) {} /*! * \brief A virtual member. */ - inline virtual void Set_SurfaceLoad_Res_n(void) {} + virtual void Set_SurfaceLoad_Res_n() {} /*! * \brief A virtual member. */ - inline virtual su2double Get_SurfaceLoad_Res_n(unsigned short iVar) {return 0.0;} + inline virtual su2double Get_SurfaceLoad_Res_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void Add_BodyForces_Res(su2double *val_bodyForce) {} + inline virtual void Add_BodyForces_Res(unsigned long iPoint, const su2double *val_bodyForce) {} /*! * \brief A virtual member. */ - inline virtual su2double Get_BodyForces_Res(unsigned short iVar) {return 0.0;} + inline virtual su2double Get_BodyForces_Res(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void Clear_BodyForces_Res(void) {} + inline virtual void Clear_BodyForces_Res(unsigned long iPoint) {} /*! * \brief A virtual member. */ - inline virtual void Set_FlowTraction(su2double *val_flowTraction) {} + inline virtual void Set_FlowTraction(unsigned long iPoint, const su2double *val_flowTraction) {} /*! * \brief A virtual member. */ - inline virtual void Add_FlowTraction(su2double *val_flowTraction) {} + inline virtual void Add_FlowTraction(unsigned long iPoint, const su2double *val_flowTraction) {} /*! * \brief A virtual member. */ - inline virtual su2double Get_FlowTraction(unsigned short iVar) {return 0.0;} + inline virtual su2double Get_FlowTraction(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void Set_FlowTraction_n(void) {} + virtual void Set_FlowTraction_n() {} /*! * \brief A virtual member. */ - inline virtual su2double Get_FlowTraction_n(unsigned short iVar) {return 0.0;} + inline virtual su2double Get_FlowTraction_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void Clear_FlowTraction(void) {} + inline virtual void Clear_FlowTraction() {} /*! * \brief A virtual member. */ - inline virtual bool Get_isVertex(void) const {return false;} + inline virtual void Set_isVertex(unsigned long iPoint, bool isVertex) {} /*! * \brief A virtual member. */ - inline virtual void SetVelocity2(void) {} + inline virtual bool Get_isVertex(unsigned long iPoint) const { return false; } + + /*! + * \brief A virtual member. + */ + inline virtual void SetVelocity2(unsigned long iPoint) {} /*! * \brief A virtual member. * \param[in] val_velocity - Pointer to the velocity. */ - inline virtual void SetVelocity_Old(su2double *val_velocity) {} + inline virtual void SetVelocity_Old(unsigned long iPoint, const su2double *val_velocity) {} /*! * \brief A virtual member. * \param[in] laminarViscosity */ - inline virtual void SetLaminarViscosity(su2double laminarViscosity) {} + inline virtual void SetLaminarViscosity(unsigned long iPoint, su2double laminarViscosity) {} /*! * \brief A virtual member. * \param[in] config - Definition of the particular problem. */ - inline virtual void SetLaminarViscosity(CConfig *config) {} + inline virtual void SetLaminarViscosity(unsigned long iPoint, CConfig *config) {} /*! * \brief A virtual member. * \param[in] thermalConductivity */ - inline virtual void SetThermalConductivity(su2double thermalConductivity) {} + inline virtual void SetThermalConductivity(unsigned long iPoint, su2double thermalConductivity) {} /*! * \brief A virtual member. * \param[in] config - Definition of the particular problem. */ - inline virtual void SetThermalConductivity(CConfig *config) {} + inline virtual void SetThermalConductivity(unsigned long iPoint, CConfig *config) {} /*! * \brief A virtual member. * \param[in] Cp - Constant pressure specific heat. */ - inline virtual void SetSpecificHeatCp(su2double Cp) {} + inline virtual void SetSpecificHeatCp(unsigned long iPoint, su2double Cp) {} /*! * \brief A virtual member. * \param[in] Cv - Constant volume specific heat. */ - inline virtual void SetSpecificHeatCv(su2double Cv) {} - - /*! - * \brief A virtual member. - */ - inline virtual bool SetVorticity(void) {return false; } - - /*! - * \brief A virtual member. - */ - inline virtual bool SetStrainMag(void) {return false; } + inline virtual void SetSpecificHeatCv(unsigned long iPoint, su2double Cv) {} /*! * \brief A virtual member. */ - inline virtual void SetVelSolutionOldDVector(void) {} + inline virtual bool SetVorticity_StrainMag() { return false; } /*! * \brief A virtual member. */ - inline virtual void SetVelSolutionDVector(void) {} + inline virtual void SetVelSolutionDVector(unsigned long iPoint) {} /*! * \brief A virtual member. */ - inline virtual void SetGradient_PrimitiveZero(unsigned short val_primvar) {} + virtual void SetGradient_PrimitiveZero() {} /*! * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. * \param[in] val_value - Value to add to the gradient of the primitive variables. */ - inline virtual void AddGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {} + inline virtual void AddGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double val_value) {} /*! * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. * \param[in] val_value - Value to subtract to the gradient of the primitive variables. */ - inline virtual void SubtractGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {} + inline virtual void SubtractGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double val_value) {} /*! * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. * \return Value of the primitive variables gradient. */ - inline virtual su2double GetGradient_Primitive(unsigned short val_var, unsigned short val_dim) {return 0; } + inline virtual su2double GetGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim) const { return 0.0; } /*! * \brief A virtual member. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Value of the primitive variables gradient. */ - inline virtual su2double GetLimiter_Primitive(unsigned short val_var) {return 0; } + inline virtual su2double GetLimiter_Primitive(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. + * \param[in] iVar - Index of the variable. + * \param[in] iDim - Index of the dimension. * \param[in] val_value - Value of the gradient. */ - inline virtual void SetGradient_Primitive(unsigned short val_var, unsigned short val_dim, su2double val_value) {} + inline virtual void SetGradient_Primitive(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double val_value) {} /*! * \brief A virtual member. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \param[in] val_value - Value of the gradient. */ - inline virtual void SetLimiter_Primitive(unsigned short val_var, su2double val_value) {} + inline virtual void SetLimiter_Primitive(unsigned long iPoint, unsigned long iVar, su2double val_value) {} /*! * \brief A virtual member. * \return Value of the primitive variables gradient. */ - inline virtual su2double **GetGradient_Primitive(void) {return NULL; } + inline virtual su2double **GetGradient_Primitive(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. * \return Value of the primitive variables gradient. */ - inline virtual su2double *GetLimiter_Primitive(void) {return NULL; } - - /*! - * \brief A virtual member. - */ - inline virtual void SetGradient_SecondaryZero(unsigned short val_secondaryvar) {} - - /*! - * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to add to the gradient of the Secondary variables. - */ - inline virtual void AddGradient_Secondary(unsigned short val_var, unsigned short val_dim, su2double val_value) {} - - /*! - * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value to subtract to the gradient of the Secondary variables. - */ - inline virtual void SubtractGradient_Secondary(unsigned short val_var, unsigned short val_dim, su2double val_value) {} - - /*! - * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \return Value of the Secondary variables gradient. - */ - inline virtual su2double GetGradient_Secondary(unsigned short val_var, unsigned short val_dim) {return 0; } - - /*! - * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \return Value of the Secondary variables gradient. - */ - inline virtual su2double GetLimiter_Secondary(unsigned short val_var) {return 0; } - - /*! - * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_dim - Index of the dimension. - * \param[in] val_value - Value of the gradient. - */ - inline virtual void SetGradient_Secondary(unsigned short val_var, unsigned short val_dim, su2double val_value) {} - - /*! - * \brief A virtual member. - * \param[in] val_var - Index of the variable. - * \param[in] val_value - Value of the gradient. - */ - inline virtual void SetLimiter_Secondary(unsigned short val_var, su2double val_value) {} - - /*! - * \brief A virtual member. - * \return Value of the Secondary variables gradient. - */ - inline virtual su2double **GetGradient_Secondary(void) {return NULL; } - - /*! - * \brief A virtual member. - * \return Value of the Secondary variables gradient. - */ - inline virtual su2double *GetLimiter_Secondary(void) {return NULL; } + inline virtual su2double *GetLimiter_Primitive(unsigned long iPoint) { return nullptr; } /*! * \brief Get the value of the primitive gradient for MUSCL reconstruction. @@ -1904,7 +1983,7 @@ class CVariable { * \param[in] val_dim - Index of the dimension. * \return Value of the primitive variables gradient. */ - inline virtual su2double GetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim) { return 0; } + inline virtual su2double GetGradient_Reconstruction(unsigned long iPoint, unsigned long val_var, unsigned long val_dim) const { return 0.0; } /*! * \brief Set the value of the primitive gradient for MUSCL reconstruction. @@ -1912,13 +1991,13 @@ class CVariable { * \param[in] val_dim - Index of the dimension. * \param[in] val_value - Value of the gradient. */ - inline virtual void SetGradient_Reconstruction(unsigned short val_var, unsigned short val_dim, su2double val_value) { } + inline virtual void SetGradient_Reconstruction(unsigned long iPoint, unsigned long val_var, unsigned long val_dim, su2double val_value) {} /*! * \brief Get the value of the primitive gradient for MUSCL reconstruction. * \return Value of the primitive gradient for MUSCL reconstruction. */ - inline virtual su2double **GetGradient_Reconstruction(void) { return NULL; } + inline virtual su2double **GetGradient_Reconstruction(unsigned long iPoint) { return nullptr; } /*! * \brief Set the blending function for the blending of k-w and k-eps. @@ -1926,499 +2005,487 @@ class CVariable { * \param[in] val_density - Value of the density. * \param[in] val_dist - Value of the distance to the wall. */ - inline virtual void SetBlendingFunc(su2double val_viscosity, su2double val_dist, su2double val_density) {} + inline virtual void SetBlendingFunc(unsigned long iPoint, su2double val_viscosity, su2double val_dist, su2double val_density) {} /*! * \brief Get the first blending function of the SST model. */ - inline virtual su2double GetF1blending(void) {return 0; } + inline virtual su2double GetF1blending(unsigned long iPoint) const { return 0.0; } /*! * \brief Get the second blending function of the SST model. */ - inline virtual su2double GetF2blending(void) {return 0; } + inline virtual su2double GetF2blending(unsigned long iPoint) const { return 0.0; } /*! * \brief Get the value of the cross diffusion of tke and omega. */ - inline virtual su2double GetCrossDiff(void) { return 0.0; } + inline virtual su2double GetCrossDiff(unsigned long iPoint) const { return 0.0; } /*! * \brief Get the value of the eddy viscosity. * \return the value of the eddy viscosity. */ - inline virtual su2double GetmuT(void) { return 0.0; } + inline virtual su2double GetmuT(unsigned long iPoint) const { return 0.0; } /*! * \brief Set the value of the eddy viscosity. * \param[in] val_muT */ - inline virtual void SetmuT(su2double val_muT) {} + inline virtual void SetmuT(unsigned long iPoint, su2double val_muT) {} /*! * \brief Add a value to the maximum eigenvalue for the inviscid terms of the PDE. * \param[in] val_max_lambda - Value of the maximum eigenvalue for the inviscid terms of the PDE. * \param[in] iSpecies - Value of iSpecies to which the eigenvalue belongs */ - inline virtual void AddMax_Lambda_Inv(su2double val_max_lambda, unsigned short iSpecies) {} + inline virtual void AddMax_Lambda_Inv(unsigned long iPoint, su2double val_max_lambda, unsigned long iSpecies) {} /*! * \brief Add a value to the maximum eigenvalue for the viscous terms of the PDE. * \param[in] val_max_lambda - Value of the maximum eigenvalue for the viscous terms of the PDE. * \param[in] iSpecies - Value of iSpecies to which the eigenvalue belongs */ - inline virtual void AddMax_Lambda_Visc(su2double val_max_lambda, unsigned short iSpecies) {} + inline virtual void AddMax_Lambda_Visc(unsigned long iPoint, su2double val_max_lambda, unsigned long iSpecies) {} /*! * \brief A virtual member. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \param[in] val_source - Value of the harmonic balance source. */ - inline virtual void SetHarmonicBalance_Source(unsigned short val_var, su2double val_source) {} + inline virtual void SetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar, su2double val_source) {} /*! * \brief A virtual member. */ - inline virtual su2double GetHarmonicBalance_Source(unsigned short val_var) {return 0; } + inline virtual su2double GetHarmonicBalance_Source(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief Set the Eddy Viscosity Sensitivity of the problem. * \param[in] val_EddyViscSens - Eddy Viscosity Sensitivity. * \param[in] numTotalVar - Number of variables. */ - inline virtual void SetEddyViscSens(su2double *val_EddyViscSens, unsigned short numTotalVar) {} + inline virtual void SetEddyViscSens(unsigned long iPoint, const su2double *val_EddyViscSens, unsigned long numTotalVar) {} /*! * \brief Get the Eddy Viscosity Sensitivity of the problem. * \return Pointer to the Eddy Viscosity Sensitivity. */ - inline virtual su2double *GetEddyViscSens(void) {return NULL; } + inline virtual su2double *GetEddyViscSens(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. Set the direct solution for the adjoint solver. - * \param[in] val_solution_direct - Value of the direct solution. + * \param[in] solution_direct - Value of the direct solution. */ - inline virtual void SetSolution_Direct(su2double *val_solution_direct) {} + inline virtual void SetSolution_Direct(unsigned long iPoint, const su2double *solution_direct) {} /*! * \brief A virtual member. Get the direct solution for the adjoint solver. * \return Pointer to the direct solution vector. */ - inline virtual su2double *GetSolution_Direct(void) { return NULL; } + inline virtual su2double *GetSolution_Direct(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. Set the restart geometry (coordinate of the converged solution) * \param[in] val_coordinate_direct - Value of the restart coordinate. */ - inline virtual void SetGeometry_Direct(su2double *val_coordinate_direct) {} + inline virtual void SetGeometry_Direct(unsigned long iPoint, const su2double *val_coordinate_direct) {} /*! * \brief A virtual member. Get the restart geometry (coordinate of the converged solution). * \return Pointer to the restart coordinate vector. */ - inline virtual su2double *GetGeometry_Direct(void) { return NULL; } + inline virtual su2double *GetGeometry_Direct(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. Get the restart geometry (coordinate of the converged solution). * \return Coordinate of the direct solver restart for . */ - inline virtual su2double GetGeometry_Direct(unsigned short val_dim) {return 0.0; } + inline virtual su2double GetGeometry_Direct(unsigned long iPoint, unsigned long iDim) const { return 0.0; } /*! * \brief A virtual member. Get the geometry solution. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline virtual su2double GetSolution_Geometry(unsigned short val_var) {return 0.0;} + inline virtual su2double GetSolution_Geometry(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. Set the value of the mesh solution (adjoint). - * \param[in] val_solution - Solution of the problem (acceleration). + * \param[in] solution - Solution of the problem (acceleration). */ - inline virtual void SetSolution_Geometry(su2double *val_solution_geometry) {} + inline virtual void SetSolution_Geometry(unsigned long iPoint, const su2double *solution_geometry) {} /*! * \brief A virtual member. Set the value of the mesh solution (adjoint). - * \param[in] val_solution - Solution of the problem (acceleration). + * \param[in] solution - Solution of the problem (acceleration). */ - inline virtual void SetSolution_Geometry(unsigned short val_var, su2double val_solution_geometry) {} + inline virtual void SetSolution_Geometry(unsigned long iPoint, unsigned long iVar, su2double solution_geometry) {} /*! * \brief A virtual member. Get the geometry solution. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline virtual su2double GetGeometry_CrossTerm_Derivative(unsigned short val_var) {return 0.0;} + inline virtual su2double GetGeometry_CrossTerm_Derivative(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. Set the value of the mesh solution (adjoint). - * \param[in] val_solution - Solution of the problem (acceleration). + * \param[in] solution - Solution of the problem (acceleration). */ - inline virtual void SetGeometry_CrossTerm_Derivative(unsigned short iDim, su2double der) {} + inline virtual void SetGeometry_CrossTerm_Derivative(unsigned long iPoint, unsigned long iDim, su2double der) {} /*! * \brief A virtual member. Get the geometry solution. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline virtual su2double GetGeometry_CrossTerm_Derivative_Flow(unsigned short val_var) {return 0.0;} + inline virtual su2double GetGeometry_CrossTerm_Derivative_Flow(unsigned long iPoint, unsigned long iVar) const { return 0.0;} /*! * \brief A virtual member. Set the value of the mesh solution (adjoint). - * \param[in] val_solution - Solution of the problem (acceleration). + * \param[in] solution - Solution of the problem (acceleration). */ - inline virtual void SetGeometry_CrossTerm_Derivative_Flow(unsigned short iDim, su2double der) {} + inline virtual void SetGeometry_CrossTerm_Derivative_Flow(unsigned long iPoint, unsigned long iDim, su2double der) {} /*! * \brief A virtual member. Set the value of the old geometry solution (adjoint). */ - inline virtual void Set_OldSolution_Geometry(void) {} + inline virtual void Set_OldSolution_Geometry() {} /*! * \brief A virtual member. Get the value of the old geometry solution (adjoint). - * \param[out] val_solution - old adjoint solution for coordinate iDim + * \param[out] solution - old adjoint solution for coordinate iDim */ - inline virtual su2double Get_OldSolution_Geometry(unsigned short iDim) {return 0.0;} + inline virtual su2double Get_OldSolution_Geometry(unsigned long iPoint, unsigned long iDim) const { return 0.0; } - /*! + /*! * \brief A virtual member. Set the value of the old geometry solution (adjoint). */ - inline virtual void Set_BGSSolution(unsigned short iDim, su2double val_solution) {} + inline virtual void Set_BGSSolution(unsigned long iPoint, unsigned long iDim, su2double solution) {} /*! * \brief Set the value of the solution in the previous BGS subiteration. */ - inline void Set_BGSSolution_k(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution_BGS_k[iVar] = Solution[iVar]; - } + virtual void Set_BGSSolution_k(); /*! * \brief Set the value of the solution in the previous BGS subiteration. */ - inline void Set_BGSSolution_k(unsigned short iVar, su2double val_var) { - Solution_BGS_k[iVar] = val_var; + inline void Set_BGSSolution_k(unsigned long iPoint, unsigned long iVar, su2double val_var) { + Solution_BGS_k(iPoint,iVar) = val_var; } /*! * \brief Get the value of the solution in the previous BGS subiteration. * \param[out] val_solution - solution in the previous BGS subiteration. */ - inline su2double Get_BGSSolution_k(unsigned short iDim) {return Solution_BGS_k[iDim];} - - /*! - * \brief A virtual member. Get the value of the old geometry solution (adjoint). - * \param[out] val_solution - old adjoint solution for coordinate iDim - */ - inline virtual su2double Get_BGSSolution(unsigned short iDim) {return 0.0;} - - /*! - * \brief A virtual member. Set the value of the old geometry solution (adjoint). - */ - inline virtual void Set_BGSSolution_Geometry(void) {} + inline virtual su2double Get_BGSSolution_k(unsigned long iPoint, unsigned long iVar) const { + return Solution_BGS_k(iPoint,iVar); + } /*! * \brief A virtual member. Get the value of the old geometry solution (adjoint). * \param[out] val_solution - old adjoint solution for coordinate iDim */ - inline virtual su2double Get_BGSSolution_Geometry(unsigned short iDim) {return 0.0;} + inline virtual su2double Get_BGSSolution(unsigned long iPoint, unsigned long iDim) const {return 0.0;} /*! * \brief A virtual member. Set the contribution of crossed terms into the derivative. */ - inline virtual void SetCross_Term_Derivative(unsigned short iVar, su2double der) {} + inline virtual void SetCross_Term_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) {} /*! * \brief A virtual member. Get the contribution of crossed terms into the derivative. * \return The contribution of crossed terms into the derivative. */ - inline virtual su2double GetCross_Term_Derivative(unsigned short iVar) {return 0.0; } + inline virtual su2double GetCross_Term_Derivative(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. Set the direct velocity solution for the adjoint solver. - * \param[in] val_solution_direct - Value of the direct velocity solution. + * \param[in] solution_direct - Value of the direct velocity solution. */ - inline virtual void SetSolution_Vel_Direct(su2double *sol) {} + inline virtual void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *sol) {} /*! * \brief A virtual member. Set the direct acceleration solution for the adjoint solver. - * \param[in] val_solution_direct - Value of the direct acceleration solution. + * \param[in] solution_direct - Value of the direct acceleration solution. */ - inline virtual void SetSolution_Accel_Direct(su2double *sol) {} + inline virtual void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *sol) {} /*! * \brief A virtual member. Get the direct velocity solution for the adjoint solver. * \return Pointer to the direct velocity solution vector. */ - inline virtual su2double* GetSolution_Vel_Direct() {return NULL; } + inline virtual su2double* GetSolution_Vel_Direct(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. Get the direct acceleraction solution for the adjoint solver. * \return Pointer to the direct acceleraction solution vector. */ - inline virtual su2double* GetSolution_Accel_Direct() {return NULL; } + inline virtual su2double* GetSolution_Accel_Direct(unsigned long iPoint) { return nullptr; } /*! * \brief Set the value of the velocity (Structural Analysis). - * \param[in] val_solution - Solution of the problem (velocity). + * \param[in] solution - Solution of the problem (velocity). */ - inline virtual void SetSolution_Vel(su2double *val_solution) {} + inline virtual void SetSolution_Vel(unsigned long iPoint, const su2double *solution) {} /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution_vel - Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] solution_vel - Value of the solution for the index iVar. */ - inline virtual void SetSolution_Vel(unsigned short val_var, su2double val_solution_vel) {} + inline virtual void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double solution_vel) {} /*! * \brief Set the value of the velocity (Structural Analysis) at time n. - * \param[in] val_solution_vel_time_n - Value of the old solution. + * \param[in] solution_vel_time_n - Value of the old solution. */ - inline virtual void SetSolution_Vel_time_n(su2double *val_solution_vel_time_n) {} + inline virtual void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *solution_vel_time_n) {} /*! * \brief Set the value of the velocity (Structural Analysis) at time n. */ - inline virtual void SetSolution_Vel_time_n(void) {} + inline virtual void SetSolution_Vel_time_n() {} /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution_vel_time_n - Value of the old solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] solution_vel_time_n - Value of the old solution for the index iVar. */ - inline virtual void SetSolution_Vel_time_n(unsigned short val_var, su2double val_solution_vel_time_n) {} + inline virtual void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double solution_vel_time_n) {} /*! * \brief Get the solution at time n. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_time_n(unsigned short val_var) {return Solution_time_n[val_var]; } + inline su2double GetSolution_time_n(unsigned long iPoint, unsigned long iVar) const { return Solution_time_n(iPoint,iVar); } /*! * \brief Get the solution at time n-1. - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_time_n1(unsigned short val_var) {return Solution_time_n1[val_var]; } + inline su2double GetSolution_time_n1(unsigned long iPoint, unsigned long iVar) const { return Solution_time_n1(iPoint,iVar); } /*! * \brief Get the velocity (Structural Analysis). - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline virtual su2double GetSolution_Vel(unsigned short val_var) {return 0; } + inline virtual su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief Get the solution of the problem. * \return Pointer to the solution vector. */ - inline virtual su2double *GetSolution_Vel(void) {return NULL; } + inline virtual su2double *GetSolution_Vel(unsigned long iPoint) {return nullptr; } /*! * \brief Get the velocity of the nodes (Structural Analysis) at time n. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline virtual su2double GetSolution_Vel_time_n(unsigned short val_var) {return 0; } + inline virtual su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline virtual su2double *GetSolution_Vel_time_n(void) {return NULL; } + inline virtual su2double *GetSolution_Vel_time_n(unsigned long iPoint) { return nullptr; } /*! * \brief Set the value of the acceleration (Structural Analysis). - * \param[in] val_solution_accel - Solution of the problem (acceleration). + * \param[in] solution_accel - Solution of the problem (acceleration). */ - inline virtual void SetSolution_Accel(su2double *val_solution_accel) {} + inline virtual void SetSolution_Accel(unsigned long iPoint, const su2double *solution_accel) {} /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution_accel - Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] solution_accel - Value of the solution for the index iVar. */ - inline virtual void SetSolution_Accel(unsigned short val_var, su2double val_solution_accel) {} + inline virtual void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double solution_accel) {} /*! * \brief Set the value of the acceleration (Structural Analysis) at time n. - * \param[in] val_solution_accel_time_n - Pointer to the residual vector. + * \param[in] solution_accel_time_n - Pointer to the residual vector. */ - inline virtual void SetSolution_Accel_time_n(su2double *val_solution_accel_time_n) {} + inline virtual void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *solution_accel_time_n) {} /*! * \brief Set the value of the acceleration (Structural Analysis) at time n. */ - inline virtual void SetSolution_Accel_time_n(void) {} + inline virtual void SetSolution_Accel_time_n() {} /*! * \overload - * \param[in] val_var - Index of the variable. - * \param[in] val_solution_accel_time_n - Value of the old solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \param[in] solution_accel_time_n - Value of the old solution for the index iVar. */ - inline virtual void SetSolution_Accel_time_n(unsigned short val_var, su2double val_solution_accel_time_n) {} + inline virtual void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double solution_accel_time_n) {} /*! * \brief Get the acceleration (Structural Analysis). - * \param[in] val_var - Index of the variable. - * \return Value of the solution for the index val_var. + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. */ - inline virtual su2double GetSolution_Accel(unsigned short val_var) {return 0; } + inline virtual su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief Get the solution of the problem. * \return Pointer to the solution vector. */ - inline virtual su2double *GetSolution_Accel(void) {return NULL; } + inline virtual su2double *GetSolution_Accel(unsigned long iPoint) { return nullptr; } /*! * \brief Get the acceleration of the nodes (Structural Analysis) at time n. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline virtual su2double GetSolution_Accel_time_n(unsigned short val_var) {return 0; } + inline virtual su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline virtual su2double *GetSolution_Accel_time_n(void) {return NULL; } + inline virtual su2double *GetSolution_Accel_time_n(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. */ - inline virtual void Set_OldSolution_Vel(void) {} + inline virtual void Set_OldSolution_Vel() {} /*! * \brief A virtual member. */ - inline virtual void Set_OldSolution_Accel(void) {} + inline virtual void Set_OldSolution_Accel() {} /*! * \brief A virtual member. Set the value of the solution predictor. */ - inline virtual void SetSolution_Pred(void) {} + inline virtual void SetSolution_Pred(unsigned long iPoint) {} /*! * \brief A virtual member. Set the value of the old solution. - * \param[in] val_solution_pred - Pointer to the residual vector. + * \param[in] solution_pred - Pointer to the residual vector. */ - inline virtual void SetSolution_Pred(su2double *val_solution_pred) {} + inline virtual void SetSolution_Pred(unsigned long iPoint, const su2double *solution_pred) {} /*! * \brief A virtual member. Set the value of the solution predicted. - * \param[in] val_solution_old - Pointer to the residual vector. + * \param[in] solution_old - Pointer to the residual vector. */ - inline virtual void SetSolution_Pred(unsigned short val_var, su2double val_solution_pred) {} + inline virtual void SetSolution_Pred(unsigned long iPoint, unsigned long iVar, su2double solution_pred) {} /*! * \brief A virtual member. Get the value of the solution predictor. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline virtual su2double GetSolution_Pred(unsigned short val_var) {return 0.0; } + inline virtual su2double GetSolution_Pred(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline virtual su2double *GetSolution_Pred(void) {return NULL; } + inline virtual su2double *GetSolution_Pred(unsigned long iPoint) {return nullptr; } /*! * \brief A virtual member. Set the value of the solution predictor. */ - inline virtual void SetSolution_Pred_Old(void) {} + inline virtual void SetSolution_Pred_Old(unsigned long iPoint) {} /*! * \brief A virtual member. Set the value of the old solution. - * \param[in] val_solution_pred_Old - Pointer to the residual vector. + * \param[in] solution_pred_Old - Pointer to the residual vector. */ - inline virtual void SetSolution_Pred_Old(su2double *val_solution_pred_Old) {} + inline virtual void SetSolution_Pred_Old(unsigned long iPoint, const su2double *solution_pred_Old) {} /*! * \brief A virtual member. Set the value of the old solution predicted. - * \param[in] val_solution_pred_old - Pointer to the residual vector. + * \param[in] solution_pred_old - Pointer to the residual vector. */ - inline virtual void SetSolution_Pred_Old(unsigned short val_var, su2double val_solution_pred_old) {} + inline virtual void SetSolution_Pred_Old(unsigned long iPoint, unsigned long iVar, su2double solution_pred_old) {} /*! * \brief A virtual member. Get the value of the solution predictor. - * \param[in] val_var - Index of the variable. + * \param[in] iVar - Index of the variable. * \return Pointer to the old solution vector. */ - inline virtual su2double GetSolution_Pred_Old(unsigned short val_var) {return 0.0; } + inline virtual su2double GetSolution_Pred_Old(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline virtual su2double *GetSolution_Pred_Old(void) {return NULL; } + inline virtual su2double *GetSolution_Pred_Old(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. */ - inline virtual void SetReference_Geometry(unsigned short iVar, su2double ref_geometry) {} + inline virtual void SetReference_Geometry(unsigned long iPoint, unsigned long iVar, su2double ref_geometry) {} /*! * \brief A virtual member. */ - inline virtual su2double *GetReference_Geometry(void) {return NULL; } + inline virtual su2double *GetReference_Geometry(unsigned long iPoint) {return nullptr; } /*! * \brief A virtual member. */ - inline virtual void SetPrestretch(unsigned short iVar, su2double val_prestretch) {} + inline virtual void SetPrestretch(unsigned long iPoint, unsigned long iVar, su2double val_prestretch) {} /*! * \brief A virtual member. */ - inline virtual su2double *GetPrestretch(void) {return NULL; } + inline virtual su2double *GetPrestretch(unsigned long iPoint) {return nullptr; } /*! * \brief A virtual member. */ - inline virtual su2double GetPrestretch(unsigned short iVar) {return 0.0; } + inline virtual su2double GetPrestretch(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual su2double GetReference_Geometry(unsigned short iVar) {return 0.0; } + inline virtual su2double GetReference_Geometry(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief A virtual member. Get the value of the undeformed coordinates. * \param[in] iDim - Index of Mesh_Coord[nDim] * \return Value of the original coordinate iDim. */ - inline virtual su2double GetMesh_Coord(unsigned short iDim) const { return 0.0; } + inline virtual su2double GetMesh_Coord(unsigned long iPoint, unsigned long iDim) const { return 0.0; } /*! * \brief A virtual member. Get the undeformed coordinates. * \return Pointer to the reference coordinates. */ - inline virtual su2double *GetMesh_Coord() { return NULL; } + inline virtual const su2double *GetMesh_Coord(unsigned long iPoint) const { return nullptr; } /*! * \brief A virtual member. Set the value of the undeformed coordinates. * \param[in] iDim - Index of Mesh_Coord[nDim] * \param[in] val_coord - Value of Mesh_Coord[nDim] */ - inline virtual void SetMesh_Coord(unsigned short iDim, const su2double val_coord) { } + inline virtual void SetMesh_Coord(unsigned long iPoint, unsigned long iDim, su2double val_coord) { } /*! * \brief A virtual member. Get the value of the wall distance in reference coordinates. * \param[in] iDim - Index of Mesh_Coord[nDim] * \return Value of the wall distance in reference coordinates. */ - inline virtual su2double GetWallDistance(void) const { return 0.0; } + inline virtual su2double GetWallDistance(unsigned long iPoint) const { return 0.0; } /*! * \brief A virtual member. Set the value of the wall distance in reference coordinates. * \param[in] val_dist - Value of wall distance. */ - inline virtual void SetWallDistance(const su2double val_dist) { } + inline virtual void SetWallDistance(unsigned long iPoint, su2double val_dist) { } /*! * \brief A virtual member. Register the reference coordinates of the mesh. @@ -2429,19 +2496,19 @@ class CVariable { /*! * \brief A virtual member. Recover the value of the adjoint of the mesh coordinates. */ - inline virtual void GetAdjoint_MeshCoord(su2double *adj_mesh) const { } + inline virtual void GetAdjoint_MeshCoord(unsigned long iPoint, su2double *adj_mesh) const { } /*! * \brief A virtual member. Get the value of the displacement imposed at the boundary. * \return Value of the boundary displacement. */ - inline virtual su2double GetBound_Disp(unsigned short iDim) const { return 0.0; } + inline virtual su2double GetBound_Disp(unsigned long iPoint, unsigned long iDim) const { return 0.0; } /*! * \brief A virtual member. Set the boundary displacement. * \param[in] val_BoundDisp - Pointer to the boundary displacements. */ - inline virtual void SetBound_Disp(const su2double *val_BoundDisp) { } + inline virtual void SetBound_Disp(unsigned long iPoint, const su2double *val_BoundDisp) { } /*! @@ -2449,32 +2516,32 @@ class CVariable { * \param[in] iDim - Index of the dimension of interest. * \param[in] val_BoundDisp - Value of the boundary displacements. */ - inline virtual void SetBound_Disp(unsigned short iDim, const su2double val_BoundDisp) { } + inline virtual void SetBound_Disp(unsigned long iPoint, unsigned long iDim, const su2double val_BoundDisp) { } /*! * \brief A virtual member. Get the value of the displacement imposed at the boundary. * \return Value of the boundary displacement. */ - inline virtual su2double* GetBoundDisp_Direct(void) { return NULL; } + inline virtual const su2double* GetBoundDisp_Direct(unsigned long iPoint) const { return nullptr; } /*! * \brief A virtual member. Set the solution for the boundary displacements. * \param[in] val_BoundDisp - Pointer to the boundary displacements. */ - inline virtual void SetBoundDisp_Direct(const su2double *val_BoundDisp) { } + inline virtual void SetBoundDisp_Direct(unsigned long iPoint, const su2double *val_BoundDisp) { } /*! * \brief Set the value of the sensitivity with respect to the undeformed coordinates. * \param[in] val_sens - Pointer to the sensitivities of the boundary displacements. */ - inline virtual void SetBoundDisp_Sens(const su2double *val_sens) { } + inline virtual void SetBoundDisp_Sens(unsigned long iPoint, const su2double *val_sens) { } /*! * \brief A virtual member. Get the value of the sensitivity with respect to the undeformed coordinates. * \param[in] iDim - Index of Mesh_Coord_Sens[nDim] * \return Value of the original Mesh_Coord_Sens iDim. */ - inline virtual su2double GetBoundDisp_Sens(unsigned short iDim) const { return 0.0; } + inline virtual su2double GetBoundDisp_Sens(unsigned long iPoint, unsigned long iDim) const { return 0.0; } /*! * \brief A virtual member. Register the boundary displacements of the mesh. @@ -2485,7 +2552,7 @@ class CVariable { /*! * \brief A virtual member. Recover the value of the adjoint of the boundary displacements. */ - inline virtual void GetAdjoint_BoundDisp(su2double *adj_disph) { } + inline virtual void GetAdjoint_BoundDisp(unsigned long iPoint, su2double *adj_disp) const { } /*! * \brief A virtual member. @@ -2515,134 +2582,151 @@ class CVariable { /*! * \brief A virtual member. */ - inline virtual void RegisterFlowTraction() { } + inline virtual void SetAdjointSolution_Vel(unsigned long iPoint, const su2double *adj_sol) {} /*! * \brief A virtual member. */ - inline virtual su2double ExtractFlowTraction_Sensitivity(unsigned short iDim) {return 0.0;} + inline virtual void RegisterFlowTraction() { } /*! * \brief A virtual member. */ - inline virtual void SetAdjointSolution_Vel(su2double *adj_sol) {} + inline virtual su2double ExtractFlowTraction_Sensitivity(unsigned long iPoint, unsigned long iDim) const { return 0.0; } /*! * \brief A virtual member. */ - inline virtual void GetAdjointSolution_Vel(su2double *adj_sol) {} + inline virtual void GetAdjointSolution_Vel(unsigned long iPoint, su2double *adj_sol) const {} /*! * \brief A virtual member. */ - inline virtual void SetAdjointSolution_Vel_time_n(su2double *adj_sol) {} + inline virtual void SetAdjointSolution_Vel_time_n(unsigned long iPoint, const su2double *adj_sol) {} /*! * \brief A virtual member. */ - inline virtual void GetAdjointSolution_Vel_time_n(su2double *adj_sol) {} + inline virtual void GetAdjointSolution_Vel_time_n(unsigned long iPoint, su2double *adj_sol) const {} /*! * \brief A virtual member. */ - inline virtual void SetAdjointSolution_Accel(su2double *adj_sol) {} + inline virtual void SetAdjointSolution_Accel(unsigned long iPoint, const su2double *adj_sol) {} /*! * \brief A virtual member. */ - inline virtual void GetAdjointSolution_Accel(su2double *adj_sol) {} + inline virtual void GetAdjointSolution_Accel(unsigned long iPoint, su2double *adj_sol) const {} /*! * \brief A virtual member. */ - inline virtual void SetAdjointSolution_Accel_time_n(su2double *adj_sol) {} + inline virtual void SetAdjointSolution_Accel_time_n(unsigned long iPoint, const su2double *adj_sol) {} /*! * \brief A virtual member. */ - inline virtual void GetAdjointSolution_Accel_time_n(su2double *adj_sol) {} + inline virtual void GetAdjointSolution_Accel_time_n(unsigned long iPoint, su2double *adj_sol) const {} /*! * \brief Register the variables in the solution array as input/output variable. * \param[in] input - input or output variables. */ - inline void RegisterSolution(bool input) { - if (input) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution[iVar]); - } - else { for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterOutput(Solution[iVar]);} - } + void RegisterSolution(bool input); + + /*! + * \brief Register the variables in the solution array as input/output variable. + * \param[in] input - input or output variables. + */ + void RegisterSolution_intIndexBased(bool input); + + /*! + * \brief Saving the adjoint vector position with respect to the solution variables. + * \param[in] input - input or output variables. + */ + void SetAdjIndices(bool input); /*! * \brief Register the variables in the solution_time_n array as input/output variable. */ - inline void RegisterSolution_time_n(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution_time_n[iVar]); - } + void RegisterSolution_time_n(); /*! * \brief Register the variables in the solution_time_n1 array as input/output variable. */ - inline void RegisterSolution_time_n1(void) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution_time_n1[iVar]); + void RegisterSolution_time_n1(); + + /*! + * \brief Set the adjoint values of the solution. + * \param[in] adj_sol - The adjoint values of the solution. + */ + inline void SetAdjointSolution(unsigned long iPoint, const su2double *adj_sol) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + SU2_TYPE::SetDerivative(Solution(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } /*! * \brief Set the adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void SetAdjointSolution(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution[iVar], SU2_TYPE::GetValue(adj_sol[iVar])); + inline void SetAdjointSolution_intIndexBased(unsigned long iPoint, const su2double *adj_sol) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::SetDerivative(Output_AdjIndices(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } /*! * \brief Get the adjoint values of the solution. * \param[out] adj_sol - The adjoint values of the solution. */ - inline void GetAdjointSolution(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution[iVar]); + inline void GetAdjointSolution(unsigned long iPoint, su2double *adj_sol) const { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution(iPoint,iVar)); + } + + /*! + * \brief Get the adjoint values of the solution. + * \param[in] adj_sol - The adjoint values of the solution. + */ + inline void GetAdjointSolution_intIndexBased(unsigned long iPoint, su2double *adj_sol) const { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = AD::GetDerivative(Input_AdjIndices(iPoint,iVar)); } /*! * \brief Set the adjoint values of the solution at time n. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void SetAdjointSolution_time_n(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_time_n[iVar], SU2_TYPE::GetValue(adj_sol[iVar])); + inline void SetAdjointSolution_time_n(unsigned long iPoint, const su2double *adj_sol) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + SU2_TYPE::SetDerivative(Solution_time_n(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } /*! * \brief Get the adjoint values of the solution at time n. * \param[out] adj_sol - The adjoint values of the solution. */ - inline void GetAdjointSolution_time_n(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n[iVar]); + inline void GetAdjointSolution_time_n(unsigned long iPoint, su2double *adj_sol) const { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n(iPoint,iVar)); } /*! * \brief Set the adjoint values of the solution at time n-1. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void SetAdjointSolution_time_n1(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_time_n1[iVar], SU2_TYPE::GetValue(adj_sol[iVar])); + inline void SetAdjointSolution_time_n1(unsigned long iPoint, const su2double *adj_sol) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + SU2_TYPE::SetDerivative(Solution_time_n1(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } /*! * \brief Get the adjoint values of the solution at time n-1. * \param[out] adj_sol - The adjoint values of the solution. */ - inline void GetAdjointSolution_time_n1(su2double *adj_sol) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n1[iVar]); + inline void GetAdjointSolution_time_n1(unsigned long iPoint, su2double *adj_sol) const { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n1(iPoint,iVar)); } /*! @@ -2650,85 +2734,85 @@ class CVariable { * \param[in] iDim - spacial component * \param[in] val - value of the Sensitivity */ - inline virtual void SetSensitivity(unsigned short iDim, su2double val) {} + inline virtual void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) {} /*! * \brief Get the Sensitivity at the node * \param[in] iDim - spacial component * \return value of the Sensitivity */ - inline virtual su2double GetSensitivity(unsigned short iDim) {return 0.0; } + inline virtual su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const { return 0.0; } - inline virtual void SetDual_Time_Derivative(unsigned short iVar, su2double der) {} + inline virtual void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual void SetDual_Time_Derivative_n(unsigned short iVar, su2double der) {} + inline virtual void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual su2double GetDual_Time_Derivative(unsigned short iVar) {return 0.0;} + inline virtual su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const {return 0.0;} - inline virtual su2double GetDual_Time_Derivative_n(unsigned short iVar) {return 0.0;} + inline virtual su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const {return 0.0;} - inline virtual void SetTauWall(su2double val_tau_wall) {} + inline virtual void SetTauWall(unsigned long iPoint, su2double val_tau_wall) {} - inline virtual su2double GetTauWall() {return 0.0; } + inline virtual su2double GetTauWall(unsigned long iPoint) const { return 0.0; } - inline virtual void SetVortex_Tilting(su2double **PrimGrad_Flow, su2double* Vorticity, su2double LaminarViscosity) {} + inline virtual void SetVortex_Tilting(unsigned long iPoint, su2double **PrimGrad_Flow, su2double* Vorticity, su2double LaminarViscosity) {} - inline virtual su2double GetVortex_Tilting() {return 0.0; } + inline virtual su2double GetVortex_Tilting(unsigned long iPoint) const { return 0.0; } - inline virtual void SetDynamic_Derivative(unsigned short iVar, su2double der) {} + inline virtual void SetDynamic_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual void SetDynamic_Derivative_n(unsigned short iVar, su2double der) {} + inline virtual void SetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual su2double GetDynamic_Derivative(unsigned short iVar) {return 0.0; } + inline virtual su2double GetDynamic_Derivative(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual su2double GetDynamic_Derivative_n(unsigned short iVar) {return 0.0; } + inline virtual su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual void SetDynamic_Derivative_Vel(unsigned short iVar, su2double der) {} + inline virtual void SetDynamic_Derivative_Vel(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual void SetDynamic_Derivative_Vel_n(unsigned short iVar, su2double der) {} + inline virtual void SetDynamic_Derivative_Vel_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual su2double GetDynamic_Derivative_Vel(unsigned short iVar) {return 0.0; } + inline virtual su2double GetDynamic_Derivative_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual su2double GetDynamic_Derivative_Vel_n(unsigned short iVar) {return 0.0; } + inline virtual su2double GetDynamic_Derivative_Vel_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual void SetDynamic_Derivative_Accel(unsigned short iVar, su2double der) {} + inline virtual void SetDynamic_Derivative_Accel(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual void SetDynamic_Derivative_Accel_n(unsigned short iVar, su2double der) {} + inline virtual void SetDynamic_Derivative_Accel_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual su2double GetDynamic_Derivative_Accel(unsigned short iVar) {return 0.0; } + inline virtual su2double GetDynamic_Derivative_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual su2double GetDynamic_Derivative_Accel_n(unsigned short iVar) {return 0.0; } + inline virtual su2double GetDynamic_Derivative_Accel_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual su2double GetSolution_Old_Vel(unsigned short iVar) {return 0.0; } + inline virtual su2double GetSolution_Old_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual su2double GetSolution_Old_Accel(unsigned short iVar) {return 0.0; } + inline virtual su2double GetSolution_Old_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } /*! * \brief Set the FSI force sensitivity at the node * \param[in] iDim - spacial component * \param[in] val - value of the Sensitivity */ - virtual void SetFlowTractionSensitivity(unsigned short iDim, su2double val) { } + virtual void SetFlowTractionSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) { } /*! * \brief Get the FSI force sensitivity at the node * \param[in] iDim - spacial component * \return value of the Sensitivity */ - virtual su2double GetFlowTractionSensitivity(unsigned short iDim) { return 0.0; } + virtual su2double GetFlowTractionSensitivity(unsigned long iPoint, unsigned long iDim) const { return 0.0; } /*! * \brief Set the source term applied into the displacement adjoint coming from external solvers * \param[in] iDim - spacial component * \param[in] val - value of the source term */ - virtual void SetSourceTerm_DispAdjoint(unsigned short iDim, su2double val) { } + virtual void SetSourceTerm_DispAdjoint(unsigned long iPoint, unsigned long iDim, su2double val) { } /*! * \brief Get the source term applied into the displacement adjoint coming from external solvers * \param[in] iDim - spacial component * \return value of the source term */ - virtual su2double GetSourceTerm_DispAdjoint(unsigned short iDim) { return 0.0; } + virtual su2double GetSourceTerm_DispAdjoint(unsigned long iPoint, unsigned long iDim) const { return 0.0; } }; diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index ae6148e8af51..4fd4d1f9048d 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -69,6 +69,7 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/drivers/CMultizoneDriver.cpp \ ../src/drivers/CSinglezoneDriver.cpp \ ../src/drivers/CDiscAdjSinglezoneDriver.cpp \ + ../src/drivers/CDiscAdjMultizoneDriver.cpp \ ../src/drivers/CDriver.cpp \ ../src/drivers/CDummyDriver.cpp \ ../src/iteration_structure.cpp \ diff --git a/SU2_CFD/src/SU2_CFD.cpp b/SU2_CFD/src/SU2_CFD.cpp index 7f94c3c0125f..d6fe18f845ae 100644 --- a/SU2_CFD/src/SU2_CFD.cpp +++ b/SU2_CFD/src/SU2_CFD.cpp @@ -109,26 +109,36 @@ int main(int argc, char *argv[]) { if (!dry_run){ - if (((config->GetSinglezone_Driver() || (nZone == 1 && config->GetDiscrete_Adjoint())) - && config->GetTime_Marching() != HARMONIC_BALANCE && (!turbo)) || (turbo && config->GetDiscrete_Adjoint())) { - + if ((!config->GetMultizone_Problem() && (config->GetTime_Marching() != HARMONIC_BALANCE) && !turbo) + || (turbo && config->GetDiscrete_Adjoint())) { /*--- Single zone problem: instantiate the single zone driver class. ---*/ if (nZone > 1 ) { SU2_MPI::Error("The required solver doesn't support multizone simulations", CURRENT_FUNCTION); } - if (config->GetDiscrete_Adjoint()) + if (config->GetDiscrete_Adjoint()) { + driver = new CDiscAdjSinglezoneDriver(config_file_name, nZone, MPICommunicator); + } else driver = new CSinglezoneDriver(config_file_name, nZone, MPICommunicator); } else if (config->GetMultizone_Problem() && !turbo && !fsi) { - /*--- Multizone Driver. ---*/ + /*--- Multizone Drivers. ---*/ + + if (config->GetDiscrete_Adjoint()) { + + driver = new CDiscAdjMultizoneDriver(config_file_name, nZone, MPICommunicator); + + } + else { driver = new CMultizoneDriver(config_file_name, nZone, MPICommunicator); + + } } else if (config->GetTime_Marching() == HARMONIC_BALANCE) { diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp new file mode 100644 index 000000000000..bd2f60f70950 --- /dev/null +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -0,0 +1,867 @@ +/*! + * \file CDiscAdjMultizoneDriver.cpp + * \brief The main subroutines for driving adjoint multi-zone problems + * \author O. Burghardt, T. Albring, R. Sanchez + * \version 6.2.0 "Falcon" + * + * The current SU2 release has been coordinated by the + * SU2 International Developers Society + * with selected contributions from the open-source community. + * + * The main research teams contributing to the current release are: + * - Prof. Juan J. Alonso's group at Stanford University. + * - Prof. Piero Colonna's group at Delft University of Technology. + * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. + * - Prof. Alberto Guardone's group at Polytechnic University of Milan. + * - Prof. Rafael Palacios' group at Imperial College London. + * - Prof. Vincent Terrapon's group at the University of Liege. + * - Prof. Edwin van der Weide's group at the University of Twente. + * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. + * + * Copyright 2012-2018, Francisco D. Palacios, Thomas D. Economon, + * Tim Albring, and the SU2 contributors. + * + * 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 . + */ + +#include "../../include/drivers/CDiscAdjMultizoneDriver.hpp" + +CDiscAdjMultizoneDriver::CDiscAdjMultizoneDriver(char* confFile, + unsigned short val_nZone, + SU2_Comm MPICommunicator) + + : CMultizoneDriver(confFile, val_nZone, MPICommunicator) { + + retape = !config_container[ZONE_0]->GetFull_Tape(); + + RecordingState = NONE; + + direct_nInst = new unsigned short[nZone]; + nInnerIter = new unsigned short[nZone]; + + + for (iZone = 0; iZone < nZone; iZone++) { + + direct_nInst[iZone] = 1; + nInnerIter[iZone] = config_container[iZone]->GetnInner_Iter(); + } + + direct_iteration = new CIteration**[nZone]; + direct_output = new COutput*[nZone]; + + for (iZone = 0; iZone < nZone; iZone++) { + + direct_iteration[iZone] = new CIteration*[direct_nInst[iZone]]; + + for(iInst = 0; iInst < direct_nInst[iZone]; iInst++) { + + switch (config_container[iZone]->GetKind_Solver()) { + + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: + direct_iteration[iZone][iInst] = new CFluidIteration(config_container[iZone]); + direct_output[iZone] = new CFlowCompOutput(config_container[iZone], nDim); + break; + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: + direct_iteration[iZone][iInst] = new CFluidIteration(config_container[iZone]); + direct_output[iZone] = new CFlowIncOutput(config_container[iZone], nDim); + break; + case DISC_ADJ_HEAT: + direct_iteration[iZone][iInst] = new CHeatIteration(config_container[iZone]); + direct_output[iZone] = new CHeatOutput(config_container[iZone], nDim); + break; + case DISC_ADJ_FEM: + SU2_MPI::Error("There is no multizone discrete adjoint functionality for problems including elasticity yet.", + CURRENT_FUNCTION); + direct_iteration[iZone][iInst] = new CFEAIteration(config_container[iZone]); + direct_output[iZone] = new CElasticityOutput(config_container[iZone], nDim); + break; + + default: + SU2_MPI::Error("There is no discrete adjoint functionality for one of the specified solvers yet.", + CURRENT_FUNCTION); + } + } + + direct_output[iZone]->PreprocessHistoryOutput(config_container[iZone], false); + } +} + +CDiscAdjMultizoneDriver::~CDiscAdjMultizoneDriver(){ + + for (iZone = 0; iZone < nZone; iZone++){ + for (iInst = 0; iInst < direct_nInst[iZone]; iInst++){ + delete direct_iteration[iZone][iInst]; + } + delete [] direct_iteration[iZone]; + } + + delete[] direct_iteration; + delete[] direct_nInst; + +} + +void CDiscAdjMultizoneDriver::StartSolver() { + + /*--- Main external loop of the solver. Runs for the number of time steps required. ---*/ + + if (rank == MASTER_NODE) + cout << endl <<"------------------------------ Begin Solver -----------------------------" << endl; + + if (rank == MASTER_NODE){ + cout << endl << "Simulation Run using the Discrete Adjoint Multizone Driver" << endl; + + if (driver_config->GetTime_Domain()) + SU2_MPI::Error("The discrete adjoint multizone driver is not ready for unsteady computations yet.", + CURRENT_FUNCTION); + } + + for (iZone = 0; iZone < nZone; iZone++){ + + /*--- Set the value of the external iteration to TimeIter. -------------------------------------*/ + /*--- TODO: This should be generalised for an homogeneous criteria throughout the code. --------*/ + config_container[iZone]->SetTimeIter(0); + + } + + /*--- We directly start the (steady-state) discrete adjoint computation. ---*/ + + Run(); + + /*--- Output the solution in files. ---*/ + + Output(TimeIter); + +} + +void CDiscAdjMultizoneDriver::Run() { + + bool checkSensitivity = false; + unsigned short jZone = 0, + wrt_sol_freq = config_container[ZONE_0]->GetVolume_Wrt_Freq(); + unsigned long nIter = 0, + iOuter_Iter = 0, + iInner_Iter = 0; + + nIter = driver_config->GetnOuter_Iter(); + + for (iZone = 0; iZone < nZone; iZone++) { + + iteration_container[iZone][INST_0]->Preprocess(output_container[iZone], integration_container, geometry_container, + solver_container, numerics_container, config_container, surface_movement, + grid_movement, FFDBox, iZone, INST_0); + + /*--- Set BGS_Solution_k to Solution. ---*/ + + Set_BGSSolution(iZone); + } + + /*--- Loop over the number of outer iterations. ---*/ + + for (iOuter_Iter = 0; iOuter_Iter < nIter; iOuter_Iter++) { + + for (iZone = 0; iZone < nZone; iZone++) { + config_container[iZone]->SetOuterIter(iOuter_Iter); + driver_config->SetOuterIter(iOuter_Iter); + } + + + /*--- For the adjoint iteration we need the derivatives of the iteration function with + * respect to the state (and possibly the mesh coordinate) variables. + * Since these derivatives do not change in the steady state case we only have to record + * if the current recording is different from them. + * + * To set the tape appropriately, the following recording methods are provided: + * (1) NONE: All information from a previous recording is removed. + * (2) FLOW_CONS_VARS: State variables of all solvers in a zone as input. + * (3) MESH_COORDS: Mesh coordinates as input. + * (4) COMBINED: Mesh coordinates and state variables as input. + * + * By default, all (state and mesh coordinate variables) will be declared as output, + * since it does not change the computational effort. ---*/ + + + /*--- If we want to set up zone-specific tapes later on, + * we just record the objective function section here. + * If not, the whole tape of a coupled run will be created. ---*/ + + if (retape) { + SetRecording(NONE, Kind_Tape::FULL_TAPE, ZONE_0); + SetRecording(FLOW_CONS_VARS, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); + } + else if (RecordingState != FLOW_CONS_VARS) { + + SetRecording(NONE, Kind_Tape::FULL_TAPE, ZONE_0); + SetRecording(FLOW_CONS_VARS, Kind_Tape::FULL_TAPE, ZONE_0); + } + + + SetExternal_Zero(); + + /*-- Start loop over zones. ---*/ + + for (iZone = 0; iZone < nZone; iZone++) { + + if (retape) { + SetRecording(NONE, Kind_Tape::FULL_TAPE, ZONE_0); + SetRecording(FLOW_CONS_VARS, Kind_Tape::ZONE_SPECIFIC_TAPE, iZone); + } + + /*--- Evaluate the objective function gradient w.r.t. to solution contributions from iZone. + * (We always initialize from Solution_BGS_k and extract to Solution.) ---*/ + + AD::ClearAdjoints(); + + SetAdj_ObjFunction(); + + AD::ComputeAdjoint(OBJECTIVE_FUNCTION, START); + + iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, + solver_container, numerics_container, config_container, + surface_movement, grid_movement, FFDBox, iZone, INST_0); + + /*--- Add the objective function contribution to the external contributions for solvers in iZone. ---*/ + + Add_Solution_To_ExternalOld(iZone); + + /*--- Inner loop to allow for multiple adjoint updates with respect to solvers in iZone. ---*/ + + for (unsigned short iInnerIter = 0; iInnerIter < nInnerIter[iZone]; iInnerIter++) { + + /*--- Evaluate the tape section belonging to solvers in iZone. ---*/ + + ComputeAdjoints(iZone); + + /*--- Extracting adjoints for solvers in iZone w.r.t. to outputs in iZone (diagonal part). ---*/ + + iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, + solver_container, numerics_container, config_container, + surface_movement, grid_movement, FFDBox, iZone, INST_0); + + /*--- Add off-diagonal contribution (including the OF gradient) to Solution for next inner evaluation. ---*/ + + Add_ExternalOld_To_Solution(iZone); + } + + + /*--- Off-diagonal (coupling term) update. ---*/ + + for (jZone = 0; jZone < nZone; jZone++) { + + if (jZone != iZone) { + + /*--- Extracting adjoints for solvers in jZone w.r.t. to the output of all solvers in iZone, + * that is, for the cases iZone != jZone we are evaluating cross derivatives between zones. ---*/ + + iteration_container[jZone][INST_0]->Iterate(output_container[jZone], integration_container, geometry_container, + solver_container, numerics_container, config_container, + surface_movement, grid_movement, FFDBox, jZone, INST_0); + + /*--- Add the cross derivatives from iZone<-jZone dependencies to the External vector. ---*/ + + Add_Solution_To_External(jZone); + + } + } + + // TODO: Add an option to _already_ update off-diagonals here (i.e., in the zone-loop) + + /*--- Compute residual from Solution and Solution_BGS_k. ---*/ + + SetResidual_BGS(iZone); + + /*--- Save Solution to Solution_BGS_k for a next outer iteration. + * (Solution might be overwritten when entering another zone because of cross derivatives.) ---*/ + + Set_BGSSolution(iZone); + } + + /*--- Now all coupling terms are summed up, set External_Old to External for next outer iteration. ---*/ + + Set_OldExternal(); + + /*--- Print out the convergence data to screen and history file ---*/ + + for (iZone = 0; iZone < nZone; iZone++) { + output_container[iZone]->SetHistory_Output(geometry_container[iZone][INST_0][MESH_0], solver_container[iZone][INST_0][MESH_0], + config_container[iZone], config_container[iZone]->GetTimeIter(), iOuter_Iter, iInner_Iter); + } + + driver_output->SetMultizoneHistory_Output(output_container, config_container, driver_config, + driver_config->GetTimeIter(), driver_config->GetOuterIter()); + + /*--- Check for convergence. ---*/ + + StopCalc = driver_output->GetConvergence(); + + /*--- Clear the stored adjoint information to be ready for a new evaluation. ---*/ + + AD::ClearAdjoints(); + + /*--- Compute the geometrical sensitivities and write them to file. ---*/ + + checkSensitivity = ((iOuter_Iter+1 >= nIter) || + (iOuter_Iter % wrt_sol_freq == 0)); + + if (checkSensitivity || StopCalc){ + + /*--- SetRecording stores the computational graph on one iteration of the direct problem. Calling it with NONE + * as argument ensures that all information from a previous recording is removed. ---*/ + + SetRecording(NONE, Kind_Tape::FULL_TAPE, ZONE_0); + + /*--- Store the computational graph of one direct iteration with the mesh coordinates as input. ---*/ + + SetRecording(MESH_COORDS, Kind_Tape::FULL_TAPE, ZONE_0); + + /*--- Initialize the adjoint of the output variables of the iteration with the adjoint solution + * of the current iteration. The values are passed to the AD tool. ---*/ + + for (iZone = 0; iZone < nZone; iZone++) { + + iteration_container[iZone][INST_0]->InitializeAdjoint(solver_container, geometry_container, + config_container, iZone, INST_0); + } + + /*--- Initialize the adjoint of the objective function with 1.0. ---*/ + + SetAdj_ObjFunction(); + + /*--- Interpret the stored information by calling the corresponding routine of the AD tool. ---*/ + + AD::ComputeAdjoint(); + + /*--- Extract the computed sensitivity values. ---*/ + + for (iZone = 0; iZone < nZone; iZone++) { + + switch (config_container[iZone]->GetKind_Solver()) { + + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: + solver_container[iZone][INST_0][MESH_0][ADJFLOW_SOL]->SetSensitivity(geometry_container[iZone][INST_0][MESH_0], + NULL, config_container[iZone]); + break; + case DISC_ADJ_HEAT: + solver_container[iZone][INST_0][MESH_0][ADJHEAT_SOL]->SetSensitivity(geometry_container[iZone][INST_0][MESH_0], + NULL, config_container[iZone]); + break; + case DISC_ADJ_FEM: + solver_container[iZone][INST_0][MESH_0][ADJFEA_SOL]->SetSensitivity(geometry_container[iZone][INST_0][MESH_0], + NULL, config_container[iZone]); + break; + + default: + cout << "WARNING: Sensitivities not set for one of the specified discrete adjoint solvers!" << endl; + break; + } + } + + /*--- Clear the stored adjoint information to be ready for a new evaluation. ---*/ + + AD::ClearAdjoints(); + + for (iZone = 0; iZone < nZone; iZone++) { + + output_container[iZone]->SetResult_Files(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone], + solver_container[iZone][INST_0][MESH_0], iOuter_Iter, StopCalc); + } + } + + if (StopCalc) break; + } +} + +void CDiscAdjMultizoneDriver::SetRecording(unsigned short kind_recording, Kind_Tape tape_type, unsigned short record_zone) { + + unsigned short iZone, jZone, iSol, UpdateMesh; + unsigned long ExtIter = 0; + bool DeformMesh = false; + + AD::Reset(); + + /*--- Prepare for recording by resetting the flow solution to the initial converged solution---*/ + + for(iZone = 0; iZone < nZone; iZone++) { + + for (iSol=0; iSol < MAX_SOLS; iSol++){ + if (solver_container[iZone][INST_0][MESH_0][iSol] != NULL) { + if (solver_container[iZone][INST_0][MESH_0][iSol]->GetAdjoint()) { + solver_container[iZone][INST_0][MESH_0][iSol]->SetRecording(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone]); + } + } + } + } + + /*---Enable recording and register input of the flow iteration (conservative variables or node coordinates) --- */ + + if(kind_recording != NONE) { + + if (rank == MASTER_NODE && kind_recording == FLOW_CONS_VARS) { + cout << endl << "-------------------------------------------------------------------------" << endl; + cout << "Storing computational graph." << endl; + } + + AD::StartRecording(); + + AD::Push_TapePosition(); + + for (iZone = 0; iZone < nZone; iZone++) { + + iteration_container[iZone][INST_0]->RegisterInput(solver_container, geometry_container, + config_container, iZone, INST_0, kind_recording); + } + } + + AD::Push_TapePosition(); + + for (iZone = 0; iZone < nZone; iZone++) { + + iteration_container[iZone][INST_0]->SetDependencies(solver_container, geometry_container, numerics_container, + config_container, iZone, INST_0, kind_recording); + } + + AD::Push_TapePosition(); + + /*--- Extract the objective function and store it --- */ + + SetObjFunction(kind_recording); + + AD::Push_TapePosition(); + + if (tape_type != Kind_Tape::OBJECTIVE_FUNCTION_TAPE) { + + /*--- We do the communication here to not derive wrt updated boundary data. ---*/ + + for(iZone = 0; iZone < nZone; iZone++) { + + /*--- In principle, the mesh does not need to be updated ---*/ + UpdateMesh = 0; + + /*--- Transfer from all the remaining zones ---*/ + for (jZone = 0; jZone < nZone; jZone++){ + /*--- The target zone is iZone ---*/ + if (jZone != iZone && interface_container[iZone][jZone] != NULL){ + DeformMesh = Transfer_Data(jZone, iZone); + if (DeformMesh) UpdateMesh+=1; + } + } + /*--- If a mesh update is required due to the transfer of data ---*/ + if (UpdateMesh > 0) DynamicMeshUpdate(iZone, ExtIter); + } + + AD::Push_TapePosition(); + + for(iZone = 0; iZone < nZone; iZone++) { + + AD::Push_TapePosition(); + + if (tape_type == Kind_Tape::ZONE_SPECIFIC_TAPE) { + if (iZone == record_zone) { + DirectIteration(iZone, kind_recording); + } + } + else { + DirectIteration(iZone, kind_recording); + } + + iteration_container[iZone][INST_0]->RegisterOutput(solver_container, geometry_container, + config_container, output_container[iZone], iZone, INST_0); + + AD::Push_TapePosition(); + } + } + + if (rank == MASTER_NODE && kind_recording == FLOW_CONS_VARS) { + + if(config_container[record_zone]->GetWrt_AD_Statistics()) { + + AD::PrintStatistics(); + } + + cout << "-------------------------------------------------------------------------" << endl << endl; + } + + AD::StopRecording(); + + RecordingState = kind_recording; +} + +void CDiscAdjMultizoneDriver::DirectIteration(unsigned short iZone, unsigned short kind_recording) { + + /*--- Do one iteration of the direct solver ---*/ + direct_iteration[iZone][INST_0]->Preprocess(output_container[iZone], integration_container, geometry_container, solver_container, + numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); + + /*--- Iterate the zone as a block a single time ---*/ + direct_iteration[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, + numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); + + Corrector(iZone); + + /*--- Print residuals in the first iteration ---*/ + + if (rank == MASTER_NODE && kind_recording == FLOW_CONS_VARS) { + + switch (config_container[iZone]->GetKind_Solver()) { + + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: + cout << " Zone " << iZone << " (flow) - log10[RMS Solution_0]: " + << log10(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetRes_RMS(0)) << endl; + break; + case DISC_ADJ_RANS: case DISC_ADJ_INC_RANS: + cout << " Zone " << iZone << " (flow) - log10[RMS Solution_0]: " + << log10(solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetRes_RMS(0)) << endl; + + if (!config_container[iZone]->GetFrozen_Visc_Disc()) { + + cout << " Zone " << iZone << " (turb) - log10[RMS k] : " + << log10(solver_container[iZone][INST_0][MESH_0][TURB_SOL]->GetRes_RMS(0)) << endl; + } + break; + case DISC_ADJ_HEAT: + cout << " Zone " << iZone << " (heat) - log10[RMS Solution_0]: " + << log10(solver_container[iZone][INST_0][MESH_0][HEAT_SOL]->GetRes_RMS(0)) << endl; + break; + } + } +} + +void CDiscAdjMultizoneDriver::SetObjFunction(unsigned short kind_recording) { + + ObjFunc = 0.0; + su2double Weight_ObjFunc; + + unsigned short iZone, iMarker_Analyze, nMarker_Analyze; + + + /*--- Call objective function calculations. ---*/ + + for (iZone = 0; iZone < nZone; iZone++){ + + switch (config_container[iZone]->GetKind_Solver()) { + + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: + solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->Pressure_Forces(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone]); + solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->Momentum_Forces(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone]); + solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->Friction_Forces(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone]); + + if(config_container[iZone]->GetWeakly_Coupled_Heat()) { + + solver_container[iZone][INST_0][MESH_0][HEAT_SOL]->Heat_Fluxes(geometry_container[iZone][INST_0][MESH_0], + solver_container[iZone][INST_0][MESH_0], config_container[iZone]); + } + solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->Evaluate_ObjFunc(config_container[iZone]); + break; + case DISC_ADJ_HEAT: + solver_container[iZone][INST_0][MESH_0][HEAT_SOL]->Heat_Fluxes(geometry_container[iZone][INST_0][MESH_0], + solver_container[iZone][INST_0][MESH_0], config_container[iZone]); + break; + } + + direct_output[iZone]->SetHistory_Output(geometry_container[iZone][INST_0][MESH_0], + solver_container[iZone][INST_0][MESH_0], config_container[iZone]); + } + + /*--- Extract objective function values. ---*/ + + for (iZone = 0; iZone < nZone; iZone++){ + + nMarker_Analyze = config_container[iZone]->GetnMarker_Analyze(); + + for (iMarker_Analyze = 0; iMarker_Analyze < nMarker_Analyze; iMarker_Analyze++) { + + Weight_ObjFunc = config_container[iZone]->GetWeight_ObjFunc(iMarker_Analyze); + + switch (config_container[iZone]->GetKind_Solver()) { + + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: + // per-surface output to be added soon + break; + case HEAT_EQUATION_FVM: case DISC_ADJ_HEAT: + // per-surface output to be added soon + break; + default: + break; + } + } + + /*--- Not-per-surface objective functions (shall not be included above) ---*/ + + Weight_ObjFunc = config_container[iZone]->GetWeight_ObjFunc(0); + + switch (config_container[iZone]->GetKind_Solver()) { + + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: + + switch(config_container[iZone]->GetKind_ObjFunc()) { + + // Aerodynamic coefficients + + case DRAG_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("DRAG")*Weight_ObjFunc; + break; + case LIFT_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("LIFT")*Weight_ObjFunc; + break; + case SIDEFORCE_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("SIDEFORCE")*Weight_ObjFunc; + break; + case EFFICIENCY: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("EFFICIENCY")*Weight_ObjFunc; + break; + case MOMENT_X_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("MOMENT-X")*Weight_ObjFunc; + break; + case MOMENT_Y_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("MOMENT-Y")*Weight_ObjFunc; + break; + case MOMENT_Z_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("MOMENT-Z")*Weight_ObjFunc; + break; + case FORCE_X_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("FORCE-X")*Weight_ObjFunc; + break; + case FORCE_Y_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("FORCE-Y")*Weight_ObjFunc; + break; + case FORCE_Z_COEFFICIENT: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("FORCE-Z")*Weight_ObjFunc; + break; + + // Other surface-related output values + + case SURFACE_MASSFLOW: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("AVG_MASSFLOW")*Weight_ObjFunc; + break; + case SURFACE_MACH: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("AVG_MACH")*Weight_ObjFunc; + break; + case SURFACE_UNIFORMITY: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("UNIFORMITY")*Weight_ObjFunc; + break; + case SURFACE_SECONDARY: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("SECONDARY_STRENGTH")*Weight_ObjFunc; + break; + case SURFACE_MOM_DISTORTION: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("MOMENTUM_DISTORTION")*Weight_ObjFunc; + break; + case SURFACE_SECOND_OVER_UNIFORM: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("SECONDARY_OVER_UNIFORMITY")*Weight_ObjFunc; + break; + case TOTAL_AVG_TEMPERATURE: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("AVG_TOTALTEMP")*Weight_ObjFunc; + break; + case SURFACE_TOTAL_PRESSURE: + ObjFunc+=direct_output[iZone]->GetHistoryFieldValue("AVG_TOTALPRESS")*Weight_ObjFunc; + break; + + // Not yet covered by new output structure. Be careful these use MARKER_MONITORING. + + case SURFACE_PRESSURE_DROP: + ObjFunc+=config_container[iZone]->GetSurface_PressureDrop(0)*Weight_ObjFunc; + break; + case SURFACE_STATIC_PRESSURE: + ObjFunc+=config_container[iZone]->GetSurface_Pressure(0)*Weight_ObjFunc; + break; + case TOTAL_HEATFLUX: + ObjFunc += solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->GetTotal_HeatFlux()*Weight_ObjFunc; + break; + + default: + cout << "Objective function not covered for discrete adjoint multiphysics." << endl; + break; + } + break; + + case DISC_ADJ_HEAT: + + switch(config_container[iZone]->GetKind_ObjFunc()) { + + // Not yet covered by new output structure. Be careful these use MARKER_MONITORING. + + case TOTAL_HEATFLUX: + ObjFunc += solver_container[iZone][INST_0][MESH_0][HEAT_SOL]->GetTotal_HeatFlux()*Weight_ObjFunc; + break; + case TOTAL_AVG_TEMPERATURE: + ObjFunc += solver_container[iZone][INST_0][MESH_0][HEAT_SOL]->GetTotal_AvgTemperature()*Weight_ObjFunc; + break; + + default: + cout << "Objective function not covered for discrete adjoint multiphysics." << endl; + break; + } + break; + + default: + break; + } + } + + if (rank == MASTER_NODE) { + AD::RegisterOutput(ObjFunc); + AD::SetAdjIndex(ObjFunc_Index, ObjFunc); + if (rank == MASTER_NODE && kind_recording == FLOW_CONS_VARS) { + + cout << " Objective function : " << ObjFunc << " (" << ObjFunc_Index << ")" << endl; + } + } +} + +void CDiscAdjMultizoneDriver::SetAdj_ObjFunction() { + + bool TimeDomain = config_container[ZONE_0]->GetTime_Marching() != STEADY; + unsigned long IterAvg_Obj = config_container[ZONE_0]->GetIter_Avg_Objective(); + + su2double seeding = 1.0; + + if (TimeDomain){ + if (TimeIter < IterAvg_Obj){ + seeding = 1.0/((su2double)IterAvg_Obj); + } + else{ + seeding = 0.0; + } + } + + if (rank == MASTER_NODE) { + AD::SetDerivative(ObjFunc_Index, SU2_TYPE::GetValue(seeding)); + } +} + +void CDiscAdjMultizoneDriver::ComputeAdjoints(unsigned short iZone) { + + unsigned short enter_izone = iZone*2+1 + ITERATION_READY; + unsigned short leave_izone = iZone*2 + ITERATION_READY; + + AD::ClearAdjoints(); + + /*--- Initialize the adjoints in iZone ---*/ + + iteration_container[iZone][INST_0]->InitializeAdjoint(solver_container, geometry_container, + config_container, iZone, INST_0); + + /*--- Interpret the stored information by calling the corresponding routine of the AD tool. ---*/ + + AD::ComputeAdjoint(enter_izone, leave_izone); + + AD::ComputeAdjoint(TRANSFER, OBJECTIVE_FUNCTION); + AD::ComputeAdjoint(DEPENDENCIES, START); +} + +void CDiscAdjMultizoneDriver::Add_ExternalOld_To_Solution(unsigned short iZone) { + + unsigned short iSol; + + for (iSol=0; iSol < MAX_SOLS; iSol++){ + if (solver_container[iZone][INST_0][MESH_0][iSol] != NULL) { + if (solver_container[iZone][INST_0][MESH_0][iSol]->GetAdjoint()) { + solver_container[iZone][INST_0][MESH_0][iSol]->Add_ExternalOld_To_Solution(geometry_container[iZone][INST_0][MESH_0]); + } + } + } +} + +void CDiscAdjMultizoneDriver::SetExternal_Zero(void) { + + unsigned short iZone, iSol; + + for(iZone=0; iZone < nZone; iZone++) { + + for (iSol=0; iSol < MAX_SOLS; iSol++){ + if (solver_container[iZone][INST_0][MESH_0][iSol] != NULL) { + if (solver_container[iZone][INST_0][MESH_0][iSol]->GetAdjoint()) { + solver_container[iZone][INST_0][MESH_0][iSol]->GetNodes()->SetExternalZero(); + } + } + } + } +} + +void CDiscAdjMultizoneDriver::Set_OldExternal(void) { + + unsigned short iZone, iSol; + + for(iZone=0; iZone < nZone; iZone++) { + + for (iSol=0; iSol < MAX_SOLS; iSol++){ + if (solver_container[iZone][INST_0][MESH_0][iSol] != NULL) { + if (solver_container[iZone][INST_0][MESH_0][iSol]->GetAdjoint()) { + solver_container[iZone][INST_0][MESH_0][iSol]->GetNodes()->Set_OldExternal(); + } + } + } + } +} + +void CDiscAdjMultizoneDriver::Add_Solution_To_External(unsigned short iZone) { + + unsigned short iSol; + + for (iSol=0; iSol < MAX_SOLS; iSol++){ + if (solver_container[iZone][INST_0][MESH_0][iSol] != NULL) { + if (solver_container[iZone][INST_0][MESH_0][iSol]->GetAdjoint()) { + solver_container[iZone][INST_0][MESH_0][iSol]->Add_Solution_To_External(geometry_container[iZone][INST_0][MESH_0]); + } + } + } +} + +void CDiscAdjMultizoneDriver::Add_Solution_To_ExternalOld(unsigned short iZone) { + + unsigned short iSol; + + for (iSol=0; iSol < MAX_SOLS; iSol++){ + if (solver_container[iZone][INST_0][MESH_0][iSol] != NULL) { + if (solver_container[iZone][INST_0][MESH_0][iSol]->GetAdjoint()) { + solver_container[iZone][INST_0][MESH_0][iSol]->Add_Solution_To_ExternalOld(geometry_container[iZone][INST_0][MESH_0]); + } + } + } +} + +void CDiscAdjMultizoneDriver::Set_BGSSolution(unsigned short iZone) { + + unsigned short iSol; + + for (iSol=0; iSol < MAX_SOLS; iSol++){ + if (solver_container[iZone][INST_0][MESH_0][iSol] != NULL) { + if (solver_container[iZone][INST_0][MESH_0][iSol]->GetAdjoint()) { + solver_container[iZone][INST_0][MESH_0][iSol]->UpdateSolution_BGS(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone]); + } + } + } +} + +void CDiscAdjMultizoneDriver::SetResidual_BGS(unsigned short iZone) { + + unsigned short iSol; + + for (iSol=0; iSol < MAX_SOLS; iSol++){ + if (solver_container[iZone][INST_0][MESH_0][iSol] != NULL) { + if (solver_container[iZone][INST_0][MESH_0][iSol]->GetAdjoint()) { + solver_container[iZone][INST_0][MESH_0][iSol]->ComputeResidual_Multizone(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone]); + } + } + } +} diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 60affee71a62..926e92796bc2 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -570,7 +570,7 @@ void CDriver::Input_Preprocessing(CConfig **&config, CConfig *&driver_config) { /*--- Initialize the configuration of the driver ---*/ - driver_config = new CConfig(config_file_name, SU2_CFD, nZone, false); + driver_config = new CConfig(config_file_name, SU2_CFD, false); for (iZone = 0; iZone < nZone; iZone++) { @@ -1928,7 +1928,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol case FEM_NAVIER_STOKES: case DISC_ADJ_FEM_NS : compressible =true; fem_ns = true; break; case FEM_RANS : case DISC_ADJ_FEM_RANS : compressible =true; fem_ns = true; fem_turbulent = true; break; case FEM_LES : compressible =true; fem_ns = true; break; - case HEAT_EQUATION_FVM: heat_fvm = true; break; + case HEAT_EQUATION_FVM: case DISC_ADJ_HEAT: heat_fvm = true; break; case FEM_ELASTICITY: case DISC_ADJ_FEM: fem = true; break; case ADJ_EULER : compressible =true; euler = true; adj_euler = true; break; case ADJ_NAVIER_STOKES : compressible =true; ns = true; turbulent = (config->GetKind_Turb_Model() != NONE); adj_ns = true; break; @@ -4593,11 +4593,11 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { for (iVar = 0; iVar < nVar; iVar++) { if (!adjoint) { - U[iVar] = solver_container[ZONE_0][jInst][iMGlevel][FLOW_SOL]->node[iPoint]->GetSolution(iVar); + U[iVar] = solver_container[ZONE_0][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source[iVar] += U[iVar]*D[iInst][jInst]; if (implicit) { - U_old[iVar] = solver_container[ZONE_0][jInst][iMGlevel][FLOW_SOL]->node[iPoint]->GetSolution_Old(iVar); + U_old[iVar] = solver_container[ZONE_0][jInst][iMGlevel][FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); deltaU = U[iVar] - U_old[iVar]; Source[iVar] += deltaU*D[iInst][jInst]; } @@ -4605,11 +4605,11 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { } else { - Psi[iVar] = solver_container[ZONE_0][jInst][iMGlevel][ADJFLOW_SOL]->node[iPoint]->GetSolution(iVar); + Psi[iVar] = solver_container[ZONE_0][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source[iVar] += Psi[iVar]*D[jInst][iInst]; if (implicit) { - Psi_old[iVar] = solver_container[ZONE_0][jInst][iMGlevel][ADJFLOW_SOL]->node[iPoint]->GetSolution_Old(iVar); + Psi_old[iVar] = solver_container[ZONE_0][jInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->GetSolution_Old(iPoint, iVar); deltaPsi = Psi[iVar] - Psi_old[iVar]; Source[iVar] += deltaPsi*D[jInst][iInst]; } @@ -4619,10 +4619,10 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { /*--- Store sources for current row ---*/ for (iVar = 0; iVar < nVar; iVar++) { if (!adjoint) { - solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->node[iPoint]->SetHarmonicBalance_Source(iVar, Source[iVar]); + solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); } else { - solver_container[ZONE_0][iInst][iMGlevel][ADJFLOW_SOL]->node[iPoint]->SetHarmonicBalance_Source(iVar, Source[iVar]); + solver_container[ZONE_0][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iVar]); } } @@ -4646,14 +4646,14 @@ void CHBDriver::SetHarmonicBalance(unsigned short iInst) { /*--- Retrieve solution at this node in current zone ---*/ for (iVar = 0; iVar < nVar_Turb; iVar++) { - U_Turb[iVar] = solver_container[ZONE_0][jInst][MESH_0][TURB_SOL]->node[iPoint]->GetSolution(iVar); + U_Turb[iVar] = solver_container[ZONE_0][jInst][MESH_0][TURB_SOL]->GetNodes()->GetSolution(iPoint, iVar); Source_Turb[iVar] += U_Turb[iVar]*D[iInst][jInst]; } } /*--- Store sources for current iZone ---*/ for (iVar = 0; iVar < nVar_Turb; iVar++) - solver_container[ZONE_0][iInst][MESH_0][TURB_SOL]->node[iPoint]->SetHarmonicBalance_Source(iVar, Source_Turb[iVar]); + solver_container[ZONE_0][iInst][MESH_0][TURB_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source_Turb[iVar]); } delete [] U_Turb; @@ -4694,7 +4694,7 @@ void CHBDriver::StabilizeHarmonicBalance() { for (iPoint = 0; iPoint < geometry_container[ZONE_0][INST_0][iMGlevel]->GetnPoint(); iPoint++) { /*--- Get time step for current node ---*/ - Delta = solver_container[ZONE_0][INST_0][iMGlevel][FLOW_SOL]->node[iPoint]->GetDelta_Time(); + Delta = solver_container[ZONE_0][INST_0][iMGlevel][FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); /*--- Setup stabilization matrix for this node ---*/ for (iInst = 0; iInst < nInstHB; iInst++) { @@ -4793,7 +4793,7 @@ void CHBDriver::StabilizeHarmonicBalance() { /*--- Get current source terms (not yet preconditioned) and zero source array to prepare preconditioning ---*/ for (iInst = 0; iInst < nInstHB; iInst++) { - Source_old[iInst] = solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->node[iPoint]->GetHarmonicBalance_Source(iVar); + Source_old[iInst] = solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->GetHarmonicBalance_Source(iPoint, iVar); Source[iInst] = 0; } @@ -4805,10 +4805,10 @@ void CHBDriver::StabilizeHarmonicBalance() { /*--- Store updated source terms for current node ---*/ if (!adjoint) { - solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->node[iPoint]->SetHarmonicBalance_Source(iVar, Source[iInst]); + solver_container[ZONE_0][iInst][iMGlevel][FLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); } else { - solver_container[ZONE_0][iInst][iMGlevel][ADJFLOW_SOL]->node[iPoint]->SetHarmonicBalance_Source(iVar, Source[iInst]); + solver_container[ZONE_0][iInst][iMGlevel][ADJFLOW_SOL]->GetNodes()->SetHarmonicBalance_Source(iPoint, iVar, Source[iInst]); } } @@ -5297,13 +5297,11 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Push solution back to correct array ---*/ for (iMesh=0; iMesh<=config_container[ZONE_FLOW]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n1(); - if (turbulent) { - solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n1(); - } + solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(); + if (turbulent) { + solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(); } } } @@ -5316,11 +5314,9 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Push solution back to correct array ---*/ for (iMesh=0; iMesh<=config_container[ZONE_FLOW]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - if (turbulent) { - solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(); - } + solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + if (turbulent) { + solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); } } } @@ -5341,11 +5337,9 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Temporarily store the loaded solution in the Solution_Old array ---*/ for (iMesh=0; iMesh<=config_container[ZONE_FLOW]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->Set_OldSolution(); - if (turbulent){ - solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->Set_OldSolution(); - } + solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->Set_OldSolution(); + if (turbulent){ + solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->Set_OldSolution(); } } @@ -5353,9 +5347,9 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, for (iMesh=0; iMesh<=config_container[ZONE_FLOW]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->SetSolution(solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->GetSolution_time_n()); + solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->GetSolution_time_n(iPoint)); if (turbulent) { - solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->SetSolution(solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->GetSolution_time_n()); + solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->SetSolution(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->GetSolution_time_n(iPoint)); } } } @@ -5363,9 +5357,9 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Set Solution at timestep n-1 to the previously loaded solution ---*/ for (iMesh=0; iMesh<=config_container[ZONE_FLOW]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->GetSolution_time_n1()); + solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); if (turbulent) { - solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->GetSolution_time_n1()); + solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); } } } @@ -5374,18 +5368,18 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Set Solution at timestep n-1 to solution at n-2 ---*/ for (iMesh=0; iMesh<=config_container[ZONE_FLOW]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->GetSolution_time_n1()); + solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); if (turbulent) { - solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->GetSolution_time_n1()); + solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); } } } /*--- Set Solution at timestep n-2 to the previously loaded solution ---*/ for (iMesh=0; iMesh<=config_container[ZONE_FLOW]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n1(solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->GetSolution_Old()); + solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint)); if (turbulent) { - solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n1(solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->node[iPoint]->GetSolution_Old()); + solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][TURB_SOL]->GetNodes()->GetSolution_Old(iPoint)); } } } @@ -5402,12 +5396,12 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, for (iMesh=0; iMesh<=config_container[ZONE_FLOW]->GetnMGLevels();iMesh++) { for (iPoint = 0; iPoint < geometry_container[ZONE_FLOW][INST_0][iMesh]->GetnPoint(); iPoint++) { - solver_container[ZONE_FLOW][INST_0][iMesh][ADJFLOW_SOL]->node[iPoint]->SetSolution_Direct(solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->node[iPoint]->GetSolution()); + solver_container[ZONE_FLOW][INST_0][iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver_container[ZONE_FLOW][INST_0][iMesh][FLOW_SOL]->GetNodes()->GetSolution(iPoint)); } } if (turbulent && !config_container[ZONE_FLOW]->GetFrozen_Visc_Disc()) { for (iPoint = 0; iPoint < geometry_container[ZONE_FLOW][INST_0][MESH_0]->GetnPoint(); iPoint++) { - solver_container[ZONE_FLOW][INST_0][MESH_0][ADJTURB_SOL]->node[iPoint]->SetSolution_Direct(solver_container[ZONE_FLOW][INST_0][MESH_0][TURB_SOL]->node[iPoint]->GetSolution()); + solver_container[ZONE_FLOW][INST_0][MESH_0][ADJTURB_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver_container[ZONE_FLOW][INST_0][MESH_0][TURB_SOL]->GetNodes()->GetSolution(iPoint)); } } } @@ -5415,7 +5409,7 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Store geometry of the converged solution also in the adjoint solver in order to be able to reset it later ---*/ for (iPoint = 0; iPoint < geometry_container[ZONE_FLOW][INST_0][MESH_0]->GetnPoint(); iPoint++){ - solver_container[ZONE_FLOW][INST_0][MESH_0][ADJFLOW_SOL]->node[iPoint]->SetGeometry_Direct(geometry_container[ZONE_FLOW][INST_0][MESH_0]->node[iPoint]->GetCoord()); + solver_container[ZONE_FLOW][INST_0][MESH_0][ADJFLOW_SOL]->GetNodes()->SetGeometry_Direct(iPoint, geometry_container[ZONE_FLOW][INST_0][MESH_0]->node[iPoint]->GetCoord()); } } @@ -5445,21 +5439,15 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Push solution back to correct array ---*/ - for(iPoint=0; iPointGetnPoint();iPoint++){ - solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->node[iPoint]->Set_Solution_time_n(); - } + solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->GetNodes()->Set_Solution_time_n(); /*--- Push solution back to correct array ---*/ - for(iPoint=0; iPointGetnPoint();iPoint++){ - solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Accel_time_n(); - } + solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Accel_time_n(); /*--- Push solution back to correct array ---*/ - for(iPoint=0; iPointGetnPoint();iPoint++){ - solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Vel_time_n(); - } + solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Vel_time_n(); /*--- Load solution timestep n ---*/ @@ -5468,15 +5456,15 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ for (iPoint = 0; iPoint < geometry_container[ZONE_STRUCT][INST_0][MESH_0]->GetnPoint(); iPoint++){ - solver_container[ZONE_STRUCT][INST_0][MESH_0][ADJFEA_SOL]->node[iPoint]->SetSolution_Direct(solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->node[iPoint]->GetSolution()); + solver_container[ZONE_STRUCT][INST_0][MESH_0][ADJFEA_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->GetNodes()->GetSolution(iPoint)); } for (iPoint = 0; iPoint < geometry_container[ZONE_STRUCT][INST_0][MESH_0]->GetnPoint(); iPoint++){ - solver_container[ZONE_STRUCT][INST_0][MESH_0][ADJFEA_SOL]->node[iPoint]->SetSolution_Accel_Direct(solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Accel()); + solver_container[ZONE_STRUCT][INST_0][MESH_0][ADJFEA_SOL]->GetNodes()->SetSolution_Accel_Direct(iPoint, solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->GetNodes()->GetSolution_Accel(iPoint)); } for (iPoint = 0; iPoint < geometry_container[ZONE_STRUCT][INST_0][MESH_0]->GetnPoint(); iPoint++){ - solver_container[ZONE_STRUCT][INST_0][MESH_0][ADJFEA_SOL]->node[iPoint]->SetSolution_Vel_Direct(solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Vel()); + solver_container[ZONE_STRUCT][INST_0][MESH_0][ADJFEA_SOL]->GetNodes()->SetSolution_Vel_Direct(iPoint, solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->GetNodes()->GetSolution_Vel(iPoint)); } } @@ -5487,7 +5475,7 @@ void CDiscAdjFSIDriver::Preprocess(unsigned short ZONE_FLOW, /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ for (iPoint = 0; iPoint < geometry_container[ZONE_STRUCT][INST_0][MESH_0]->GetnPoint(); iPoint++){ - solver_container[ZONE_STRUCT][INST_0][MESH_0][ADJFEA_SOL]->node[iPoint]->SetSolution_Direct(solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->node[iPoint]->GetSolution()); + solver_container[ZONE_STRUCT][INST_0][MESH_0][ADJFEA_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver_container[ZONE_STRUCT][INST_0][MESH_0][FEA_SOL]->GetNodes()->GetSolution(iPoint)); } } @@ -6223,9 +6211,8 @@ bool CDiscAdjFSIDriver::CheckConvergence(unsigned long IntIter, unsigned short kind_recording){ bool flow_convergence = false, - struct_convergence = false; - - bool adjoint_convergence = false; + struct_convergence = false, + adjoint_convergence = false; // su2double residual_1, residual_2; diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 4485732a3fa9..4b14df45f0fe 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -538,7 +538,7 @@ void CMultizoneDriver::DynamicMeshUpdate(unsigned long TimeIter) { void CMultizoneDriver::DynamicMeshUpdate(unsigned short val_iZone, unsigned long TimeIter) { /*--- Legacy dynamic mesh update - Only if GRID_MOVEMENT = YES ---*/ - if (config_container[ZONE_0]->GetGrid_Movement()) { + if (config_container[ZONE_0]->GetGrid_Movement() || config_container[ZONE_0]->GetSurface_Movement(FLUID_STRUCTURE_STATIC)) { iteration_container[val_iZone][INST_0]->SetGrid_Movement(geometry_container[val_iZone][INST_0],surface_movement[val_iZone], grid_movement[val_iZone][INST_0], solver_container[val_iZone][INST_0], config_container[val_iZone], 0, TimeIter); diff --git a/SU2_CFD/src/integration_structure.cpp b/SU2_CFD/src/integration_structure.cpp index 2fa8814dc77c..606c6ca7143a 100644 --- a/SU2_CFD/src/integration_structure.cpp +++ b/SU2_CFD/src/integration_structure.cpp @@ -311,8 +311,9 @@ void CIntegration::Adjoint_Setup(CGeometry ****geometry, CSolver *****solver_con if (iMGLevel != config[iZone]->GetnMGLevels()) { SetRestricted_Solution(RUNTIME_FLOW_SYS, solver_container[iZone][INST_0][iMGLevel][FLOW_SOL], solver_container[iZone][INST_0][iMGLevel+1][FLOW_SOL], geometry[iZone][INST_0][iMGLevel], geometry[iZone][INST_0][iMGLevel+1], config[iZone]); - SetRestricted_Gradient(RUNTIME_FLOW_SYS, solver_container[iZone][INST_0][iMGLevel][FLOW_SOL], solver_container[iZone][INST_0][iMGLevel+1][FLOW_SOL], - geometry[iZone][INST_0][iMGLevel], geometry[iZone][INST_0][iMGLevel+1], config[iZone]); +// ToDo: The flow solvers do not use the conservative variable gradients +// SetRestricted_Gradient(RUNTIME_FLOW_SYS, solver_container[iZone][INST_0][iMGLevel][FLOW_SOL], solver_container[iZone][INST_0][iMGLevel+1][FLOW_SOL], +// geometry[iZone][INST_0][iMGLevel], geometry[iZone][INST_0][iMGLevel+1], config[iZone]); } } @@ -441,12 +442,13 @@ void CIntegration::Time_Integration_FEM(CGeometry *geometry, CSolver **solver_co void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) { + unsigned long iPoint; - + + solver->GetNodes()->Set_Solution_time_n1(); + solver->GetNodes()->Set_Solution_time_n(); + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - solver->node[iPoint]->Set_Solution_time_n1(); - solver->node[iPoint]->Set_Solution_time_n(); - geometry->node[iPoint]->SetVolume_nM1(); geometry->node[iPoint]->SetVolume_n(); @@ -529,36 +531,27 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon } void CIntegration::SetStructural_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) { - - unsigned long iPoint; - - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - - solver->node[iPoint]->Set_Solution_time_n(); - solver->node[iPoint]->SetSolution_Vel_time_n(); - solver->node[iPoint]->SetSolution_Accel_time_n(); - - } - + + solver->GetNodes()->Set_Solution_time_n(); + solver->GetNodes()->SetSolution_Vel_time_n(); + solver->GetNodes()->SetSolution_Accel_time_n(); + bool fsi = config->GetFSI_Simulation(); - + /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ - + if (fsi) { - + su2double WAitk=0.0; - + WAitk = solver->GetWAitken_Dyn(); solver->SetWAitken_Dyn_tn1(WAitk); - + } - - } void CIntegration::SetFEM_StructuralSolver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { - - unsigned long iPoint; + bool fsi = config->GetFSI_Simulation(); /*--- Update the solution according to the integration scheme used ---*/ @@ -575,25 +568,21 @@ void CIntegration::SetFEM_StructuralSolver(CGeometry *geometry, CSolver **solver solver_container[FEA_SOL]->GeneralizedAlpha_UpdateLoads(geometry, solver_container, config); break; } - + /*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/ - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - - solver_container[FEA_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[FEA_SOL]->node[iPoint]->SetSolution_Vel_time_n(); - solver_container[FEA_SOL]->node[iPoint]->SetSolution_Accel_time_n(); - - } - + + solver_container[FEA_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[FEA_SOL]->GetNodes()->SetSolution_Vel_time_n(); + solver_container[FEA_SOL]->GetNodes()->SetSolution_Accel_time_n(); + /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ - + if (fsi) { - + su2double WAitk=0.0; - + WAitk = solver_container[FEA_SOL]->GetWAitken_Dyn(); solver_container[FEA_SOL]->SetWAitken_Dyn_tn1(WAitk); - + } - } diff --git a/SU2_CFD/src/integration_time.cpp b/SU2_CFD/src/integration_time.cpp index 78b93d3fecc6..6f7602073fcd 100644 --- a/SU2_CFD/src/integration_time.cpp +++ b/SU2_CFD/src/integration_time.cpp @@ -254,18 +254,18 @@ void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqS for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); Area_Children = geo_fine->node[Point_Fine]->GetVolume(); - Solution_Fine = sol_fine->node[Point_Fine]->GetSolution(); + Solution_Fine = sol_fine->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] -= Solution_Fine[iVar]*Area_Children/Area_Parent; } - Solution_Coarse = sol_coarse->node[Point_Coarse]->GetSolution(); + Solution_Coarse = sol_coarse->GetNodes()->GetSolution(Point_Coarse); for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] += Solution_Coarse[iVar]; for (iVar = 0; iVar < nVar; iVar++) - sol_coarse->node[Point_Coarse]->SetSolution_Old(Solution); + sol_coarse->GetNodes()->SetSolution_Old(Point_Coarse,Solution); } @@ -284,7 +284,7 @@ void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqS /*--- For dirichlet boundary condtions, set the correction to zero. Note that Solution_Old stores the correction not the actual value ---*/ - sol_coarse->node[Point_Coarse]->SetVelSolutionOldZero(); + sol_coarse->GetNodes()->SetVelSolutionOldZero(Point_Coarse); } @@ -299,7 +299,7 @@ void CMultiGridIntegration::GetProlongated_Correction(unsigned short RunTime_EqS for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); - sol_fine->LinSysRes.SetBlock(Point_Fine, sol_coarse->node[Point_Coarse]->GetSolution_Old()); + sol_fine->LinSysRes.SetBlock(Point_Fine, sol_coarse->GetNodes()->GetSolution_Old(Point_Coarse)); } } @@ -321,14 +321,13 @@ void CMultiGridIntegration::SmoothProlongated_Correction (unsigned short RunTime for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Residual_Old = solver->LinSysRes.GetBlock(iPoint); - solver->node[iPoint]->SetResidual_Old(Residual_Old); + solver->GetNodes()->SetResidual_Old(iPoint,Residual_Old); } /*--- Jacobi iterations ---*/ for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) - solver->node[iPoint]->SetResidualSumZero(); + solver->GetNodes()->SetResidualSumZero(); /*--- Loop over Interior edges ---*/ @@ -341,16 +340,16 @@ void CMultiGridIntegration::SmoothProlongated_Correction (unsigned short RunTime /*--- Accumulate nearest neighbor Residual to Res_sum for each variable ---*/ - solver->node[iPoint]->AddResidual_Sum(Residual_j); - solver->node[jPoint]->AddResidual_Sum(Residual_i); + solver->GetNodes()->AddResidual_Sum(iPoint,Residual_j); + solver->GetNodes()->AddResidual_Sum(jPoint,Residual_i); } /*--- Loop over all mesh points (Update Residuals with averaged sum) ---*/ for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { nneigh = geometry->node[iPoint]->GetnPoint(); - Residual_Sum = solver->node[iPoint]->GetResidual_Sum(); - Residual_Old = solver->node[iPoint]->GetResidual_Old(); + Residual_Sum = solver->GetNodes()->GetResidual_Sum(iPoint); + Residual_Old = solver->GetNodes()->GetResidual_Old(iPoint); for (iVar = 0; iVar < nVar; iVar++) { Residual[iVar] =(Residual_Old[iVar] + val_smooth_coeff*Residual_Sum[iVar]) /(1.0 + val_smooth_coeff*su2double(nneigh)); @@ -365,7 +364,7 @@ void CMultiGridIntegration::SmoothProlongated_Correction (unsigned short RunTime (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Residual_Old = solver->node[iPoint]->GetResidual_Old(); + Residual_Old = solver->GetNodes()->GetResidual_Old(iPoint); solver->LinSysRes.SetBlock(iPoint, Residual_Old); } } @@ -389,15 +388,14 @@ void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSo Solution = new su2double [nVar]; for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - Solution_Old = solver->node[iPoint]->GetSolution(); - solver->node[iPoint]->SetResidual_Old(Solution_Old); + Solution_Old = solver->GetNodes()->GetSolution(iPoint); + solver->GetNodes()->SetResidual_Old(iPoint,Solution_Old); } /*--- Jacobi iterations ---*/ for (iSmooth = 0; iSmooth < val_nSmooth; iSmooth++) { - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) - solver->node[iPoint]->SetResidualSumZero(); + solver->GetNodes()->SetResidualSumZero(); /*--- Loop over Interior edges ---*/ @@ -405,26 +403,26 @@ void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSo iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Solution_i = solver->node[iPoint]->GetSolution(); - Solution_j = solver->node[jPoint]->GetSolution(); + Solution_i = solver->GetNodes()->GetSolution(iPoint); + Solution_j = solver->GetNodes()->GetSolution(jPoint); /*--- Accumulate nearest neighbor Residual to Res_sum for each variable ---*/ - solver->node[iPoint]->AddResidual_Sum(Solution_j); - solver->node[jPoint]->AddResidual_Sum(Solution_i); + solver->GetNodes()->AddResidual_Sum(iPoint,Solution_j); + solver->GetNodes()->AddResidual_Sum(jPoint,Solution_i); } /*--- Loop over all mesh points (Update Residuals with averaged sum) ---*/ for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { nneigh = geometry->node[iPoint]->GetnPoint(); - Solution_Sum = solver->node[iPoint]->GetResidual_Sum(); - Solution_Old = solver->node[iPoint]->GetResidual_Old(); + Solution_Sum = solver->GetNodes()->GetResidual_Sum(iPoint); + Solution_Old = solver->GetNodes()->GetResidual_Old(iPoint); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] =(Solution_Old[iVar] + val_smooth_coeff*Solution_Sum[iVar]) /(1.0 + val_smooth_coeff*su2double(nneigh)); } - solver->node[iPoint]->SetSolution(Solution); + solver->GetNodes()->SetSolution(iPoint,Solution); } /*--- Copy boundary values ---*/ @@ -434,8 +432,8 @@ void CMultiGridIntegration::Smooth_Solution(unsigned short RunTime_EqSystem, CSo (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Solution_Old = solver->node[iPoint]->GetResidual_Old(); - solver->node[iPoint]->SetSolution(Solution_Old); + Solution_Old = solver->GetNodes()->GetResidual_Old(iPoint); + solver->GetNodes()->SetSolution(iPoint,Solution_Old); } } } @@ -458,13 +456,13 @@ void CMultiGridIntegration::SetProlongated_Correction(CSolver *sol_fine, CGeomet for (Point_Fine = 0; Point_Fine < geo_fine->GetnPointDomain(); Point_Fine++) { Residual_Fine = sol_fine->LinSysRes.GetBlock(Point_Fine); - Solution_Fine = sol_fine->node[Point_Fine]->GetSolution(); + Solution_Fine = sol_fine->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { /*--- Prevent a fine grid divergence due to a coarse grid divergence ---*/ if (Residual_Fine[iVar] != Residual_Fine[iVar]) Residual_Fine[iVar] = 0.0; Solution[iVar] = Solution_Fine[iVar]+factor*Residual_Fine[iVar]; } - sol_fine->node[Point_Fine]->SetSolution(Solution); + sol_fine->GetNodes()->SetSolution(Point_Fine,Solution); } /*--- MPI the new interpolated solution ---*/ @@ -483,7 +481,7 @@ void CMultiGridIntegration::SetProlongated_Solution(unsigned short RunTime_EqSys for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); - sol_fine->node[Point_Fine]->SetSolution(sol_coarse->node[Point_Coarse]->GetSolution()); + sol_fine->GetNodes()->SetSolution(Point_Fine, sol_coarse->GetNodes()->GetSolution(Point_Coarse)); } } } @@ -499,7 +497,7 @@ void CMultiGridIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coar su2double *Residual = new su2double[nVar]; for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - sol_coarse->node[Point_Coarse]->SetRes_TruncErrorZero(); + sol_coarse->GetNodes()->SetRes_TruncErrorZero(Point_Coarse); for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { @@ -508,7 +506,7 @@ void CMultiGridIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coar for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] += factor*Residual_Fine[iVar]; } - sol_coarse->node[Point_Coarse]->AddRes_TruncError(Residual); + sol_coarse->GetNodes()->AddRes_TruncError(Point_Coarse,Residual); } for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -517,13 +515,13 @@ void CMultiGridIntegration::SetForcing_Term(CSolver *sol_fine, CSolver *sol_coar (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE )) { for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) { Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); - sol_coarse->node[Point_Coarse]->SetVel_ResTruncError_Zero(); + sol_coarse->GetNodes()->SetVel_ResTruncError_Zero(Point_Coarse); } } } for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - sol_coarse->node[Point_Coarse]->SubtractRes_TruncError(sol_coarse->LinSysRes.GetBlock(Point_Coarse)); + sol_coarse->GetNodes()->SubtractRes_TruncError(Point_Coarse, sol_coarse->LinSysRes.GetBlock(Point_Coarse)); } delete [] Residual; @@ -533,7 +531,7 @@ void CMultiGridIntegration::SetResidual_Term(CGeometry *geometry, CSolver *solve unsigned long iPoint; for (iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) - solver->LinSysRes.AddBlock(iPoint, solver->node[iPoint]->GetResTruncError()); + solver->LinSysRes.AddBlock(iPoint, solver->GetNodes()->GetResTruncError(iPoint)); } @@ -547,7 +545,7 @@ void CMultiGridIntegration::SetRestricted_Residual(CSolver *sol_fine, CSolver *s su2double *Residual = new su2double[nVar]; for (Point_Coarse = 0; Point_Coarse < geo_coarse->GetnPointDomain(); Point_Coarse++) { - sol_coarse->node[Point_Coarse]->SetRes_TruncErrorZero(); + sol_coarse->GetNodes()->SetRes_TruncErrorZero(Point_Coarse); for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { @@ -556,7 +554,7 @@ void CMultiGridIntegration::SetRestricted_Residual(CSolver *sol_fine, CSolver *s for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] += Residual_Fine[iVar]; } - sol_coarse->node[Point_Coarse]->AddRes_TruncError(Residual); + sol_coarse->GetNodes()->AddRes_TruncError(Point_Coarse,Residual); } for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { @@ -565,7 +563,7 @@ void CMultiGridIntegration::SetRestricted_Residual(CSolver *sol_fine, CSolver *s (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE )) { for (iVertex = 0; iVertexnVertex[iMarker]; iVertex++) { Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); - sol_coarse->node[Point_Coarse]->SetVel_ResTruncError_Zero(); + sol_coarse->GetNodes()->SetVel_ResTruncError_Zero(Point_Coarse); } } } @@ -596,13 +594,13 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); Area_Children = geo_fine->node[Point_Fine]->GetVolume(); - Solution_Fine = sol_fine->node[Point_Fine]->GetSolution(); + Solution_Fine = sol_fine->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - sol_coarse->node[Point_Coarse]->SetSolution(Solution); + sol_coarse->GetNodes()->SetSolution(Point_Coarse,Solution); } @@ -623,19 +621,19 @@ void CMultiGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSyst if (grid_movement) { Grid_Vel = geo_coarse->node[Point_Coarse]->GetGridVel(); for (iDim = 0; iDim < nDim; iDim++) - Vector[iDim] = sol_coarse->node[Point_Coarse]->GetSolution(0)*Grid_Vel[iDim]; - sol_coarse->node[Point_Coarse]->SetVelSolutionVector(Vector); + Vector[iDim] = sol_coarse->GetNodes()->GetSolution(Point_Coarse,0)*Grid_Vel[iDim]; + sol_coarse->GetNodes()->SetVelSolutionVector(Point_Coarse,Vector); } else { /*--- For stationary no-slip walls, set the velocity to zero. ---*/ - sol_coarse->node[Point_Coarse]->SetVelSolutionZero(); + sol_coarse->GetNodes()->SetVelSolutionZero(Point_Coarse); } } if (SolContainer_Position == ADJFLOW_SOL) { - sol_coarse->node[Point_Coarse]->SetVelSolutionDVector(); + sol_coarse->GetNodes()->SetVelSolutionDVector(Point_Coarse); } } @@ -674,13 +672,13 @@ void CMultiGridIntegration::SetRestricted_Gradient(unsigned short RunTime_EqSyst for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); Area_Children = geo_fine->node[Point_Fine]->GetVolume(); - Gradient_fine = sol_fine->node[Point_Fine]->GetGradient(); + Gradient_fine = sol_fine->GetNodes()->GetGradient(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) for (iDim = 0; iDim < nDim; iDim++) Gradient[iVar][iDim] += Gradient_fine[iVar][iDim]*Area_Children/Area_Parent; } - sol_coarse->node[Point_Coarse]->SetGradient(Gradient); + sol_coarse->GetNodes()->SetGradient(Point_Coarse,Gradient); } for (iVar = 0; iVar < nVar; iVar++) @@ -800,12 +798,12 @@ void CSingleGridIntegration::SetRestricted_Solution(unsigned short RunTime_EqSys Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); Area_Children = geo_fine->node[Point_Fine]->GetVolume(); - Solution_Fine = sol_fine->node[Point_Fine]->GetSolution(); + Solution_Fine = sol_fine->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } - sol_coarse->node[Point_Coarse]->SetSolution(Solution); + sol_coarse->GetNodes()->SetSolution(Point_Coarse,Solution); } @@ -834,11 +832,11 @@ void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSys for (iChildren = 0; iChildren < geo_coarse->node[Point_Coarse]->GetnChildren_CV(); iChildren++) { Point_Fine = geo_coarse->node[Point_Coarse]->GetChildren_CV(iChildren); Area_Children = geo_fine->node[Point_Fine]->GetVolume(); - EddyVisc_Fine = sol_fine->node[Point_Fine]->GetmuT(); + EddyVisc_Fine = sol_fine->GetNodes()->GetmuT(Point_Fine); EddyVisc += EddyVisc_Fine*Area_Children/Area_Parent; } - sol_coarse->node[Point_Coarse]->SetmuT(EddyVisc); + sol_coarse->GetNodes()->SetmuT(Point_Coarse,EddyVisc); } @@ -852,7 +850,7 @@ void CSingleGridIntegration::SetRestricted_EddyVisc(unsigned short RunTime_EqSys (config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE )) { for (iVertex = 0; iVertex < geo_coarse->nVertex[iMarker]; iVertex++) { Point_Coarse = geo_coarse->vertex[iMarker][iVertex]->GetNode(); - sol_coarse->node[Point_Coarse]->SetmuT(0); + sol_coarse->GetNodes()->SetmuT(Point_Coarse,0.0); } } } diff --git a/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp b/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp index 91804d930309..aeece59b71e0 100644 --- a/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CConservativeVarsInterface.cpp @@ -65,7 +65,7 @@ void CConservativeVarsInterface::GetDonor_Variable(CSolver *donor_solution, CGeo unsigned short iVar; /*--- Retrieve solution and set it as the donor variable ---*/ - Solution = donor_solution->node[Point_Donor]->GetSolution(); + Solution = donor_solution->GetNodes()->GetSolution(Point_Donor); for (iVar = 0; iVar < nVar; iVar++) Donor_Variable[iVar] = Solution[iVar]; @@ -76,6 +76,6 @@ void CConservativeVarsInterface::SetTarget_Variable(CSolver *target_solution, CG unsigned long Vertex_Target, unsigned long Point_Target) { /*--- Set the target solution with the value of the Target Variable ---*/ - target_solution->node[Point_Target]->SetSolution(Target_Variable); + target_solution->GetNodes()->SetSolution(Point_Target,Target_Variable); } diff --git a/SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp b/SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp index e73596ddaa74..20b3671549be 100644 --- a/SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp +++ b/SU2_CFD/src/interfaces/cfd/CSlidingInterface.cpp @@ -99,14 +99,14 @@ void CSlidingInterface::GetDonor_Variable(CSolver *donor_solution, CGeometry *do if (turbulent){ /*--- for turbulent solver retrieve solution and set it as the donor variable ---*/ - Donor_Variable[0] = donor_solution->node[Point_Donor]->GetSolution(0); - Donor_Variable[1] = donor_solution->node[Point_Donor]->GetSolution(1); + Donor_Variable[0] = donor_solution->GetNodes()->GetSolution(Point_Donor,0); + Donor_Variable[1] = donor_solution->GetNodes()->GetSolution(Point_Donor,1); } else{ /*--- Retrieve primitive variables and set them as the donor variables ---*/ for (iVar = 0; iVar < nDonorVar; iVar++) - Donor_Variable[iVar] = donor_solution->node[Point_Donor]->GetPrimitive(iVar); + Donor_Variable[iVar] = donor_solution->GetNodes()->GetPrimitive(Point_Donor,iVar); } } diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index bddd32cb5756..bfd7cfe8874e 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -38,39 +38,31 @@ #include "../../../include/interfaces/cht/CConjugateHeatInterface.hpp" -CConjugateHeatInterface::CConjugateHeatInterface(void) : CInterface() { - -} +CConjugateHeatInterface::CConjugateHeatInterface(void) : CInterface() { } CConjugateHeatInterface::CConjugateHeatInterface(unsigned short val_nVar, unsigned short val_nConst, - CConfig *config) : CInterface(val_nVar, val_nConst, config) { - -} - -CConjugateHeatInterface::~CConjugateHeatInterface(void) { + CConfig *config) : CInterface(val_nVar, val_nConst, config) { } -} +CConjugateHeatInterface::~CConjugateHeatInterface(void) { } void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeometry *donor_geometry, CConfig *donor_config, unsigned long Marker_Donor, unsigned long Vertex_Donor, unsigned long Point_Donor) { - unsigned long iPoint; - unsigned long PointNormal; unsigned short nDim, iDim; + unsigned long iPoint, PointNormal; + + su2double *Coord, *Coord_Normal, *Normal, *Edge_Vector, dist, dist2, Area, + Twall, Tnormal, dTdn, rho_cp_solid, Prandtl_Lam, laminar_viscosity, + thermal_diffusivity, thermal_conductivity=0.0, thermal_conductivityND, + heat_flux_density=0.0, conductivity_over_dist=0.0; nDim = donor_geometry->GetnDim(); - su2double *Coord, *Coord_Normal, *Normal, *Edge_Vector, dist, dist2, Area, Twall = 0.0, Tnormal = 0.0, - dTdn, cp_fluid, rho_cp_solid, Prandtl_Lam, laminar_viscosity, - thermal_diffusivity, thermal_conductivity, thermal_conductivityND, - heat_flux_density, conductivity_over_dist, Temperature_Ref; - su2double Gamma = donor_config->GetGamma(); - su2double Gas_Constant = donor_config->GetGas_ConstantND(); - su2double Cp = (Gamma / (Gamma - 1.0)) * Gas_Constant; Edge_Vector = new su2double[nDim]; /*--- Check whether the current zone is a solid zone or a fluid zone ---*/ + bool flow = ((donor_config->GetKind_Solver() == NAVIER_STOKES) || (donor_config->GetKind_Solver() == RANS) || (donor_config->GetKind_Solver() == DISC_ADJ_NAVIER_STOKES) @@ -79,23 +71,20 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet || (donor_config->GetKind_Solver() == INC_RANS) || (donor_config->GetKind_Solver() == DISC_ADJ_INC_NAVIER_STOKES) || (donor_config->GetKind_Solver() == DISC_ADJ_INC_RANS)); - bool compressible_flow = (donor_config->GetKind_Regime() == COMPRESSIBLE) && flow; - bool incompressible_flow = (donor_config->GetEnergy_Equation()) && flow; - bool heat_equation = donor_config->GetKind_Solver() == HEAT_EQUATION_FVM; - Temperature_Ref = donor_config->GetTemperature_Ref(); - Prandtl_Lam = donor_config->GetPrandtl_Lam(); - laminar_viscosity = donor_config->GetMu_ConstantND(); // TDE check for consistency - cp_fluid = donor_config->GetSpecific_Heat_Cp(); - rho_cp_solid = donor_config->GetSpecific_Heat_Cp_Solid()*donor_config->GetDensity_Solid(); + bool compressible_flow = (donor_config->GetKind_Regime() == COMPRESSIBLE) && flow; + bool incompressible_flow = (donor_config->GetEnergy_Equation()) && flow; + bool heat_equation = (donor_config->GetKind_Solver() == HEAT_EQUATION_FVM + || donor_config->GetKind_Solver() == DISC_ADJ_HEAT); - PointNormal = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNormal_Neighbor(); Coord = donor_geometry->node[Point_Donor]->GetCoord(); - Coord_Normal = donor_geometry->node[PointNormal]->GetCoord(); + Normal = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNormal(); + PointNormal = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNormal_Neighbor(); + Coord_Normal = donor_geometry->node[PointNormal]->GetCoord(); + + Twall = 0.0; Tnormal = 0.0; dTdn = 0.0; dist2 = 0.0; Area = 0.0; - dist2 = 0.0; - Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Edge_Vector[iDim] = Coord_Normal[iDim] - Coord[iDim]; dist2 += Edge_Vector[iDim]*Edge_Vector[iDim]; @@ -104,28 +93,27 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet dist = sqrt(dist2); Area = sqrt(Area); - /*--- Retrieve temperature solution (later set is as the first donor variable) and its gradient ---*/ - - dTdn = 0.0; + /*--- Retrieve temperature solution and its gradient ---*/ if (compressible_flow) { - Twall = donor_solution->node[Point_Donor]->GetPrimitive(0)*Temperature_Ref; - Tnormal = donor_solution->node[PointNormal]->GetPrimitive(0)*Temperature_Ref; + Twall = donor_solution->GetNodes()->GetPrimitive(Point_Donor,0); + Tnormal = donor_solution->GetNodes()->GetPrimitive(PointNormal,0); dTdn = (Twall - Tnormal)/dist; } else if (incompressible_flow) { - Twall = donor_solution->node[Point_Donor]->GetTemperature()*Temperature_Ref; - Tnormal = donor_solution->node[PointNormal]->GetTemperature()*Temperature_Ref; + Twall = donor_solution->GetNodes()->GetTemperature(Point_Donor); + Tnormal = donor_solution->GetNodes()->GetTemperature(PointNormal); dTdn = (Twall - Tnormal)/dist; } - else if (flow || heat_equation) { - Twall = donor_solution->node[Point_Donor]->GetSolution(0)*Temperature_Ref; - Tnormal = donor_solution->node[PointNormal]->GetSolution(0)*Temperature_Ref; + else if (heat_equation) { + Twall = donor_solution->GetNodes()->GetSolution(Point_Donor,0); + Tnormal = donor_solution->GetNodes()->GetSolution(PointNormal,0); + // TODO: Check if these improve accuracy, if needed at all // for (iDim = 0; iDim < nDim; iDim++) { // dTdn += (Twall - Tnormal)/dist * (Edge_Vector[iDim]/dist) * (Normal[iDim]/Area); // } @@ -133,66 +121,85 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet dTdn = (Twall - Tnormal)/dist; } else { - cout << "WARNING: Transfer of conjugate heat variables is called with non-supported donor solver!" << endl; + + SU2_MPI::Error("Transfer of conjugate heat variables failed (non-supported donor solver).", CURRENT_FUNCTION); } - /*--- Calculate the heat flux density (temperature gradient times thermal conductivity) - *--- and set it as second donor variable ---*/ + /*--- Calculate the heat flux density (temperature gradient times thermal conductivity) ---*/ + if (compressible_flow) { - iPoint = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNode(); + su2double Gamma = donor_config->GetGamma(); + su2double Gas_Constant = donor_config->GetGas_ConstantND(); + su2double Cp = (Gamma / (Gamma - 1.0)) * Gas_Constant; + + Prandtl_Lam = donor_config->GetPrandtl_Lam(); + laminar_viscosity = donor_solution->GetNodes()->GetLaminarViscosity(Point_Donor); // TDE check for consistency + Cp = (Gamma / (Gamma - 1.0)) * Gas_Constant; thermal_conductivityND = Cp*(laminar_viscosity/Prandtl_Lam); - thermal_conductivity = thermal_conductivityND*donor_config->GetViscosity_Ref(); + heat_flux_density = thermal_conductivityND*dTdn; - heat_flux_density = thermal_conductivity*dTdn; - conductivity_over_dist = thermal_conductivity/dist; + if (donor_config->GetCHT_Robin()) { + + thermal_conductivity = thermal_conductivityND*donor_config->GetViscosity_Ref(); + conductivity_over_dist = thermal_conductivity/dist; + } } else if (incompressible_flow) { iPoint = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNode(); - thermal_conductivityND = donor_solution->node[iPoint]->GetThermalConductivity(); - thermal_conductivity = thermal_conductivityND*donor_config->GetConductivity_Ref(); + thermal_conductivityND = donor_solution->GetNodes()->GetThermalConductivity(iPoint); + heat_flux_density = thermal_conductivityND*dTdn; - switch (donor_config->GetKind_ConductivityModel()) { + if (donor_config->GetCHT_Robin()) { - case CONSTANT_CONDUCTIVITY: - thermal_conductivity = thermal_conductivityND*donor_config->GetConductivity_Ref(); - break; + switch (donor_config->GetKind_ConductivityModel()) { - case CONSTANT_PRANDTL: - thermal_conductivity = thermal_conductivityND*donor_config->GetGas_Constant_Ref() - *donor_config->GetViscosity_Ref(); - break; - } + case CONSTANT_CONDUCTIVITY: + thermal_conductivity = thermal_conductivityND*donor_config->GetConductivity_Ref(); + break; - heat_flux_density = thermal_conductivity*dTdn; - conductivity_over_dist = thermal_conductivity/dist; + case CONSTANT_PRANDTL: + thermal_conductivity = thermal_conductivityND*donor_config->GetGas_Constant_Ref() + *donor_config->GetViscosity_Ref(); + break; + } + + conductivity_over_dist = thermal_conductivity/dist; + } } - else if (flow) { + else if (heat_equation) { - iPoint = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNode(); + /*--- Heat solver stand-alone case ---*/ - thermal_conductivityND = laminar_viscosity/Prandtl_Lam; - thermal_conductivity = thermal_conductivityND*donor_config->GetViscosity_Ref()*cp_fluid; + thermal_diffusivity = donor_config->GetThermalDiffusivity_Solid(); + heat_flux_density = thermal_diffusivity*dTdn; - heat_flux_density = thermal_conductivity*dTdn; - conductivity_over_dist = thermal_conductivity/dist; + if (donor_config->GetCHT_Robin()) { + rho_cp_solid = donor_config->GetSpecific_Heat_Cp_Solid()*donor_config->GetDensity_Solid(); + conductivity_over_dist = thermal_diffusivity*rho_cp_solid/dist; + } } - else { - thermal_diffusivity = donor_config->GetThermalDiffusivity_Solid(); - heat_flux_density = (thermal_diffusivity*dTdn)*rho_cp_solid; - conductivity_over_dist = thermal_diffusivity*rho_cp_solid/dist; + /*--- Set the conjugate heat variables that are transferred by default ---*/ + + Donor_Variable[0] = Twall*donor_config->GetTemperature_Ref(); + Donor_Variable[1] = heat_flux_density*donor_config->GetHeat_Flux_Ref(); + + /*--- We only need these for the Robin BC option ---*/ + + if (donor_config->GetCHT_Robin()) { + + Donor_Variable[2] = conductivity_over_dist; + Donor_Variable[3] = Tnormal*donor_config->GetTemperature_Ref(); } - Donor_Variable[0] = Twall; - Donor_Variable[1] = heat_flux_density; - Donor_Variable[2] = conductivity_over_dist; - Donor_Variable[3] = Tnormal; + if (Edge_Vector != NULL) { - delete [] Edge_Vector; + delete [] Edge_Vector; + } } void CConjugateHeatInterface::SetTarget_Variable(CSolver *target_solution, CGeometry *target_geometry, @@ -203,8 +210,12 @@ void CConjugateHeatInterface::SetTarget_Variable(CSolver *target_solution, CGeom target_config->GetRelaxation_Factor_CHT(), Target_Variable[0]); target_solution->SetConjugateHeatVariable(Marker_Target, Vertex_Target, 1, target_config->GetRelaxation_Factor_CHT(), Target_Variable[1]); - target_solution->SetConjugateHeatVariable(Marker_Target, Vertex_Target, 2, - target_config->GetRelaxation_Factor_CHT(), Target_Variable[2]); - target_solution->SetConjugateHeatVariable(Marker_Target, Vertex_Target, 3, - target_config->GetRelaxation_Factor_CHT(), Target_Variable[3]); + + if (target_config->GetCHT_Robin()) { + + target_solution->SetConjugateHeatVariable(Marker_Target, Vertex_Target, 2, + target_config->GetRelaxation_Factor_CHT(), Target_Variable[2]); + target_solution->SetConjugateHeatVariable(Marker_Target, Vertex_Target, 3, + target_config->GetRelaxation_Factor_CHT(), Target_Variable[3]); + } } diff --git a/SU2_CFD/src/interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.cpp b/SU2_CFD/src/interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.cpp index d3090df53ada..e135e6c2ba76 100644 --- a/SU2_CFD/src/interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.cpp +++ b/SU2_CFD/src/interfaces/fsi/CDiscAdjDisplacementsInterfaceLegacy.cpp @@ -78,7 +78,7 @@ void CDiscAdjDisplacementsInterfaceLegacy::GetDonor_Variable(CSolver *struct_sol Coord_Struct = struct_geometry->node[Point_Struct]->GetCoord(); /*--- The displacements come from the predicted solution ---*/ - Displacement_Struct = struct_solution->node[Point_Struct]->GetSolution(); + Displacement_Struct = struct_solution->GetNodes()->GetSolution(Point_Struct); for (iVar = 0; iVar < nVar; iVar++) Donor_Variable[iVar] = Coord_Struct[iVar] + Displacement_Struct[iVar]; diff --git a/SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp b/SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp index 237bf18c8580..0d13487004a4 100644 --- a/SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp +++ b/SU2_CFD/src/interfaces/fsi/CDiscAdjFlowTractionInterface.cpp @@ -58,8 +58,7 @@ void CDiscAdjFlowTractionInterface::GetPhysical_Constants(CSolver *flow_solution /*--- We have to clear the traction before applying it, because we are "adding" to node and not "setting" ---*/ - for (unsigned long iPoint = 0; iPoint < struct_geometry->GetnPoint(); iPoint++) - struct_solution->node[iPoint]->Clear_FlowTraction(); + struct_solution->GetNodes()->Clear_FlowTraction(); Preprocess(flow_config); diff --git a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp index d46c272b215d..b08f240b7234 100644 --- a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp +++ b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp @@ -62,7 +62,7 @@ void CDisplacementsInterface::GetDonor_Variable(CSolver *struct_solution, CGeome unsigned short iVar; /*--- The displacements come from the predicted solution, but they are no longer incremental ---*/ - DisplacementDonor = struct_solution->node[Point_Struct]->GetSolution_Pred(); + DisplacementDonor = struct_solution->GetNodes()->GetSolution_Pred(Point_Struct); for (iVar = 0; iVar < nVar; iVar++) Donor_Variable[iVar] = DisplacementDonor[iVar]; @@ -75,6 +75,6 @@ void CDisplacementsInterface::SetTarget_Variable(CSolver *mesh_solver, CGeometry /*--- Impose the boundary displacements ---*/ - mesh_solver->node[Point_Mesh]->SetBound_Disp(Target_Variable); + mesh_solver->GetNodes()->SetBound_Disp(Point_Mesh,Target_Variable); } diff --git a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterfaceLegacy.cpp b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterfaceLegacy.cpp index 469e389fbb86..3d81f1911cba 100644 --- a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterfaceLegacy.cpp +++ b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterfaceLegacy.cpp @@ -66,9 +66,9 @@ void CDisplacementsInterfaceLegacy::GetDonor_Variable(CSolver *struct_solution, unsigned short iVar; /*--- The displacements come from the predicted solution ---*/ - DisplacementDonor = struct_solution->node[Point_Struct]->GetSolution_Pred(); + DisplacementDonor = struct_solution->GetNodes()->GetSolution_Pred(Point_Struct); - DisplacementDonor_Prev = struct_solution->node[Point_Struct]->GetSolution_Pred_Old(); + DisplacementDonor_Prev = struct_solution->GetNodes()->GetSolution_Pred_Old(Point_Struct); for (iVar = 0; iVar < nVar; iVar++) Donor_Variable[iVar] = DisplacementDonor[iVar] - DisplacementDonor_Prev[iVar]; diff --git a/SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp b/SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp index d240d4f95771..513e9ddf30ff 100644 --- a/SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp +++ b/SU2_CFD/src/interfaces/fsi/CFlowTractionInterface.cpp @@ -84,8 +84,7 @@ void CFlowTractionInterface::GetPhysical_Constants(CSolver *flow_solution, CSolv /*--- We have to clear the traction before applying it, because we are "adding" to node and not "setting" ---*/ - for (unsigned long iPoint = 0; iPoint < struct_geometry->GetnPoint(); iPoint++) - struct_solution->node[iPoint]->Clear_FlowTraction(); + struct_solution->GetNodes()->Clear_FlowTraction(); Preprocess(flow_config); @@ -164,7 +163,7 @@ void CFlowTractionInterface::GetDonor_Variable(CSolver *flow_solution, CGeometry // Retrieve the values of pressure - Pn = flow_solution->node[Point_Flow]->GetPressure(); + Pn = flow_solution->GetNodes()->GetPressure(Point_Flow); // Calculate tn in the fluid nodes for the inviscid term --> Units of force (non-dimensional). for (iVar = 0; iVar < nVar; iVar++) @@ -174,11 +173,11 @@ void CFlowTractionInterface::GetDonor_Variable(CSolver *flow_solution, CGeometry if ((incompressible || compressible) && viscous_flow) { - Viscosity = flow_solution->node[Point_Flow]->GetLaminarViscosity(); + Viscosity = flow_solution->GetNodes()->GetLaminarViscosity(Point_Flow); for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0 ; jVar < nVar; jVar++) { - Grad_Vel[iVar][jVar] = flow_solution->node[Point_Flow]->GetGradient_Primitive(iVar+1, jVar); + Grad_Vel[iVar][jVar] = flow_solution->GetNodes()->GetGradient_Primitive(Point_Flow, iVar+1, jVar); } } @@ -212,6 +211,6 @@ void CFlowTractionInterface::SetTarget_Variable(CSolver *fea_solution, CGeometry /*--- Add to the Flow traction. If nonconservative interpolation is in use, this is a stress and is integrated by the structural solver later on. ---*/ - fea_solution->node[Point_Struct]->Add_FlowTraction(Target_Variable); + fea_solution->GetNodes()->Add_FlowTraction(Point_Struct,Target_Variable); } diff --git a/SU2_CFD/src/iteration_structure.cpp b/SU2_CFD/src/iteration_structure.cpp index 67e6f099a5f4..b550fde51c9c 100644 --- a/SU2_CFD/src/iteration_structure.cpp +++ b/SU2_CFD/src/iteration_structure.cpp @@ -69,7 +69,7 @@ void CIteration::SetGrid_Movement(CGeometry **geometry, bool Screen_Output = config->GetDeform_Output(); unsigned short val_iZone = config->GetiZone(); - + /*--- Perform mesh movement depending on specified type ---*/ switch (Kind_Grid_Movement) { @@ -99,10 +99,9 @@ void CIteration::SetGrid_Movement(CGeometry **geometry, break; - /*--- Already initialized in the static mesh movement routine at driver level. ---*/ - case STEADY_TRANSLATION: case ROTATING_FRAME: - break; + case STEADY_TRANSLATION: case ROTATING_FRAME: + break; } @@ -280,8 +279,7 @@ void CIteration::SetGrid_Movement(CGeometry **geometry, if ((rank == MASTER_NODE) && (!discrete_adjoint)&& Screen_Output) cout << "Deforming the volume grid." << endl; - grid_movement->SetVolume_Deformation_Elas(geometry[MESH_0], - config, true, false); + grid_movement->SetVolume_Deformation_Elas(geometry[MESH_0], config, true, false); if ((rank == MASTER_NODE) && (!discrete_adjoint)&& Screen_Output) cout << "There is no grid velocity." << endl; @@ -976,8 +974,8 @@ void CFluidIteration::SetWind_GustField(CConfig *config, CGeometry **geometry, C GustDer[1] = dgust_dy; GustDer[2] = dgust_dt; - solver[iMGlevel][FLOW_SOL]->node[iPoint]->SetWindGust(Gust); - solver[iMGlevel][FLOW_SOL]->node[iPoint]->SetWindGustDer(GustDer); + solver[iMGlevel][FLOW_SOL]->GetNodes()->SetWindGust(iPoint, Gust); + solver[iMGlevel][FLOW_SOL]->GetNodes()->SetWindGustDer(iPoint, GustDer); GridVel = geometry[iMGlevel]->node[iPoint]->GetGridVel(); @@ -2024,21 +2022,21 @@ void CDiscAdjFluidIteration::Preprocess(COutput *output, /*--- Push solution back to correct array ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n1(); - if (grid_IsMoving) { + solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(); + if (turbulent) { + solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); + solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(); + } + if (heat) { + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n1(); + } + if (grid_IsMoving) { + for(iPoint=0; iPointGetnPoint();iPoint++) { geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->SetCoord_n(); geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->SetCoord_n1(); } - if (turbulent) { - solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(); - solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n1(); - } - if (heat) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(); - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n1(); - } } } } @@ -2050,17 +2048,17 @@ void CDiscAdjFluidIteration::Preprocess(COutput *output, /*--- Push solution back to correct array ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - if (grid_IsMoving) { + solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + if (turbulent) { + solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); + } + if (heat) { + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(); + } + if (grid_IsMoving) { + for(iPoint=0; iPointGetnPoint();iPoint++) { geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->SetCoord_n(); } - if (turbulent) { - solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(); - } - if (heat) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(); - } } } } @@ -2089,17 +2087,17 @@ void CDiscAdjFluidIteration::Preprocess(COutput *output, /*--- Temporarily store the loaded solution in the Solution_Old array ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->Set_OldSolution(); - if (grid_IsMoving) { + solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->Set_OldSolution(); + if (turbulent) { + solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->Set_OldSolution(); + } + if (heat) { + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_OldSolution(); + } + if (grid_IsMoving) { + for(iPoint=0; iPointGetnPoint();iPoint++) { geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->SetCoord_Old(); } - if (turbulent){ - solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->Set_OldSolution(); - } - if (heat){ - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_OldSolution(); - } } } @@ -2107,15 +2105,16 @@ void CDiscAdjFluidIteration::Preprocess(COutput *output, for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->SetSolution(solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->GetSolution_time_n()); + solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint, solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->GetSolution_time_n(iPoint)); + if (grid_IsMoving) { geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->SetCoord(geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->GetCoord_n()); } if (turbulent) { - solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->SetSolution(solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->GetSolution_time_n()); + solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->SetSolution(iPoint, solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->GetSolution_time_n(iPoint)); } if (heat) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->SetSolution(solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->GetSolution_time_n()); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->SetSolution(iPoint, solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->GetSolution_time_n(iPoint)); } } } @@ -2123,15 +2122,16 @@ void CDiscAdjFluidIteration::Preprocess(COutput *output, /*--- Set Solution at timestep n-1 to the previously loaded solution ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->GetSolution_Old()); + solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint)); + if (grid_IsMoving) { geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->SetCoord_n(geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->GetCoord_Old()); } if (turbulent) { - solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->GetSolution_Old()); + solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->GetSolution_Old(iPoint)); } if (heat) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->GetSolution_Old()); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->GetSolution_Old(iPoint)); } } } @@ -2140,30 +2140,32 @@ void CDiscAdjFluidIteration::Preprocess(COutput *output, /*--- Set Solution at timestep n-1 to solution at n-2 ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->GetSolution_time_n1()); + solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); + if (grid_IsMoving) { geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->SetCoord_n(geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->GetCoord_n1()); } if (turbulent) { - solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->GetSolution_time_n1()); + solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); } if (heat) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->GetSolution_time_n1()); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); } } } /*--- Set Solution at timestep n-2 to the previously loaded solution ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n1(solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->GetSolution_Old()); + solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(iPoint, solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint)); + if (grid_IsMoving) { geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->SetCoord_n1(geometry[val_iZone][val_iInst][iMesh]->node[iPoint]->GetCoord_Old()); } if (turbulent) { - solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n1(solver[val_iZone][val_iInst][iMesh][TURB_SOL]->node[iPoint]->GetSolution_Old()); + solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(iPoint, solver[val_iZone][val_iInst][iMesh][TURB_SOL]->GetNodes()->GetSolution_Old(iPoint)); } if (heat) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n1(solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->GetSolution_Old()); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n1(iPoint, solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->GetSolution_Old(iPoint)); } } } @@ -2183,17 +2185,17 @@ void CDiscAdjFluidIteration::Preprocess(COutput *output, if (TimeIter == 0 || dual_time) { for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][iMesh]->GetnPoint(); iPoint++) { - solver[val_iZone][val_iInst][iMesh][ADJFLOW_SOL]->node[iPoint]->SetSolution_Direct(solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->node[iPoint]->GetSolution()); + solver[val_iZone][val_iInst][iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver[val_iZone][val_iInst][iMesh][FLOW_SOL]->GetNodes()->GetSolution(iPoint)); } } if (turbulent && !config[val_iZone]->GetFrozen_Visc_Disc()) { for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++) { - solver[val_iZone][val_iInst][MESH_0][ADJTURB_SOL]->node[iPoint]->SetSolution_Direct(solver[val_iZone][val_iInst][MESH_0][TURB_SOL]->node[iPoint]->GetSolution()); + solver[val_iZone][val_iInst][MESH_0][ADJTURB_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver[val_iZone][val_iInst][MESH_0][TURB_SOL]->GetNodes()->GetSolution(iPoint)); } } if (heat) { for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++) { - solver[val_iZone][val_iInst][MESH_0][ADJHEAT_SOL]->node[iPoint]->SetSolution_Direct(solver[val_iZone][val_iInst][MESH_0][HEAT_SOL]->node[iPoint]->GetSolution()); + solver[val_iZone][val_iInst][MESH_0][ADJHEAT_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver[val_iZone][val_iInst][MESH_0][HEAT_SOL]->GetNodes()->GetSolution(iPoint)); } } } @@ -2295,10 +2297,6 @@ void CDiscAdjFluidIteration::InitializeAdjoint(CSolver *****solver, CGeometry ** bool heat = config[iZone]->GetWeakly_Coupled_Heat(); bool interface_boundary = (config[iZone]->GetnMarker_Fluid_Load() > 0); - /*--- Initialize the adjoint of the objective function (typically with 1.0) ---*/ - - solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->SetAdj_ObjFunc(geometry[iZone][iInst][MESH_0], config[iZone]); - /*--- Initialize the adjoints the conservative variables ---*/ if ((Kind_Solver == DISC_ADJ_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_RANS) || (Kind_Solver == DISC_ADJ_EULER) || @@ -2435,7 +2433,7 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver *****solver, } /*--- Compute coupling between flow and turbulent equations ---*/ - + solver[iZone][iInst][MESH_0][FLOW_SOL]->Preprocessing(geometry[iZone][iInst][MESH_0], solver[iZone][iInst][MESH_0], config[iZone], MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, true); solver[iZone][iInst][MESH_0][FLOW_SOL]->InitiateComms(geometry[iZone][iInst][MESH_0], config[iZone], SOLUTION); solver[iZone][iInst][MESH_0][FLOW_SOL]->CompleteComms(geometry[iZone][iInst][MESH_0], config[iZone], SOLUTION); @@ -2468,15 +2466,15 @@ void CDiscAdjFluidIteration::RegisterOutput(CSolver *****solver, CGeometry ****g /*--- Register conservative variables as output of the iteration ---*/ - solver[iZone][iInst][MESH_0][FLOW_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0],config[iZone]); + solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0],config[iZone]); } if (turbulent && !frozen_visc){ - solver[iZone][iInst][MESH_0][TURB_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0], + solver[iZone][iInst][MESH_0][ADJTURB_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0], config[iZone]); } if (heat){ - solver[iZone][iInst][MESH_0][HEAT_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0], + solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0], config[iZone]); } if (interface_boundary){ @@ -2652,21 +2650,15 @@ void CDiscAdjFEAIteration::Preprocess(COutput *output, /*--- Push solution back to correct array ---*/ - for(iPoint=0; iPointGetnPoint();iPoint++){ - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->Set_Solution_time_n(); - } + solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->Set_Solution_time_n(); /*--- Push solution back to correct array ---*/ - for(iPoint=0; iPointGetnPoint();iPoint++){ - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Accel_time_n(); - } + solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Accel_time_n(); /*--- Push solution back to correct array ---*/ - for(iPoint=0; iPointGetnPoint();iPoint++){ - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Vel_time_n(); - } + solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Vel_time_n(); /*--- Load solution timestep n ---*/ @@ -2675,15 +2667,15 @@ void CDiscAdjFEAIteration::Preprocess(COutput *output, /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++){ - solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->node[iPoint]->SetSolution_Direct(solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->GetSolution()); + solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->GetSolution(iPoint)); } for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++){ - solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->node[iPoint]->SetSolution_Accel_Direct(solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Accel()); + solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->GetNodes()->SetSolution_Accel_Direct(iPoint, solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->GetSolution_Accel(iPoint)); } for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++){ - solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->node[iPoint]->SetSolution_Vel_Direct(solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Vel()); + solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->GetNodes()->SetSolution_Vel_Direct(iPoint, solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->GetSolution_Vel(iPoint)); } } @@ -2691,7 +2683,7 @@ void CDiscAdjFEAIteration::Preprocess(COutput *output, /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++){ - solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->node[iPoint]->SetSolution_Direct(solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->GetSolution()); + solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->GetSolution(iPoint)); } } @@ -2723,9 +2715,9 @@ void CDiscAdjFEAIteration::LoadDynamic_Solution(CGeometry ****geometry, /*--- Push solution back to correct array ---*/ for(iPoint=0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint();iPoint++){ for (iVar = 0; iVar < solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetnVar(); iVar++){ - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->SetSolution(iVar, 0.0); - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Accel(iVar, 0.0); - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Vel(iVar, 0.0); + solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution(iPoint, iVar, 0.0); + solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Accel(iPoint, iVar, 0.0); + solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Vel(iPoint, iVar, 0.0); } } } @@ -3249,11 +3241,8 @@ void CDiscAdjHeatIteration::Preprocess(COutput *output, /*--- Push solution back to correct array ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(); - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n1(); - } + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n1(); } } if (dual_time) { @@ -3265,10 +3254,7 @@ void CDiscAdjHeatIteration::Preprocess(COutput *output, /*--- Push solution back to correct array ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(); - } + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(); } } @@ -3287,19 +3273,15 @@ void CDiscAdjHeatIteration::Preprocess(COutput *output, /*--- Temporarily store the loaded solution in the Solution_Old array ---*/ - for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { - for(iPoint=0; iPointGetnPoint();iPoint++) { - - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_OldSolution(); - } - } + for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_OldSolution(); /*--- Set Solution at timestep n to solution at n-1 ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->SetSolution(solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->GetSolution_time_n()); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->SetSolution(iPoint, solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->GetSolution_time_n(iPoint)); } } if (dual_time_1st){ @@ -3307,7 +3289,7 @@ void CDiscAdjHeatIteration::Preprocess(COutput *output, for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->GetSolution_time_n1()); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); } } } @@ -3316,14 +3298,14 @@ void CDiscAdjHeatIteration::Preprocess(COutput *output, for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->GetSolution_time_n1()); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(iPoint, solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->GetSolution_time_n1(iPoint)); } } /*--- Set Solution at timestep n-2 to the previously loaded solution ---*/ for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { for(iPoint=0; iPointGetnPoint();iPoint++) { - solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n1(solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->node[iPoint]->GetSolution_Old()); + solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n1(iPoint, solver[val_iZone][val_iInst][iMesh][HEAT_SOL]->GetNodes()->GetSolution_Old(iPoint)); } } } @@ -3334,7 +3316,7 @@ void CDiscAdjHeatIteration::Preprocess(COutput *output, if (TimeIter == 0 || dual_time) { for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++) { - solver[val_iZone][val_iInst][MESH_0][ADJHEAT_SOL]->node[iPoint]->SetSolution_Direct(solver[val_iZone][val_iInst][MESH_0][HEAT_SOL]->node[iPoint]->GetSolution()); + solver[val_iZone][val_iInst][MESH_0][ADJHEAT_SOL]->GetNodes()->SetSolution_Direct(iPoint, solver[val_iZone][val_iInst][MESH_0][HEAT_SOL]->GetNodes()->GetSolution(iPoint)); } } diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 7d3be2212ced..a3bb55115caa 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -77,10 +77,8 @@ su2_cfd_src += files(['variables/CIncNSVariable.cpp', 'variables/CBaselineVariable.cpp', 'variables/CDiscAdjFEAVariable.cpp', 'variables/CDiscAdjFEABoundVariable.cpp', - 'variables/CDiscAdjMeshVariable.cpp', 'variables/CDiscAdjMeshBoundVariable.cpp', 'variables/CFEABoundVariable.cpp', - 'variables/CFEAFSIBoundVariable.cpp', 'variables/CDiscAdjVariable.cpp', 'variables/CTurbSAVariable.cpp', 'variables/CFEAVariable.cpp', @@ -113,6 +111,7 @@ su2_cfd_src += files(['interfaces/CInterface.cpp', su2_cfd_src += files(['drivers/CDriver.cpp', 'drivers/CMultizoneDriver.cpp', 'drivers/CSinglezoneDriver.cpp', + 'drivers/CDiscAdjMultizoneDriver.cpp', 'drivers/CDiscAdjSinglezoneDriver.cpp', 'drivers/CDummyDriver.cpp']) diff --git a/SU2_CFD/src/numerics_direct_mean.cpp b/SU2_CFD/src/numerics_direct_mean.cpp index 7511b4961d2b..a76e150de33a 100644 --- a/SU2_CFD/src/numerics_direct_mean.cpp +++ b/SU2_CFD/src/numerics_direct_mean.cpp @@ -1044,6 +1044,9 @@ CUpwAUSMPLUSUP_Flow::CUpwAUSMPLUSUP_Flow(unsigned short val_nDim, unsigned short Kp = 0.25; Ku = 0.75; sigma = 1.0; + + if (Minf < EPS) + SU2_MPI::Error("AUSM+Up requires a reference Mach number (\"MACH_NUMBER\") greater than 0.", CURRENT_FUNCTION); } CUpwAUSMPLUSUP_Flow::~CUpwAUSMPLUSUP_Flow(void) { @@ -1269,6 +1272,9 @@ CUpwAUSMPLUSUP2_Flow::CUpwAUSMPLUSUP2_Flow(unsigned short val_nDim, unsigned sho Minf = config->GetMach(); Kp = 0.25; sigma = 1.0; + + if (Minf < EPS) + SU2_MPI::Error("AUSM+Up2 requires a reference Mach number (\"MACH_NUMBER\") greater than 0.", CURRENT_FUNCTION); } CUpwAUSMPLUSUP2_Flow::~CUpwAUSMPLUSUP2_Flow(void) { diff --git a/SU2_CFD/src/output/CAdjElasticityOutput.cpp b/SU2_CFD/src/output/CAdjElasticityOutput.cpp index 3f44b4eeb48d..62470f03c9e9 100644 --- a/SU2_CFD/src/output/CAdjElasticityOutput.cpp +++ b/SU2_CFD/src/output/CAdjElasticityOutput.cpp @@ -147,7 +147,7 @@ inline void CAdjElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *ge void CAdjElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ - CVariable* Node_Struc = solver[FEA_SOL]->node[iPoint]; + CVariable* Node_Struc = solver[FEA_SOL]->GetNodes(); CPoint* Node_Geo = geometry->node[iPoint]; SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(0)); @@ -155,9 +155,9 @@ void CAdjElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, if (nDim == 3) SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(2)); - SetVolumeOutputValue("SENSITIVITY-X", iPoint, Node_Struc->GetSolution(0)); - SetVolumeOutputValue("SENSITIVITY-Y", iPoint, Node_Struc->GetSolution(1)); - if (nDim == 3) SetVolumeOutputValue("SENSITIVITY-Z", iPoint, Node_Struc->GetSolution(2)); + SetVolumeOutputValue("SENSITIVITY-X", iPoint, Node_Struc->GetSolution(iPoint, 0)); + SetVolumeOutputValue("SENSITIVITY-Y", iPoint, Node_Struc->GetSolution(iPoint, 1)); + if (nDim == 3) SetVolumeOutputValue("SENSITIVITY-Z", iPoint, Node_Struc->GetSolution(iPoint, 2)); } diff --git a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp index aee945be59d1..a6859b69ae47 100644 --- a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp @@ -366,14 +366,14 @@ void CAdjFlowCompOutput::SetVolumeOutputFields(CConfig *config){ void CAdjFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ - CVariable* Node_AdjFlow = solver[ADJFLOW_SOL]->node[iPoint]; + CVariable* Node_AdjFlow = solver[ADJFLOW_SOL]->GetNodes(); CVariable* Node_AdjTurb = NULL; CPoint* Node_Geo = geometry->node[iPoint]; if (config->GetKind_Turb_Model() != NONE && ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj))){ - Node_AdjTurb = solver[ADJTURB_SOL]->node[iPoint]; + Node_AdjTurb = solver[ADJTURB_SOL]->GetNodes(); } SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(0)); @@ -381,26 +381,26 @@ void CAdjFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CS if (nDim == 3) SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(2)); - SetVolumeOutputValue("ADJ_DENSITY", iPoint, Node_AdjFlow->GetSolution(0)); - SetVolumeOutputValue("ADJ_MOMENTUM-X", iPoint, Node_AdjFlow->GetSolution(1)); - SetVolumeOutputValue("ADJ_MOMENTUM-Y", iPoint, Node_AdjFlow->GetSolution(2)); + SetVolumeOutputValue("ADJ_DENSITY", iPoint, Node_AdjFlow->GetSolution(iPoint, 0)); + SetVolumeOutputValue("ADJ_MOMENTUM-X", iPoint, Node_AdjFlow->GetSolution(iPoint, 1)); + SetVolumeOutputValue("ADJ_MOMENTUM-Y", iPoint, Node_AdjFlow->GetSolution(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("ADJ_MOMENTUM-Z", iPoint, Node_AdjFlow->GetSolution(3)); - SetVolumeOutputValue("ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(4)); + SetVolumeOutputValue("ADJ_MOMENTUM-Z", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); + SetVolumeOutputValue("ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(iPoint, 4)); } else { - SetVolumeOutputValue("ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(3)); + SetVolumeOutputValue("ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); } if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){ // Turbulent switch(turb_model){ case SST: - SetVolumeOutputValue("ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(0)); - SetVolumeOutputValue("ADJ_DISSIPATION", iPoint, Node_AdjTurb->GetSolution(1)); + SetVolumeOutputValue("ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0)); + SetVolumeOutputValue("ADJ_DISSIPATION", iPoint, Node_AdjTurb->GetSolution(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("ADJ_NU_TILDE", iPoint, Node_AdjTurb->GetSolution(0)); + SetVolumeOutputValue("ADJ_NU_TILDE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0)); break; case NONE: break; @@ -408,35 +408,35 @@ void CAdjFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CS } // Residuals - SetVolumeOutputValue("RES_ADJ_DENSITY", iPoint, Node_AdjFlow->GetSolution(0) - Node_AdjFlow->GetSolution_Old(0)); - SetVolumeOutputValue("RES_ADJ_MOMENTUM-X", iPoint, Node_AdjFlow->GetSolution(1) - Node_AdjFlow->GetSolution_Old(1)); - SetVolumeOutputValue("RES_ADJ_MOMENTUM-Y", iPoint, Node_AdjFlow->GetSolution(2) - Node_AdjFlow->GetSolution_Old(2)); + SetVolumeOutputValue("RES_ADJ_DENSITY", iPoint, Node_AdjFlow->GetSolution(iPoint, 0) - Node_AdjFlow->GetSolution_Old(iPoint, 0)); + SetVolumeOutputValue("RES_ADJ_MOMENTUM-X", iPoint, Node_AdjFlow->GetSolution(iPoint, 1) - Node_AdjFlow->GetSolution_Old(iPoint, 1)); + SetVolumeOutputValue("RES_ADJ_MOMENTUM-Y", iPoint, Node_AdjFlow->GetSolution(iPoint, 2) - Node_AdjFlow->GetSolution_Old(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("RES_ADJ_MOMENTUM-Z", iPoint, Node_AdjFlow->GetSolution(3) - Node_AdjFlow->GetSolution_Old(3)); - SetVolumeOutputValue("RES_ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(4) - Node_AdjFlow->GetSolution_Old(4)); + SetVolumeOutputValue("RES_ADJ_MOMENTUM-Z", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); + SetVolumeOutputValue("RES_ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(iPoint, 4) - Node_AdjFlow->GetSolution_Old(iPoint, 4)); } else { - SetVolumeOutputValue("RES_ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(3) - Node_AdjFlow->GetSolution_Old(3)); + SetVolumeOutputValue("RES_ADJ_ENERGY", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); } if ((!config->GetFrozen_Visc_Disc() && !cont_adj) || (!config->GetFrozen_Visc_Cont() && cont_adj)){ switch(config->GetKind_Turb_Model()){ case SST: - SetVolumeOutputValue("RES_ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(0) - Node_AdjTurb->GetSolution_Old(0)); - SetVolumeOutputValue("RES_ADJ_DISSIPATION", iPoint, Node_AdjTurb->GetSolution(1) - Node_AdjTurb->GetSolution_Old(1)); + SetVolumeOutputValue("RES_ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0) - Node_AdjTurb->GetSolution_Old(iPoint, 0)); + SetVolumeOutputValue("RES_ADJ_DISSIPATION", iPoint, Node_AdjTurb->GetSolution(iPoint, 1) - Node_AdjTurb->GetSolution_Old(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("RES_ADJ_NU_TILDE", iPoint, Node_AdjTurb->GetSolution(0) - Node_AdjTurb->GetSolution_Old(0)); + SetVolumeOutputValue("RES_ADJ_NU_TILDE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0) - Node_AdjTurb->GetSolution_Old(iPoint, 0)); break; case NONE: break; } } - SetVolumeOutputValue("SENSITIVITY-X", iPoint, Node_AdjFlow->GetSensitivity(0)); - SetVolumeOutputValue("SENSITIVITY-Y", iPoint, Node_AdjFlow->GetSensitivity(1)); + SetVolumeOutputValue("SENSITIVITY-X", iPoint, Node_AdjFlow->GetSensitivity(iPoint, 0)); + SetVolumeOutputValue("SENSITIVITY-Y", iPoint, Node_AdjFlow->GetSensitivity(iPoint, 1)); if (nDim == 3) - SetVolumeOutputValue("SENSITIVITY-Z", iPoint, Node_AdjFlow->GetSensitivity(2)); + SetVolumeOutputValue("SENSITIVITY-Z", iPoint, Node_AdjFlow->GetSensitivity(iPoint, 2)); } diff --git a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp index 0dd430963119..d6356f136a0b 100644 --- a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp @@ -115,7 +115,7 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config){ /// DESCRIPTION: Root-mean square residual of the adjoint Velocity z-component. AddHistoryOutput("RMS_ADJ_VELOCITY-Z", "rms[A_W]", ScreenOutputFormat::FIXED, "RMS_RES", "Root-mean square residual of the adjoint Velocity z-component.", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. - AddHistoryOutput("RMS_ADJ_HEAT", "rms[A_T]", ScreenOutputFormat::FIXED, "RMS_RES", " Root-mean square residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); + AddHistoryOutput("RMS_ADJ_TEMPERATURE", "rms[A_T]", ScreenOutputFormat::FIXED, "RMS_RES", " Root-mean square residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){ switch(turb_model){ case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP: @@ -143,7 +143,7 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config){ /// DESCRIPTION: Maximum residual of the adjoint Velocity z-component AddHistoryOutput("MAX_ADJ_VELOCITY-Z", "max[A_RhoW]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the adjoint Velocity z-component", HistoryFieldType::RESIDUAL); /// DESCRIPTION: Maximum residual of the temperature. - AddHistoryOutput("MAX_ADJ_HEAT", "max[A_T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); + AddHistoryOutput("MAX_ADJ_TEMPERATURE", "max[A_T]", ScreenOutputFormat::FIXED, "MAX_RES", "Maximum residual of the temperature.", HistoryFieldType::RESIDUAL); if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){ switch(turb_model){ case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP: @@ -171,7 +171,7 @@ void CAdjFlowIncOutput::SetHistoryOutputFields(CConfig *config){ /// DESCRIPTION: BGS residual of the adjoint Velocity z-component AddHistoryOutput("BGS_ADJ_VELOCITY-Z", "bgs[A_RhoW]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint Velocity z-component", HistoryFieldType::RESIDUAL); /// DESCRIPTION: BGS residual of the temperature. - AddHistoryOutput("BGS_ADJ_HEAT", "bgs[A_T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); + AddHistoryOutput("BGS_ADJ_TEMPERATURE", "bgs[A_T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){ switch(turb_model){ case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP: @@ -217,11 +217,11 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("RMS_ADJ_VELOCITY-Z", log10(adjflow_solver->GetRes_RMS(3))); } if (weakly_coupled_heat){ - SetHistoryOutputValue("RMS_ADJ_HEAT", log10(adjheat_solver->GetRes_RMS(0))); + SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_RMS(0))); } if (heat){ - if (nDim == 3) SetHistoryOutputValue("RMS_ADJ_HEAT", log10(adjflow_solver->GetRes_RMS(4))); - else SetHistoryOutputValue("RMS_ADJ_HEAT", log10(adjflow_solver->GetRes_RMS(3))); + if (nDim == 3) SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(4))); + else SetHistoryOutputValue("RMS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_RMS(3))); } if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){ switch(turb_model){ @@ -242,11 +242,11 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("MAX_ADJ_VELOCITY-Z", log10(adjflow_solver->GetRes_Max(3))); } if (weakly_coupled_heat){ - SetHistoryOutputValue("MAX_ADJ_HEAT", log10(adjheat_solver->GetRes_Max(0))); + SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_Max(0))); } if (heat){ - if (nDim == 3) SetHistoryOutputValue("MAX_ADJ_HEAT", log10(adjflow_solver->GetRes_Max(4))); - else SetHistoryOutputValue("MAX_ADJ_HEAT", log10(adjflow_solver->GetRes_Max(3))); + if (nDim == 3) SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(4))); + else SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_Max(3))); } if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){ switch(turb_model){ @@ -269,11 +269,11 @@ void CAdjFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS SetHistoryOutputValue("BGS_ADJ_VELOCITY-Z", log10(adjflow_solver->GetRes_BGS(3))); } if (weakly_coupled_heat){ - SetHistoryOutputValue("BGS_ADJ_HEAT", log10(adjheat_solver->GetRes_BGS(0))); + SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_BGS(0))); } if (heat){ - if (nDim == 3) SetHistoryOutputValue("BGS_ADJ_HEAT", log10(adjflow_solver->GetRes_BGS(4))); - else SetHistoryOutputValue("BGS_ADJ_HEAT", log10(adjflow_solver->GetRes_BGS(3))); + if (nDim == 3) SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(4))); + else SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjflow_solver->GetRes_BGS(3))); } if (!config->GetFrozen_Visc_Disc() || !config->GetFrozen_Visc_Cont()){ switch(turb_model){ @@ -316,10 +316,9 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config){ if (nDim == 3) /// DESCRIPTION: Adjoint Velocity z-component. AddVolumeOutput("ADJ_VELOCITY-Z", "Adjoint_Velocity_z", "SOLUTION", "z-component of the adjoint velocity vector"); - - if (weakly_coupled_heat || heat){ - AddVolumeOutput("ADJ_HEAT", "Adjoint_Heat", "SOLUTION", "Adjoint heat"); - } + + AddVolumeOutput("ADJ_TEMPERATURE", "Adjoint_Temperature", "SOLUTION", "Adjoint temperature"); + if (!config->GetFrozen_Visc_Disc()){ switch(turb_model){ @@ -355,9 +354,9 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("RES_ADJ_VELOCITY-Y", "Residual_Adjoint_Velocity_y", "RESIDUAL", "Residual of the adjoint y-velocity"); if (nDim == 3) /// DESCRIPTION: Residual of the adjoint Velocity z-component. - AddVolumeOutput("RES_ADJ_Velocity-Z", "Residual_Adjoint_Velocity_z", "RESIDUAL", "Residual of the adjoint z-velocity"); + AddVolumeOutput("RES_ADJ_VELOCITY-Z", "Residual_Adjoint_Velocity_z", "RESIDUAL", "Residual of the adjoint z-velocity"); /// DESCRIPTION: Residual of the adjoint energy. - AddVolumeOutput("RES_ADJ_HEAT", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint heat"); + AddVolumeOutput("RES_ADJ_TEMPERATURE", "Residual_Adjoint_Heat", "RESIDUAL", "Residual of the adjoint temperature"); if (!config->GetFrozen_Visc_Disc()){ switch(turb_model){ case SA: case SA_NEG: case SA_E: case SA_COMP: case SA_E_COMP: @@ -391,16 +390,16 @@ void CAdjFlowIncOutput::SetVolumeOutputFields(CConfig *config){ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ - CVariable* Node_AdjFlow = solver[ADJFLOW_SOL]->node[iPoint]; + CVariable* Node_AdjFlow = solver[ADJFLOW_SOL]->GetNodes(); CVariable* Node_AdjHeat = NULL; CVariable* Node_AdjTurb = NULL; CPoint* Node_Geo = geometry->node[iPoint]; if (config->GetKind_Turb_Model() != NONE && !config->GetFrozen_Visc_Disc()){ - Node_AdjTurb = solver[ADJTURB_SOL]->node[iPoint]; + Node_AdjTurb = solver[ADJTURB_SOL]->GetNodes(); } if (weakly_coupled_heat){ - Node_AdjHeat = solver[ADJHEAT_SOL]->node[iPoint]; + Node_AdjHeat = solver[ADJHEAT_SOL]->GetNodes(); } SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(0)); @@ -408,30 +407,30 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo if (nDim == 3) SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(2)); - SetVolumeOutputValue("ADJ_PRESSURE", iPoint, Node_AdjFlow->GetSolution(0)); - SetVolumeOutputValue("ADJ_VELOCITY-X", iPoint, Node_AdjFlow->GetSolution(1)); - SetVolumeOutputValue("ADJ_VELOCITY-Y", iPoint, Node_AdjFlow->GetSolution(2)); + SetVolumeOutputValue("ADJ_PRESSURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 0)); + SetVolumeOutputValue("ADJ_VELOCITY-X", iPoint, Node_AdjFlow->GetSolution(iPoint, 1)); + SetVolumeOutputValue("ADJ_VELOCITY-Y", iPoint, Node_AdjFlow->GetSolution(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("ADJ_VELOCITY-Z", iPoint, Node_AdjFlow->GetSolution(3)); + SetVolumeOutputValue("ADJ_VELOCITY-Z", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); } if (weakly_coupled_heat){ - SetVolumeOutputValue("ADJ_HEAT", iPoint, Node_AdjHeat->GetSolution(0)); + SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(iPoint, 0)); } - if (heat){ - if (nDim == 3) SetVolumeOutputValue("ADJ_HEAT", iPoint, Node_AdjFlow->GetSolution(4)); - else SetVolumeOutputValue("ADJ_HEAT", iPoint, Node_AdjFlow->GetSolution(3)); + else { + if (nDim == 3) SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4)); + else SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3)); } // Turbulent if (!config->GetFrozen_Visc_Disc()){ switch(turb_model){ case SST: - SetVolumeOutputValue("ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(0)); - SetVolumeOutputValue("ADJ_DISSIPATION", iPoint, Node_AdjTurb->GetSolution(1)); + SetVolumeOutputValue("ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0)); + SetVolumeOutputValue("ADJ_DISSIPATION", iPoint, Node_AdjTurb->GetSolution(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("ADJ_NU_TILDE", iPoint, Node_AdjTurb->GetSolution(0)); + SetVolumeOutputValue("ADJ_NU_TILDE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0)); break; case NONE: break; @@ -439,31 +438,34 @@ void CAdjFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo } // Residuals - SetVolumeOutputValue("RES_ADJ_PRESSURE", iPoint, Node_AdjFlow->GetSolution(0) - Node_AdjFlow->GetSolution_Old(0)); - SetVolumeOutputValue("RES_ADJ_VELOCITY-X", iPoint, Node_AdjFlow->GetSolution(1) - Node_AdjFlow->GetSolution_Old(1)); - SetVolumeOutputValue("RES_ADJ_VELOCITY-Y", iPoint, Node_AdjFlow->GetSolution(2) - Node_AdjFlow->GetSolution_Old(2)); + SetVolumeOutputValue("RES_ADJ_PRESSURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 0) - Node_AdjFlow->GetSolution_Old(iPoint, 0)); + SetVolumeOutputValue("RES_ADJ_VELOCITY-X", iPoint, Node_AdjFlow->GetSolution(iPoint, 1) - Node_AdjFlow->GetSolution_Old(iPoint, 1)); + SetVolumeOutputValue("RES_ADJ_VELOCITY-Y", iPoint, Node_AdjFlow->GetSolution(iPoint, 2) - Node_AdjFlow->GetSolution_Old(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("RES_ADJ_VELOCITY-Z", iPoint, Node_AdjFlow->GetSolution(3) - Node_AdjFlow->GetSolution_Old(3)); + SetVolumeOutputValue("RES_ADJ_VELOCITY-Z", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); + SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 4) - Node_AdjFlow->GetSolution_Old(iPoint, 4)); + } else { + SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjFlow->GetSolution(iPoint, 3) - Node_AdjFlow->GetSolution_Old(iPoint, 3)); } if (!config->GetFrozen_Visc_Disc()){ switch(config->GetKind_Turb_Model()){ case SST: - SetVolumeOutputValue("RES_ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(0) - Node_AdjTurb->GetSolution_Old(0)); - SetVolumeOutputValue("RES_ADJ_DISSIPATION", iPoint, Node_AdjTurb->GetSolution(1) - Node_AdjTurb->GetSolution_Old(1)); + SetVolumeOutputValue("RES_ADJ_TKE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0) - Node_AdjTurb->GetSolution_Old(iPoint, 0)); + SetVolumeOutputValue("RES_ADJ_DISSIPATION", iPoint, Node_AdjTurb->GetSolution(iPoint, 1) - Node_AdjTurb->GetSolution_Old(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("RES_ADJ_NU_TILDE", iPoint, Node_AdjTurb->GetSolution(0) - Node_AdjTurb->GetSolution_Old(0)); + SetVolumeOutputValue("RES_ADJ_NU_TILDE", iPoint, Node_AdjTurb->GetSolution(iPoint, 0) - Node_AdjTurb->GetSolution_Old(iPoint, 0)); break; case NONE: break; } } - SetVolumeOutputValue("SENSITIVITY-X", iPoint, Node_AdjFlow->GetSensitivity(0)); - SetVolumeOutputValue("SENSITIVITY-Y", iPoint, Node_AdjFlow->GetSensitivity(1)); + SetVolumeOutputValue("SENSITIVITY-X", iPoint, Node_AdjFlow->GetSensitivity(iPoint, 0)); + SetVolumeOutputValue("SENSITIVITY-Y", iPoint, Node_AdjFlow->GetSensitivity(iPoint, 1)); if (nDim == 3) - SetVolumeOutputValue("SENSITIVITY-Z", iPoint, Node_AdjFlow->GetSensitivity(2)); + SetVolumeOutputValue("SENSITIVITY-Z", iPoint, Node_AdjFlow->GetSensitivity(iPoint, 2)); } diff --git a/SU2_CFD/src/output/CAdjHeatOutput.cpp b/SU2_CFD/src/output/CAdjHeatOutput.cpp index feabf5c5adbd..c766805c9cdd 100644 --- a/SU2_CFD/src/output/CAdjHeatOutput.cpp +++ b/SU2_CFD/src/output/CAdjHeatOutput.cpp @@ -107,7 +107,7 @@ void CAdjHeatOutput::SetHistoryOutputFields(CConfig *config){ /// BEGIN_GROUP: MAX_RES, DESCRIPTION: The maximum residuals of the conservative variables. /// DESCRIPTION: Maximum residual of the adjoint Pressure. - AddHistoryOutput("MAX_ADJ_TEMPERATURE", "max[A_T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); + AddHistoryOutput("BGS_ADJ_TEMPERATURE", "bgs[A_T]", ScreenOutputFormat::FIXED, "BGS_RES", "BGS residual of the adjoint temperature.", HistoryFieldType::RESIDUAL); /// BEGIN_GROUP: SENSITIVITY, DESCRIPTION: Sensitivities of different geometrical or boundary values. /// DESCRIPTION: Sum of the geometrical sensitivities on all markers set in MARKER_MONITORING. @@ -124,8 +124,9 @@ void CAdjHeatOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_Max(0))); - if (multiZone) - SetHistoryOutputValue("MAX_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_BGS(0))); + if (multiZone) { + SetHistoryOutputValue("BGS_ADJ_TEMPERATURE", log10(adjheat_solver->GetRes_BGS(0))); + } SetHistoryOutputValue("SENS_GEO", adjheat_solver->GetTotal_Sens_Geo()); @@ -168,7 +169,7 @@ void CAdjHeatOutput::SetVolumeOutputFields(CConfig *config){ void CAdjHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ - CVariable* Node_AdjHeat = solver[ADJHEAT_SOL]->node[iPoint]; + CVariable* Node_AdjHeat = solver[ADJHEAT_SOL]->GetNodes(); CPoint* Node_Geo = geometry->node[iPoint]; @@ -177,15 +178,15 @@ void CAdjHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve if (nDim == 3) SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(2)); - SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(0)); + SetVolumeOutputValue("ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(iPoint, 0)); // Residuals - SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(0) - Node_AdjHeat->GetSolution_Old(0)); + SetVolumeOutputValue("RES_ADJ_TEMPERATURE", iPoint, Node_AdjHeat->GetSolution(iPoint, 0) - Node_AdjHeat->GetSolution_Old(iPoint, 0)); - SetVolumeOutputValue("SENSITIVITY-X", iPoint, Node_AdjHeat->GetSensitivity(0)); - SetVolumeOutputValue("SENSITIVITY-Y", iPoint, Node_AdjHeat->GetSensitivity(1)); + SetVolumeOutputValue("SENSITIVITY-X", iPoint, Node_AdjHeat->GetSensitivity(iPoint, 0)); + SetVolumeOutputValue("SENSITIVITY-Y", iPoint, Node_AdjHeat->GetSensitivity(iPoint, 1)); if (nDim == 3) - SetVolumeOutputValue("SENSITIVITY-Z", iPoint, Node_AdjHeat->GetSensitivity(2)); + SetVolumeOutputValue("SENSITIVITY-Z", iPoint, Node_AdjHeat->GetSensitivity(iPoint, 2)); } diff --git a/SU2_CFD/src/output/CBaselineOutput.cpp b/SU2_CFD/src/output/CBaselineOutput.cpp index 9139c03eb724..5b6aa2474641 100644 --- a/SU2_CFD/src/output/CBaselineOutput.cpp +++ b/SU2_CFD/src/output/CBaselineOutput.cpp @@ -117,10 +117,10 @@ void CBaselineOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv /*--- Take the solver at index 0 --- */ - CVariable* Node_Sol = solver[0]->node[iPoint]; - + CVariable* Node_Sol = solver[0]->GetNodes(); + for (iField = 0; iField < fields.size(); iField++){ - SetVolumeOutputValue(fields[iField], iPoint, Node_Sol->GetSolution(iField)); + SetVolumeOutputValue(fields[iField], iPoint, Node_Sol->GetSolution(iPoint, iField)); } } diff --git a/SU2_CFD/src/output/CElasticityOutput.cpp b/SU2_CFD/src/output/CElasticityOutput.cpp index d1db7ec89a64..5221da31ac75 100644 --- a/SU2_CFD/src/output/CElasticityOutput.cpp +++ b/SU2_CFD/src/output/CElasticityOutput.cpp @@ -172,7 +172,7 @@ void CElasticityOutput::SetHistoryOutputFields(CConfig *config){ void CElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ - CVariable* Node_Struc = solver[FEA_SOL]->node[iPoint]; + CVariable* Node_Struc = solver[FEA_SOL]->GetNodes(); CPoint* Node_Geo = geometry->node[iPoint]; SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(0)); @@ -180,29 +180,29 @@ void CElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo if (nDim == 3) SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(2)); - SetVolumeOutputValue("DISPLACEMENT-X", iPoint, Node_Struc->GetSolution(0)); - SetVolumeOutputValue("DISPLACEMENT-Y", iPoint, Node_Struc->GetSolution(1)); - if (nDim == 3) SetVolumeOutputValue("DISPLACEMENT-Z", iPoint, Node_Struc->GetSolution(2)); + SetVolumeOutputValue("DISPLACEMENT-X", iPoint, Node_Struc->GetSolution(iPoint, 0)); + SetVolumeOutputValue("DISPLACEMENT-Y", iPoint, Node_Struc->GetSolution(iPoint, 1)); + if (nDim == 3) SetVolumeOutputValue("DISPLACEMENT-Z", iPoint, Node_Struc->GetSolution(iPoint, 2)); if(dynamic){ - SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Struc->GetSolution_Vel(0)); - SetVolumeOutputValue("VELOCITY-Y", iPoint, Node_Struc->GetSolution_Vel(1)); - if (nDim == 3) SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Struc->GetSolution_Vel(2)); + SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Struc->GetSolution_Vel(iPoint, 0)); + SetVolumeOutputValue("VELOCITY-Y", iPoint, Node_Struc->GetSolution_Vel(iPoint, 1)); + if (nDim == 3) SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Struc->GetSolution_Vel(iPoint, 2)); - SetVolumeOutputValue("ACCELERATION-X", iPoint, Node_Struc->GetSolution_Accel(0)); - SetVolumeOutputValue("ACCELERATION-Y", iPoint, Node_Struc->GetSolution_Accel(1)); - if (nDim == 3) SetVolumeOutputValue("ACCELERATION-Z", iPoint, Node_Struc->GetSolution_Accel(2)); + SetVolumeOutputValue("ACCELERATION-X", iPoint, Node_Struc->GetSolution_Accel(iPoint, 0)); + SetVolumeOutputValue("ACCELERATION-Y", iPoint, Node_Struc->GetSolution_Accel(iPoint, 1)); + if (nDim == 3) SetVolumeOutputValue("ACCELERATION-Z", iPoint, Node_Struc->GetSolution_Accel(iPoint, 2)); } - SetVolumeOutputValue("STRESS-XX", iPoint, Node_Struc->GetStress_FEM()[0]); - SetVolumeOutputValue("STRESS-YY", iPoint, Node_Struc->GetStress_FEM()[1]); - SetVolumeOutputValue("STRESS-XY", iPoint, Node_Struc->GetStress_FEM()[2]); + SetVolumeOutputValue("STRESS-XX", iPoint, Node_Struc->GetStress_FEM(iPoint)[0]); + SetVolumeOutputValue("STRESS-YY", iPoint, Node_Struc->GetStress_FEM(iPoint)[1]); + SetVolumeOutputValue("STRESS-XY", iPoint, Node_Struc->GetStress_FEM(iPoint)[2]); if (nDim == 3){ - SetVolumeOutputValue("STRESS-ZZ", iPoint, Node_Struc->GetStress_FEM()[3]); - SetVolumeOutputValue("STRESS-XZ", iPoint, Node_Struc->GetStress_FEM()[4]); - SetVolumeOutputValue("STRESS-YZ", iPoint, Node_Struc->GetStress_FEM()[5]); + SetVolumeOutputValue("STRESS-ZZ", iPoint, Node_Struc->GetStress_FEM(iPoint)[3]); + SetVolumeOutputValue("STRESS-XZ", iPoint, Node_Struc->GetStress_FEM(iPoint)[4]); + SetVolumeOutputValue("STRESS-YZ", iPoint, Node_Struc->GetStress_FEM(iPoint)[5]); } - SetVolumeOutputValue("VON_MISES_STRESS", iPoint, Node_Struc->GetVonMises_Stress()); + SetVolumeOutputValue("VON_MISES_STRESS", iPoint, Node_Struc->GetVonMises_Stress(iPoint)); } diff --git a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp index 20769af8def6..9534d1c2142a 100644 --- a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp @@ -285,35 +285,6 @@ void CFlowCompFEMOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C } -su2double CFlowCompFEMOutput::GetQ_Criterion(CConfig *config, CGeometry *geometry, CVariable* node_flow){ - - unsigned short iDim, jDim; - su2double Grad_Vel[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}; - su2double Omega[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}; - su2double Strain[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}; - for (iDim = 0; iDim < nDim; iDim++) { - for (unsigned short jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node_flow->GetGradient_Primitive(iDim+1, jDim); - Strain[iDim][jDim] = 0.5*(Grad_Vel[iDim][jDim] + Grad_Vel[jDim][iDim]); - Omega[iDim][jDim] = 0.5*(Grad_Vel[iDim][jDim] - Grad_Vel[jDim][iDim]); - } - } - - su2double OmegaMag = 0.0, StrainMag = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0 ; jDim < nDim; jDim++) { - StrainMag += Strain[iDim][jDim]*Strain[iDim][jDim]; - OmegaMag += Omega[iDim][jDim]*Omega[iDim][jDim]; - } - } - StrainMag = sqrt(StrainMag); OmegaMag = sqrt(OmegaMag); - - su2double Q = 0.5*(OmegaMag - StrainMag); - - return Q; -} - - bool CFlowCompFEMOutput::SetInit_Residuals(CConfig *config){ return (config->GetTime_Marching() != STEADY && (curInnerIter == 0))|| diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 745bb1ace2c5..84e736c7e6a0 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -399,11 +399,11 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ - CVariable* Node_Flow = solver[FLOW_SOL]->node[iPoint]; + CVariable* Node_Flow = solver[FLOW_SOL]->GetNodes(); CVariable* Node_Turb = NULL; if (config->GetKind_Turb_Model() != NONE){ - Node_Turb = solver[TURB_SOL]->node[iPoint]; + Node_Turb = solver[TURB_SOL]->GetNodes(); } CPoint* Node_Geo = geometry->node[iPoint]; @@ -413,25 +413,25 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv if (nDim == 3) SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(2)); - SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetSolution(0)); - SetVolumeOutputValue("MOMENTUM-X", iPoint, Node_Flow->GetSolution(1)); - SetVolumeOutputValue("MOMENTUM-Y", iPoint, Node_Flow->GetSolution(2)); + SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetSolution(iPoint, 0)); + SetVolumeOutputValue("MOMENTUM-X", iPoint, Node_Flow->GetSolution(iPoint, 1)); + SetVolumeOutputValue("MOMENTUM-Y", iPoint, Node_Flow->GetSolution(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("MOMENTUM-Z", iPoint, Node_Flow->GetSolution(3)); - SetVolumeOutputValue("ENERGY", iPoint, Node_Flow->GetSolution(4)); + SetVolumeOutputValue("MOMENTUM-Z", iPoint, Node_Flow->GetSolution(iPoint, 3)); + SetVolumeOutputValue("ENERGY", iPoint, Node_Flow->GetSolution(iPoint, 4)); } else { - SetVolumeOutputValue("ENERGY", iPoint, Node_Flow->GetSolution(3)); + SetVolumeOutputValue("ENERGY", iPoint, Node_Flow->GetSolution(iPoint, 3)); } // Turbulent Residuals switch(config->GetKind_Turb_Model()){ case SST: case SST_SUST: - SetVolumeOutputValue("TKE", iPoint, Node_Turb->GetSolution(0)); - SetVolumeOutputValue("DISSIPATION", iPoint, Node_Turb->GetSolution(1)); + SetVolumeOutputValue("TKE", iPoint, Node_Turb->GetSolution(iPoint, 0)); + SetVolumeOutputValue("DISSIPATION", iPoint, Node_Turb->GetSolution(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("NU_TILDE", iPoint, Node_Turb->GetSolution(0)); + SetVolumeOutputValue("NU_TILDE", iPoint, Node_Turb->GetSolution(iPoint, 0)); break; case NONE: break; @@ -444,26 +444,27 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("GRID_VELOCITY-Z", iPoint, Node_Geo->GetGridVel()[2]); } - SetVolumeOutputValue("PRESSURE", iPoint, Node_Flow->GetPressure()); - SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetTemperature()); - SetVolumeOutputValue("MACH", iPoint, sqrt(Node_Flow->GetVelocity2())/Node_Flow->GetSoundSpeed()); + SetVolumeOutputValue("PRESSURE", iPoint, Node_Flow->GetPressure(iPoint)); + SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetTemperature(iPoint)); + SetVolumeOutputValue("MACH", iPoint, sqrt(Node_Flow->GetVelocity2(iPoint))/Node_Flow->GetSoundSpeed(iPoint)); + su2double VelMag = 0.0; for (unsigned short iDim = 0; iDim < nDim; iDim++){ - VelMag += solver[FLOW_SOL]->GetVelocity_Inf(iDim)*solver[FLOW_SOL]->GetVelocity_Inf(iDim); + VelMag += pow(solver[FLOW_SOL]->GetVelocity_Inf(iDim),2.0); } su2double factor = 1.0/(0.5*solver[FLOW_SOL]->GetDensity_Inf()*VelMag); - SetVolumeOutputValue("PRESSURE_COEFF", iPoint, (Node_Flow->GetPressure() - solver[FLOW_SOL]->GetPressure_Inf())*factor); + SetVolumeOutputValue("PRESSURE_COEFF", iPoint, (Node_Flow->GetPressure(iPoint) - solver[FLOW_SOL]->GetPressure_Inf())*factor); if (config->GetKind_Solver() == RANS || config->GetKind_Solver() == NAVIER_STOKES){ - SetVolumeOutputValue("LAMINAR_VISCOSITY", iPoint, Node_Flow->GetLaminarViscosity()); + SetVolumeOutputValue("LAMINAR_VISCOSITY", iPoint, Node_Flow->GetLaminarViscosity(iPoint)); } if (config->GetKind_Solver() == RANS) { - SetVolumeOutputValue("EDDY_VISCOSITY", iPoint, Node_Flow->GetEddyViscosity()); + SetVolumeOutputValue("EDDY_VISCOSITY", iPoint, Node_Flow->GetEddyViscosity(iPoint)); } if (config->GetKind_Trans_Model() == BC){ - SetVolumeOutputValue("INTERMITTENCY", iPoint, Node_Turb->GetGammaBC()); + SetVolumeOutputValue("INTERMITTENCY", iPoint, Node_Turb->GetGammaBC(iPoint)); } SetVolumeOutputValue("RES_DENSITY", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 0)); @@ -489,45 +490,45 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv break; } - SetVolumeOutputValue("LIMITER_DENSITY", iPoint, Node_Flow->GetLimiter_Primitive(0)); - SetVolumeOutputValue("LIMITER_MOMENTUM-X", iPoint, Node_Flow->GetLimiter_Primitive(1)); - SetVolumeOutputValue("LIMITER_MOMENTUM-Y", iPoint, Node_Flow->GetLimiter_Primitive(2)); + SetVolumeOutputValue("LIMITER_DENSITY", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 0)); + SetVolumeOutputValue("LIMITER_MOMENTUM-X", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 1)); + SetVolumeOutputValue("LIMITER_MOMENTUM-Y", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("LIMITER_MOMENTUM-Z", iPoint, Node_Flow->GetLimiter_Primitive(3)); - SetVolumeOutputValue("LIMITER_ENERGY", iPoint, Node_Flow->GetLimiter_Primitive(4)); + SetVolumeOutputValue("LIMITER_MOMENTUM-Z", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 3)); + SetVolumeOutputValue("LIMITER_ENERGY", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 4)); } else { - SetVolumeOutputValue("LIMITER_ENERGY", iPoint, Node_Flow->GetLimiter_Primitive(3)); + SetVolumeOutputValue("LIMITER_ENERGY", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 3)); } switch(config->GetKind_Turb_Model()){ case SST: case SST_SUST: - SetVolumeOutputValue("LIMITER_TKE", iPoint, Node_Turb->GetLimiter_Primitive(0)); - SetVolumeOutputValue("LIMITER_DISSIPATION", iPoint, Node_Turb->GetLimiter_Primitive(1)); + SetVolumeOutputValue("LIMITER_TKE", iPoint, Node_Turb->GetLimiter_Primitive(iPoint, 0)); + SetVolumeOutputValue("LIMITER_DISSIPATION", iPoint, Node_Turb->GetLimiter_Primitive(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("LIMITER_NU_TILDE", iPoint, Node_Turb->GetLimiter_Primitive(0)); + SetVolumeOutputValue("LIMITER_NU_TILDE", iPoint, Node_Turb->GetLimiter_Primitive(iPoint, 0)); break; case NONE: break; } if (config->GetKind_HybridRANSLES() != NO_HYBRIDRANSLES){ - SetVolumeOutputValue("DES_LENGTHSCALE", iPoint, Node_Flow->GetDES_LengthScale()); + SetVolumeOutputValue("DES_LENGTHSCALE", iPoint, Node_Flow->GetDES_LengthScale(iPoint)); SetVolumeOutputValue("WALL_DISTANCE", iPoint, Node_Geo->GetWall_Distance()); } if (config->GetKind_RoeLowDiss() != NO_ROELOWDISS){ - SetVolumeOutputValue("ROE_DISSIPATION", iPoint, Node_Flow->GetRoe_Dissipation()); + SetVolumeOutputValue("ROE_DISSIPATION", iPoint, Node_Flow->GetRoe_Dissipation(iPoint)); } if(config->GetKind_Solver() == RANS || config->GetKind_Solver() == NAVIER_STOKES){ if (nDim == 3){ - SetVolumeOutputValue("VORTICITY_X", iPoint, Node_Flow->GetVorticity()[0]); - SetVolumeOutputValue("VORTICITY_Y", iPoint, Node_Flow->GetVorticity()[1]); - SetVolumeOutputValue("Q_CRITERION", iPoint, GetQ_Criterion(config, geometry, Node_Flow)); + SetVolumeOutputValue("VORTICITY_X", iPoint, Node_Flow->GetVorticity(iPoint)[0]); + SetVolumeOutputValue("VORTICITY_Y", iPoint, Node_Flow->GetVorticity(iPoint)[1]); + SetVolumeOutputValue("Q_CRITERION", iPoint, GetQ_Criterion(&(Node_Flow->GetGradient_Primitive(iPoint)[1]))); } - SetVolumeOutputValue("VORTICITY_Z", iPoint, Node_Flow->GetVorticity()[2]); + SetVolumeOutputValue("VORTICITY_Z", iPoint, Node_Flow->GetVorticity(iPoint)[2]); } if (config->GetTime_Domain()){ @@ -659,34 +660,6 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol } -su2double CFlowCompOutput::GetQ_Criterion(CConfig *config, CGeometry *geometry, CVariable* node_flow){ - - unsigned short iDim; - su2double Grad_Vel[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}; - - for (iDim = 0; iDim < nDim; iDim++) { - for (unsigned short jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node_flow->GetGradient_Primitive(iDim+1, jDim); - } - } - - su2double s11 = Grad_Vel[0][0]; - su2double s12 = 0.5 * (Grad_Vel[0][1] + Grad_Vel[1][0]); - su2double s13 = 0.5 * (Grad_Vel[0][2] + Grad_Vel[2][0]); - su2double s22 = Grad_Vel[1][1]; - su2double s23 = 0.5 * (Grad_Vel[1][2] + Grad_Vel[2][1]); - su2double s33 = Grad_Vel[2][2]; - su2double omega12 = 0.5 * (Grad_Vel[0][1] - Grad_Vel[1][0]); - su2double omega13 = 0.5 * (Grad_Vel[0][2] - Grad_Vel[2][0]); - su2double omega23 = 0.5 * (Grad_Vel[1][2] - Grad_Vel[2][1]); - - su2double Q = 2. * pow( omega12, 2.) + 2. * pow( omega13, 2.) + 2. * pow( omega23, 2.) - \ - pow( s11, 2.) - pow( s22, 2.) - pow( s33, 2.0) - 2. * pow( s12, 2.) - 2. * pow( s13, 2.) - 2. * pow( s23, 2.0); - - return Q; -} - - bool CFlowCompOutput::SetInit_Residuals(CConfig *config){ return (config->GetTime_Marching() != STEADY && (curInnerIter == 0))|| diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 8f40985459c6..14a658a11b53 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -285,7 +285,7 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv SetHistoryOutputValue("TEMPERATURE", heat_solver->GetTotal_AvgTemperature()); SetHistoryOutputValue("RMS_TEMPERATURE", log10(heat_solver->GetRes_RMS(0))); SetHistoryOutputValue("MAX_TEMPERATURE", log10(heat_solver->GetRes_Max(0))); - if (multiZone) SetHistoryOutputValue("BGS_HEAT", log10(heat_solver->GetRes_BGS(0))); + if (multiZone) SetHistoryOutputValue("BGS_TEMPERATURE", log10(heat_solver->GetRes_BGS(0))); } if (heat){ SetHistoryOutputValue("HEATFLUX", flow_solver->GetTotal_HeatFlux()); @@ -459,15 +459,15 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ - CVariable* Node_Flow = solver[FLOW_SOL]->node[iPoint]; + CVariable* Node_Flow = solver[FLOW_SOL]->GetNodes(); CVariable* Node_Heat = NULL; CVariable* Node_Turb = NULL; if (config->GetKind_Turb_Model() != NONE){ - Node_Turb = solver[TURB_SOL]->node[iPoint]; + Node_Turb = solver[TURB_SOL]->GetNodes(); } if (weakly_coupled_heat){ - Node_Heat = solver[HEAT_SOL]->node[iPoint]; + Node_Heat = solver[HEAT_SOL]->GetNodes(); } CPoint* Node_Geo = geometry->node[iPoint]; @@ -477,25 +477,25 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve if (nDim == 3) SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(2)); - SetVolumeOutputValue("PRESSURE", iPoint, Node_Flow->GetSolution(0)); - SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Flow->GetSolution(1)); - SetVolumeOutputValue("VELOCITY-Y", iPoint, Node_Flow->GetSolution(2)); + SetVolumeOutputValue("PRESSURE", iPoint, Node_Flow->GetSolution(iPoint, 0)); + SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Flow->GetSolution(iPoint, 1)); + SetVolumeOutputValue("VELOCITY-Y", iPoint, Node_Flow->GetSolution(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Flow->GetSolution(3)); - if (heat) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetSolution(4)); + SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Flow->GetSolution(iPoint, 3)); + if (heat) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetSolution(iPoint, 4)); } else { - if (heat) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetSolution(3)); + if (heat) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Flow->GetSolution(iPoint, 3)); } - if (weakly_coupled_heat) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(0)); + if (weakly_coupled_heat) SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0)); switch(config->GetKind_Turb_Model()){ case SST: case SST_SUST: - SetVolumeOutputValue("TKE", iPoint, Node_Turb->GetSolution(0)); - SetVolumeOutputValue("DISSIPATION", iPoint, Node_Turb->GetSolution(1)); + SetVolumeOutputValue("TKE", iPoint, Node_Turb->GetSolution(iPoint, 0)); + SetVolumeOutputValue("DISSIPATION", iPoint, Node_Turb->GetSolution(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("NU_TILDE", iPoint, Node_Turb->GetSolution(0)); + SetVolumeOutputValue("NU_TILDE", iPoint, Node_Turb->GetSolution(iPoint, 0)); break; case NONE: break; @@ -510,22 +510,22 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve su2double VelMag = 0.0; for (unsigned short iDim = 0; iDim < nDim; iDim++){ - VelMag += solver[FLOW_SOL]->GetVelocity_Inf(iDim)*solver[FLOW_SOL]->GetVelocity_Inf(iDim); + VelMag += pow(solver[FLOW_SOL]->GetVelocity_Inf(iDim),2.0); } su2double factor = 1.0/(0.5*solver[FLOW_SOL]->GetDensity_Inf()*VelMag); - SetVolumeOutputValue("PRESSURE_COEFF", iPoint, (Node_Flow->GetPressure() - config->GetPressure_FreeStreamND())*factor); - SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetDensity()); + SetVolumeOutputValue("PRESSURE_COEFF", iPoint, (Node_Flow->GetPressure(iPoint) - config->GetPressure_FreeStreamND())*factor); + SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetDensity(iPoint)); if (config->GetKind_Solver() == INC_RANS || config->GetKind_Solver() == INC_NAVIER_STOKES){ - SetVolumeOutputValue("LAMINAR_VISCOSITY", iPoint, Node_Flow->GetLaminarViscosity()); + SetVolumeOutputValue("LAMINAR_VISCOSITY", iPoint, Node_Flow->GetLaminarViscosity(iPoint)); } if (config->GetKind_Solver() == INC_RANS) { - SetVolumeOutputValue("EDDY_VISCOSITY", iPoint, Node_Flow->GetEddyViscosity()); + SetVolumeOutputValue("EDDY_VISCOSITY", iPoint, Node_Flow->GetEddyViscosity(iPoint)); } if (config->GetKind_Trans_Model() == BC){ - SetVolumeOutputValue("INTERMITTENCY", iPoint, Node_Turb->GetGammaBC()); + SetVolumeOutputValue("INTERMITTENCY", iPoint, Node_Turb->GetGammaBC(iPoint)); } SetVolumeOutputValue("RES_PRESSURE", iPoint, solver[FLOW_SOL]->LinSysRes.GetBlock(iPoint, 0)); @@ -551,45 +551,45 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve break; } - SetVolumeOutputValue("LIMITER_PRESSURE", iPoint, Node_Flow->GetLimiter_Primitive(0)); - SetVolumeOutputValue("LIMITER_VELOCITY-X", iPoint, Node_Flow->GetLimiter_Primitive(1)); - SetVolumeOutputValue("LIMITER_VELOCITY-Y", iPoint, Node_Flow->GetLimiter_Primitive(2)); + SetVolumeOutputValue("LIMITER_PRESSURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 0)); + SetVolumeOutputValue("LIMITER_VELOCITY-X", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 1)); + SetVolumeOutputValue("LIMITER_VELOCITY-Y", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 2)); if (nDim == 3){ - SetVolumeOutputValue("LIMITER_VELOCITY-Z", iPoint, Node_Flow->GetLimiter_Primitive(3)); - SetVolumeOutputValue("LIMITER_TEMPERATURE", iPoint, Node_Flow->GetLimiter_Primitive(4)); + SetVolumeOutputValue("LIMITER_VELOCITY-Z", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 3)); + SetVolumeOutputValue("LIMITER_TEMPERATURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 4)); } else { - SetVolumeOutputValue("LIMITER_TEMPERATURE", iPoint, Node_Flow->GetLimiter_Primitive(3)); + SetVolumeOutputValue("LIMITER_TEMPERATURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 3)); } switch(config->GetKind_Turb_Model()){ case SST: case SST_SUST: - SetVolumeOutputValue("LIMITER_TKE", iPoint, Node_Turb->GetLimiter_Primitive(0)); - SetVolumeOutputValue("LIMITER_DISSIPATION", iPoint, Node_Turb->GetLimiter_Primitive(1)); + SetVolumeOutputValue("LIMITER_TKE", iPoint, Node_Turb->GetLimiter_Primitive(iPoint, 0)); + SetVolumeOutputValue("LIMITER_DISSIPATION", iPoint, Node_Turb->GetLimiter_Primitive(iPoint, 1)); break; case SA: case SA_COMP: case SA_E: case SA_E_COMP: case SA_NEG: - SetVolumeOutputValue("LIMITER_NU_TILDE", iPoint, Node_Turb->GetLimiter_Primitive(0)); + SetVolumeOutputValue("LIMITER_NU_TILDE", iPoint, Node_Turb->GetLimiter_Primitive(iPoint, 0)); break; case NONE: break; } if (config->GetKind_HybridRANSLES() != NO_HYBRIDRANSLES){ - SetVolumeOutputValue("DES_LENGTHSCALE", iPoint, Node_Flow->GetDES_LengthScale()); + SetVolumeOutputValue("DES_LENGTHSCALE", iPoint, Node_Flow->GetDES_LengthScale(iPoint)); SetVolumeOutputValue("WALL_DISTANCE", iPoint, Node_Geo->GetWall_Distance()); } if (config->GetKind_RoeLowDiss() != NO_ROELOWDISS){ - SetVolumeOutputValue("ROE_DISSIPATION", iPoint, Node_Flow->GetRoe_Dissipation()); + SetVolumeOutputValue("ROE_DISSIPATION", iPoint, Node_Flow->GetRoe_Dissipation(iPoint)); } if(config->GetKind_Solver() == INC_RANS || config->GetKind_Solver() == INC_NAVIER_STOKES){ if (nDim == 3){ - SetVolumeOutputValue("VORTICITY_X", iPoint, Node_Flow->GetVorticity()[0]); - SetVolumeOutputValue("VORTICITY_Y", iPoint, Node_Flow->GetVorticity()[1]); - SetVolumeOutputValue("Q_CRITERION", iPoint, GetQ_Criterion(config, geometry, Node_Flow)); + SetVolumeOutputValue("VORTICITY_X", iPoint, Node_Flow->GetVorticity(iPoint)[0]); + SetVolumeOutputValue("VORTICITY_Y", iPoint, Node_Flow->GetVorticity(iPoint)[1]); + SetVolumeOutputValue("Q_CRITERION", iPoint, GetQ_Criterion(&(Node_Flow->GetGradient_Primitive(iPoint)[1]))); } - SetVolumeOutputValue("VORTICITY_Z", iPoint, Node_Flow->GetVorticity()[2]); + SetVolumeOutputValue("VORTICITY_Z", iPoint, Node_Flow->GetVorticity(iPoint)[2]); } } @@ -611,33 +611,6 @@ void CFlowIncOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolv } } -su2double CFlowIncOutput::GetQ_Criterion(CConfig *config, CGeometry *geometry, CVariable* node_flow){ - - unsigned short iDim; - su2double Grad_Vel[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}; - - for (iDim = 0; iDim < nDim; iDim++) { - for (unsigned short jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node_flow->GetGradient_Primitive(iDim+1, jDim); - } - } - - su2double s11 = Grad_Vel[0][0]; - su2double s12 = 0.5 * (Grad_Vel[0][1] + Grad_Vel[1][0]); - su2double s13 = 0.5 * (Grad_Vel[0][2] + Grad_Vel[2][0]); - su2double s22 = Grad_Vel[1][1]; - su2double s23 = 0.5 * (Grad_Vel[1][2] + Grad_Vel[2][1]); - su2double s33 = Grad_Vel[2][2]; - su2double omega12 = 0.5 * (Grad_Vel[0][1] - Grad_Vel[1][0]); - su2double omega13 = 0.5 * (Grad_Vel[0][2] - Grad_Vel[2][0]); - su2double omega23 = 0.5 * (Grad_Vel[1][2] - Grad_Vel[2][1]); - - su2double Q = 2. * pow( omega12, 2.) + 2. * pow( omega13, 2.) + 2. * pow( omega23, 2.) - \ - pow( s11, 2.) - pow( s22, 2.) - pow( s33, 2.0) - 2. * pow( s12, 2.) - 2. * pow( s13, 2.) - 2. * pow( s23, 2.0); - - return Q; -} - bool CFlowIncOutput::SetInit_Residuals(CConfig *config){ return (config->GetTime_Marching() != STEADY && (curInnerIter == 0))|| diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 76208552ba1d..7d9e36e7d237 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -122,7 +122,7 @@ void CFlowOutput::SetAnalyzeSurface(CSolver *solver, CGeometry *geometry, CConfi unsigned short iDim, iMarker, iMarker_Analyze; unsigned long iVertex, iPoint; su2double Mach = 0.0, Pressure, Temperature = 0.0, TotalPressure = 0.0, TotalTemperature = 0.0, - Enthalpy, Velocity[3], TangVel[3], Velocity2, MassFlow, Density, Area, + Enthalpy, Velocity[3] = {}, TangVel[3], Velocity2, MassFlow, Density, Area, AxiFactor = 1.0, SoundSpeed, Vn, Vn2, Vtang2, Weight = 1.0; su2double Gas_Constant = config->GetGas_ConstantND(); @@ -207,12 +207,12 @@ void CFlowOutput::SetAnalyzeSurface(CSolver *solver, CGeometry *geometry, CConfi AxiFactor = 1.0; } - Density = solver->node[iPoint]->GetDensity(); + Density = solver->GetNodes()->GetDensity(iPoint); Velocity2 = 0.0; Area = 0.0; MassFlow = 0.0; Vn = 0.0; Vtang2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Area += (Vector[iDim] * AxiFactor) * (Vector[iDim] * AxiFactor); - Velocity[iDim] = solver->node[iPoint]->GetVelocity(iDim); + Velocity[iDim] = solver->GetNodes()->GetVelocity(iPoint,iDim); Velocity2 += Velocity[iDim] * Velocity[iDim]; Vn += Velocity[iDim] * Vector[iDim] * AxiFactor; MassFlow += Vector[iDim] * AxiFactor * Density * Velocity[iDim]; @@ -221,8 +221,8 @@ void CFlowOutput::SetAnalyzeSurface(CSolver *solver, CGeometry *geometry, CConfi Area = sqrt (Area); if (AxiFactor == 0.0) Vn = 0.0; else Vn /= Area; Vn2 = Vn * Vn; - Pressure = solver->node[iPoint]->GetPressure(); - SoundSpeed = solver->node[iPoint]->GetSoundSpeed(); + Pressure = solver->GetNodes()->GetPressure(iPoint); + SoundSpeed = solver->GetNodes()->GetSoundSpeed(iPoint); for (iDim = 0; iDim < nDim; iDim++) { TangVel[iDim] = Velocity[iDim] - Vn*Vector[iDim]*AxiFactor/Area; @@ -231,21 +231,21 @@ void CFlowOutput::SetAnalyzeSurface(CSolver *solver, CGeometry *geometry, CConfi if (incompressible){ if (config->GetKind_DensityModel() == VARIABLE) { - Mach = sqrt(solver->node[iPoint]->GetVelocity2())/ - sqrt(solver->node[iPoint]->GetSpecificHeatCp()*config->GetPressure_ThermodynamicND()/(solver->node[iPoint]->GetSpecificHeatCv()*solver->node[iPoint]->GetDensity())); + Mach = sqrt(solver->GetNodes()->GetVelocity2(iPoint))/ + sqrt(solver->GetNodes()->GetSpecificHeatCp(iPoint)*config->GetPressure_ThermodynamicND()/(solver->GetNodes()->GetSpecificHeatCv(iPoint)*solver->GetNodes()->GetDensity(iPoint))); } else { - Mach = sqrt(solver->node[iPoint]->GetVelocity2())/ - sqrt(config->GetBulk_Modulus()/(solver->node[iPoint]->GetDensity())); + Mach = sqrt(solver->GetNodes()->GetVelocity2(iPoint))/ + sqrt(config->GetBulk_Modulus()/(solver->GetNodes()->GetDensity(iPoint))); } - Temperature = solver->node[iPoint]->GetTemperature(); - Enthalpy = solver->node[iPoint]->GetSpecificHeatCp()*Temperature; - TotalTemperature = Temperature + 0.5*Velocity2/solver->node[iPoint]->GetSpecificHeatCp(); + Temperature = solver->GetNodes()->GetTemperature(iPoint); + Enthalpy = solver->GetNodes()->GetSpecificHeatCp(iPoint)*Temperature; + TotalTemperature = Temperature + 0.5*Velocity2/solver->GetNodes()->GetSpecificHeatCp(iPoint); TotalPressure = Pressure + 0.5*Density*Velocity2; } else{ Mach = sqrt(Velocity2)/SoundSpeed; Temperature = Pressure / (Gas_Constant * Density); - Enthalpy = solver->node[iPoint]->GetEnthalpy(); + Enthalpy = solver->GetNodes()->GetEnthalpy(iPoint); TotalTemperature = Temperature * (1.0 + Mach * Mach * 0.5 * (Gamma - 1.0)); TotalPressure = Pressure * pow( 1.0 + Mach * Mach * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); } @@ -922,6 +922,39 @@ void CFlowOutput::Set_CpInverseDesign(CSolver *solver, CGeometry *geometry, CCon } +su2double CFlowOutput::GetQ_Criterion(su2double** VelocityGradient) const { + + /*--- Make a 3D copy of the gradient so we do not have worry about nDim ---*/ + + su2double Grad_Vel[3][3] = {{0.0, 0.0, 0.0},{0.0, 0.0, 0.0},{0.0, 0.0, 0.0}}; + + for (unsigned short iDim = 0; iDim < nDim; iDim++) + for (unsigned short jDim = 0 ; jDim < nDim; jDim++) + Grad_Vel[iDim][jDim] = VelocityGradient[iDim][jDim]; + + /*--- Q Criterion Eq 1.2 of HALLER, G. (2005). An objective definition of a vortex. + Journal of Fluid Mechanics, 525, 1-26. doi:10.1017/S0022112004002526 ---*/ + + /*--- Components of the strain rate tensor (symmetric) ---*/ + su2double s11 = Grad_Vel[0][0]; + su2double s12 = 0.5 * (Grad_Vel[0][1] + Grad_Vel[1][0]); + su2double s13 = 0.5 * (Grad_Vel[0][2] + Grad_Vel[2][0]); + su2double s22 = Grad_Vel[1][1]; + su2double s23 = 0.5 * (Grad_Vel[1][2] + Grad_Vel[2][1]); + su2double s33 = Grad_Vel[2][2]; + + /*--- Components of the spin tensor (skew-symmetric) ---*/ + su2double omega12 = 0.5 * (Grad_Vel[0][1] - Grad_Vel[1][0]); + su2double omega13 = 0.5 * (Grad_Vel[0][2] - Grad_Vel[2][0]); + su2double omega23 = 0.5 * (Grad_Vel[1][2] - Grad_Vel[2][1]); + + /*--- Q = ||Omega|| - ||Strain|| ---*/ + su2double Q = 2*(pow(omega12,2) + pow(omega13,2) + pow(omega23,2)) - + (pow(s11,2) + pow(s22,2) + pow(s33,2) + 2*(pow(s12,2) + pow(s13,2) + pow(s23,2))); + + return Q; +} + void CFlowOutput::WriteAdditionalFiles(CConfig *config, CGeometry *geometry, CSolver **solver_container){ if (config->GetFixed_CL_Mode() || config->GetFixed_CM_Mode()){ @@ -968,7 +1001,6 @@ void CFlowOutput::WriteMetaData(CConfig *config, CGeometry *geometry){ } meta_file.close(); - } void CFlowOutput::WriteForcesBreakdown(CConfig *config, CGeometry *geometry, CSolver **solver_container){ @@ -2853,22 +2885,22 @@ void CFlowOutput::SetTimeAveragedFields(){ } void CFlowOutput::LoadTimeAveragedData(unsigned long iPoint, CVariable *Node_Flow){ - SetAvgVolumeOutputValue("MEAN_DENSITY", iPoint, Node_Flow->GetDensity()); - SetAvgVolumeOutputValue("MEAN_VELOCITY-X", iPoint, Node_Flow->GetVelocity(0)); - SetAvgVolumeOutputValue("MEAN_VELOCITY-Y", iPoint, Node_Flow->GetVelocity(1)); + SetAvgVolumeOutputValue("MEAN_DENSITY", iPoint, Node_Flow->GetDensity(iPoint)); + SetAvgVolumeOutputValue("MEAN_VELOCITY-X", iPoint, Node_Flow->GetVelocity(iPoint,0)); + SetAvgVolumeOutputValue("MEAN_VELOCITY-Y", iPoint, Node_Flow->GetVelocity(iPoint,1)); if (nDim == 3) - SetAvgVolumeOutputValue("MEAN_VELOCITY-Z", iPoint, Node_Flow->GetVelocity(2)); + SetAvgVolumeOutputValue("MEAN_VELOCITY-Z", iPoint, Node_Flow->GetVelocity(iPoint,2)); - SetAvgVolumeOutputValue("MEAN_PRESSURE", iPoint, Node_Flow->GetPressure()); + SetAvgVolumeOutputValue("MEAN_PRESSURE", iPoint, Node_Flow->GetPressure(iPoint)); - SetAvgVolumeOutputValue("RMS_U", iPoint, pow(Node_Flow->GetVelocity(0),2)); - SetAvgVolumeOutputValue("RMS_V", iPoint, pow(Node_Flow->GetVelocity(1),2)); - SetAvgVolumeOutputValue("RMS_UV", iPoint, Node_Flow->GetVelocity(0) * Node_Flow->GetVelocity(1)); - SetAvgVolumeOutputValue("RMS_P", iPoint, pow(Node_Flow->GetPressure(),2)); + SetAvgVolumeOutputValue("RMS_U", iPoint, pow(Node_Flow->GetVelocity(iPoint,0),2)); + SetAvgVolumeOutputValue("RMS_V", iPoint, pow(Node_Flow->GetVelocity(iPoint,1),2)); + SetAvgVolumeOutputValue("RMS_UV", iPoint, Node_Flow->GetVelocity(iPoint,0) * Node_Flow->GetVelocity(iPoint,1)); + SetAvgVolumeOutputValue("RMS_P", iPoint, pow(Node_Flow->GetPressure(iPoint),2)); if (nDim == 3){ - SetAvgVolumeOutputValue("RMS_W", iPoint, pow(Node_Flow->GetVelocity(2),2)); - SetAvgVolumeOutputValue("RMS_VW", iPoint, Node_Flow->GetVelocity(2) * Node_Flow->GetVelocity(1)); - SetAvgVolumeOutputValue("RMS_UW", iPoint, Node_Flow->GetVelocity(2) * Node_Flow->GetVelocity(0)); + SetAvgVolumeOutputValue("RMS_W", iPoint, pow(Node_Flow->GetVelocity(iPoint,2),2)); + SetAvgVolumeOutputValue("RMS_VW", iPoint, Node_Flow->GetVelocity(iPoint,2) * Node_Flow->GetVelocity(iPoint,1)); + SetAvgVolumeOutputValue("RMS_UW", iPoint, Node_Flow->GetVelocity(iPoint,2) * Node_Flow->GetVelocity(iPoint,0)); } const su2double umean = GetVolumeOutputValue("MEAN_VELOCITY-X", iPoint); diff --git a/SU2_CFD/src/output/CHeatOutput.cpp b/SU2_CFD/src/output/CHeatOutput.cpp index 2e51d7387403..33e98660477f 100644 --- a/SU2_CFD/src/output/CHeatOutput.cpp +++ b/SU2_CFD/src/output/CHeatOutput.cpp @@ -132,16 +132,18 @@ void CHeatOutput::SetVolumeOutputFields(CConfig *config){ // SOLUTION AddVolumeOutput("TEMPERATURE", "Temperature", "SOLUTION", "Temperature"); + // Primitives + AddVolumeOutput("HEAT_FLUX", "Heat_Flux", "PRIMITIVE", "Heatflux"); + // Residuals - AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "RMS residual of the temperature"); + AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature"); } void CHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ - CVariable* Node_Heat = solver[HEAT_SOL]->node[iPoint]; - + CVariable* Node_Heat = solver[HEAT_SOL]->GetNodes(); CPoint* Node_Geo = geometry->node[iPoint]; // Grid coordinates @@ -151,10 +153,17 @@ void CHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver * SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(2)); // SOLUTION - SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(0)); + SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0)); // Residuals SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[HEAT_SOL]->LinSysRes.GetBlock(iPoint, 0)); } +void CHeatOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex){ + + /* Heat flux value at each surface grid node. */ + SetVolumeOutputValue("HEAT_FLUX", iPoint, solver[HEAT_SOL]->GetHeatFlux(iMarker, iVertex)); + +} + diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 055b4d86d733..bbbb8d715fec 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1456,6 +1456,18 @@ void COutput::Postprocess_HistoryData(CConfig *config){ Average[currentField.outputGroup].second++; } + + for (unsigned short iField = 0; iField < historyOutputPerSurface_List.size(); iField++){ + for (unsigned short iMarker = 0; iMarker < historyOutputPerSurface_Map[historyOutputPerSurface_List[iField]].size(); iMarker++){ + HistoryOutputField &Field = historyOutputPerSurface_Map[historyOutputPerSurface_List[iField]][iMarker]; + if (Field.fieldType == HistoryFieldType::COEFFICIENT){ + if (config->GetDirectDiff() != NO_DERIVATIVE){ + SetHistoryOutputValue("D_" + historyOutputPerSurface_List[iField][iMarker], SU2_TYPE::GetDerivative(Field.value)); + } + } + } + } + if (currentField.fieldType == HistoryFieldType::COEFFICIENT){ if(SetUpdate_Averages(config)){ if (config->GetTime_Domain()){ @@ -1542,6 +1554,15 @@ void COutput::Postprocess_HistoryFields(CConfig *config){ } } } + + for (unsigned short iField = 0; iField < historyOutputPerSurface_List.size(); iField++){ + for (unsigned short iMarker = 0; iMarker < historyOutputPerSurface_Map[historyOutputPerSurface_List[iField]].size(); iMarker++){ + HistoryOutputField &Field = historyOutputPerSurface_Map[historyOutputPerSurface_List[iField]][iMarker]; + if (Field.fieldType == HistoryFieldType::COEFFICIENT){ + AddHistoryOutput("D_" + historyOutputPerSurface_List[iField][iMarker], "d[" + Field.fieldName + "]", Field.screenFormat, "D_" + Field.outputGroup, "Derivative values for per-surface output.", HistoryFieldType::AUTO_COEFFICIENT); + } + } + } for (unsigned short iFieldConv = 0; iFieldConv < convFields.size(); iFieldConv++){ const string &convField = convFields[iFieldConv]; diff --git a/SU2_CFD/src/output/output_structure_legacy.cpp b/SU2_CFD/src/output/output_structure_legacy.cpp index 77ee8feff6a8..f4d6a0b5e0cc 100644 --- a/SU2_CFD/src/output/output_structure_legacy.cpp +++ b/SU2_CFD/src/output/output_structure_legacy.cpp @@ -506,14 +506,14 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, if (nDim == 3) zCoord *= 12.0; } - Pressure = FlowSolver->node[iPoint]->GetPressure(); + Pressure = FlowSolver->GetNodes()->GetPressure(iPoint); PressCoeff = FlowSolver->GetCPressure(iMarker, iVertex); SurfFlow_file << scientific << Global_Index << ", " << xCoord << ", " << yCoord << ", "; if (nDim == 3) SurfFlow_file << scientific << zCoord << ", "; SurfFlow_file << scientific << Pressure << ", " << PressCoeff << ", "; switch (solver) { case EULER : case FEM_EULER: case INC_EULER: - Mach = sqrt(FlowSolver->node[iPoint]->GetVelocity2()) / FlowSolver->node[iPoint]->GetSoundSpeed(); + Mach = sqrt(FlowSolver->GetNodes()->GetVelocity2(iPoint)) / FlowSolver->GetNodes()->GetSoundSpeed(iPoint); SurfFlow_file << scientific << Mach << "\n"; break; case NAVIER_STOKES: case RANS: case FEM_NAVIER_STOKES: case FEM_RANS: case FEM_LES: @@ -623,7 +623,7 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) { - Buffer_Send_Press[nVertex_Surface] = FlowSolver->node[iPoint]->GetPressure(); + Buffer_Send_Press[nVertex_Surface] = FlowSolver->GetNodes()->GetPressure(iPoint); Buffer_Send_CPress[nVertex_Surface] = FlowSolver->GetCPressure(iMarker, iVertex); Buffer_Send_Coord_x[nVertex_Surface] = geometry->node[iPoint]->GetCoord(0); Buffer_Send_Coord_y[nVertex_Surface] = geometry->node[iPoint]->GetCoord(1); @@ -640,7 +640,7 @@ void COutputLegacy::SetSurfaceCSV_Flow(CConfig *config, CGeometry *geometry, Buffer_Send_GlobalIndex[nVertex_Surface] = geometry->node[iPoint]->GetGlobalIndex(); if (solver == EULER || solver == FEM_EULER || solver == INC_EULER) - Buffer_Send_Mach[nVertex_Surface] = sqrt(FlowSolver->node[iPoint]->GetVelocity2()) / FlowSolver->node[iPoint]->GetSoundSpeed(); + Buffer_Send_Mach[nVertex_Surface] = sqrt(FlowSolver->GetNodes()->GetVelocity2(iPoint)) / FlowSolver->GetNodes()->GetSoundSpeed(iPoint); if (solver == NAVIER_STOKES || solver == RANS || solver == INC_NAVIER_STOKES || solver == INC_RANS || solver == FEM_NAVIER_STOKES || solver == FEM_RANS || solver == FEM_LES) { @@ -841,7 +841,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - Solution = AdjSolver->node[iPoint]->GetSolution(); + Solution = AdjSolver->GetNodes()->GetSolution(iPoint); xCoord = geometry->node[iPoint]->GetCoord(0); yCoord = geometry->node[iPoint]->GetCoord(1); @@ -858,7 +858,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, SurfAdj_file << scientific << Global_Index << ", " << AdjSolver->GetCSensitivity(iMarker, iVertex) << ", " << Solution[0] << ", " << Solution[1] << ", " << Solution[2] <<", " << xCoord <<", "<< yCoord; if (config->GetDiscrete_Adjoint()) { - SurfAdj_file << ", " << AdjSolver->node[iPoint]->GetSensitivity(0) << ", " << AdjSolver->node[iPoint]->GetSensitivity(1); + SurfAdj_file << ", " << AdjSolver->GetNodes()->GetSensitivity(iPoint,0) << ", " << AdjSolver->GetNodes()->GetSensitivity(iPoint,1); } SurfAdj_file << "\n"; } @@ -880,7 +880,7 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); Global_Index = geometry->node[iPoint]->GetGlobalIndex(); - Solution = AdjSolver->node[iPoint]->GetSolution(); + Solution = AdjSolver->GetNodes()->GetSolution(iPoint); xCoord = geometry->node[iPoint]->GetCoord(0); yCoord = geometry->node[iPoint]->GetCoord(1); @@ -900,8 +900,8 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, SurfAdj_file << scientific << Global_Index << ", " << AdjSolver->GetCSensitivity(iMarker, iVertex) << ", " << Solution[0] << ", " << Solution[1] << ", " << Solution[2] << ", " << Solution[3] << ", " << xCoord <<", "<< yCoord <<", "<< zCoord; if (config->GetDiscrete_Adjoint()) { - SurfAdj_file << ", " << AdjSolver->node[iPoint]->GetSensitivity(0) << ", " << AdjSolver->node[iPoint]->GetSensitivity(1) - << ", " << AdjSolver->node[iPoint]->GetSensitivity(2); + SurfAdj_file << ", " << AdjSolver->GetNodes()->GetSensitivity(iPoint,0) << ", " << AdjSolver->GetNodes()->GetSensitivity(iPoint,1) + << ", " << AdjSolver->GetNodes()->GetSensitivity(iPoint, 2); } SurfAdj_file << "\n"; } @@ -967,10 +967,10 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) { - Solution = AdjSolver->node[iPoint]->GetSolution(); + Solution = AdjSolver->GetNodes()->GetSolution(iPoint); //Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Coord = geometry->node[iPoint]->GetCoord(); - //d = AdjSolver->node[iPoint]->GetForceProj_Vector(); + //d = AdjSolver->GetNodes()->GetForceProj_Vector(iPoint); Buffer_Send_GlobalPoint[nVertex_Surface] = geometry->node[iPoint]->GetGlobalIndex(); Buffer_Send_Coord_x[nVertex_Surface] = Coord[0]; Buffer_Send_Coord_y[nVertex_Surface] = Coord[1]; @@ -985,10 +985,10 @@ void COutputLegacy::SetSurfaceCSV_Adjoint(CConfig *config, CGeometry *geometry, if(config->GetKind_Regime() == COMPRESSIBLE) Buffer_Send_PsiE[nVertex_Surface] = Solution[4]; } if (config->GetDiscrete_Adjoint()) { - Buffer_Send_Sens_x[nVertex_Surface] = AdjSolver->node[iPoint]->GetSensitivity(0); - Buffer_Send_Sens_y[nVertex_Surface] = AdjSolver->node[iPoint]->GetSensitivity(1); + Buffer_Send_Sens_x[nVertex_Surface] = AdjSolver->GetNodes()->GetSensitivity(iPoint, 0); + Buffer_Send_Sens_y[nVertex_Surface] = AdjSolver->GetNodes()->GetSensitivity(iPoint, 1); if (nDim == 3) { - Buffer_Send_Sens_z[nVertex_Surface] = AdjSolver->node[iPoint]->GetSensitivity(2); + Buffer_Send_Sens_z[nVertex_Surface] = AdjSolver->GetNodes()->GetSensitivity(iPoint, 2); } } @@ -2612,24 +2612,23 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Get this variable into the temporary send buffer. ---*/ - Buffer_Send_Var[jPoint] = solver[CurrentIndex]->node[iPoint]->GetSolution(jVar); - - + Buffer_Send_Var[jPoint] = solver[CurrentIndex]->GetNodes()->GetSolution(iPoint, jVar); + + if (config->GetWrt_Limiters()) { - Buffer_Send_Vol[jPoint] = solver[CurrentIndex]->node[iPoint]->GetLimiter_Primitive(jVar); + Buffer_Send_Vol[jPoint] = solver[CurrentIndex]->GetNodes()->GetLimiter_Primitive(iPoint, jVar); } if (config->GetWrt_Residuals()) { if (!config->GetDiscrete_Adjoint()) { Buffer_Send_Res[jPoint] = solver[CurrentIndex]->LinSysRes.GetBlock(iPoint, jVar); } else { - Buffer_Send_Res[jPoint] = solver[CurrentIndex]->node[iPoint]->GetSolution(jVar) - - solver[CurrentIndex]->node[iPoint]->GetSolution_Old(jVar); + Buffer_Send_Res[jPoint] = solver[CurrentIndex]->GetNodes()->GetSolution(iPoint, jVar) - + solver[CurrentIndex]->GetNodes()->GetSolution_Old(iPoint, jVar); } } - /*--- Only send/recv the volumes & global indices during the first loop ---*/ if (iVar == 0) { @@ -2799,13 +2798,13 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the pressure, Cp, and mach variables. ---*/ - Buffer_Send_Var[jPoint] = solver[FLOW_SOL]->node[iPoint]->GetPressure(); + Buffer_Send_Var[jPoint] = solver[FLOW_SOL]->GetNodes()->GetPressure(iPoint); if (compressible){ - Buffer_Send_Res[jPoint] = solver[FLOW_SOL]->node[iPoint]->GetTemperature(); + Buffer_Send_Res[jPoint] = solver[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); } else{ Buffer_Send_Res[jPoint] = 0.0; } - Buffer_Send_Vol[jPoint] = (solver[FLOW_SOL]->node[iPoint]->GetPressure() - RefPressure)*factor*RefArea; + Buffer_Send_Vol[jPoint] = (solver[FLOW_SOL]->GetNodes()->GetPressure(iPoint) - RefPressure)*factor*RefArea; jPoint++; } @@ -2864,12 +2863,12 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the temperature and laminar viscosity variables. ---*/ if (compressible) { - Buffer_Send_Var[jPoint] = sqrt(solver[FLOW_SOL]->node[iPoint]->GetVelocity2())/ - solver[FLOW_SOL]->node[iPoint]->GetSoundSpeed(); + Buffer_Send_Var[jPoint] = sqrt(solver[FLOW_SOL]->GetNodes()->GetVelocity2(iPoint))/ + solver[FLOW_SOL]->GetNodes()->GetSoundSpeed(iPoint); } if (incompressible) { - Buffer_Send_Var[jPoint] = sqrt(solver[FLOW_SOL]->node[iPoint]->GetVelocity2())*config->GetVelocity_Ref()/ - sqrt(config->GetBulk_Modulus()/(solver[FLOW_SOL]->node[iPoint]->GetDensity()*config->GetDensity_Ref())); + Buffer_Send_Var[jPoint] = sqrt(solver[FLOW_SOL]->GetNodes()->GetVelocity2(iPoint))*config->GetVelocity_Ref()/ + sqrt(config->GetBulk_Modulus()/(solver[FLOW_SOL]->GetNodes()->GetDensity(iPoint)*config->GetDensity_Ref())); } jPoint++; } @@ -2921,7 +2920,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the temperature and laminar viscosity variables. ---*/ - Buffer_Send_Res[jPoint] = solver[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); + Buffer_Send_Res[jPoint] = solver[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); jPoint++; } @@ -3134,7 +3133,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the pressure and mach variables. ---*/ - Buffer_Send_Var[jPoint] = solver[FLOW_SOL]->node[iPoint]->GetEddyViscosity(); + Buffer_Send_Var[jPoint] = solver[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); jPoint++; } @@ -3266,9 +3265,9 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver Buffer_Send_Var[jPoint] = Aux_Sens[iPoint]; if ((config->GetKind_ConvNumScheme() == SPACE_CENTERED) && (!config->GetDiscrete_Adjoint())) - Buffer_Send_Res[jPoint] = solver[ADJFLOW_SOL]->node[iPoint]->GetSensor(iPoint); + Buffer_Send_Res[jPoint] = solver[ADJFLOW_SOL]->GetNodes()->GetSensor(iPoint, iPoint); if ((config->GetKind_ConvNumScheme() == SPACE_UPWIND) && (!config->GetDiscrete_Adjoint())) - Buffer_Send_Res[jPoint] = solver[ADJFLOW_SOL]->node[iPoint]->GetLimiter(0); + Buffer_Send_Res[jPoint] = solver[ADJFLOW_SOL]->GetNodes()->GetLimiter(iPoint, 0); jPoint++; } @@ -3326,10 +3325,10 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the skin friction, heat transfer, y+ variables. ---*/ - Buffer_Send_Var[jPoint] = solver[ADJFLOW_SOL]->node[iPoint]->GetSensitivity(0); - Buffer_Send_Res[jPoint] = solver[ADJFLOW_SOL]->node[iPoint]->GetSensitivity(1); + Buffer_Send_Var[jPoint] = solver[ADJFLOW_SOL]->GetNodes()->GetSensitivity(iPoint, 0); + Buffer_Send_Res[jPoint] = solver[ADJFLOW_SOL]->GetNodes()->GetSensitivity(iPoint, 1); if (nDim == 3) - Buffer_Send_Vol[jPoint] = solver[ADJFLOW_SOL]->node[iPoint]->GetSensitivity(2); + Buffer_Send_Vol[jPoint] = solver[ADJFLOW_SOL]->GetNodes()->GetSensitivity(iPoint, 2); jPoint++; } } @@ -3388,7 +3387,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the three grid velocity components. ---*/ - Node_Vel = solver[FEA_SOL]->node[iPoint]->GetSolution_Vel(); + Node_Vel = solver[FEA_SOL]->GetNodes()->GetSolution_Vel(iPoint); Buffer_Send_Var[jPoint] = Node_Vel[0]; Buffer_Send_Res[jPoint] = Node_Vel[1]; if (geometry->GetnDim() == 3) Buffer_Send_Vol[jPoint] = Node_Vel[2]; @@ -3451,7 +3450,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the three grid velocity components. ---*/ - Node_Accel = solver[FEA_SOL]->node[iPoint]->GetSolution_Accel(); + Node_Accel = solver[FEA_SOL]->GetNodes()->GetSolution_Accel(iPoint); Buffer_Send_Var[jPoint] = Node_Accel[0]; Buffer_Send_Res[jPoint] = Node_Accel[1]; if (geometry->GetnDim() == 3) Buffer_Send_Vol[jPoint] = Node_Accel[2]; @@ -3514,7 +3513,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the three grid velocity components. ---*/ - Stress = solver[FEA_SOL]->node[iPoint]->GetStress_FEM(); + Stress = solver[FEA_SOL]->GetNodes()->GetStress_FEM(iPoint); /*--- Sigma xx ---*/ Buffer_Send_Var[jPoint] = Stress[0]; /*--- Sigma yy ---*/ @@ -3575,7 +3574,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the three grid velocity components. ---*/ - Stress = solver[FEA_SOL]->node[iPoint]->GetStress_FEM(); + Stress = solver[FEA_SOL]->GetNodes()->GetStress_FEM(iPoint); /*--- Sigma zz ---*/ Buffer_Send_Var[jPoint] = Stress[3]; /*--- Sigma xz ---*/ @@ -3637,7 +3636,7 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the temperature and laminar viscosity variables. ---*/ - Buffer_Send_Var[jPoint] = solver[FEA_SOL]->node[iPoint]->GetVonMises_Stress(); + Buffer_Send_Var[jPoint] = solver[FEA_SOL]->GetNodes()->GetVonMises_Stress(iPoint); jPoint++; } } @@ -3683,10 +3682,10 @@ void COutputLegacy::MergeSolution(CConfig *config, CGeometry *geometry, CSolver /*--- Load buffers with the skin friction, heat transfer, y+ variables. ---*/ - Buffer_Send_Var[jPoint] = solver[ADJFEA_SOL]->node[iPoint]->GetGeometry_CrossTerm_Derivative(0); - Buffer_Send_Res[jPoint] = solver[ADJFEA_SOL]->node[iPoint]->GetGeometry_CrossTerm_Derivative(1); + Buffer_Send_Var[jPoint] = solver[ADJFEA_SOL]->GetNodes()->GetGeometry_CrossTerm_Derivative(iPoint, 0); + Buffer_Send_Res[jPoint] = solver[ADJFEA_SOL]->GetNodes()->GetGeometry_CrossTerm_Derivative(iPoint, 1); if (geometry->GetnDim() == 3) - Buffer_Send_Vol[jPoint] = solver[ADJFEA_SOL]->node[iPoint]->GetGeometry_CrossTerm_Derivative(2); + Buffer_Send_Vol[jPoint] = solver[ADJFEA_SOL]->GetNodes()->GetGeometry_CrossTerm_Derivative(iPoint, 2); jPoint++; } } @@ -3883,7 +3882,7 @@ void COutputLegacy::MergeBaselineSolution(CConfig *config, CGeometry *geometry, unsigned short jVar = 0; for (iVar = 0; iVar < nVar_Total; iVar++) { - Data[jVar][jPoint] = solver->node[iPoint]->GetSolution(iVar); + Data[jVar][jPoint] = solver->GetNodes()->GetSolution(iPoint,iVar); jVar++; } } @@ -3994,7 +3993,7 @@ void COutputLegacy::MergeBaselineSolution(CConfig *config, CGeometry *geometry, if (!Local_Halo[iPoint] || Wrt_Halo) { /*--- Get this variable into the temporary send buffer. ---*/ - Buffer_Send_Var[jPoint] = solver->node[iPoint]->GetSolution(iVar); + Buffer_Send_Var[jPoint] = solver->GetNodes()->GetSolution(iPoint,iVar); /*--- Only send/recv the volumes & global indices during the first loop ---*/ if (iVar == 0) { @@ -8794,7 +8793,7 @@ void COutputLegacy::SpecialOutput_SpanLoad(CSolver *solver, CGeometry *geometry, /*--- Copy the pressure to an auxiliar structure ---*/ for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - CPressure[iPoint] = (solver->node[iPoint]->GetPressure() + CPressure[iPoint] = (solver->GetNodes()->GetPressure(iPoint) - RefPressure) * factor * RefArea; } @@ -9562,7 +9561,7 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry } if (AzimuthalAngle[nVertex_NearField] <= 60) { - Pressure[nVertex_NearField] = solver->node[iPoint]->GetPressure(); + Pressure[nVertex_NearField] = solver->GetNodes()->GetPressure(iPoint); FaceArea[nVertex_NearField] = fabs(Face_Normal[nDim-1]); nVertex_NearField ++; } @@ -9660,7 +9659,7 @@ void COutputLegacy::SpecialOutput_SonicBoom(CSolver *solver, CGeometry *geometry Buffer_Send_Xcoord[nLocalVertex_NearField] = geometry->node[iPoint]->GetCoord(0); Buffer_Send_Ycoord[nLocalVertex_NearField] = geometry->node[iPoint]->GetCoord(1); Buffer_Send_Zcoord[nLocalVertex_NearField] = geometry->node[iPoint]->GetCoord(2); - Buffer_Send_Pressure[nLocalVertex_NearField] = solver->node[iPoint]->GetPressure(); + Buffer_Send_Pressure[nLocalVertex_NearField] = solver->GetNodes()->GetPressure(iPoint); Buffer_Send_FaceArea[nLocalVertex_NearField] = fabs(Face_Normal[nDim-1]); nLocalVertex_NearField++; } @@ -10249,11 +10248,11 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr Buffer_Send_Coord_y[nVertex_Surface] = geometry->node[iPoint]->GetCoord(1); if (nDim == 3) { Buffer_Send_Coord_z[nVertex_Surface] = geometry->node[iPoint]->GetCoord(2); } - Pressure = solver->node[iPoint]->GetPressure(); - Density = solver->node[iPoint]->GetDensity(); - Temperature = solver->node[iPoint]->GetTemperature(); - SoundSpeed = solver->node[iPoint]->GetSoundSpeed(); - Velocity2 = solver->node[iPoint]->GetVelocity2(); + Pressure = solver->GetNodes()->GetPressure(iPoint); + Density = solver->GetNodes()->GetDensity(iPoint); + Temperature = solver->GetNodes()->GetTemperature(iPoint); + SoundSpeed = solver->GetNodes()->GetSoundSpeed(iPoint); + Velocity2 = solver->GetNodes()->GetVelocity2(iPoint); Mach = sqrt(Velocity2)/SoundSpeed; Gamma = config->GetGamma(); @@ -10276,10 +10275,10 @@ void COutputLegacy::SpecialOutput_Distortion(CSolver *solver, CGeometry *geometr TotalTemperature_Inf = Temperature_Inf * (1.0 + Mach * Mach * 0.5 * (Gamma - 1.0)); Buffer_Send_TT[nVertex_Surface] = TotalTemperature / TotalTemperature_Inf; - Buffer_Send_Vel_x[nVertex_Surface] = solver->node[iPoint]->GetVelocity(0) / Velocity_Inf; - Buffer_Send_Vel_y[nVertex_Surface] = solver->node[iPoint]->GetVelocity(1) / Velocity_Inf; + Buffer_Send_Vel_x[nVertex_Surface] = solver->GetNodes()->GetVelocity(iPoint,0) / Velocity_Inf; + Buffer_Send_Vel_y[nVertex_Surface] = solver->GetNodes()->GetVelocity(iPoint,1) / Velocity_Inf; if (nDim == 3) { - Buffer_Send_Vel_z[nVertex_Surface] = solver->node[iPoint]->GetVelocity(2) / Velocity_Inf; + Buffer_Send_Vel_z[nVertex_Surface] = solver->GetNodes()->GetVelocity(iPoint,2) / Velocity_Inf; } Buffer_Send_q[nVertex_Surface] = 0.5*Density*Velocity2; @@ -11523,10 +11522,10 @@ void COutputLegacy::SetSensitivity_Files(CGeometry ***geometry, CConfig **config for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iDim = 0; iDim < nDim; iDim++) { - solver[iZone][INST_0]->node[iPoint]->SetSolution(iDim, geometry[iZone][INST_0]->node[iPoint]->GetCoord(iDim)); + solver[iZone][INST_0]->GetNodes()->SetSolution(iPoint, iDim, geometry[iZone][INST_0]->node[iPoint]->GetCoord(iDim)); } for (iVar = 0; iVar < nDim; iVar++) { - solver[iZone][INST_0]->node[iPoint]->SetSolution(iVar+nDim, geometry[iZone][INST_0]->GetSensitivity(iPoint, iVar)); + solver[iZone][INST_0]->GetNodes()->SetSolution(iPoint, iVar+nDim, geometry[iZone][INST_0]->GetSensitivity(iPoint, iVar)); } } @@ -11566,7 +11565,7 @@ void COutputLegacy::SetSensitivity_Files(CGeometry ***geometry, CConfig **config Sens = Prod/Area; - solver[iZone][INST_0]->node[iPoint]->SetSolution(2*nDim, Sens); + solver[iZone][INST_0]->GetNodes()->SetSolution(iPoint, 2*nDim, Sens); } } @@ -12932,7 +12931,7 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo /*--- Load the conservative variable states for the mean flow variables. ---*/ for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } @@ -12941,7 +12940,7 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->node[iPoint]->GetSolution(jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } } @@ -12952,13 +12951,13 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo if (config->GetWrt_Limiters()) { /*--- Mean Flow Limiters ---*/ for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetLimiter_Primitive(jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetLimiter_Primitive(iPoint, jVar); iVar++; } /*--- RANS Limiters ---*/ if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->node[iPoint]->GetLimiter_Primitive(jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetLimiter_Primitive(iPoint, jVar); iVar++; } } @@ -12996,16 +12995,16 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo /*--- Load data for the pressure, temperature, Cp, and Mach variables. ---*/ - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetPressure(); iVar++; - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetTemperature(); iVar++; - Local_Data[jPoint][iVar] = sqrt(solver[FLOW_SOL]->node[iPoint]->GetVelocity2())/solver[FLOW_SOL]->node[iPoint]->GetSoundSpeed(); iVar++; - Local_Data[jPoint][iVar] = (solver[FLOW_SOL]->node[iPoint]->GetPressure() - RefPressure)*factor*RefArea; iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetPressure(iPoint); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); iVar++; + Local_Data[jPoint][iVar] = sqrt(solver[FLOW_SOL]->GetNodes()->GetVelocity2(iPoint))/solver[FLOW_SOL]->GetNodes()->GetSoundSpeed(iPoint); iVar++; + Local_Data[jPoint][iVar] = (solver[FLOW_SOL]->GetNodes()->GetPressure(iPoint) - RefPressure)*factor*RefArea; iVar++; if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { /*--- Load data for the laminar viscosity. ---*/ - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); iVar++; /*--- Load data for the skin friction, heat flux, buffet, and y-plus. ---*/ @@ -13027,7 +13026,7 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo if (Kind_Solver == RANS) { Local_Data[jPoint][iVar] = Aux_yPlus[iPoint]; iVar++; - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetEddyViscosity(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); iVar++; } /*--- Load data for the distance to the nearest sharp edge. ---*/ @@ -13039,16 +13038,16 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo /*--- Load data for the intermittency of the BC trans. model. ---*/ if (transition) { - Local_Data[jPoint][iVar] = solver[TURB_SOL]->node[iPoint]->GetGammaBC(); iVar++; + Local_Data[jPoint][iVar] = solver[TURB_SOL]->GetNodes()->GetGammaBC(iPoint); iVar++; } if (config->GetKind_HybridRANSLES()!=NO_HYBRIDRANSLES){ - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetDES_LengthScale(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetDES_LengthScale(iPoint); iVar++; Local_Data[jPoint][iVar] = geometry->node[iPoint]->GetWall_Distance(); iVar++; } if (config->GetKind_RoeLowDiss() != NO_ROELOWDISS){ - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetRoe_Dissipation(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetRoe_Dissipation(iPoint); iVar++; } if (solver[FLOW_SOL]->VerificationSolution) { @@ -13060,7 +13059,7 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo /* Set the pointers to the coordinates and solution of this DOF. */ const su2double *coor = geometry->node[iPoint]->GetCoord(); - su2double *solDOF = solver[FLOW_SOL]->node[iPoint]->GetSolution(); + su2double *solDOF = solver[FLOW_SOL]->GetNodes()->GetSolution(iPoint); su2double mmsSol[5] = {0.0,0.0,0.0,0.0,0.0}; su2double error[5] = {0.0,0.0,0.0,0.0,0.0}; @@ -13085,17 +13084,17 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo assuming they were registered above correctly. ---*/ if ((Kind_Solver == NAVIER_STOKES) || (Kind_Solver == RANS)) { - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetVorticity()[0]; iVar++; - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetVorticity()[1]; iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint)[0]; iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint)[1]; iVar++; if (geometry->GetnDim() == 3) { - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetVorticity()[2]; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint)[2]; iVar++; } if (nDim == 3){ for (iDim = 0; iDim < nDim; iDim++) { for (unsigned short jDim = 0; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = solver[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = solver[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint, iDim+1, jDim); } } @@ -13122,7 +13121,7 @@ void COutputLegacy::LoadLocalData_Flow(CConfig *config, CGeometry *geometry, CSo if (rotating_frame) { Grid_Vel = geometry->node[iPoint]->GetGridVel(); - su2double *Solution = solver[FLOW_SOL]->node[iPoint]->GetSolution(); + su2double *Solution = solver[FLOW_SOL]->GetNodes()->GetSolution(iPoint); Local_Data[jPoint][iVar] = Solution[1]/Solution[0] - Grid_Vel[0]; iVar++; Local_Data[jPoint][iVar] = Solution[2]/Solution[0] - Grid_Vel[1]; iVar++; if (geometry->GetnDim() == 3) { @@ -13564,17 +13563,17 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, /*--- Load the conservative variable states for the mean flow variables. ---*/ - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(0); iVar++; - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(1); iVar++; - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(2); iVar++; + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, 0); iVar++; + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, 1); iVar++; + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, 2); iVar++; if (nDim == 3) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(3); iVar++; + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, 3); iVar++; } if (weakly_coupled_heat) { - Local_Data[jPoint][iVar] = solver[HEAT_SOL]->node[iPoint]->GetSolution(0); + Local_Data[jPoint][iVar] = solver[HEAT_SOL]->GetNodes()->GetSolution(iPoint, 0); iVar++; } else if (energy) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(nDim+1); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, nDim+1); iVar++; } @@ -13583,7 +13582,7 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->node[iPoint]->GetSolution(jVar); iVar++; + Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } } @@ -13593,13 +13592,13 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, if (config->GetWrt_Limiters()) { /*--- Mean Flow Limiters ---*/ for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetLimiter_Primitive(jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetLimiter_Primitive(iPoint, jVar); iVar++; } /*--- RANS Limiters ---*/ if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->node[iPoint]->GetLimiter_Primitive(jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetLimiter_Primitive(iPoint, jVar); iVar++; } } @@ -13612,6 +13611,7 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes.GetBlock(iPoint, jVar); iVar++; } + /*--- RANS Residuals ---*/ if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { @@ -13622,7 +13622,6 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, } - /*--- Load buffers with the three grid velocity components. ---*/ if (dynamic_grid) { @@ -13637,13 +13636,13 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, /*--- Load data for Cp and Mach variables. ---*/ - Local_Data[jPoint][iVar] = (solver[FLOW_SOL]->node[iPoint]->GetPressure() - RefPressure)*factor*RefArea; iVar++; + Local_Data[jPoint][iVar] = (solver[FLOW_SOL]->GetNodes()->GetPressure(iPoint) - RefPressure)*factor*RefArea; iVar++; if ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) { /*--- Load data for the laminar viscosity. ---*/ - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); iVar++; /*--- Load data for the skin friction, heat flux, and y-plus. ---*/ @@ -13664,7 +13663,7 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, if (Kind_Solver == INC_RANS) { Local_Data[jPoint][iVar] = Aux_yPlus[iPoint]; iVar++; - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetEddyViscosity(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); iVar++; } /*--- Load data for the distance to the nearest sharp edge. ---*/ @@ -13676,22 +13675,22 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, /*--- Load data for the intermittency of the BC trans. model. ---*/ if (transition) { - Local_Data[jPoint][iVar] = solver[TURB_SOL]->node[iPoint]->GetGammaBC(); iVar++; + Local_Data[jPoint][iVar] = solver[TURB_SOL]->GetNodes()->GetGammaBC(iPoint); iVar++; } /*--- Load density if we are solving a variable density problem. ---*/ if (variable_density) { - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetDensity(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetDensity(iPoint); iVar++; } /*--- Load Cp and conductivity if they are temperature-dependent. ---*/ if (wrt_cp) { - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetSpecificHeatCp(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetSpecificHeatCp(iPoint); iVar++; } if (wrt_kt) { - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetThermalConductivity(); iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetThermalConductivity(iPoint); iVar++; } if (solver[FLOW_SOL]->VerificationSolution) { @@ -13703,7 +13702,7 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, /* Set the pointers to the coordinates and solution of this DOF. */ const su2double *coor = geometry->node[iPoint]->GetCoord(); - su2double *solDOF = solver[FLOW_SOL]->node[iPoint]->GetSolution(); + su2double *solDOF = solver[FLOW_SOL]->GetNodes()->GetSolution(iPoint); su2double mmsSol[5] = {0.0,0.0,0.0,0.0,0.0}; su2double error[5] = {0.0,0.0,0.0,0.0,0.0}; @@ -13726,14 +13725,14 @@ void COutputLegacy::LoadLocalData_IncFlow(CConfig *config, CGeometry *geometry, if ((Kind_Solver == INC_NAVIER_STOKES) || (Kind_Solver == INC_RANS)) { - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetVorticity()[0]; iVar++; - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetVorticity()[1]; iVar++; - Local_Data[jPoint][iVar] = solver[FLOW_SOL]->node[iPoint]->GetVorticity()[2]; iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint)[0]; iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint)[1]; iVar++; + Local_Data[jPoint][iVar] = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint)[2]; iVar++; if (nDim == 3){ for (iDim = 0; iDim < nDim; iDim++) { for (unsigned short jDim = 0; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = solver[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = solver[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint, iDim+1, jDim); } } @@ -14086,7 +14085,7 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, If requested, load the limiters and residuals as well. ---*/ for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } @@ -14097,7 +14096,7 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->node[iPoint]->GetSolution(jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } } @@ -14110,22 +14109,22 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, (Kind_Solver == DISC_ADJ_INC_EULER) || (Kind_Solver == DISC_ADJ_INC_NAVIER_STOKES) || (Kind_Solver == DISC_ADJ_INC_RANS)) { - Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->node[iPoint]->GetSensitivity(0); iVar++; - Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->node[iPoint]->GetSensitivity(1); iVar++; + Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->GetNodes()->GetSensitivity(iPoint, 0); iVar++; + Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->GetNodes()->GetSensitivity(iPoint, 1); iVar++; if (geometry->GetnDim()== 3) { - Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->node[iPoint]->GetSensitivity(2); + Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->GetNodes()->GetSensitivity(iPoint, 2); iVar++; } } if (config->GetWrt_Limiters()) { for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetLimiter(jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetLimiter(iPoint, jVar); iVar++; } if (SecondIndex != NONE) { for (jVar = 0; jVar < nVar_Second; jVar++) { - Local_Data[jPoint][iVar] = solver[SecondIndex]->node[iPoint]->GetLimiter(jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetLimiter(iPoint, jVar); iVar++; } } @@ -14136,8 +14135,8 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, if (!config->GetDiscrete_Adjoint()) { Local_Data[jPoint][iVar] = solver[FirstIndex]->LinSysRes.GetBlock(iPoint, jVar); } else { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(jVar) - - solver[FirstIndex]->node[iPoint]->GetSolution_Old(jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar) - + solver[FirstIndex]->GetNodes()->GetSolution_Old(iPoint, jVar); } iVar++; } @@ -14146,8 +14145,8 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, if (!config->GetDiscrete_Adjoint()) { Local_Data[jPoint][iVar] = solver[SecondIndex]->LinSysRes.GetBlock(iPoint, jVar); } else { - Local_Data[jPoint][iVar] = solver[SecondIndex]->node[iPoint]->GetSolution(jVar) - - solver[SecondIndex]->node[iPoint]->GetSolution_Old(jVar); + Local_Data[jPoint][iVar] = solver[SecondIndex]->GetNodes()->GetSolution(iPoint, jVar) - + solver[SecondIndex]->GetNodes()->GetSolution_Old(iPoint, jVar); } iVar++; } @@ -14176,9 +14175,9 @@ void COutputLegacy::LoadLocalData_AdjFlow(CConfig *config, CGeometry *geometry, ( Kind_Solver == ADJ_NAVIER_STOKES ) || ( Kind_Solver == ADJ_RANS )) { if (config->GetKind_ConvNumScheme() == SPACE_CENTERED) { - Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->node[iPoint]->GetSensor(iPoint); iVar++; + Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->GetNodes()->GetSensor(iPoint); iVar++; } else { - Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->node[iPoint]->GetLimiter(0); iVar++; + Local_Data[jPoint][iVar] = solver[ADJFLOW_SOL]->GetNodes()->GetLimiter(iPoint, 0); iVar++; } } @@ -14392,7 +14391,7 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr If requested, load the limiters and residuals as well. ---*/ for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } @@ -14411,7 +14410,7 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr /*--- Velocities ---*/ - Node_Vel = solver[FEA_SOL]->node[iPoint]->GetSolution_Vel(); + Node_Vel = solver[FEA_SOL]->GetNodes()->GetSolution_Vel(iPoint); Local_Data[jPoint][iVar] = Node_Vel[0]; iVar++; Local_Data[jPoint][iVar] = Node_Vel[1]; iVar++; if (geometry->GetnDim() == 3) { @@ -14421,7 +14420,7 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr /*--- Accelerations ---*/ - Node_Accel = solver[FEA_SOL]->node[iPoint]->GetSolution_Accel(); + Node_Accel = solver[FEA_SOL]->GetNodes()->GetSolution_Accel(iPoint); Local_Data[jPoint][iVar] = Node_Accel[0]; iVar++; Local_Data[jPoint][iVar] = Node_Accel[1]; iVar++; if (geometry->GetnDim() == 3) { @@ -14434,7 +14433,7 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr /*--- Add the stresses. ---*/ - Stress = solver[FEA_SOL]->node[iPoint]->GetStress_FEM(); + Stress = solver[FEA_SOL]->GetNodes()->GetStress_FEM(iPoint); /*--- Sigma xx ---*/ Local_Data[jPoint][iVar] = Stress[0]; iVar++; @@ -14454,7 +14453,7 @@ void COutputLegacy::LoadLocalData_Elasticity(CConfig *config, CGeometry *geometr /*--- Add the Von Mises Stress. ---*/ - Local_Data[iPoint][iVar] = solver[FEA_SOL]->node[iPoint]->GetVonMises_Stress(); iVar++; + Local_Data[iPoint][iVar] = solver[FEA_SOL]->GetNodes()->GetVonMises_Stress(iPoint); iVar++; /*--- New variables can be loaded to the Local_Data structure here, @@ -14618,7 +14617,7 @@ void COutputLegacy::LoadLocalData_Base(CConfig *config, CGeometry *geometry, CSo If requested, load the limiters and residuals as well. ---*/ for (jVar = 0; jVar < nVar_First; jVar++) { - Local_Data[jPoint][iVar] = solver[FirstIndex]->node[iPoint]->GetSolution(jVar); + Local_Data[jPoint][iVar] = solver[FirstIndex]->GetNodes()->GetSolution(iPoint, jVar); iVar++; } @@ -18498,12 +18497,12 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo AxiFactor = 1.0; } - Density = solver->node[iPoint]->GetDensity(); + Density = solver->GetNodes()->GetDensity(iPoint); Velocity2 = 0.0; Area = 0.0; MassFlow = 0.0; Vn = 0.0; Vtang2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) { Area += (Vector[iDim] * AxiFactor) * (Vector[iDim] * AxiFactor); - Velocity[iDim] = solver->node[iPoint]->GetVelocity(iDim); + Velocity[iDim] = solver->GetNodes()->GetVelocity(iPoint,iDim); Velocity2 += Velocity[iDim] * Velocity[iDim]; Vn += Velocity[iDim] * Vector[iDim] * AxiFactor; MassFlow += Vector[iDim] * AxiFactor * Density * Velocity[iDim]; @@ -18512,8 +18511,8 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo Area = sqrt (Area); if (AxiFactor == 0.0) Vn = 0.0; else Vn /= Area; Vn2 = Vn * Vn; - Pressure = solver->node[iPoint]->GetPressure(); - SoundSpeed = solver->node[iPoint]->GetSoundSpeed(); + Pressure = solver->GetNodes()->GetPressure(iPoint); + SoundSpeed = solver->GetNodes()->GetSoundSpeed(iPoint); for (iDim = 0; iDim < nDim; iDim++) { TangVel[iDim] = Velocity[iDim] - Vn*Vector[iDim]*AxiFactor/Area; @@ -18522,21 +18521,21 @@ void COutputLegacy::SpecialOutput_AnalyzeSurface(CSolver *solver, CGeometry *geo if (incompressible){ if (config->GetKind_DensityModel() == VARIABLE) { - Mach = sqrt(solver->node[iPoint]->GetVelocity2())/ - sqrt(solver->node[iPoint]->GetSpecificHeatCp()*config->GetPressure_ThermodynamicND()/(solver->node[iPoint]->GetSpecificHeatCv()*solver->node[iPoint]->GetDensity())); + Mach = sqrt(solver->GetNodes()->GetVelocity2(iPoint))/ + sqrt(solver->GetNodes()->GetSpecificHeatCp(iPoint)*config->GetPressure_ThermodynamicND()/(solver->GetNodes()->GetSpecificHeatCv(iPoint)*solver->GetNodes()->GetDensity(iPoint))); } else { - Mach = sqrt(solver->node[iPoint]->GetVelocity2())/ - sqrt(config->GetBulk_Modulus()/(solver->node[iPoint]->GetDensity())); + Mach = sqrt(solver->GetNodes()->GetVelocity2(iPoint))/ + sqrt(config->GetBulk_Modulus()/(solver->GetNodes()->GetDensity(iPoint))); } - Temperature = solver->node[iPoint]->GetTemperature(); - Enthalpy = solver->node[iPoint]->GetSpecificHeatCp()*Temperature; - TotalTemperature = Temperature + 0.5*Velocity2/solver->node[iPoint]->GetSpecificHeatCp(); + Temperature = solver->GetNodes()->GetTemperature(iPoint); + Enthalpy = solver->GetNodes()->GetSpecificHeatCp(iPoint)*Temperature; + TotalTemperature = Temperature + 0.5*Velocity2/solver->GetNodes()->GetSpecificHeatCp(iPoint); TotalPressure = Pressure + 0.5*Density*Velocity2; } else{ Mach = sqrt(Velocity2)/SoundSpeed; Temperature = Pressure / (Gas_Constant * Density); - Enthalpy = solver->node[iPoint]->GetEnthalpy(); + Enthalpy = solver->GetNodes()->GetEnthalpy(iPoint); TotalTemperature = Temperature * (1.0 + Mach * Mach * 0.5 * (Gamma - 1.0)); TotalPressure = Pressure * pow( 1.0 + Mach * Mach * 0.5 * (Gamma - 1.0), Gamma / (Gamma - 1.0)); } diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 501939b3be6a..049cf2134179 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -47,21 +47,21 @@ void CDriver::PythonInterface_Preprocessing(CConfig **config, CGeometry ****geom /* --- Initialize boundary conditions customization, this is achieve through the Python wrapper --- */ for(iZone=0; iZone < nZone; iZone++){ - + if (config[iZone]->GetnMarker_PyCustom() > 0){ - + if (rank == MASTER_NODE) cout << endl << "----------------- Python Interface Preprocessing ( Zone "<< iZone <<" ) -----------------" << endl; - + if (rank == MASTER_NODE) cout << "Setting customized boundary conditions for zone " << iZone << endl; for (iMesh = 0; iMesh <= config[iZone]->GetnMGLevels(); iMesh++) { geometry[iZone][INST_0][iMesh]->SetCustomBoundary(config[iZone]); } geometry[iZone][INST_0][MESH_0]->UpdateCustomBoundaryConditions(geometry[iZone][INST_0], config[iZone]); - + if ((config[iZone]->GetKind_Solver() == EULER) || (config[iZone]->GetKind_Solver() == NAVIER_STOKES) || (config[iZone]->GetKind_Solver() == RANS)) { - + solver[iZone][INST_0][MESH_0][FLOW_SOL]->UpdateCustomBoundaryConditions(geometry[iZone][INST_0], config[iZone]); } } @@ -391,14 +391,14 @@ bool CDriver::ComputeVertexForces(unsigned short iMarker, unsigned short iVertex Area = sqrt(AreaSquare); /*--- Get the values of pressure and viscosity ---*/ - Pn = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->node[iPoint]->GetPressure(); + Pn = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetPressure(iPoint); if (viscous_flow) { for(iDim=0; iDimnode[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = solver_container[ZONE_0][INST_0][FinestMesh][FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint, iDim+1, jDim); } } - Viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); + Viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); } /*--- Calculate the inviscid (pressure) part of tn in the fluid nodes (force units) ---*/ @@ -523,11 +523,11 @@ passivedouble CDriver::GetVertexTemperature(unsigned short iMarker, unsigned sho su2double vertexWallTemp(0.0); bool compressible = (config_container[ZONE_0]->GetKind_Regime() == COMPRESSIBLE); - + iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); if(geometry_container[ZONE_0][INST_0][MESH_0]->node[iPoint]->GetDomain() && compressible){ - vertexWallTemp = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->node[iPoint]->GetTemperature(); + vertexWallTemp = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetTemperature(iPoint); } return SU2_TYPE::GetValue(vertexWallTemp); @@ -564,10 +564,10 @@ bool CDriver::ComputeVertexHeatFluxes(unsigned short iMarker, unsigned short iVe } if(!halo && compressible){ - laminar_viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); + laminar_viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); thermal_conductivity = Cp * (laminar_viscosity/Prandtl_Lam); for(iDim=0; iDim < nDim; iDim++){ - GradT[iDim] = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->node[iPoint]->GetGradient_Primitive(0, iDim); + GradT[iDim] = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint, 0, iDim); PyWrapNodalHeatFlux[iDim] = -thermal_conductivity*GradT[iDim]; } } @@ -605,7 +605,7 @@ passivedouble CDriver::GetVertexNormalHeatFlux(unsigned short iMarker, unsigned su2double *Normal, GradT[3] = {0.0,0.0,0.0}, UnitNormal[3] = {0.0,0.0,0.0}; bool compressible = (config_container[ZONE_0]->GetKind_Regime() == COMPRESSIBLE); - + vertexWallHeatFlux = 0.0; dTdn = 0.0; @@ -621,11 +621,11 @@ passivedouble CDriver::GetVertexNormalHeatFlux(unsigned short iMarker, unsigned for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = Normal[iDim]/Area; - laminar_viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); + laminar_viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); thermal_conductivity = Cp * (laminar_viscosity/Prandtl_Lam); /*Compute wall heat flux (normal to the wall) based on computed temperature gradient*/ for(iDim=0; iDim < nDim; iDim++){ - GradT[iDim] = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->node[iPoint]->GetGradient_Primitive(0, iDim); + GradT[iDim] = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint, 0, iDim); dTdn += GradT[iDim]*UnitNormal[iDim]; } @@ -651,7 +651,7 @@ passivedouble CDriver::GetThermalConductivity(unsigned short iMarker, unsigned s su2double laminar_viscosity, thermal_conductivity; iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - laminar_viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); + laminar_viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); thermal_conductivity = Cp * (laminar_viscosity/Prandtl_Lam); return SU2_TYPE::GetValue(thermal_conductivity); @@ -983,7 +983,7 @@ void CDriver::SetMeshDisplacement(unsigned short iMarker, unsigned long iVertex, iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->node[iPoint]->SetBound_Disp(PyWrapVarCoord); + solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->SetBound_Disp(iPoint,PyWrapVarCoord); } @@ -1006,10 +1006,10 @@ vector CDriver::GetMeshDisp_Sensitivity(unsigned short iMarker, u CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][ADJMESH_SOL]; CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; - Disp_Sens[0] = solver->node[iPoint]->GetBoundDisp_Sens(0); - Disp_Sens[1] = solver->node[iPoint]->GetBoundDisp_Sens(1); + Disp_Sens[0] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 0); + Disp_Sens[1] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 1); if (geometry->GetnDim() == 3) - Disp_Sens[2] = solver->node[iPoint]->GetBoundDisp_Sens(2); + Disp_Sens[2] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 2); else Disp_Sens[2] = 0.0; @@ -1030,7 +1030,7 @@ void CDriver::SetFEA_Loads(unsigned short iMarker, unsigned short iVertex, passi PyWrapNodalForce[2] = LoadZ; iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - solver_container[ZONE_0][INST_0][MESH_0][FEA_SOL]->node[iPoint]->Set_FlowTraction(PyWrapNodalForce); + solver_container[ZONE_0][INST_0][MESH_0][FEA_SOL]->GetNodes()->Set_FlowTraction(iPoint,PyWrapNodalForce); } @@ -1044,10 +1044,10 @@ vector CDriver::GetFEA_Displacements(unsigned short iMarker, unsi CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][FEA_SOL]; CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; - Displacements[0] = solver->node[iPoint]->GetSolution(0); - Displacements[1] = solver->node[iPoint]->GetSolution(1); + Displacements[0] = solver->GetNodes()->GetSolution(iPoint, 0); + Displacements[1] = solver->GetNodes()->GetSolution(iPoint, 1); if (geometry->GetnDim() == 3) - Displacements[2] = solver->node[iPoint]->GetSolution(2); + Displacements[2] = solver->GetNodes()->GetSolution(iPoint, 2); else Displacements[2] = 0.0; @@ -1070,10 +1070,10 @@ vector CDriver::GetFEA_Velocity(unsigned short iMarker, unsigned CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; if (config_container[ZONE_0]->GetDynamic_Analysis() == DYNAMIC){ - Velocity[0] = solver->node[iPoint]->GetSolution_Vel(0); - Velocity[1] = solver->node[iPoint]->GetSolution_Vel(1); + Velocity[0] = solver->GetNodes()->GetSolution_Vel(iPoint, 0); + Velocity[1] = solver->GetNodes()->GetSolution_Vel(iPoint, 1); if (geometry->GetnDim() == 3) - Velocity[2] = solver->node[iPoint]->GetSolution_Vel(2); + Velocity[2] = solver->GetNodes()->GetSolution_Vel(iPoint, 2); else Velocity[2] = 0.0; } @@ -1101,10 +1101,10 @@ vector CDriver::GetFEA_Velocity_n(unsigned short iMarker, unsigne CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; if (config_container[ZONE_0]->GetDynamic_Analysis() == DYNAMIC){ - Velocity_n[0] = solver->node[iPoint]->GetSolution_Vel_time_n(0); - Velocity_n[1] = solver->node[iPoint]->GetSolution_Vel_time_n(1); + Velocity_n[0] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 0); + Velocity_n[1] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 1); if (geometry->GetnDim() == 3) - Velocity_n[2] = solver->node[iPoint]->GetSolution_Vel_time_n(2); + Velocity_n[2] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 2); else Velocity_n[2] = 0.0; } @@ -1132,10 +1132,10 @@ vector CDriver::GetFlowLoad_Sensitivity(unsigned short iMarker, u CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][ADJFEA_SOL]; CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; - FlowLoad_Sens[0] = solver->node[iPoint]->GetFlowTractionSensitivity(0); - FlowLoad_Sens[1] = solver->node[iPoint]->GetFlowTractionSensitivity(1); + FlowLoad_Sens[0] = solver->GetNodes()->GetFlowTractionSensitivity(iPoint, 0); + FlowLoad_Sens[1] = solver->GetNodes()->GetFlowTractionSensitivity(iPoint, 1); if (geometry->GetnDim() == 3) - FlowLoad_Sens[2] = solver->node[iPoint]->GetFlowTractionSensitivity(2); + FlowLoad_Sens[2] = solver->GetNodes()->GetFlowTractionSensitivity(iPoint, 2); else FlowLoad_Sens[2] = 0.0; @@ -1199,10 +1199,10 @@ void CDriver::SetSourceTerm_DispAdjoint(unsigned short iMarker, unsigned short i CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - solver->node[iPoint]->SetSourceTerm_DispAdjoint(0, val_AdjointX); - solver->node[iPoint]->SetSourceTerm_DispAdjoint(1, val_AdjointY); + solver->GetNodes()->SetSourceTerm_DispAdjoint(iPoint, 0, val_AdjointX); + solver->GetNodes()->SetSourceTerm_DispAdjoint(iPoint, 1, val_AdjointY); if (geometry->GetnDim() == 3) - solver->node[iPoint]->SetSourceTerm_DispAdjoint(2, val_AdjointZ); + solver->GetNodes()->SetSourceTerm_DispAdjoint(iPoint, 2, val_AdjointZ); } @@ -1217,10 +1217,10 @@ vector CDriver::GetVertex_UndeformedCoord(unsigned short iMarker, iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); if (solver != NULL) { - MeshCoord[0] = solver->node[iPoint]->GetMesh_Coord(0); - MeshCoord[1] = solver->node[iPoint]->GetMesh_Coord(1); + MeshCoord[0] = solver->GetNodes()->GetMesh_Coord(iPoint,0); + MeshCoord[1] = solver->GetNodes()->GetMesh_Coord(iPoint,1); if (geometry->GetnDim() == 3) - MeshCoord[2] = solver->node[iPoint]->GetMesh_Coord(2); + MeshCoord[2] = solver->GetNodes()->GetMesh_Coord(iPoint,2); else MeshCoord[2] = 0.0; } diff --git a/SU2_CFD/src/solver_adjoint_discrete.cpp b/SU2_CFD/src/solver_adjoint_discrete.cpp index 4cc42e00e070..3aac9731a57f 100644 --- a/SU2_CFD/src/solver_adjoint_discrete.cpp +++ b/SU2_CFD/src/solver_adjoint_discrete.cpp @@ -49,11 +49,13 @@ CDiscAdjSolver::CDiscAdjSolver(CGeometry *geometry, CConfig *config) : CSolver( CDiscAdjSolver::CDiscAdjSolver(CGeometry *geometry, CConfig *config, CSolver *direct_solver, unsigned short Kind_Solver, unsigned short iMesh) : CSolver() { unsigned short iVar, iMarker, iDim; - unsigned long iVertex, iPoint; + unsigned long iVertex; string text_line, mesh_filename; ifstream restart_file; string filename, AdjExt; + adjoint = true; + nVar = direct_solver->GetnVar(); nDim = geometry->GetnDim(); @@ -70,10 +72,6 @@ CDiscAdjSolver::CDiscAdjSolver(CGeometry *geometry, CConfig *config, CSolver *di nPoint = geometry->GetnPoint(); nPointDomain = geometry->GetnPointDomain(); - /*--- Allocate the node variables ---*/ - - node = new CVariable*[nPoint]; - /*--- Define some auxiliary vectors related to the residual ---*/ Residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 1.0; @@ -133,9 +131,23 @@ CDiscAdjSolver::CDiscAdjSolver(CGeometry *geometry, CConfig *config, CSolver *di /*--- Initialize the discrete adjoint solution to zero everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CDiscAdjVariable(Solution, nDim, nVar, config); - + nodes = new CDiscAdjVariable(Solution, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); + + switch(KindDirect_Solver){ + case RUNTIME_FLOW_SYS: + SolverName = "ADJ.FLOW"; + break; + case RUNTIME_HEAT_SYS: + SolverName = "ADJ.HEAT"; + break; + case RUNTIME_TURB_SYS: + SolverName = "ADJ.TURB"; + break; + default: + SolverName = "ADJ.SOL"; + break; + } } CDiscAdjSolver::~CDiscAdjSolver(void) { @@ -149,6 +161,7 @@ CDiscAdjSolver::~CDiscAdjSolver(void) { delete [] CSensitivity; } + if (nodes != nullptr) delete nodes; } void CDiscAdjSolver::SetRecording(CGeometry* geometry, CConfig *config){ @@ -164,20 +177,20 @@ void CDiscAdjSolver::SetRecording(CGeometry* geometry, CConfig *config){ /*--- Reset the solution to the initial (converged) solution ---*/ for (iPoint = 0; iPoint < nPoint; iPoint++) { - direct_solver->node[iPoint]->SetSolution(node[iPoint]->GetSolution_Direct()); + direct_solver->GetNodes()->SetSolution(iPoint, nodes->GetSolution_Direct(iPoint)); } if (time_n_needed) { for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - AD::ResetInput(direct_solver->node[iPoint]->GetSolution_time_n()[iVar]); + AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n(iPoint)[iVar]); } } } if (time_n1_needed) { for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - AD::ResetInput(direct_solver->node[iPoint]->GetSolution_time_n1()[iVar]); + AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n1(iPoint)[iVar]); } } } @@ -209,7 +222,7 @@ void CDiscAdjSolver::SetMesh_Recording(CGeometry** geometry, CVolumetricMovement for (iPoint = 0; iPoint < nPoint; iPoint++){ for (iDim = 0; iDim < nDim; iDim++){ - geometry[MESH_0]->node[iPoint]->SetCoord(iDim,node[iPoint]->GetGeometry_Direct(iDim)); + geometry[MESH_0]->node[iPoint]->SetCoord(iDim,nodes->GetGeometry_Direct(iPoint,iDim)); } } @@ -231,14 +244,14 @@ void CDiscAdjSolver::SetMesh_Recording(CGeometry** geometry, CVolumetricMovement // if (time_n_needed){ // for (iPoint = 0; iPoint < nPoint; iPoint++){ // for (iVar = 0; iVar < nVar; iVar++){ -// AD::ResetInput(direct_solver->node[iPoint]->GetSolution_time_n()[iVar]); +// AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n(iPoint,iVar)); // } // } // } // if (time_n1_needed){ // for (iPoint = 0; iPoint < nPoint; iPoint++){ // for (iVar = 0; iVar < nVar; iVar++){ -// AD::ResetInput(direct_solver->node[iPoint]->GetSolution_time_n1()[iVar]); +// AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n1(iPoint,iVar)); // } // } // } @@ -246,28 +259,25 @@ void CDiscAdjSolver::SetMesh_Recording(CGeometry** geometry, CVolumetricMovement } void CDiscAdjSolver::RegisterSolution(CGeometry *geometry, CConfig *config) { - unsigned long iPoint, nPoint = geometry->GetnPoint(); - bool time_n_needed = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)), - time_n1_needed = config->GetTime_Marching() == DT_STEPPING_2ND, - input = true; + bool time_n1_needed = (config->GetTime_Marching() == DT_STEPPING_2ND); + bool time_n_needed = (config->GetTime_Marching() == DT_STEPPING_1ST) || time_n1_needed; + bool input = true; /*--- Register solution at all necessary time instances and other variables on the tape ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) { - direct_solver->node[iPoint]->RegisterSolution(input); - } - if (time_n_needed) { - for (iPoint = 0; iPoint < nPoint; iPoint++) { - direct_solver->node[iPoint]->RegisterSolution_time_n(); - } - } - if (time_n1_needed) { - for (iPoint = 0; iPoint < nPoint; iPoint++) { - direct_solver->node[iPoint]->RegisterSolution_time_n1(); - } + if(config->GetMultizone_Problem()) { + direct_solver->GetNodes()->RegisterSolution_intIndexBased(input); + direct_solver->GetNodes()->SetAdjIndices(input); + } else { + direct_solver->GetNodes()->RegisterSolution(input); } + + if (time_n_needed) + direct_solver->GetNodes()->RegisterSolution_time_n(); + + if (time_n1_needed) + direct_solver->GetNodes()->RegisterSolution_time_n1(); } void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset) { @@ -367,16 +377,15 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo void CDiscAdjSolver::RegisterOutput(CGeometry *geometry, CConfig *config) { - unsigned long iPoint, nPoint = geometry->GetnPoint(); - /*--- Register variables as output of the solver iteration ---*/ - bool input = false; - /*--- Register output variables on the tape ---*/ - - for (iPoint = 0; iPoint < nPoint; iPoint++) { - direct_solver->node[iPoint]->RegisterSolution(input); + if(config->GetMultizone_Problem()) { + direct_solver->GetNodes()->RegisterSolution_intIndexBased(input); + direct_solver->GetNodes()->SetAdjIndices(input); + } + else { + direct_solver->GetNodes()->RegisterSolution(input); } } @@ -476,19 +485,24 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi SetRes_Max(iVar,0.0,0); } - for (iPoint = 0; iPoint < nPoint; iPoint++) { - - /*--- Set the old solution ---*/ + /*--- Set the old solution ---*/ - node[iPoint]->Set_OldSolution(); + if(!config->GetMultizone_Problem()) nodes->Set_OldSolution(); + + for (iPoint = 0; iPoint < nPoint; iPoint++) { /*--- Extract the adjoint solution ---*/ - - direct_solver->node[iPoint]->GetAdjointSolution(Solution); + + if(config->GetMultizone_Problem()) { + direct_solver->GetNodes()->GetAdjointSolution_intIndexBased(iPoint,Solution); + } + else { + direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); + } /*--- Store the adjoint solution ---*/ - node[iPoint]->SetSolution(Solution); + nodes->SetSolution(iPoint,Solution); } if (time_n_needed) { @@ -496,11 +510,11 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Extract the adjoint solution at time n ---*/ - direct_solver->node[iPoint]->GetAdjointSolution_time_n(Solution); + direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); /*--- Store the adjoint solution at time n ---*/ - node[iPoint]->Set_Solution_time_n(Solution); + nodes->Set_Solution_time_n(iPoint,Solution); } } if (time_n1_needed) { @@ -508,11 +522,11 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Extract the adjoint solution at time n-1 ---*/ - direct_solver->node[iPoint]->GetAdjointSolution_time_n1(Solution); + direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution); /*--- Store the adjoint solution at time n-1 ---*/ - node[iPoint]->Set_Solution_time_n1(Solution); + nodes->Set_Solution_time_n1(iPoint,Solution); } } @@ -520,7 +534,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi for (iPoint = 0; iPoint < nPointDomain; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - residual = node[iPoint]->GetSolution(iVar) - node[iPoint]->GetSolution_Old(iVar); + residual = nodes->GetSolution(iPoint,iVar) - nodes->GetSolution_Old(iPoint,iVar); AddRes_RMS(iVar,residual*residual); AddRes_Max(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); @@ -528,6 +542,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi } SetResidual_RMS(geometry, config); + } void CDiscAdjSolver::ExtractAdjoint_Variables(CGeometry *geometry, CConfig *config) { @@ -616,11 +631,11 @@ void CDiscAdjSolver::ExtractAdjoint_Geometry(CGeometry *geometry, CConfig *confi // SetRes_Max(iVar,0.0,0); // } - for (iPoint = 0; iPoint < nPoint; iPoint++){ + /*--- Set the old solution ---*/ - /*--- Set the old solution ---*/ + nodes->Set_OldSolution_Geometry(); - node[iPoint]->Set_OldSolution_Geometry(); + for (iPoint = 0; iPoint < nPoint; iPoint++){ /*--- Extract the adjoint solution ---*/ @@ -628,7 +643,7 @@ void CDiscAdjSolver::ExtractAdjoint_Geometry(CGeometry *geometry, CConfig *confi /*--- Store the adjoint solution ---*/ - node[iPoint]->SetSolution_Geometry(Solution_Geometry); + nodes->SetSolution_Geometry(iPoint,Solution_Geometry); } @@ -637,11 +652,11 @@ void CDiscAdjSolver::ExtractAdjoint_Geometry(CGeometry *geometry, CConfig *confi // // /*--- Extract the adjoint solution at time n ---*/ // -// direct_solver->node[iPoint]->GetAdjointSolution_time_n(Solution); +// direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); // // /*--- Store the adjoint solution at time n ---*/ // -// node[iPoint]->Set_Solution_time_n(Solution); +// nodes->Set_Solution_time_n(iPoint,Solution); // } // } // if (time_n1_needed){ @@ -649,11 +664,11 @@ void CDiscAdjSolver::ExtractAdjoint_Geometry(CGeometry *geometry, CConfig *confi // // /*--- Extract the adjoint solution at time n-1 ---*/ // -// direct_solver->node[iPoint]->GetAdjointSolution_time_n1(Solution); +// direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution); // // /*--- Store the adjoint solution at time n-1 ---*/ // -// node[iPoint]->Set_Solution_time_n1(Solution); +// nodes->Set_Solution_time_n1(iPoint,Solution); // } // } @@ -680,9 +695,9 @@ void CDiscAdjSolver::ExtractAdjoint_CrossTerm(CGeometry *geometry, CConfig *conf /*--- Extract the adjoint solution ---*/ - direct_solver->node[iPoint]->GetAdjointSolution(Solution); + direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); - for (iVar = 0; iVar < nVar; iVar++) node[iPoint]->SetCross_Term_Derivative(iVar, Solution[iVar]); + for (iVar = 0; iVar < nVar; iVar++) nodes->SetCross_Term_Derivative(iPoint,iVar, Solution[iVar]); } @@ -700,7 +715,7 @@ void CDiscAdjSolver::ExtractAdjoint_CrossTerm_Geometry(CGeometry *geometry, CCon geometry->node[iPoint]->GetAdjointCoord(Solution_Geometry); - for (iDim = 0; iDim < nDim; iDim++) node[iPoint]->SetGeometry_CrossTerm_Derivative(iDim, Solution_Geometry[iDim]); + for (iDim = 0; iDim < nDim; iDim++) nodes->SetGeometry_CrossTerm_Derivative(iPoint,iDim, Solution_Geometry[iDim]); } @@ -718,7 +733,7 @@ void CDiscAdjSolver::ExtractAdjoint_CrossTerm_Geometry_Flow(CGeometry *geometry, geometry->node[iPoint]->GetAdjointCoord(Solution_Geometry); - for (iDim = 0; iDim < nDim; iDim++) node[iPoint]->SetGeometry_CrossTerm_Derivative_Flow(iDim, Solution_Geometry[iDim]); + for (iDim = 0; iDim < nDim; iDim++) nodes->SetGeometry_CrossTerm_Derivative_Flow(iPoint,iDim, Solution_Geometry[iDim]); } @@ -736,21 +751,30 @@ void CDiscAdjSolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = node[iPoint]->GetSolution(iVar); + if(config->GetMultizone_Problem()) { + Solution[iVar] = nodes->Get_BGSSolution_k(iPoint,iVar); + } + else { + Solution[iVar] = nodes->GetSolution(iPoint,iVar); + } } if (fsi) { for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] += node[iPoint]->GetCross_Term_Derivative(iVar); + Solution[iVar] += nodes->GetCross_Term_Derivative(iPoint,iVar); } } if (dual_time) { for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] += node[iPoint]->GetDual_Time_Derivative(iVar); + Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar); } } - direct_solver->node[iPoint]->SetAdjointSolution(Solution); + if(config->GetMultizone_Problem()) { + direct_solver->GetNodes()->SetAdjointSolution_intIndexBased(iPoint,Solution); + } + else { + direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); + } } - } void CDiscAdjSolver::SetAdjoint_OutputMesh(CGeometry *geometry, CConfig *config){ @@ -769,19 +793,19 @@ void CDiscAdjSolver::SetAdjoint_OutputMesh(CGeometry *geometry, CConfig *config) } if (fsi){ for (iDim = 0; iDim < nDim; iDim++){ - Solution_Geometry[iDim] += node[iPoint]->GetGeometry_CrossTerm_Derivative(iDim); + Solution_Geometry[iDim] += nodes->GetGeometry_CrossTerm_Derivative(iPoint,iDim); } for (iDim = 0; iDim < nDim; iDim++){ - Solution_Geometry[iDim] += node[iPoint]->GetGeometry_CrossTerm_Derivative_Flow(iDim); + Solution_Geometry[iDim] += nodes->GetGeometry_CrossTerm_Derivative_Flow(iPoint,iDim); } } // if (dual_time){ // for (iDim = 0; iDim < nVar; iDim++){ -// Solution_Geometry[iDim] += node[iPoint]->GetDual_Time_Derivative_Geometry(iDim); +// Solution_Geometry[iDim] += nodes->GetDual_Time_Derivative_Geometry(iPoint,iDim); // } // } for (iDim = 0; iDim < nDim; iDim++){ - node[iPoint]->SetSensitivity(iDim, Solution_Geometry[iDim]); + nodes->SetSensitivity(iPoint,iDim, Solution_Geometry[iDim]); } geometry->node[iPoint]->SetAdjointCoord(Solution_Geometry); } @@ -801,11 +825,16 @@ void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CSolver **solver, CConf for (iDim = 0; iDim < nDim; iDim++) { - Sensitivity = SU2_TYPE::GetDerivative(Coord[iDim]); + if(config->GetMultizone_Problem()) { + Sensitivity = geometry->node[iPoint]->GetAdjointSolution(iDim); + } + else { + Sensitivity = SU2_TYPE::GetDerivative(Coord[iDim]); + } /*--- Set the index manually to zero. ---*/ - AD::ResetInput(Coord[iDim]); + AD::ResetInput(Coord[iDim]); /*--- If sharp edge, set the sensitivity to 0 on that region ---*/ @@ -815,9 +844,9 @@ void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CSolver **solver, CConf Sensitivity = 0.0; } if (!time_stepping) { - node[iPoint]->SetSensitivity(iDim, Sensitivity); + nodes->SetSensitivity(iPoint,iDim, Sensitivity); } else { - node[iPoint]->SetSensitivity(iDim, node[iPoint]->GetSensitivity(iDim) + Sensitivity); + nodes->SetSensitivity(iPoint, iDim, nodes->GetSensitivity(iPoint,iDim) + Sensitivity); } } } @@ -842,7 +871,8 @@ void CDiscAdjSolver::SetSurface_Sensitivity(CGeometry *geometry, CConfig *config if(config->GetMarker_All_KindBC(iMarker) == EULER_WALL || config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX - || config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL) { + || config->GetMarker_All_KindBC(iMarker) == ISOTHERMAL + || config->GetMarker_All_KindBC(iMarker) == CHT_WALL_INTERFACE) { Sens = 0.0; @@ -854,7 +884,7 @@ void CDiscAdjSolver::SetSurface_Sensitivity(CGeometry *geometry, CConfig *config Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) { /*--- retrieve the gradient calculated with AD -- */ - SensDim = node[iPoint]->GetSensitivity(iDim); + SensDim = nodes->GetSensitivity(iPoint,iDim); /*--- calculate scalar product for projection onto the normal vector ---*/ Prod += Normal[iDim]*SensDim; @@ -917,11 +947,11 @@ void CDiscAdjSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contain unsigned short iVar; if (dual_time) { for (iPoint = 0; iPointGetnPoint(); iPoint++) { - solution_n = node[iPoint]->GetSolution_time_n(); - solution_n1 = node[iPoint]->GetSolution_time_n1(); + solution_n = nodes->GetSolution_time_n(iPoint); + solution_n1 = nodes->GetSolution_time_n1(iPoint); for (iVar=0; iVar < nVar; iVar++) { - node[iPoint]->SetDual_Time_Derivative(iVar, solution_n[iVar]+node[iPoint]->GetDual_Time_Derivative_n(iVar)); - node[iPoint]->SetDual_Time_Derivative_n(iVar, solution_n1[iVar]); + nodes->SetDual_Time_Derivative(iPoint, iVar, solution_n[iVar]+nodes->GetDual_Time_Derivative_n(iPoint, iVar)); + nodes->SetDual_Time_Derivative_n(iPoint,iVar, solution_n1[iVar]); } } } @@ -992,7 +1022,7 @@ void CDiscAdjSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfi index = counter*Restart_Vars[1] + skipVars; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); iPoint_Global_Local++; /*--- Increment the overall counter for how many points have been loaded. ---*/ @@ -1024,12 +1054,12 @@ void CDiscAdjSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfi for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver[iMesh-1][ADJFLOW_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver[iMesh-1][ADJFLOW_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver[iMesh][ADJFLOW_SOL]->node[iPoint]->SetSolution(Solution); + solver[iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution(iPoint, Solution); } } @@ -1057,23 +1087,26 @@ void CDiscAdjSolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig *con /*--- Compute the BGS solution (adding the cross term) ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++){ for (iVar = 0; iVar < nVar; iVar++){ - bgs_sol = node[iPoint]->GetSolution(iVar) + node[iPoint]->GetCross_Term_Derivative(iVar); - node[iPoint]->Set_BGSSolution(iVar, bgs_sol); + if(config->GetMultizone_Problem()) { + bgs_sol = nodes->GetSolution(iPoint,iVar); + } + else { + bgs_sol = nodes->GetSolution(iPoint,iVar) + nodes->GetCross_Term_Derivative(iPoint,iVar); + } + nodes->Set_BGSSolution(iPoint, iVar, bgs_sol); } } /*--- Set the residuals ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ - residual = node[iPoint]->Get_BGSSolution(iVar) - node[iPoint]->Get_BGSSolution_k(iVar); - - AddRes_BGS(iVar,residual*residual); - AddRes_Max_BGS(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); - } + for (iVar = 0; iVar < nVar; iVar++){ + residual = nodes->Get_BGSSolution(iPoint,iVar) - nodes->Get_BGSSolution_k(iPoint,iVar); + AddRes_BGS(iVar,residual*residual); + AddRes_Max_BGS(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); + } } SetResidual_BGS(geometry, config); } - diff --git a/SU2_CFD/src/solver_adjoint_elasticity.cpp b/SU2_CFD/src/solver_adjoint_elasticity.cpp index bbd221d050a4..c3ec97ab7d7e 100644 --- a/SU2_CFD/src/solver_adjoint_elasticity.cpp +++ b/SU2_CFD/src/solver_adjoint_elasticity.cpp @@ -55,6 +55,8 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(void) : CSolver (){ Solution_Vel = NULL; Solution_Accel= NULL; + nodes = nullptr; + } CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config) : CSolver(){ @@ -75,10 +77,14 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config) : CS SolRest = NULL; + nodes = nullptr; + } CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolver *direct_solver, unsigned short Kind_Solver, unsigned short iMesh) : CSolver(){ + adjoint = true; + unsigned short iVar, iMarker, iDim; unsigned long iVertex, iPoint; @@ -104,10 +110,6 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolv nMarker_nL = 0; - /*--- Allocate the node variables ---*/ - - node = new CVariable*[nPoint]; - /*--- Define some auxiliary vectors related to the residual ---*/ Residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 1.0; @@ -185,43 +187,35 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolv } } - if (dynamic){ - /*--- Restart the solution from zero ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CDiscAdjFEAVariable(Solution, Solution_Accel, Solution_Vel, nDim, nVar, config); - } - else{ - bool isVertex; - long indexVertex; - /*--- Restart the solution from zero ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) { - isVertex = false; - for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if (config->GetMarker_All_Fluid_Load(iMarker) == YES) { - indexVertex = geometry->node[iPoint]->GetVertex(iMarker); - if (indexVertex != -1){isVertex = true; break;} - } + nodes = new CDiscAdjFEABoundVariable(Solution, Solution_Accel, Solution_Vel, nPoint, nDim, nVar, dynamic, config); + SetBaseClassPointerToNodes(); + + /*--- Set which points are vertices and allocate boundary data. ---*/ + + for (iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + long iVertex = geometry->node[iPoint]->GetVertex(iMarker); + if (iVertex >= 0) { + nodes->Set_isVertex(iPoint,true); + break; } - if (isVertex) - node[iPoint] = new CDiscAdjFEABoundVariable(Solution, nDim, nVar, config); - else - node[iPoint] = new CDiscAdjFEAVariable(Solution, nDim, nVar, config); } - } + nodes->AllocateBoundaryVariables(config); + /*--- Store the direct solution ---*/ for (iPoint = 0; iPoint < nPoint; iPoint++){ - node[iPoint]->SetSolution_Direct(direct_solver->node[iPoint]->GetSolution()); + nodes->SetSolution_Direct(iPoint, direct_solver->GetNodes()->GetSolution(iPoint)); } if (dynamic){ for (iPoint = 0; iPoint < nPoint; iPoint++){ - node[iPoint]->SetSolution_Accel_Direct(direct_solver->node[iPoint]->GetSolution_Accel()); + nodes->SetSolution_Accel_Direct(iPoint, direct_solver->GetNodes()->GetSolution_Accel(iPoint)); } for (iPoint = 0; iPoint < nPoint; iPoint++){ - node[iPoint]->SetSolution_Vel_Direct(direct_solver->node[iPoint]->GetSolution_Vel()); + nodes->SetSolution_Vel_Direct(iPoint, direct_solver->GetNodes()->GetSolution_Vel(iPoint)); } } @@ -378,6 +372,7 @@ CDiscAdjFEASolver::~CDiscAdjFEASolver(void){ if (Solution_Accel != NULL) delete [] Solution_Accel; if (SolRest != NULL) delete [] SolRest; + if (nodes != nullptr) delete nodes; } void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ @@ -391,35 +386,35 @@ void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ /*--- Reset the solution to the initial (converged) solution ---*/ for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->SetSolution(node[iPoint]->GetSolution_Direct()); + direct_solver->GetNodes()->SetSolution(iPoint, nodes->GetSolution_Direct(iPoint)); } if (dynamic){ /*--- Reset the solution to the initial (converged) solution ---*/ for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->SetSolution_Accel(node[iPoint]->GetSolution_Accel_Direct()); + direct_solver->GetNodes()->SetSolution_Accel(iPoint, nodes->GetSolution_Accel_Direct(iPoint)); } for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->SetSolution_Vel(node[iPoint]->GetSolution_Vel_Direct()); + direct_solver->GetNodes()->SetSolution_Vel(iPoint, nodes->GetSolution_Vel_Direct(iPoint)); } /*--- Reset the input for time n ---*/ for (iPoint = 0; iPoint < nPoint; iPoint++){ for (iVar = 0; iVar < nVar; iVar++){ - AD::ResetInput(direct_solver->node[iPoint]->GetSolution_time_n()[iVar]); + AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n(iPoint)[iVar]); } } for (iPoint = 0; iPoint < nPoint; iPoint++){ for (iVar = 0; iVar < nVar; iVar++){ - AD::ResetInput(direct_solver->node[iPoint]->GetSolution_Accel_time_n()[iVar]); + AD::ResetInput(direct_solver->GetNodes()->GetSolution_Accel_time_n(iPoint)[iVar]); } } for (iPoint = 0; iPoint < nPoint; iPoint++){ for (iVar = 0; iVar < nVar; iVar++){ - AD::ResetInput(direct_solver->node[iPoint]->GetSolution_Vel_time_n()[iVar]); + AD::ResetInput(direct_solver->GetNodes()->GetSolution_Vel_time_n(iPoint)[iVar]); } } @@ -438,35 +433,26 @@ void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ void CDiscAdjFEASolver::RegisterSolution(CGeometry *geometry, CConfig *config){ - unsigned long iPoint, nPoint = geometry->GetnPoint(); - - bool dynamic (config->GetTime_Domain()); + bool dynamic = config->GetTime_Domain(); bool input = true; /*--- Register solution at all necessary time instances and other variables on the tape ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterSolution(input); - } + direct_solver->GetNodes()->RegisterSolution(input); + + if (dynamic) { - if (dynamic){ /*--- Register acceleration (u'') and velocity (u') at time step n ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterSolution_Accel(input); - } - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterSolution_Vel(input); - } + + direct_solver->GetNodes()->RegisterSolution_Accel(input); + direct_solver->GetNodes()->RegisterSolution_Vel(input); + /*--- Register solution (u), acceleration (u'') and velocity (u') at time step n-1 ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->Register_femSolution_time_n(); - } - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterSolution_Accel_time_n(); - } - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterSolution_Vel_time_n(); - } + + direct_solver->GetNodes()->Register_femSolution_time_n(); + direct_solver->GetNodes()->RegisterSolution_Accel_time_n(); + direct_solver->GetNodes()->RegisterSolution_Vel_time_n(); + } } @@ -498,29 +484,26 @@ void CDiscAdjFEASolver::RegisterVariables(CGeometry *geometry, CConfig *config, // for (iVar = 0; iVar < nDV; iVar++) DV_Val[iVar] = config->GetDV_Value(iVar,0); // } - if (!reset){ - for (iVar = 0; iVar < nMPROP; iVar++) AD::RegisterInput(E_i[iVar]); - for (iVar = 0; iVar < nMPROP; iVar++) AD::RegisterInput(Nu_i[iVar]); - for (iVar = 0; iVar < nMPROP; iVar++) AD::RegisterInput(Rho_i[iVar]); - for (iVar = 0; iVar < nMPROP; iVar++) AD::RegisterInput(Rho_DL_i[iVar]); + if (!reset) { + for (iVar = 0; iVar < nMPROP; iVar++) AD::RegisterInput(E_i[iVar]); + for (iVar = 0; iVar < nMPROP; iVar++) AD::RegisterInput(Nu_i[iVar]); + for (iVar = 0; iVar < nMPROP; iVar++) AD::RegisterInput(Rho_i[iVar]); + for (iVar = 0; iVar < nMPROP; iVar++) AD::RegisterInput(Rho_DL_i[iVar]); - if(de_effects){ - for (iVar = 0; iVar < nEField; iVar++) AD::RegisterInput(EField[iVar]); - } + if(de_effects){ + for (iVar = 0; iVar < nEField; iVar++) AD::RegisterInput(EField[iVar]); + } - if(fea_dv){ - for (iVar = 0; iVar < nDV; iVar++) AD::RegisterInput(DV_Val[iVar]); - } + if(fea_dv){ + for (iVar = 0; iVar < nDV; iVar++) AD::RegisterInput(DV_Val[iVar]); + } - if (config->GetTopology_Optimization()) - direct_solver->RegisterVariables(geometry,config); + if (config->GetTopology_Optimization()) + direct_solver->RegisterVariables(geometry,config); - /*--- Register the flow traction sensitivities ---*/ - if (config->GetnMarker_Fluid_Load() > 0){ - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterFlowTraction(); - } - } + /*--- Register the flow traction sensitivities ---*/ + if (config->GetnMarker_Fluid_Load() > 0) + direct_solver->GetNodes()->RegisterFlowTraction(); } } @@ -533,30 +516,20 @@ void CDiscAdjFEASolver::RegisterVariables(CGeometry *geometry, CConfig *config, void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ - unsigned long iPoint, nPoint = geometry->GetnPoint(); - - bool dynamic = (config->GetTime_Domain()); + bool dynamic = config->GetTime_Domain(); /*--- Register variables as output of the solver iteration ---*/ bool input = false; - /*--- Register output variables on the tape ---*/ + direct_solver->GetNodes()->RegisterSolution(input); - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterSolution(input); - } - if (dynamic){ + if (dynamic) { /*--- Register acceleration (u'') and velocity (u') at time step n ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterSolution_Accel(input); - } - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->RegisterSolution_Vel(input); - } + direct_solver->GetNodes()->RegisterSolution_Accel(input); + direct_solver->GetNodes()->RegisterSolution_Vel(input); } - } void CDiscAdjFEASolver::RegisterObj_Func(CConfig *config){ @@ -635,19 +608,19 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co SetRes_Max(iVar,0.0,0); } - for (iPoint = 0; iPoint < nPoint; iPoint++){ + /*--- Set the old solution ---*/ - /*--- Set the old solution ---*/ + nodes->Set_OldSolution(); - node[iPoint]->Set_OldSolution(); + for (iPoint = 0; iPoint < nPoint; iPoint++){ /*--- Extract the adjoint solution ---*/ - direct_solver->node[iPoint]->GetAdjointSolution(Solution); + direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); /*--- Store the adjoint solution ---*/ - node[iPoint]->SetSolution(Solution); + nodes->SetSolution(iPoint,Solution); } @@ -656,36 +629,36 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co if (dynamic){ /*--- FIRST: The acceleration solution ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - /*--- Set the old acceleration solution ---*/ + /*--- Set the old acceleration solution ---*/ + nodes->Set_OldSolution_Accel(); - node[iPoint]->Set_OldSolution_Accel(); + for (iPoint = 0; iPoint < nPoint; iPoint++){ /*--- Extract the adjoint acceleration solution u'' ---*/ - direct_solver->node[iPoint]->GetAdjointSolution_Accel(Solution_Accel); + direct_solver->GetNodes()->GetAdjointSolution_Accel(iPoint,Solution_Accel); /*--- Store the adjoint acceleration solution u'' ---*/ - node[iPoint]->SetSolution_Accel(Solution_Accel); + nodes->SetSolution_Accel(iPoint,Solution_Accel); } /*--- NEXT: The velocity solution ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - - /*--- Set the old velocity solution ---*/ - node[iPoint]->Set_OldSolution_Vel(); + /*--- Set the old velocity solution ---*/ + nodes->Set_OldSolution_Vel(); + + for (iPoint = 0; iPoint < nPoint; iPoint++){ /*--- Extract the adjoint velocity solution u'' ---*/ - direct_solver->node[iPoint]->GetAdjointSolution_Vel(Solution_Vel); + direct_solver->GetNodes()->GetAdjointSolution_Vel(iPoint,Solution_Vel); /*--- Store the adjoint velocity solution u'' ---*/ - node[iPoint]->SetSolution_Vel(Solution_Vel); + nodes->SetSolution_Vel(iPoint,Solution_Vel); } @@ -694,11 +667,11 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution at time n ---*/ - direct_solver->node[iPoint]->GetAdjointSolution_time_n(Solution); + direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); /*--- Store the adjoint solution at time n ---*/ - node[iPoint]->Set_Solution_time_n(Solution); + nodes->Set_Solution_time_n(iPoint,Solution); } /*--- The acceleration solution at time n... ---*/ @@ -706,11 +679,11 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint acceleration solution u'' at time n ---*/ - direct_solver->node[iPoint]->GetAdjointSolution_Accel_time_n(Solution_Accel); + direct_solver->GetNodes()->GetAdjointSolution_Accel_time_n(iPoint,Solution_Accel); /*--- Store the adjoint acceleration solution u'' at time n---*/ - node[iPoint]->SetSolution_Accel_time_n(Solution_Accel); + nodes->SetSolution_Accel_time_n(iPoint,Solution_Accel); } @@ -719,11 +692,11 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint velocity solution u' at time n ---*/ - direct_solver->node[iPoint]->GetAdjointSolution_Vel_time_n(Solution_Vel); + direct_solver->GetNodes()->GetAdjointSolution_Vel_time_n(iPoint,Solution_Vel); /*--- Store the adjoint velocity solution u' at time n ---*/ - node[iPoint]->SetSolution_Vel_time_n(Solution_Vel); + nodes->SetSolution_Vel_time_n(iPoint,Solution_Vel); } @@ -735,20 +708,20 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co for (iPoint = 0; iPoint < nPointDomain; iPoint++){ for (iVar = 0; iVar < nVar; iVar++){ - residual = node[iPoint]->GetSolution(iVar) - node[iPoint]->GetSolution_Old(iVar); + residual = nodes->GetSolution(iPoint, iVar) - nodes->GetSolution_Old(iPoint, iVar); AddRes_RMS(iVar,residual*residual); AddRes_Max(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); } if (dynamic){ for (iVar = 0; iVar < nVar; iVar++){ - residual = node[iPoint]->GetSolution_Accel(iVar) - node[iPoint]->GetSolution_Old_Accel(iVar); + residual = nodes->GetSolution_Accel(iPoint, iVar) - nodes->GetSolution_Old_Accel(iPoint, iVar); AddRes_RMS(iVar,residual*residual); AddRes_Max(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); } for (iVar = 0; iVar < nVar; iVar++){ - residual = node[iPoint]->GetSolution_Vel(iVar) - node[iPoint]->GetSolution_Old_Vel(iVar); + residual = nodes->GetSolution_Vel(iPoint, iVar) - nodes->GetSolution_Old_Vel(iPoint, iVar); AddRes_RMS(iVar,residual*residual); AddRes_Max(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); @@ -819,8 +792,8 @@ void CDiscAdjFEASolver::ExtractAdjoint_Variables(CGeometry *geometry, CConfig *c su2double val_sens; for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++){ for (unsigned short iDim = 0; iDim < nDim; iDim++){ - val_sens = direct_solver->node[iPoint]->ExtractFlowTraction_Sensitivity(iDim); - node[iPoint]->SetFlowTractionSensitivity(iDim, val_sens); + val_sens = direct_solver->GetNodes()->ExtractFlowTraction_Sensitivity(iPoint,iDim); + nodes->SetFlowTractionSensitivity(iPoint, iDim, val_sens); } } } @@ -841,44 +814,44 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ for (iPoint = 0; iPoint < nPoint; iPoint++){ for (iVar = 0; iVar < nVar; iVar++){ - Solution[iVar] = node[iPoint]->GetSolution(iVar); + Solution[iVar] = nodes->GetSolution(iPoint,iVar); } if (fsi) { for (iVar = 0; iVar < nVar; iVar++){ - Solution[iVar] += node[iPoint]->GetGeometry_CrossTerm_Derivative(iVar); + Solution[iVar] += nodes->GetGeometry_CrossTerm_Derivative(iPoint,iVar); } for (iVar = 0; iVar < nVar; iVar++){ - Solution[iVar] += node[iPoint]->GetCross_Term_Derivative(iVar); + Solution[iVar] += nodes->GetCross_Term_Derivative(iPoint,iVar); } } if(deform_mesh){ for (iVar = 0; iVar < nVar; iVar++){ - Solution[iVar] += node[iPoint]->GetSourceTerm_DispAdjoint(iVar); + Solution[iVar] += nodes->GetSourceTerm_DispAdjoint(iPoint,iVar); } } if (dynamic){ for (iVar = 0; iVar < nVar; iVar++){ - Solution_Accel[iVar] = node[iPoint]->GetSolution_Accel(iVar); + Solution_Accel[iVar] = nodes->GetSolution_Accel(iPoint,iVar); } for (iVar = 0; iVar < nVar; iVar++){ - Solution_Vel[iVar] = node[iPoint]->GetSolution_Vel(iVar); + Solution_Vel[iVar] = nodes->GetSolution_Vel(iPoint,iVar); } for (iVar = 0; iVar < nVar; iVar++){ - Solution[iVar] += node[iPoint]->GetDynamic_Derivative_n(iVar); + Solution[iVar] += nodes->GetDynamic_Derivative_n(iPoint,iVar); } for (iVar = 0; iVar < nVar; iVar++){ - Solution_Accel[iVar] += node[iPoint]->GetDynamic_Derivative_Accel_n(iVar); + Solution_Accel[iVar] += nodes->GetDynamic_Derivative_Accel_n(iPoint,iVar); } for (iVar = 0; iVar < nVar; iVar++){ - Solution_Vel[iVar] += node[iPoint]->GetDynamic_Derivative_Vel_n(iVar); + Solution_Vel[iVar] += nodes->GetDynamic_Derivative_Vel_n(iPoint,iVar); } } - direct_solver->node[iPoint]->SetAdjointSolution(Solution); + direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); if (dynamic){ - direct_solver->node[iPoint]->SetAdjointSolution_Accel(Solution_Accel); - direct_solver->node[iPoint]->SetAdjointSolution_Vel(Solution_Vel); + direct_solver->GetNodes()->SetAdjointSolution_Accel(iPoint,Solution_Accel); + direct_solver->GetNodes()->SetAdjointSolution_Vel(iPoint,Solution_Vel); } } @@ -894,13 +867,13 @@ void CDiscAdjFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_cont if (dynamic){ for (iPoint = 0; iPointGetnPoint(); iPoint++){ for (iVar=0; iVar < nVar; iVar++){ - node[iPoint]->SetDynamic_Derivative_n(iVar, node[iPoint]->GetSolution_time_n(iVar)); + nodes->SetDynamic_Derivative_n(iPoint, iVar, nodes->GetSolution_time_n(iPoint, iVar)); } for (iVar=0; iVar < nVar; iVar++){ - node[iPoint]->SetDynamic_Derivative_Accel_n(iVar, node[iPoint]->GetSolution_Accel_time_n(iVar)); + nodes->SetDynamic_Derivative_Accel_n(iPoint, iVar, nodes->GetSolution_Accel_time_n(iPoint, iVar)); } for (iVar=0; iVar < nVar; iVar++){ - node[iPoint]->SetDynamic_Derivative_Vel_n(iVar, node[iPoint]->GetSolution_Vel_time_n(iVar)); + nodes->SetDynamic_Derivative_Vel_n(iPoint, iVar, nodes->GetSolution_Vel_time_n(iPoint, iVar)); } } } @@ -916,9 +889,9 @@ void CDiscAdjFEASolver::ExtractAdjoint_CrossTerm(CGeometry *geometry, CConfig *c /*--- Extract the adjoint solution ---*/ - direct_solver->node[iPoint]->GetAdjointSolution(Solution); + direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); - for (iVar = 0; iVar < nVar; iVar++) node[iPoint]->SetCross_Term_Derivative(iVar, Solution[iVar]); + for (iVar = 0; iVar < nVar; iVar++) nodes->SetCross_Term_Derivative(iPoint,iVar, Solution[iVar]); } @@ -935,14 +908,14 @@ void CDiscAdjFEASolver::ExtractAdjoint_CrossTerm_Geometry(CGeometry *geometry, C /*--- Extract the adjoint solution ---*/ - direct_solver->node[iPoint]->GetAdjointSolution(Solution); + direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); /*--- Relax and set the solution ---*/ for(iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = relax*Solution[iVar] + (1.0-relax)*node[iPoint]->GetGeometry_CrossTerm_Derivative(iVar); + Solution[iVar] = relax*Solution[iVar] + (1.0-relax)*nodes->GetGeometry_CrossTerm_Derivative(iPoint,iVar); - for (iVar = 0; iVar < nVar; iVar++) node[iPoint]->SetGeometry_CrossTerm_Derivative(iVar, Solution[iVar]); + for (iVar = 0; iVar < nVar; iVar++) nodes->SetGeometry_CrossTerm_Derivative(iPoint,iVar, Solution[iVar]); } @@ -992,15 +965,15 @@ void CDiscAdjFEASolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig * /*--- Compute the BGS solution (adding the cross term) ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++){ for (iVar = 0; iVar < nVar; iVar++){ - bgs_sol = node[iPoint]->GetSolution(iVar) + node[iPoint]->GetGeometry_CrossTerm_Derivative(iVar); - node[iPoint]->Set_BGSSolution(iVar, bgs_sol); + bgs_sol = nodes->GetSolution(iPoint, iVar) + nodes->GetGeometry_CrossTerm_Derivative(iPoint, iVar); + nodes->Set_BGSSolution(iPoint,iVar, bgs_sol); } } /*--- Set the residuals ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++){ for (iVar = 0; iVar < nVar; iVar++){ - residual = node[iPoint]->Get_BGSSolution(iVar) - node[iPoint]->Get_BGSSolution_k(iVar); + residual = nodes->Get_BGSSolution(iPoint, iVar) - nodes->Get_BGSSolution_k(iPoint, iVar); AddRes_BGS(iVar,residual*residual); AddRes_Max_BGS(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); } @@ -1010,7 +983,6 @@ void CDiscAdjFEASolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig * } - void CDiscAdjFEASolver::BC_Clamped_Post(CGeometry *geometry, CNumerics *numerics, CConfig *config, unsigned short val_marker) { unsigned long iPoint, iVertex; @@ -1029,11 +1001,11 @@ void CDiscAdjFEASolver::BC_Clamped_Post(CGeometry *geometry, CNumerics *numerics Solution[0] = 0.0; Solution[1] = 0.0; Solution[2] = 0.0; } - node[iPoint]->SetSolution(Solution); + nodes->SetSolution(iPoint,Solution); if (dynamic){ - node[iPoint]->SetSolution_Vel(Solution); - node[iPoint]->SetSolution_Accel(Solution); + nodes->SetSolution_Vel(iPoint,Solution); + nodes->SetSolution_Accel(iPoint,Solution); } } @@ -1200,7 +1172,7 @@ void CDiscAdjFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CCo index = counter*Restart_Vars[1] + skipVars; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); iPoint_Global_Local++; /*--- Increment the overall counter for how many points have been loaded. ---*/ @@ -1232,12 +1204,12 @@ void CDiscAdjFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CCo for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver[iMesh-1][ADJFLOW_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver[iMesh-1][ADJFLOW_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver[iMesh][ADJFLOW_SOL]->node[iPoint]->SetSolution(Solution); + solver[iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution(iPoint,Solution); } } diff --git a/SU2_CFD/src/solver_adjoint_mean.cpp b/SU2_CFD/src/solver_adjoint_mean.cpp index 62c6c6a29d96..0d612a537afa 100644 --- a/SU2_CFD/src/solver_adjoint_mean.cpp +++ b/SU2_CFD/src/solver_adjoint_mean.cpp @@ -68,6 +68,8 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned string filename, AdjExt; su2double myArea_Monitored, Area, *Normal; + adjoint = true; + bool restart = config->GetRestart(); bool axisymmetric = config->GetAxisymmetric(); @@ -116,8 +118,6 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned nVarGrad = nVar; - node = new CVariable*[nPoint]; - /*--- Define some auxiliary vectors related to the residual ---*/ Residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; Residual_RMS = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual_RMS[iVar] = 0.0; @@ -292,8 +292,8 @@ CAdjEulerSolver::CAdjEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- Initialize the solution with the far-field state everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CAdjEulerVariable(PsiRho_Inf, Phi_Inf, PsiE_Inf, nDim, nVar, config); + nodes = new CAdjEulerVariable(PsiRho_Inf, Phi_Inf, PsiE_Inf, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); /*--- Read the restart metadata. ---*/ @@ -409,6 +409,7 @@ CAdjEulerSolver::~CAdjEulerSolver(void) { delete [] CSensitivity; } + if (nodes != nullptr) delete nodes; } void CAdjEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, @@ -582,7 +583,7 @@ void CAdjEulerSolver::Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geo jMarker = geometry->vertex[iMarker][iVertex]->GetDonorMarker(); for (iVar = 0; iVar < nVar; iVar++) { - Buffer_Send_AdjVar[(nVar+3)*(PointTotal_Counter+iPointTotal)+iVar] = node[iPoint]->GetSolution(iVar); + Buffer_Send_AdjVar[(nVar+3)*(PointTotal_Counter+iPointTotal)+iVar] = nodes->GetSolution(iPoint,iVar); } Buffer_Send_AdjVar[(nVar+3)*(PointTotal_Counter+iPointTotal)+(nVar+0)] = su2double(iGlobalIndex); Buffer_Send_AdjVar[(nVar+3)*(PointTotal_Counter+iPointTotal)+(nVar+1)] = su2double(jVertex); @@ -897,7 +898,7 @@ void CAdjEulerSolver::Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { jMarker = geometry->vertex[iMarker][iVertex]->GetDonorMarker(); for (iVar = 0; iVar < nVar; iVar++) { - Buffer_Send_AdjVar[(nVar+3)*(PointTotal_Counter+iPointTotal)+iVar] = node[iPoint]->GetSolution(iVar); + Buffer_Send_AdjVar[(nVar+3)*(PointTotal_Counter+iPointTotal)+iVar] = nodes->GetSolution(iPoint,iVar); } Buffer_Send_AdjVar[(nVar+3)*(PointTotal_Counter+iPointTotal)+(nVar+0)] = su2double(iGlobalIndex); Buffer_Send_AdjVar[(nVar+3)*(PointTotal_Counter+iPointTotal)+(nVar+1)] = su2double(jVertex); @@ -1090,7 +1091,7 @@ void CAdjEulerSolver::SetForceProj_Vector(CGeometry *geometry, CSolver **solver_ for (iDim=0; iDimvertex[iMarker][iVertex]->GetNode(); - node[iPoint]->SetForceProj_Vector(ForceProj_Vector); + nodes->SetForceProj_Vector(iPoint,ForceProj_Vector); } } @@ -1117,7 +1118,7 @@ void CAdjEulerSolver::SetForceProj_Vector(CGeometry *geometry, CSolver **solver_ if (nDim == 3) z = geometry->node[iPoint]->GetCoord(2); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - ForceProj_Vector2 = node[iPoint]->GetForceProj_Vector(); + ForceProj_Vector2 = nodes->GetForceProj_Vector(iPoint); for (iDim=0; iDimSetForceProj_Vector(ForceProj_Vector); + nodes->SetForceProj_Vector(iPoint,ForceProj_Vector); } } @@ -1449,7 +1450,7 @@ void CAdjEulerSolver::SetIntBoundary_Jump(CGeometry *geometry, CSolver **solver_ case NEARFIELD_PRESSURE : - DerivativeOF = factor*WeightSB*(solver_container[FLOW_SOL]->node[iPoint]->GetPressure() + DerivativeOF = factor*WeightSB*(solver_container[FLOW_SOL]->GetNodes()->GetPressure(iPoint) - solver_container[FLOW_SOL]->GetPressure_Inf()); break; @@ -1458,7 +1459,7 @@ void CAdjEulerSolver::SetIntBoundary_Jump(CGeometry *geometry, CSolver **solver_ /*--- Compute the jump of the adjoint variables (2D, and 3D problems) --*/ - FlowSolution = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + FlowSolution = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); Rho = FlowSolution[0]; Energy = FlowSolution[nVar-1]/FlowSolution[0]; @@ -1558,7 +1559,7 @@ void CAdjEulerSolver::SetIntBoundary_Jump(CGeometry *geometry, CSolver **solver_ for (iVar = 0; iVar < nVar; iVar++) IntBound_Vector[iVar] = b[iVar]; - node[iPoint]->SetIntBoundary_Jump(IntBound_Vector); + nodes->SetIntBoundary_Jump(iPoint,IntBound_Vector); } } @@ -1599,12 +1600,12 @@ void CAdjEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver_container[iMesh-1][ADJFLOW_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver_container[iMesh-1][ADJFLOW_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver_container[iMesh][ADJFLOW_SOL]->node[iPoint]->SetSolution(Solution); + solver_container[iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution(iPoint, Solution); } solver_container[iMesh][ADJFLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); @@ -1615,11 +1616,9 @@ void CAdjEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve /*--- The value of the solution for the first iteration of the dual time ---*/ for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { - if ((TimeIter == 0) && (dual_time)) { - solver_container[iMesh][ADJFLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[iMesh][ADJFLOW_SOL]->node[iPoint]->Set_Solution_time_n1(); - } + if ((TimeIter == 0) && (dual_time)) { + solver_container[iMesh][ADJFLOW_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[iMesh][ADJFLOW_SOL]->GetNodes()->Set_Solution_time_n1(); } } @@ -1657,7 +1656,7 @@ void CAdjEulerSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contai /*--- Set the primitive variables compressible adjoint variables ---*/ - physical = node[iPoint]->SetPrimVar(SharpEdge_Distance, false, config); + physical = nodes->SetPrimVar(iPoint,SharpEdge_Distance, false, config); /* Check for non-realizable states for reporting. */ @@ -1733,25 +1732,25 @@ void CAdjEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co /*--- Adjoint variables w/o reconstruction ---*/ - numerics->SetAdjointVar(node[iPoint]->GetSolution(), node[jPoint]->GetSolution()); + numerics->SetAdjointVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetConservative(solver_container[FLOW_SOL]->node[iPoint]->GetSolution(), - solver_container[FLOW_SOL]->node[jPoint]->GetSolution()); + numerics->SetConservative(solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetSolution(jPoint)); - numerics->SetSoundSpeed(solver_container[FLOW_SOL]->node[iPoint]->GetSoundSpeed(), - solver_container[FLOW_SOL]->node[jPoint]->GetSoundSpeed()); - numerics->SetEnthalpy(solver_container[FLOW_SOL]->node[iPoint]->GetEnthalpy(), - solver_container[FLOW_SOL]->node[jPoint]->GetEnthalpy()); + numerics->SetSoundSpeed(solver_container[FLOW_SOL]->GetNodes()->GetSoundSpeed(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetSoundSpeed(jPoint)); + numerics->SetEnthalpy(solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(jPoint)); - numerics->SetLambda(solver_container[FLOW_SOL]->node[iPoint]->GetLambda(), - solver_container[FLOW_SOL]->node[jPoint]->GetLambda()); + numerics->SetLambda(solver_container[FLOW_SOL]->GetNodes()->GetLambda(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetLambda(jPoint)); if (jst_scheme) { - numerics->SetUndivided_Laplacian(node[iPoint]->GetUndivided_Laplacian(), node[jPoint]->GetUndivided_Laplacian()); - numerics->SetSensor(node[iPoint]->GetSensor(), node[jPoint]->GetSensor()); + numerics->SetUndivided_Laplacian(nodes->GetUndivided_Laplacian(iPoint), nodes->GetUndivided_Laplacian(jPoint)); + numerics->SetSensor(nodes->GetSensor(iPoint), nodes->GetSensor(jPoint)); } /*--- Mesh motion ---*/ @@ -1807,14 +1806,14 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Adjoint variables w/o reconstruction ---*/ - Psi_i = node[iPoint]->GetSolution(); - Psi_j = node[jPoint]->GetSolution(); + Psi_i = nodes->GetSolution(iPoint); + Psi_j = nodes->GetSolution(jPoint); numerics->SetAdjointVar(Psi_i, Psi_j); /*--- Primitive variables w/o reconstruction ---*/ - V_i = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); - V_j = solver_container[FLOW_SOL]->node[jPoint]->GetPrimitive(); + V_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); + V_j = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(jPoint); numerics->SetPrimitive(V_i, V_j); /*--- Grid velocities for dynamic meshes ---*/ @@ -1834,12 +1833,12 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Adjoint variables using gradient reconstruction and limiters ---*/ - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = nodes->GetGradient_Reconstruction(jPoint); if (limiter) { - Limiter_i = node[iPoint]->GetLimiter(); - Limiter_j = node[jPoint]->GetLimiter(); + Limiter_i = nodes->GetLimiter(iPoint); + Limiter_j = nodes->GetLimiter(jPoint); } for (iVar = 0; iVar < nVar; iVar++) { @@ -1865,21 +1864,21 @@ void CAdjEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont bool phi_bound_i = (fabs(Solution_i[0]) > adj_limit); bool phi_bound_j = (fabs(Solution_j[0]) > adj_limit); - if (phi_bound_i) node[iPoint]->SetNon_Physical(true); - else node[iPoint]->SetNon_Physical(false); + if (phi_bound_i) nodes->SetNon_Physical(iPoint, true); + else nodes->SetNon_Physical(iPoint, false); - if (phi_bound_j) node[jPoint]->SetNon_Physical(true); - else node[jPoint]->SetNon_Physical(false); + if (phi_bound_j) nodes->SetNon_Physical(jPoint, true); + else nodes->SetNon_Physical(jPoint, false); /* Lastly, check for existing first-order points still active from previous iterations. */ - if (node[iPoint]->GetNon_Physical()) { + if (nodes->GetNon_Physical(iPoint)) { counter_local++; for (iVar = 0; iVar < nVar; iVar++) Solution_i[iVar] = Psi_i[iVar]; } - if (node[jPoint]->GetNon_Physical()) { + if (nodes->GetNon_Physical(jPoint)) { counter_local++; for (iVar = 0; iVar < nVar; iVar++) Solution_j[iVar] = Psi_j[iVar]; @@ -1942,8 +1941,8 @@ void CAdjEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the adjoint variables ---*/ - numerics->SetAdjointVar(node[iPoint]->GetSolution(), - node[iPoint]->GetSolution()); + numerics->SetAdjointVar(nodes->GetSolution(iPoint), + nodes->GetSolution(iPoint)); /*--- Load the volume of the dual mesh cell ---*/ numerics->SetVolume(geometry->node[iPoint]->GetVolume()); @@ -1972,7 +1971,7 @@ void CAdjEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Get stored harmonic balance source term ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Source = node[iPoint]->GetHarmonicBalance_Source(iVar); + Source = nodes->GetHarmonicBalance_Source(iPoint,iVar); Residual[iVar] = Source*Volume; } @@ -1995,10 +1994,10 @@ void CAdjEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Set solution ---*/ - numerics->SetConservative(solver_container[FLOW_SOL]->node[iPoint]->GetSolution(), solver_container[FLOW_SOL]->node[iPoint]->GetSolution()); + numerics->SetConservative(solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint), solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint)); /*--- Set adjoint variables ---*/ - numerics->SetAdjointVar(node[iPoint]->GetSolution(), node[iPoint]->GetSolution()); + numerics->SetAdjointVar(nodes->GetSolution(iPoint), nodes->GetSolution(iPoint)); /*--- Set control volume ---*/ numerics->SetVolume(geometry->node[iPoint]->GetVolume()); @@ -2036,20 +2035,19 @@ void CAdjEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *confi Diff = new su2double[nVar]; - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetUnd_LaplZero(); + nodes->SetUnd_LaplZero(); for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); for (iVar = 0; iVar < nVar; iVar++) - Diff[iVar] = node[iPoint]->GetSolution(iVar) - node[jPoint]->GetSolution(iVar); + Diff[iVar] = nodes->GetSolution(iPoint,iVar) - nodes->GetSolution(jPoint,iVar); #ifdef STRUCTURED_GRID - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint, Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint, Diff); #else @@ -2058,17 +2056,17 @@ void CAdjEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *confi /*--- Both points inside the domain, or both in the boundary ---*/ if ((!boundary_i && !boundary_j) || (boundary_i && boundary_j)) { - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint, Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint, Diff); } /*--- iPoint inside the domain, jPoint on the boundary ---*/ if (!boundary_i && boundary_j) - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint, Diff); /*--- jPoint inside the domain, iPoint on the boundary ---*/ if (boundary_i && !boundary_j) - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint, Diff); #endif @@ -2101,13 +2099,13 @@ void CAdjEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *confi /*--- Interpolate & compute difference in the conserved variables ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Psi_mirror[iVar] = 2.0*node[iPoint]->GetSolution(iVar) - node[Point_Normal]->GetSolution(iVar); - Diff[iVar] = node[iPoint]->GetSolution(iVar) - Psi_mirror[iVar]; + Psi_mirror[iVar] = 2.0*node[iPoint]->GetSolution(iVar) - nodes->GetSolution(Point_Normal, iVar); + Diff[iVar] = nodes->GetSolution(iPoint,iVar) - Psi_mirror[iVar]; } /*--- Subtract contribution at the boundary node only ---*/ - node[iPoint]->SubtractUnd_Lapl(Diff); + nodes->SubtractUnd_Lapl(iPoint,Diff); } } } @@ -2149,7 +2147,7 @@ void CAdjEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfi Sensor = scale * ds; - node[iPoint]->SetSensor(Sensor); + nodes->SetSensor(iPoint,Sensor); } @@ -2176,14 +2174,14 @@ void CAdjEulerSolver::ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver /*--- Update the solution ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Vol = geometry->node[iPoint]->GetVolume(); - Delta = solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time() / Vol; + Delta = solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint) / Vol; - Res_TruncError = node[iPoint]->GetResTruncError(); + Res_TruncError = nodes->GetResTruncError(iPoint); Residual = LinSysRes.GetBlock(iPoint); for (iVar = 0; iVar < nVar; iVar++) { Res = Residual[iVar] + Res_TruncError[iVar]; - node[iPoint]->AddSolution(iVar, -Res*Delta*RK_AlphaCoeff); + nodes->AddSolution(iPoint,iVar, -Res*Delta*RK_AlphaCoeff); AddRes_RMS(iVar, Res*Res); AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); } @@ -2213,14 +2211,14 @@ void CAdjEulerSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **sol /*--- Update the solution ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Vol = geometry->node[iPoint]->GetVolume(); - Delta = solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time() / Vol; + Delta = solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint) / Vol; - local_Res_TruncError = node[iPoint]->GetResTruncError(); + local_Res_TruncError = nodes->GetResTruncError(iPoint); local_Residual = LinSysRes.GetBlock(iPoint); for (iVar = 0; iVar < nVar; iVar++) { Res = local_Residual[iVar] + local_Res_TruncError[iVar]; - node[iPoint]->AddSolution(iVar, -Res*Delta); + nodes->AddSolution(iPoint,iVar, -Res*Delta); AddRes_RMS(iVar, Res*Res); AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); } @@ -2256,7 +2254,7 @@ void CAdjEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol /*--- Read the residual ---*/ - local_Res_TruncError = node[iPoint]->GetResTruncError(); + local_Res_TruncError = nodes->GetResTruncError(iPoint); /*--- Read the volume ---*/ @@ -2264,8 +2262,8 @@ void CAdjEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - if (solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time() != 0.0) { - Delta = Vol / solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time(); + if (solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint) != 0.0) { + Delta = Vol / solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); Jacobian.AddVal2Diag(iPoint, Delta); } else { @@ -2307,7 +2305,7 @@ void CAdjEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol for (iPoint = 0; iPoint < nPointDomain; iPoint++) for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddSolution(iVar, config->GetRelaxation_Factor_AdjFlow()*LinSysSol[iPoint*nVar+iVar]); + nodes->AddSolution(iPoint,iVar, config->GetRelaxation_Factor_AdjFlow()*LinSysSol[iPoint*nVar+iVar]); } /*--- MPI solution ---*/ @@ -2397,24 +2395,24 @@ void CAdjEulerSolver::Inviscid_Sensitivity(CGeometry *geometry, CSolver **solver for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) { - Psi = node[iPoint]->GetSolution(); - U = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); - Enthalpy = solver_container[FLOW_SOL]->node[iPoint]->GetEnthalpy(); + Psi = nodes->GetSolution(iPoint); + U = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); + Enthalpy = solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(iPoint); conspsi = U[0]*Psi[0] + U[0]*Enthalpy*Psi[nDim+1]; for (iDim = 0; iDim < nDim; iDim++) conspsi += U[iDim+1]*Psi[iDim+1]; - node[iPoint]->SetAuxVar(conspsi); + nodes->SetAuxVar(iPoint,conspsi); /*--- Also load the auxiliary variable for first neighbors ---*/ for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); iNeigh++) { Neigh = geometry->node[iPoint]->GetPoint(iNeigh); - Psi = node[Neigh]->GetSolution(); - U = solver_container[FLOW_SOL]->node[Neigh]->GetSolution(); - Enthalpy = solver_container[FLOW_SOL]->node[Neigh]->GetEnthalpy(); + Psi = nodes->GetSolution(Neigh); + U = solver_container[FLOW_SOL]->GetNodes()->GetSolution(Neigh); + Enthalpy = solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(Neigh); conspsi = U[0]*Psi[0] + U[0]*Enthalpy*Psi[nDim+1]; for (iDim = 0; iDim < nDim; iDim++) conspsi += U[iDim+1]*Psi[iDim+1]; - node[Neigh]->SetAuxVar(conspsi); + nodes->SetAuxVar(Neigh,conspsi); } } } @@ -2433,16 +2431,16 @@ void CAdjEulerSolver::Inviscid_Sensitivity(CGeometry *geometry, CSolver **solver iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) { - d = node[iPoint]->GetForceProj_Vector(); + d = nodes->GetForceProj_Vector(iPoint); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Area = 0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); - PrimVar_Grad = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); - ConsPsi_Grad = node[iPoint]->GetAuxVarGradient(); - ConsPsi = node[iPoint]->GetAuxVar(); + PrimVar_Grad = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); + ConsPsi_Grad = nodes->GetAuxVarGradient(iPoint); + ConsPsi = nodes->GetAuxVar(iPoint); d_press = 0.0; grad_v = 0.0; v_gradconspsi = 0.0; for (iDim = 0; iDim < nDim; iDim++) { @@ -2457,7 +2455,7 @@ void CAdjEulerSolver::Inviscid_Sensitivity(CGeometry *geometry, CSolver **solver /*-- Retrieve the value of the theta gradient ---*/ - v_gradconspsi += solver_container[FLOW_SOL]->node[iPoint]->GetVelocity(iDim) * ConsPsi_Grad[iDim]; + v_gradconspsi += solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim) * ConsPsi_Grad[iDim]; /*--- Additional sensitivity term for grid movement ---*/ @@ -2502,8 +2500,8 @@ void CAdjEulerSolver::Inviscid_Sensitivity(CGeometry *geometry, CSolver **solver iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) { - Psi = node[iPoint]->GetSolution(); - U = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + Psi = nodes->GetSolution(iPoint); + U = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Mach_Inf = config->GetMach(); @@ -2520,7 +2518,7 @@ void CAdjEulerSolver::Inviscid_Sensitivity(CGeometry *geometry, CSolver **solver Vn += UnitNormal[iDim]*Velocity[iDim]; } - SoundSpeed = solver_container[FLOW_SOL]->node[iPoint]->GetSoundSpeed(); + SoundSpeed = solver_container[FLOW_SOL]->GetNodes()->GetSoundSpeed(iPoint); if (Vn0) { /*TODO: MDO compatible*/ Sens_BPress[iMarker]+=Psi[nDim+1]*(SoundSpeed*SoundSpeed-Vn*Vn)/(Vn*Gamma_Minus_One); @@ -2549,8 +2547,8 @@ void CAdjEulerSolver::Inviscid_Sensitivity(CGeometry *geometry, CSolver **solver iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) { - Psi = node[iPoint]->GetSolution(); - U = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + Psi = nodes->GetSolution(iPoint); + U = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Mach_Inf = config->GetMach(); @@ -2702,12 +2700,12 @@ void CAdjEulerSolver::Inviscid_Sensitivity(CGeometry *geometry, CSolver **solver if (geometry->node[iPoint]->GetDomain()) { Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - p = solver_container[FLOW_SOL]->node[iPoint]->GetPressure(); + p = solver_container[FLOW_SOL]->GetNodes()->GetPressure(iPoint); Mach_Inf = config->GetMach(); if (grid_movement) Mach_Inf = config->GetMach_Motion(); - d = node[iPoint]->GetForceProj_Vector(); + d = nodes->GetForceProj_Vector(iPoint); Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = -Normal[iDim]/Area; @@ -3059,14 +3057,14 @@ void CAdjEulerSolver::BC_Euler_Wall(CGeometry *geometry, Normal = geometry->vertex[val_marker][iVertex]->GetNormal(); /*--- Create a copy of the adjoint solution ---*/ - Psi_Aux = node[iPoint]->GetSolution(); + Psi_Aux = nodes->GetSolution(iPoint); for (iVar = 0; iVar < nVar; iVar++) Psi[iVar] = Psi_Aux[iVar]; /*--- Flow solution ---*/ - U = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + U = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); /*--- Read the value of the objective function ---*/ - d = node[iPoint]->GetForceProj_Vector(); + d = nodes->GetForceProj_Vector(iPoint); /*--- Normal vector computation ---*/ Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; @@ -3076,8 +3074,8 @@ void CAdjEulerSolver::BC_Euler_Wall(CGeometry *geometry, for (iDim = 0; iDim < nDim; iDim++) Velocity[iDim] = U[iDim+1] / U[0]; - Enthalpy = solver_container[FLOW_SOL]->node[iPoint]->GetEnthalpy(); - sq_vel = 0.5*solver_container[FLOW_SOL]->node[iPoint]->GetVelocity2(); + Enthalpy = solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(iPoint); + sq_vel = 0.5*solver_container[FLOW_SOL]->GetNodes()->GetVelocity2(iPoint); /*--- Compute projections ---*/ ProjVel = 0.0; bcn = 0.0; vn = 0.0; phin = 0.0; @@ -3212,15 +3210,15 @@ void CAdjEulerSolver::BC_Sym_Plane(CGeometry *geometry, CSolver **solver_contain /*--- Create a copy of the adjoint solution ---*/ - for (iVar = 0; iVar < nVar; iVar++) Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); + for (iVar = 0; iVar < nVar; iVar++) Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Retrieve flow variables ---*/ for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = solver_container[FLOW_SOL]->node[iPoint]->GetVelocity(iDim); + Velocity[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); - Enthalpy = solver_container[FLOW_SOL]->node[iPoint]->GetEnthalpy(); - sq_vel = 0.5*solver_container[FLOW_SOL]->node[iPoint]->GetVelocity2(); + Enthalpy = solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(iPoint); + sq_vel = 0.5*solver_container[FLOW_SOL]->GetNodes()->GetVelocity2(iPoint); /*--- Compute projections ---*/ @@ -3361,7 +3359,7 @@ void CAdjEulerSolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solve /*--- Store the solution for both points ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Psi_i[iVar] = node[iPoint]->GetSolution(iVar); + Psi_i[iVar] = nodes->GetSolution(iPoint,iVar); Psi_j[iVar] = GetDonorAdjVar(val_marker, iVertex, iVar); } @@ -3371,7 +3369,7 @@ void CAdjEulerSolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solve /*--- Conservative variables w/o reconstruction (the same at both points) ---*/ - V_i = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); numerics->SetPrimitive(V_i, V_i); /*--- Set Normal ---*/ @@ -3426,7 +3424,7 @@ void CAdjEulerSolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solve /*--- Store the solution for both points ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Psi_i[iVar] = node[iPoint]->GetSolution(iVar); + Psi_i[iVar] = nodes->GetSolution(iPoint,iVar); Psi_j[iVar] = GetDonorAdjVar(val_marker, iVertex, iVar); } @@ -3443,7 +3441,7 @@ void CAdjEulerSolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solve /*--- Read the jump ---*/ - IntBoundary_Jump = node[iPoint]->GetIntBoundary_Jump(); + IntBoundary_Jump = nodes->GetIntBoundary_Jump(iPoint); /*--- Inner point ---*/ @@ -3475,7 +3473,7 @@ void CAdjEulerSolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solve /*--- Conservative variables w/o reconstruction (the same at both points) ---*/ - V_i = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); numerics->SetPrimitive(V_i, V_i); /*--- Compute residual ---*/ @@ -3537,14 +3535,14 @@ void CAdjEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); conv_numerics->SetPrimitive(V_domain, V_infty); /*--- Adjoint flow solution at the wall ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); Psi_infty[iVar] = 0.0; } conv_numerics->SetAdjointVar(Psi_domain, Psi_infty); @@ -3583,7 +3581,7 @@ void CAdjEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Gradient and limiter of Adjoint Variables ---*/ - visc_numerics->SetAdjointVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetAdjointVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute residual ---*/ @@ -3639,12 +3637,12 @@ void CAdjEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_ /*--- Retrieve solution at the boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Adjoint flow solution at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Construct the flow & adjoint states at the inlet ---*/ /*--- Supersonic Inlet: All characteristic are exiting: using nearest neighbor to set value ---*/ @@ -3696,7 +3694,7 @@ void CAdjEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_ /*--- Gradient and limiter of Adjoint Variables ---*/ - visc_numerics->SetAdjointVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetAdjointVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute residual ---*/ @@ -3754,12 +3752,12 @@ void CAdjEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver /*--- Retrieve solution at the boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Adjoint flow solution at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Construct the flow & adjoint states at the inlet ---*/ @@ -3811,7 +3809,7 @@ void CAdjEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver /*--- Gradient and limiter of Adjoint Variables ---*/ - visc_numerics->SetAdjointVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetAdjointVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute residual ---*/ @@ -3880,12 +3878,12 @@ void CAdjEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve solution at the boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Adjoint flow solution at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Construct the flow & adjoint states at the inlet ---*/ @@ -3913,11 +3911,11 @@ void CAdjEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Get primitives from current inlet state. ---*/ for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = solver_container[FLOW_SOL]->node[iPoint]->GetVelocity(iDim); + Velocity[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint, iDim); /*--- Retrieve current adjoint solution values at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi_inlet[iVar] = node[iPoint]->GetSolution(iVar); + Psi_inlet[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Some terms needed for the adjoint BC ---*/ bcn = 0.0; phin = 0.0; @@ -3986,7 +3984,7 @@ void CAdjEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Gradient and limiter of Adjoint Variables ---*/ - visc_numerics->SetAdjointVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetAdjointVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute residual ---*/ @@ -4077,12 +4075,12 @@ void CAdjEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve solution at the boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Adjoint flow solution at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Construct the flow & adjoint states at the outlet ---*/ @@ -4254,8 +4252,8 @@ void CAdjEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, if (config->GetViscous()) { /*--- Set laminar and eddy viscosity at the infinity ---*/ - V_outlet[nDim+5] = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); - V_outlet[nDim+6] = solver_container[FLOW_SOL]->node[iPoint]->GetEddyViscosity(); + V_outlet[nDim+5] = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + V_outlet[nDim+6] = solver_container[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); /*--- Points in edge, coordinates and normal vector---*/ visc_numerics->SetNormal(Normal); @@ -4267,13 +4265,13 @@ void CAdjEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, visc_numerics->SetAdjointVar(Psi_domain, Psi_outlet); /*--- Turbulent kinetic energy ---*/ - if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Gradient and limiter of Adjoint Variables ---*/ - visc_numerics->SetAdjointVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetAdjointVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute residual ---*/ @@ -4340,12 +4338,12 @@ void CAdjEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_con /*--- Retrieve solution at the boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Adjoint flow solution at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Subsonic flow is assumed, note that there is no non-dimensionalization. ---*/ @@ -4464,18 +4462,18 @@ void CAdjEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_co /*--- Retrieve solution at the boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Adjoint flow solution at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Adjoint flow solution at the exhaust (this should be improved using characteristics bc) ---*/ Psi_exhaust[0] = 0.0; for (iDim = 0; iDim < nDim; iDim++) - Psi_exhaust[iDim+1] = node[Point_Normal]->GetSolution(iDim+1); + Psi_exhaust[iDim+1] = nodes->GetSolution(Point_Normal,iDim+1); Psi_exhaust[nDim+1] = 0.0; /*--- Set the flow and adjoint states in the solver ---*/ @@ -4540,13 +4538,13 @@ void CAdjEulerSolver::BC_ActDisk_Inlet(CGeometry *geometry, CSolver **solver_con /*--- Retrieve solution at the boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Adjoint flow solution at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); - Psi_inlet[iVar] = 0.0;// node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); + Psi_inlet[iVar] = 0.0;// nodes->GetSolution(iPoint,iVar); } #ifdef CHECK @@ -4673,13 +4671,13 @@ void CAdjEulerSolver::BC_ActDisk_Outlet(CGeometry *geometry, CSolver **solver_co /*--- Retrieve solution at the boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Adjoint flow solution at the boundary ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Psi_domain[iVar] = node[iPoint]->GetSolution(iVar); - Psi_outlet[iVar] = 0.0; //node[iPoint]->GetSolution(iVar); + Psi_domain[iVar] = nodes->GetSolution(iPoint,iVar); + Psi_outlet[iVar] = 0.0; //nodes->GetSolution(iPoint,iVar); } #ifdef CHECK @@ -4692,7 +4690,7 @@ void CAdjEulerSolver::BC_ActDisk_Outlet(CGeometry *geometry, CSolver **solver_co Psi_outlet[0] = 0.0; for (iDim = 0; iDim < nDim; iDim++) - Psi_outlet[iDim+1] = node[Point_Normal]->GetSolution(iDim+1); + Psi_outlet[iDim+1] = nodes->GetSolution(Point_Normal,iDim+1); Psi_outlet[nDim+1] = 0.0; #endif @@ -4743,9 +4741,9 @@ void CAdjEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Solution at time n-1, n and n+1 ---*/ - U_time_nM1 = node[iPoint]->GetSolution_time_n1(); - U_time_n = node[iPoint]->GetSolution_time_n(); - U_time_nP1 = node[iPoint]->GetSolution(); + U_time_nM1 = nodes->GetSolution_time_n1(iPoint); + U_time_n = nodes->GetSolution_time_n(iPoint); + U_time_nP1 = nodes->GetSolution(iPoint); /*--- Volume at time n-1 and n ---*/ if (Grid_Movement) { @@ -4842,7 +4840,7 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf index = counter*Restart_Vars[1] + skipVars; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); iPoint_Global_Local++; /*--- Increment the overall counter for how many points have been loaded. ---*/ @@ -4881,12 +4879,12 @@ void CAdjEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver[iMesh-1][ADJFLOW_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver[iMesh-1][ADJFLOW_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver[iMesh][ADJFLOW_SOL]->node[iPoint]->SetSolution(Solution); + solver[iMesh][ADJFLOW_SOL]->GetNodes()->SetSolution(iPoint,Solution); } solver[iMesh][ADJFLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); solver[iMesh][ADJFLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); @@ -4948,8 +4946,6 @@ CAdjNSSolver::CAdjNSSolver(CGeometry *geometry, CConfig *config, unsigned short nVarGrad = nVar; - node = new CVariable*[nPoint]; - /*--- Define some auxiliary arrays related to the residual ---*/ Point_Max = new unsigned long[nVar]; for (iVar = 0; iVar < nVar; iVar++) Point_Max[iVar] = 0; @@ -5101,8 +5097,8 @@ CAdjNSSolver::CAdjNSSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Initialize the solution to the far-field state everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CAdjNSVariable(PsiRho_Inf, Phi_Inf, PsiE_Inf, nDim, nVar, config); + nodes = new CAdjNSVariable(PsiRho_Inf, Phi_Inf, PsiE_Inf, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); /*--- Read the restart metadata. ---*/ @@ -5233,7 +5229,7 @@ void CAdjNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container /*--- Set the primitive variables compressible adjoint variables ---*/ - physical = node[iPoint]->SetPrimVar(SharpEdge_Distance, false, config); + physical = nodes->SetPrimVar(iPoint,SharpEdge_Distance, false, config); /* Check for non-realizable states for reporting. */ @@ -5310,14 +5306,14 @@ void CAdjNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Primitive variables w/o reconstruction and adjoint variables w/o reconstruction---*/ - numerics->SetPrimitive(solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(), - solver_container[FLOW_SOL]->node[jPoint]->GetPrimitive()); + numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(jPoint)); - numerics->SetAdjointVar(node[iPoint]->GetSolution(), node[jPoint]->GetSolution()); + numerics->SetAdjointVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); /*--- Gradient and limiter of Adjoint Variables ---*/ - numerics->SetAdjointVarGradient(node[iPoint]->GetGradient(), node[jPoint]->GetGradient()); + numerics->SetAdjointVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(jPoint)); /*--- Compute residual ---*/ @@ -5354,13 +5350,13 @@ void CAdjNSSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Primitive variables w/o reconstruction, and its gradient ---*/ - numerics->SetPrimitive(solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(), NULL); + numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), NULL); - numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(), NULL); + numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint), NULL); /*--- Gradient of adjoint variables ---*/ - numerics->SetAdjointVarGradient(node[iPoint]->GetGradient(), NULL); + numerics->SetAdjointVarGradient(nodes->GetGradient(iPoint), NULL); /*--- Set volume ---*/ @@ -5372,15 +5368,15 @@ void CAdjNSSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Turbulent variables w/o reconstruction and its gradient ---*/ - numerics->SetTurbVar(solver_container[TURB_SOL]->node[iPoint]->GetSolution(), NULL); + numerics->SetTurbVar(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint), NULL); - numerics->SetTurbVarGradient(solver_container[TURB_SOL]->node[iPoint]->GetGradient(), NULL); + numerics->SetTurbVarGradient(solver_container[TURB_SOL]->GetNodes()->GetGradient(iPoint), NULL); /*--- Turbulent adjoint variables w/o reconstruction and its gradient ---*/ - numerics->SetTurbAdjointVar(solver_container[ADJTURB_SOL]->node[iPoint]->GetSolution(), NULL); + numerics->SetTurbAdjointVar(solver_container[ADJTURB_SOL]->GetNodes()->GetSolution(iPoint), NULL); - numerics->SetTurbAdjointGradient(solver_container[ADJTURB_SOL]->node[iPoint]->GetGradient(), NULL); + numerics->SetTurbAdjointGradient(solver_container[ADJTURB_SOL]->GetNodes()->GetGradient(iPoint), NULL); /*--- Set distance to the surface ---*/ @@ -5412,28 +5408,28 @@ void CAdjNSSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Conservative variables w/o reconstruction ---*/ - second_numerics->SetConservative(solver_container[FLOW_SOL]->node[iPoint]->GetSolution(), - solver_container[FLOW_SOL]->node[jPoint]->GetSolution()); + second_numerics->SetConservative(solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetSolution(jPoint)); /*--- Gradient of primitive variables w/o reconstruction ---*/ - second_numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(), - solver_container[FLOW_SOL]->node[jPoint]->GetGradient_Primitive()); + second_numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(jPoint)); /*--- Viscosity ---*/ - second_numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(), - solver_container[FLOW_SOL]->node[jPoint]->GetLaminarViscosity()); + second_numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint)); /*--- Turbulent variables w/o reconstruction ---*/ - second_numerics->SetTurbVar(solver_container[TURB_SOL]->node[iPoint]->GetSolution(), - solver_container[TURB_SOL]->node[jPoint]->GetSolution()); + second_numerics->SetTurbVar(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint), + solver_container[TURB_SOL]->GetNodes()->GetSolution(jPoint)); /*--- Turbulent adjoint variables w/o reconstruction ---*/ - second_numerics->SetTurbAdjointVar(solver_container[ADJTURB_SOL]->node[iPoint]->GetSolution(), - solver_container[ADJTURB_SOL]->node[jPoint]->GetSolution()); + second_numerics->SetTurbAdjointVar(solver_container[ADJTURB_SOL]->GetNodes()->GetSolution(iPoint), + solver_container[ADJTURB_SOL]->GetNodes()->GetSolution(jPoint)); /*--- Set distance to the surface ---*/ @@ -5459,8 +5455,8 @@ void CAdjNSSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the adjoint variables ---*/ - second_numerics->SetAdjointVar(node[iPoint]->GetSolution(), - node[iPoint]->GetSolution()); + second_numerics->SetAdjointVar(nodes->GetSolution(iPoint), + nodes->GetSolution(iPoint)); /*--- Load the volume of the dual mesh cell ---*/ second_numerics->SetVolume(geometry->node[iPoint]->GetVolume()); @@ -5576,10 +5572,10 @@ void CAdjNSSolver::Viscous_Sensitivity(CGeometry *geometry, CSolver **solver_con if (geometry->node[iPoint]->GetDomain()) { - PsiVar_Grad = node[iPoint]->GetGradient(); - PrimVar_Grad = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); + PsiVar_Grad = nodes->GetGradient(iPoint); + PrimVar_Grad = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); - Laminar_Viscosity = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); + Laminar_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); heat_flux_factor = Cp * Laminar_Viscosity / Prandtl_Lam; @@ -5647,16 +5643,16 @@ void CAdjNSSolver::Viscous_Sensitivity(CGeometry *geometry, CSolver **solver_con if (grid_movement) { - Psi = node[iPoint]->GetSolution(); - U = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + Psi = nodes->GetSolution(iPoint); + U = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); Density = U[0]; - Pressure = solver_container[FLOW_SOL]->node[iPoint]->GetPressure(); - Enthalpy = solver_container[FLOW_SOL]->node[iPoint]->GetEnthalpy(); + Pressure = solver_container[FLOW_SOL]->GetNodes()->GetPressure(iPoint); + Enthalpy = solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(iPoint); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - val_turb_ke = solver_container[TURB_SOL]->node[iPoint]->GetSolution(0); + val_turb_ke = solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); else val_turb_ke = 0.0; @@ -5805,8 +5801,8 @@ void CAdjNSSolver::Viscous_Sensitivity(CGeometry *geometry, CSolver **solver_con iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) { - Psi = node[iPoint]->GetSolution(); - U = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + Psi = nodes->GetSolution(iPoint); + U = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Mach_Inf = config->GetMach(); @@ -5961,12 +5957,12 @@ void CAdjNSSolver::Viscous_Sensitivity(CGeometry *geometry, CSolver **solver_con if (geometry->node[iPoint]->GetDomain()) { Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); - p = solver_container[FLOW_SOL]->node[iPoint]->GetPressure(); + p = solver_container[FLOW_SOL]->GetNodes()->GetPressure(iPoint); Mach_Inf = config->GetMach(); if (grid_movement) Mach_Inf = config->GetMach_Motion(); - d = node[iPoint]->GetForceProj_Vector(); + d = nodes->GetForceProj_Vector(iPoint); Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); for (iDim = 0; iDim < nDim; iDim++) UnitNormal[iDim] = -Normal[iDim]/Area; @@ -6073,7 +6069,7 @@ void CAdjNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_contai unsigned short iDim, iVar, jVar, jDim; unsigned long iVertex, iPoint, total_index, Point_Normal; - su2double *d, l1psi, vartheta, Sigma_5, **PsiVar_Grad, phi[3]; + su2double *d, l1psi, vartheta, Sigma_5, **PsiVar_Grad, phi[3] = {}; su2double sq_vel, ProjGridVel, Enthalpy = 0.0, *GridVel; su2double ViscDens, XiDens, Density, Pressure = 0.0, dPhiE_dn; su2double Laminar_Viscosity = 0.0, Eddy_Viscosity = 0.0; @@ -6129,11 +6125,11 @@ void CAdjNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_contai /*--- Retrieve adjoint solution at the wall boundary node ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi[iVar] = node[iPoint]->GetSolution(iVar); + Psi[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Get the force projection vector (based on the objective function) ---*/ - d = node[iPoint]->GetForceProj_Vector(); + d = nodes->GetForceProj_Vector(iPoint); /*--- Set the adjoint velocity BC ---*/ @@ -6152,11 +6148,11 @@ void CAdjNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_contai contribution to the residual at this node. ---*/ for (iDim = 0; iDim < nDim; iDim++) - node[iPoint]->SetSolution_Old(iDim+1, phi[iDim]); + nodes->SetSolution_Old(iPoint,iDim+1, phi[iDim]); for (iDim = 0; iDim < nDim; iDim++) LinSysRes.SetBlock_Zero(iPoint, iDim+1); - node[iPoint]->SetVel_ResTruncError_Zero(); + nodes->SetVel_ResTruncError_Zero(iPoint); /*--- Compute additional contributions to the adjoint density and energy equations which will be added to the residual (weak imposition) ---*/ @@ -6181,11 +6177,11 @@ void CAdjNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_contai /*--- Get some additional quantities from the flow solution ---*/ - Density = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - Pressure = solver_container[FLOW_SOL]->node[iPoint]->GetPressure(); - Enthalpy = solver_container[FLOW_SOL]->node[iPoint]->GetEnthalpy(); - Laminar_Viscosity = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); - Eddy_Viscosity = solver_container[FLOW_SOL]->node[iPoint]->GetEddyViscosity(); // Should be zero at the wall + Density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + Pressure = solver_container[FLOW_SOL]->GetNodes()->GetPressure(iPoint); + Enthalpy = solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(iPoint); + Laminar_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + Eddy_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); // Should be zero at the wall ViscDens = (Laminar_Viscosity + Eddy_Viscosity) / Density; XiDens = Gamma * (Laminar_Viscosity/Prandtl_Lam + Eddy_Viscosity/Prandtl_Turb) / Density; @@ -6220,7 +6216,7 @@ void CAdjNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_contai /*--- Store the adjoint velocity and energy gradients for clarity ---*/ - PsiVar_Grad = node[iPoint]->GetGradient(); + PsiVar_Grad = nodes->GetGradient(iPoint); for (iDim = 0; iDim < nDim; iDim++) { GradPsiE[iDim] = PsiVar_Grad[nVar-1][iDim]; for (jDim = 0; jDim < nDim; jDim++) @@ -6509,7 +6505,7 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont /*--- Retrieve adjoint solution at the wall boundary node ---*/ for (iVar = 0; iVar < nVar; iVar++) - Psi[iVar] = node[iPoint]->GetSolution(iVar); + Psi[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Normal vector for this vertex (negate for outward convention) ---*/ geometry->vertex[val_marker][iVertex]->GetNormal(Normal); @@ -6517,7 +6513,7 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont for (iDim = 0; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim]; /*--- Get the force projection vector (based on the objective function) ---*/ - d = node[iPoint]->GetForceProj_Vector(); + d = nodes->GetForceProj_Vector(iPoint); /*--- Adjustments to strong boundary condition for dynamic meshes ---*/ if ( grid_movement) { @@ -6534,9 +6530,9 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont /*--- Strong BC imposition for the adjoint velocity equations ---*/ for (iDim = 0; iDim < nDim; iDim++) LinSysRes.SetBlock_Zero(iPoint, iDim+1); - node[iPoint]->SetVel_ResTruncError_Zero(); + nodes->SetVel_ResTruncError_Zero(iPoint); for (iDim = 0; iDim < nDim; iDim++) - node[iPoint]->SetSolution_Old(iDim+1, phi[iDim]); + nodes->SetSolution_Old(iPoint,iDim+1, phi[iDim]); if (implicit) { for (iVar = 1; iVar <= nDim; iVar++) { total_index = iPoint*nVar+iVar; @@ -6545,12 +6541,12 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont } /*--- Get transport coefficient information ---*/ - Laminar_Viscosity = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); - Eddy_Viscosity = solver_container[FLOW_SOL]->node[iPoint]->GetEddyViscosity(); + Laminar_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + Eddy_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); Thermal_Conductivity = Cp * ( Laminar_Viscosity/Prandtl_Lam +Eddy_Viscosity/Prandtl_Turb); -// GradV = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); +// GradV = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); /*--- Calculate Dirichlet condition for energy equation ---*/ if (!heat_flux_obj) { @@ -6563,7 +6559,7 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont Area = sqrt(Area); /*--- Temperature gradient term ---*/ - GradT = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive()[0]; + GradT = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint)[0]; kGTdotn = 0.0; for (iDim = 0; iDim < nDim; iDim++) kGTdotn += Cp * Laminar_Viscosity/Prandtl_Lam*GradT[iDim]*Normal[iDim]/Area; @@ -6578,8 +6574,8 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont /*--- Strong BC enforcement of the energy equation ---*/ LinSysRes.SetBlock_Zero(iPoint, nVar-1); - node[iPoint]->SetEnergy_ResTruncError_Zero(); - node[iPoint]->SetSolution_Old(nDim+1, q); + nodes->SetEnergy_ResTruncError_Zero(iPoint); + nodes->SetSolution_Old(iPoint,nDim+1, q); if (implicit) { iVar = nDim+1; total_index = iPoint*nVar+iVar; @@ -6589,13 +6585,13 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont /*--- Additional contributions to adjoint density (weak imposition) ---*/ /*--- Acquire gradient information ---*/ - PsiVar_Grad = node[iPoint]->GetGradient(); - GradP = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive()[nVar-1]; - GradDens = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive()[nVar]; + PsiVar_Grad = nodes->GetGradient(iPoint); + GradP = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint)[nVar-1]; + GradDens = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint)[nVar]; /*--- Acqure flow information ---*/ - rho = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - pressure = solver_container[FLOW_SOL]->node[iPoint]->GetPressure(); + rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + pressure = solver_container[FLOW_SOL]->GetNodes()->GetPressure(iPoint); invrho3 = (1.0/rho)*(1.0/rho)*(1.0/rho); /*--- Calculate supporting quantities ---*/ @@ -6615,7 +6611,7 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont Res_Visc_i[0] = -mu2*Gamma/(rho*Gamma_Minus_One)*(pressure/rho)*gpsi5n; /*--- Components of the effective and adjoint stress tensors ---*/ - PsiVar_Grad = node[iPoint]->GetGradient(); + PsiVar_Grad = nodes->GetGradient(iPoint); div_phi = 0; for (iDim = 0; iDim < nDim; iDim++) { div_phi += PsiVar_Grad[iDim+1][iDim]; @@ -6632,16 +6628,16 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont force_stress += Normal[iDim]*Tau[iDim][jDim]*d[jDim]; /*--- \partial \mu_dyn \partial T ---*/ - // mu_dyn = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); - // Temp = solver_container[FLOW_SOL]->node[iPoint]->GetTemperature(); + // mu_dyn = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + // Temp = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint); dVisc_T = 0.0; // dVisc_T = mu_dyn*(Temp+3.0*mu2)/(2.0*Temp*(Temp+mu2)); /*--- \Sigma_5 Check Area computation for Res_Conv[0] ---*/ Sigma_5 = (Gamma/Cp)*dVisc_T*force_stress; /*--- Imposition of residuals ---*/ - rho = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - pressure = solver_container[FLOW_SOL]->node[iPoint]->GetPressure(); + rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + pressure = solver_container[FLOW_SOL]->GetNodes()->GetPressure(iPoint); Res_Conv_i[0] = pressure*Sigma_5/(Gamma_Minus_One*rho*rho); /*--- Flux contribution and Jacobian contributions for moving @@ -6653,7 +6649,7 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont GridVel = geometry->node[iPoint]->GetGridVel(); /*--- Get the enthalpy from the direct solution ---*/ - Enthalpy = solver_container[FLOW_SOL]->node[iPoint]->GetEnthalpy(); + Enthalpy = solver_container[FLOW_SOL]->GetNodes()->GetEnthalpy(iPoint); /*--- Compute projections, velocity squared divided by two, and other inner products. Note that we are imposing v = u_wall from @@ -6683,9 +6679,9 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont /*--- Viscous flux contributions at the wall node ---*/ - U = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); - Laminar_Viscosity = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); - Eddy_Viscosity = solver_container[FLOW_SOL]->node[iPoint]->GetEddyViscosity(); // Should be zero at the wall + U = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); + Laminar_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + Eddy_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint); // Should be zero at the wall Density = U[0]; for (iDim = 0; iDim < nDim; iDim++) { Velocity[iDim] = GridVel[iDim]; @@ -6697,7 +6693,7 @@ void CAdjNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont XiDens = Gamma * (Laminar_Viscosity/Prandtl_Lam + Eddy_Viscosity/Prandtl_Turb) / Density; /*--- Average of the derivatives of the adjoint variables ---*/ - PsiVar_Grad = node[iPoint]->GetGradient(); + PsiVar_Grad = nodes->GetGradient(iPoint); for (iDim = 0; iDim < nDim; iDim++) { GradPsiE[iDim] = PsiVar_Grad[nVar-1][iDim]; diff --git a/SU2_CFD/src/solver_adjoint_turbulent.cpp b/SU2_CFD/src/solver_adjoint_turbulent.cpp index 5a60b454adb0..f6f8bdcc6bbd 100644 --- a/SU2_CFD/src/solver_adjoint_turbulent.cpp +++ b/SU2_CFD/src/solver_adjoint_turbulent.cpp @@ -41,9 +41,11 @@ CAdjTurbSolver::CAdjTurbSolver(void) : CSolver() {} CAdjTurbSolver::CAdjTurbSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CSolver() { - unsigned long iPoint; + unsigned short iDim, iVar, nLineLets; + adjoint = true; + nDim = geometry->GetnDim(); Gamma = config->GetGamma(); Gamma_Minus_One = Gamma - 1.0; @@ -122,16 +124,12 @@ CAdjTurbSolver::CAdjTurbSolver(CGeometry *geometry, CConfig *config, unsigned sh } /*--- Far-Field values and initizalization ---*/ - node = new CVariable* [nPoint]; bool restart = config->GetRestart(); - - if (!restart || (iMesh != MESH_0)) { - PsiNu_Inf = 0.0; - for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint] = new CAdjTurbVariable(PsiNu_Inf, nDim, nVar, config); - } - } - else { + + nodes = new CAdjTurbVariable(0.0, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); + + if (restart && (iMesh == MESH_0)) { unsigned long index; su2double dull_val; string filename, AdjExt, text_line; @@ -171,7 +169,8 @@ CAdjTurbSolver::CAdjTurbSolver(CGeometry *geometry, CConfig *config, unsigned sh if (nDim == 2) point_line >> index >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> Solution[0]; if (nDim == 3) point_line >> index >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> Solution[0]; - node[iPoint_Local] = new CAdjTurbVariable(Solution[0], nDim, nVar, config); + nodes->SetSolution(iPoint_Local,0,Solution[0]); + nodes->SetSolution_Old(iPoint_Local,0,Solution[0]); iPoint_Global_Local++; } @@ -191,16 +190,8 @@ CAdjTurbSolver::CAdjTurbSolver(CGeometry *geometry, CConfig *config, unsigned sh string("It could be empty lines at the end of the file."), CURRENT_FUNCTION); } - /*--- Instantiate the variable class with an arbitrary solution - at any halo/periodic nodes. The initial solution can be arbitrary, - because a send/recv is performed immediately in the solver. ---*/ - for (iPoint = nPointDomain; iPoint < nPoint; iPoint++) { - node[iPoint] = new CAdjTurbVariable(Solution[0], nDim, nVar, config); - } - /*--- Close the restart file ---*/ restart_file.close(); - } /*--- MPI solution ---*/ @@ -211,6 +202,7 @@ CAdjTurbSolver::CAdjTurbSolver(CGeometry *geometry, CConfig *config, unsigned sh } CAdjTurbSolver::~CAdjTurbSolver(void) { + if (nodes != nullptr) delete nodes; } void CAdjTurbSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { @@ -226,7 +218,7 @@ void CAdjTurbSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont Solution[0] = 0.0; /*--- Set the solution values and zero the residual ---*/ - node[iPoint]->SetSolution_Old(Solution); + nodes->SetSolution_Old(iPoint,Solution); LinSysRes.SetBlock_Zero(iPoint); /*--- Change rows of the Jacobian (includes 1 in the diagonal) ---*/ @@ -250,7 +242,7 @@ void CAdjTurbSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_co Solution[0] = 0.0; /*--- Set the solution values and zero the residual ---*/ - node[iPoint]->SetSolution_Old(Solution); + nodes->SetSolution_Old(iPoint,Solution); LinSysRes.SetBlock_Zero(iPoint); /*--- Change rows of the Jacobian (includes 1 in the diagonal) ---*/ @@ -272,11 +264,11 @@ void CAdjTurbSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_containe conv_numerics->SetNormal(geometry->vertex[val_marker][iVertex]->GetNormal()); /*--- Set Conservative variables (for convection) ---*/ - su2double* U_i = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + su2double* U_i = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); conv_numerics->SetConservative(U_i, NULL); /*--- Turbulent adjoint variables w/o reconstruction ---*/ - su2double* TurbPsi_i = node[iPoint]->GetSolution(); + su2double* TurbPsi_i = nodes->GetSolution(iPoint); conv_numerics->SetTurbAdjointVar(TurbPsi_i, NULL); /*--- Add Residuals and Jacobians ---*/ @@ -324,21 +316,21 @@ void CAdjTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta jPoint = geometry->edge[iEdge]->GetNode(1); /*--- Conservative variables w/o reconstruction ---*/ - U_i = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); - U_j = solver_container[FLOW_SOL]->node[jPoint]->GetSolution(); + U_i = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); + U_j = solver_container[FLOW_SOL]->GetNodes()->GetSolution(jPoint); numerics->SetConservative(U_i, U_j); /*--- Set normal vectors and length ---*/ numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); /*--- Turbulent adjoint variables w/o reconstruction ---*/ - TurbPsi_i = node[iPoint]->GetSolution(); - TurbPsi_j = node[jPoint]->GetSolution(); + TurbPsi_i = nodes->GetSolution(iPoint); + TurbPsi_j = nodes->GetSolution(jPoint); numerics->SetTurbAdjointVar(TurbPsi_i, TurbPsi_j); /*--- Gradient of turbulent variables w/o reconstruction ---*/ - TurbVar_Grad_i = solver_container[TURB_SOL]->node[iPoint]->GetGradient(); - TurbVar_Grad_j = solver_container[TURB_SOL]->node[jPoint]->GetGradient(); + TurbVar_Grad_i = solver_container[TURB_SOL]->GetNodes()->GetGradient(iPoint); + TurbVar_Grad_j = solver_container[TURB_SOL]->GetNodes()->GetGradient(jPoint); numerics->SetTurbVarGradient(TurbVar_Grad_i, TurbVar_Grad_j); /*--- Set normal vectors and length ---*/ @@ -377,16 +369,16 @@ void CAdjTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Conservative variables w/o reconstruction, turbulent variables w/o reconstruction, and turbulent adjoint variables w/o reconstruction ---*/ - numerics->SetConservative(solver_container[FLOW_SOL]->node[iPoint]->GetSolution(), solver_container[FLOW_SOL]->node[jPoint]->GetSolution()); - numerics->SetTurbVar(solver_container[TURB_SOL]->node[iPoint]->GetSolution(), solver_container[TURB_SOL]->node[jPoint]->GetSolution()); - numerics->SetTurbAdjointVar(node[iPoint]->GetSolution(), node[jPoint]->GetSolution()); + numerics->SetConservative(solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint), solver_container[FLOW_SOL]->GetNodes()->GetSolution(jPoint)); + numerics->SetTurbVar(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint), solver_container[TURB_SOL]->GetNodes()->GetSolution(jPoint)); + numerics->SetTurbAdjointVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); /*--- Viscosity ---*/ - numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(), - solver_container[FLOW_SOL]->node[jPoint]->GetLaminarViscosity()); + numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint)); /*--- Turbulent adjoint variables w/o reconstruction ---*/ - numerics->SetTurbAdjointGradient(node[iPoint]->GetGradient(), node[jPoint]->GetGradient()); + numerics->SetTurbAdjointGradient(nodes->GetGradient(iPoint), nodes->GetGradient(jPoint)); /*--- Compute residual in a non-conservative way, and update ---*/ numerics->ComputeResidual(Residual_i, Residual_j, Jacobian_ii, Jacobian_ij, Jacobian_ji, Jacobian_jj, config); @@ -413,31 +405,31 @@ void CAdjTurbSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Conservative variables w/o reconstruction ---*/ - U_i = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + U_i = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); numerics->SetConservative(U_i, NULL); /*--- Gradient of primitive variables w/o reconstruction ---*/ - GradPrimVar_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); + GradPrimVar_i = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); numerics->SetPrimVarGradient(GradPrimVar_i, NULL); /*--- Laminar viscosity of the fluid ---*/ - numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(), 0.0); + numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint), 0.0); /*--- Turbulent variables w/o reconstruction ---*/ - TurbVar_i = solver_container[TURB_SOL]->node[iPoint]->GetSolution(); + TurbVar_i = solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint); numerics->SetTurbVar(TurbVar_i, NULL); /*--- Gradient of Turbulent Variables w/o reconstruction ---*/ - TurbVar_Grad_i = solver_container[TURB_SOL]->node[iPoint]->GetGradient(); + TurbVar_Grad_i = solver_container[TURB_SOL]->GetNodes()->GetGradient(iPoint); numerics->SetTurbVarGradient(TurbVar_Grad_i, NULL); /*--- Turbulent adjoint variables w/o reconstruction ---*/ - TurbPsi_i = node[iPoint]->GetSolution(); + TurbPsi_i = nodes->GetSolution(iPoint); numerics->SetTurbAdjointVar(TurbPsi_i, NULL); /*--- Gradient of Adjoint flow variables w/o reconstruction (for non-conservative terms depending on gradients of flow adjoint vars.) ---*/ - PsiVar_Grad_i = solver_container[ADJFLOW_SOL]->node[iPoint]->GetGradient(); + PsiVar_Grad_i = solver_container[ADJFLOW_SOL]->GetNodes()->GetGradient(iPoint); numerics->SetAdjointVarGradient(PsiVar_Grad_i, NULL); /*--- Set volume and distances to the surface ---*/ @@ -462,13 +454,13 @@ void CAdjTurbSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta // jPoint = geometry->edge[iEdge]->GetNode(1); // // /*--- Gradient of turbulent variables w/o reconstruction ---*/ -// TurbVar_Grad_i = solver_container[TURB_SOL]->node[iPoint]->GetGradient(); -// TurbVar_Grad_j = solver_container[TURB_SOL]->node[jPoint]->GetGradient(); +// TurbVar_Grad_i = solver_container[TURB_SOL]->GetNodes()->GetGradient(iPoint); +// TurbVar_Grad_j = solver_container[TURB_SOL]->GetNodes()->GetGradient(jPoint); // second_numerics->SetTurbVarGradient(TurbVar_Grad_i, TurbVar_Grad_j); // // /*--- Turbulent adjoint variables w/o reconstruction ---*/ -// TurbPsi_i = node[iPoint]->GetSolution(); -// TurbPsi_j = node[jPoint]->GetSolution(); +// TurbPsi_i = nodes->GetSolution(iPoint); +// TurbPsi_j = nodes->GetSolution(jPoint); // second_numerics->SetTurbAdjointVar(TurbPsi_i, TurbPsi_j); // // /*--- Set normal vectors and length ---*/ @@ -510,7 +502,7 @@ void CAdjTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - Delta = Vol / (config->GetCFLRedCoeff_AdjTurb()*solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time()); + Delta = Vol / (config->GetCFLRedCoeff_AdjTurb()*solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint)); Jacobian.AddVal2Diag(iPoint, Delta); @@ -544,7 +536,7 @@ void CAdjTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv for (iPoint = 0; iPoint < nPointDomain; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->AddSolution(iVar, LinSysSol[iPoint*nVar+iVar]); + nodes->AddSolution(iPoint,iVar, LinSysSol[iPoint*nVar+iVar]); } /*--- MPI solution ---*/ diff --git a/SU2_CFD/src/solver_direct_elasticity.cpp b/SU2_CFD/src/solver_direct_elasticity.cpp index 28113e871a44..c51f66082091 100644 --- a/SU2_CFD/src/solver_direct_elasticity.cpp +++ b/SU2_CFD/src/solver_direct_elasticity.cpp @@ -36,9 +36,7 @@ */ #include "../include/solver_structure.hpp" -#include "../include/variables/CFEAFSIBoundVariable.hpp" #include "../include/variables/CFEABoundVariable.hpp" -#include "../include/variables/CFEAVariable.hpp" #include "../../Common/include/toolboxes/printing_toolbox.hpp" #include @@ -64,7 +62,7 @@ CFEASolver::CFEASolver(bool mesh_deform_mode) : CSolver(mesh_deform_mode) { for (iTerm = 0; iTerm < MAX_TERMS; iTerm++) element_container[iTerm] = new CElement* [MAX_FE_KINDS](); - node = NULL; + nodes = nullptr; element_properties = NULL; elProperties = NULL; @@ -111,15 +109,17 @@ CFEASolver::CFEASolver(CGeometry *geometry, CConfig *config) : CSolver() { unsigned short iVar, jVar, iDim, jDim; unsigned short iTerm; - bool dynamic = (config->GetTime_Domain()); // Dynamic simulations. - bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); // Nonlinear analysis. - bool gen_alpha = (config->GetKind_TimeIntScheme_FEA() == GENERALIZED_ALPHA); // Generalized alpha method requires residual at previous time step. - - bool de_effects = config->GetDE_Effects(); // Test whether we consider dielectric elastomers - - bool body_forces = config->GetDeadLoad(); // Body forces (dead loads). - - element_based = false; // A priori we don't have an element-based input file (most of the applications will be like this) + bool dynamic = (config->GetTime_Domain()); + bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); + /*--- Generalized alpha method requires residual at previous time step. ---*/ + bool gen_alpha = (config->GetKind_TimeIntScheme_FEA() == GENERALIZED_ALPHA); + /*--- Test whether we consider dielectric elastomers ---*/ + bool de_effects = config->GetDE_Effects(); + bool body_forces = config->GetDeadLoad(); + + /*--- A priori we don't have an element-based input file (most of the applications will be like this) ---*/ + element_based = false; + topol_filter_applied = false; nElement = geometry->GetnElem(); @@ -169,8 +169,6 @@ CFEASolver::CFEASolver(CGeometry *geometry, CConfig *config) : CSolver() { } - node = new CVariable*[nPoint]; - /*--- Set element properties ---*/ elProperties = new unsigned long[4]; for (iVar = 0; iVar < 4; iVar++) @@ -230,28 +228,26 @@ CFEASolver::CFEASolver(CGeometry *geometry, CConfig *config) : CSolver() { else nSolVar = nVar; SolRest = new su2double[nSolVar]; + for (iVar = 0; iVar < nSolVar; iVar++) SolRest[iVar] = 0.0; - /*--- Initialize from zero everywhere. ---*/ - long iVertex; - bool isVertex, isInterface; + /*--- Initialize from zero everywhere ---*/ - for (iVar = 0; iVar < nSolVar; iVar++) SolRest[iVar] = 0.0; - for (iPoint = 0; iPoint < nPoint; iPoint++) { - isVertex = false; - isInterface = false; + nodes = new CFEABoundVariable(SolRest, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); + + /*--- Set which points are vertices and allocate boundary data. ---*/ + + for (iPoint = 0; iPoint < nPoint; iPoint++) for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - iVertex = geometry->node[iPoint]->GetVertex(iMarker); - if (iVertex != -1){ - isVertex = true; - if (config->GetMarker_All_Fluid_Load(iMarker) == YES) {isInterface = true;} + long iVertex = geometry->node[iPoint]->GetVertex(iMarker); + if (iVertex >= 0) { + nodes->Set_isVertex(iPoint,true); break; } } - if (isVertex && isInterface) node[iPoint] = new CFEAFSIBoundVariable(SolRest, nDim, nVar, config); - else if (isVertex && !isInterface) node[iPoint] = new CFEABoundVariable(SolRest, nDim, nVar, config); - else node[iPoint] = new CFEAVariable(SolRest, nDim, nVar, config); - } - + static_cast(nodes)->AllocateBoundaryVariables(config); + + bool reference_geometry = config->GetRefGeom(); if (reference_geometry) Set_ReferenceGeometry(geometry, config); @@ -523,6 +519,7 @@ CFEASolver::~CFEASolver(void) { if (Res_FSI_Cont != NULL) delete [] Res_FSI_Cont; + if (nodes != nullptr) delete nodes; } void CFEASolver::Set_ElementProperties(CGeometry *geometry, CConfig *config) { @@ -730,7 +727,7 @@ void CFEASolver::Set_Prestretch(CGeometry *geometry, CConfig *config) { if (nDim == 2) point_line >> Solution[0] >> Solution[1] >> index; if (nDim == 3) point_line >> Solution[0] >> Solution[1] >> Solution[2] >> index; - for (iVar = 0; iVar < nVar; iVar++) node[iPoint_Local]->SetPrestretch(iVar, Solution[iVar]); + for (iVar = 0; iVar < nVar; iVar++) nodes->SetPrestretch(iPoint_Local,iVar, Solution[iVar]); iPoint_Global_Local++; } @@ -790,7 +787,7 @@ void CFEASolver::Set_Prestretch(CGeometry *geometry, CConfig *config) { for (iVertex = 0; iVertex < nVertexS; iVertex++) { iPoint = geometry->vertex[MarkerS][iVertex]->GetNode(); for (iVar = 0; iVar < nVar; iVar++) - Buffer_Send_U[iVar*nVertexS+iVertex] = node[iPoint]->GetPrestretch(iVar); + Buffer_Send_U[iVar*nVertexS+iVertex] = nodes->GetPrestretch(iPoint,iVar); } #ifdef HAVE_MPI @@ -824,7 +821,7 @@ void CFEASolver::Set_Prestretch(CGeometry *geometry, CConfig *config) { /*--- Store received values back into the variable. ---*/ for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->SetPrestretch(iVar, SolRest[iVar]); + nodes->SetPrestretch(iPoint,iVar, SolRest[iVar]); } @@ -915,7 +912,7 @@ void CFEASolver::Set_ReferenceGeometry(CGeometry *geometry, CConfig *config) { Solution[2] = PrintingToolbox::stod(point_line[6]); } - for (iVar = 0; iVar < nVar; iVar++) node[iPoint_Local]->SetReference_Geometry(iVar, Solution[iVar]); + for (iVar = 0; iVar < nVar; iVar++) nodes->SetReference_Geometry(iPoint_Local,iVar, Solution[iVar]); iPoint_Global_Local++; } @@ -970,7 +967,7 @@ void CFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, bool body_forces = config->GetDeadLoad(); // Body forces (dead loads). - bool fsi = (config->GetnMarker_Fluid_Load() > 0); + bool fsi = config->GetFSI_Simulation(); bool consistent_interpolation = (!config->GetConservativeInterpolation() || (config->GetKindInterpolation() == WEIGHTED_AVERAGE)); @@ -1045,7 +1042,7 @@ void CFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, (body_forces && restart && initial_calc_restart && first_iter)) { // If the load is incremental, we have to reset the variable to avoid adding up over the increments if (incremental_load) { - for (iPoint = 0; iPoint < nPoint; iPoint++) node[iPoint]->Clear_BodyForces_Res(); + for (iPoint = 0; iPoint < nPoint; iPoint++) nodes->Clear_BodyForces_Res(iPoint); } // Compute the dead load term Compute_DeadLoad(geometry, numerics, config); @@ -1066,7 +1063,7 @@ void CFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, * Some external forces may be considered constant over the time step. */ if (first_iter) { - for (iPoint = 0; iPoint < nPoint; iPoint++) node[iPoint]->Clear_SurfaceLoad_Res(); + for (iPoint = 0; iPoint < nPoint; iPoint++) nodes->Clear_SurfaceLoad_Res(iPoint); } /* @@ -1085,7 +1082,7 @@ void CFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve the point ID ---*/ iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); /*--- Clear the residual of the node, to avoid adding on previous values ---*/ - node[iPoint]->Clear_SurfaceLoad_Res(); + nodes->Clear_SurfaceLoad_Res(iPoint); } } break; @@ -1095,7 +1092,7 @@ void CFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve the point ID ---*/ iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); /*--- Clear the residual of the node, to avoid adding on previous values ---*/ - node[iPoint]->Clear_SurfaceLoad_Res(); + nodes->Clear_SurfaceLoad_Res(iPoint); } break; } @@ -1111,34 +1108,19 @@ void CFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, void CFEASolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) { } void CFEASolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) { - - unsigned long iPoint, nPoint; - bool incremental_load = config->GetIncrementalLoad(); // If an incremental load is applied - - nPoint = geometry[MESH_0]->GetnPoint(); - + /*--- We store the current solution as "Solution Old", for the case that we need to retrieve it ---*/ - - if (incremental_load) { - for (iPoint = 0; iPoint < nPoint; iPoint++) node[iPoint]->Set_OldSolution(); - } - - + + if (config->GetIncrementalLoad()) nodes->Set_OldSolution(); + } void CFEASolver::ResetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) { - - unsigned long iPoint, nPoint; - bool incremental_load = config->GetIncrementalLoad(); // If an incremental load is applied - - nPoint = geometry[MESH_0]->GetnPoint(); - + /*--- We store the current solution as "Solution Old", for the case that we need to retrieve it ---*/ - - if (incremental_load) { - for (iPoint = 0; iPoint < nPoint; iPoint++) node[iPoint]->Set_Solution(); - } - + + if (config->GetIncrementalLoad()) nodes->Set_Solution(); + } void CFEASolver::Compute_StiffMatrix(CGeometry *geometry, CNumerics **numerics, CConfig *config) { @@ -1175,7 +1157,7 @@ void CFEASolver::Compute_StiffMatrix(CGeometry *geometry, CNumerics **numerics, for (iDim = 0; iDim < nDim; iDim++) { val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim); - val_Sol = node[indexNode[iNode]]->GetSolution(iDim) + val_Coord; + val_Sol = nodes->GetSolution(indexNode[iNode],iDim) + val_Coord; element_container[FEA_TERM][EL_KIND]->SetRef_Coord(val_Coord, iNode, iDim); element_container[FEA_TERM][EL_KIND]->SetCurr_Coord(val_Sol, iNode, iDim); } @@ -1269,7 +1251,7 @@ void CFEASolver::Compute_StiffMatrix_NodalStressRes(CGeometry *geometry, CNumeri indexNode[iNode] = geometry->elem[iElem]->GetNode(iNode); for (iDim = 0; iDim < nDim; iDim++) { val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim); - val_Sol = node[indexNode[iNode]]->GetSolution(iDim) + val_Coord; + val_Sol = nodes->GetSolution(indexNode[iNode],iDim) + val_Coord; /*--- Set current coordinate ---*/ element_container[FEA_TERM][EL_KIND]->SetCurr_Coord(val_Sol, iNode, iDim); @@ -1277,7 +1259,7 @@ void CFEASolver::Compute_StiffMatrix_NodalStressRes(CGeometry *geometry, CNumeri /*--- Set reference coordinate ---*/ if (prestretch_fem) { - val_Ref = node[indexNode[iNode]]->GetPrestretch(iDim); + val_Ref = nodes->GetPrestretch(indexNode[iNode],iDim); element_container[FEA_TERM][EL_KIND]->SetRef_Coord(val_Ref, iNode, iDim); if (de_effects) element_container[DE_TERM][EL_KIND]->SetRef_Coord(val_Ref, iNode, iDim); } @@ -1541,10 +1523,10 @@ void CFEASolver::Compute_NodalStressRes(CGeometry *geometry, CNumerics **numeric indexNode[iNode] = geometry->elem[iElem]->GetNode(iNode); for (iDim = 0; iDim < nDim; iDim++) { val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim); - val_Sol = node[indexNode[iNode]]->GetSolution(iDim) + val_Coord; + val_Sol = nodes->GetSolution(indexNode[iNode],iDim) + val_Coord; element_container[FEA_TERM][EL_KIND]->SetCurr_Coord(val_Sol, iNode, iDim); if (prestretch_fem) { - val_Ref = node[indexNode[iNode]]->GetPrestretch(iDim); + val_Ref = nodes->GetPrestretch(indexNode[iNode],iDim); element_container[FEA_TERM][EL_KIND]->SetRef_Coord(val_Ref, iNode, iDim); } else { @@ -1612,7 +1594,7 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, for (iPoint = 0; iPoint < nPointDomain; iPoint++) { for (iStress = 0; iStress < nStress; iStress++) { - node[iPoint]->SetStress_FEM(iStress, 0.0); + nodes->SetStress_FEM(iPoint,iStress, 0.0); } } @@ -1633,16 +1615,16 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, indexNode[iNode] = geometry->elem[iElem]->GetNode(iNode); // for (iDim = 0; iDim < nDim; iDim++) { // val_Coord = geometry->node[indexNode[iNode]]->GetCoord(iDim); - // val_Sol = node[indexNode[iNode]]->GetSolution(iDim) + val_Coord; + // val_Sol = nodes->GetSolution(indexNode[iNode],iDim) + val_Coord; // element_container[FEA_TERM][EL_KIND]->SetRef_Coord(val_Coord, iNode, iDim); // element_container[FEA_TERM][EL_KIND]->SetCurr_Coord(val_Sol, iNode, iDim); // } for (iDim = 0; iDim < nDim; iDim++) { val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim); - val_Sol = node[indexNode[iNode]]->GetSolution(iDim) + val_Coord; + val_Sol = nodes->GetSolution(indexNode[iNode],iDim) + val_Coord; element_container[FEA_TERM][EL_KIND]->SetCurr_Coord(val_Sol, iNode, iDim); if (prestretch_fem) { - val_Ref = node[indexNode[iNode]]->GetPrestretch(iDim); + val_Ref = nodes->GetPrestretch(indexNode[iNode],iDim); element_container[FEA_TERM][EL_KIND]->SetRef_Coord(val_Ref, iNode, iDim); } else { @@ -1679,7 +1661,7 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, LinSysReact.AddBlock(indexNode[iNode], Res_Stress_i); for (iStress = 0; iStress < nStress; iStress++) { - node[indexNode[iNode]]->AddStress_FEM(iStress, simp_penalty * + nodes->AddStress_FEM(indexNode[iNode],iStress, simp_penalty * (element_container[FEA_TERM][EL_KIND]->Get_NodalStress(iNode, iStress) / geometry->node[indexNode[iNode]]->GetnElem()) ); } @@ -1697,7 +1679,7 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, /*--- Get the stresses, added up from all the elements that connect to the node ---*/ - Stress = node[iPoint]->GetStress_FEM(); + Stress = nodes->GetStress_FEM(iPoint); /*--- Compute the stress averaged from all the elements connecting to the node and the Von Mises stress ---*/ @@ -1731,7 +1713,7 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, } - node[iPoint]->SetVonMises_Stress(VonMises_Stress); + nodes->SetVonMises_Stress(iPoint,VonMises_Stress); /*--- Compute the maximum value of the Von Mises Stress ---*/ @@ -1812,10 +1794,10 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, /*--- Loop over all points, and set aux vector TimeRes_Aux = a0*U+a2*U'+a3*U'' ---*/ for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - Residual[iVar] = a_dt[0]*node[iPoint]->GetSolution_time_n(iVar) //a0*U(t) - - a_dt[0]*node[iPoint]->GetSolution(iVar) //a0*U(t+dt)(k-1) - + a_dt[2]*node[iPoint]->GetSolution_Vel_time_n(iVar) //a2*U'(t) - + a_dt[3]*node[iPoint]->GetSolution_Accel_time_n(iVar); //a3*U''(t) + Residual[iVar] = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) //a0*U(t) + - a_dt[0]*nodes->GetSolution(iPoint,iVar) //a0*U(t+dt)(k-1) + + a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) //a2*U'(t) + + a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); //a3*U''(t) } TimeRes_Aux.SetBlock(iPoint, Residual); } @@ -1926,7 +1908,7 @@ void CFEASolver::Compute_DeadLoad(CGeometry *geometry, CNumerics **numerics, CCo Dead_Load = element_container[FEA_TERM][EL_KIND]->Get_FDL_a(iNode); for (iVar = 0; iVar < nVar; iVar++) Res_Dead_Load[iVar] = simp_penalty*Dead_Load[iVar]; - node[indexNode[iNode]]->Add_BodyForces_Res(Res_Dead_Load); + nodes->Add_BodyForces_Res(indexNode[iNode],Res_Dead_Load); } @@ -2007,18 +1989,18 @@ void CFEASolver::BC_Clamped(CGeometry *geometry, CNumerics *numerics, CConfig *c iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); /*--- Set and enforce solution at current and previous time-step ---*/ - node[iPoint]->SetSolution(Solution); + nodes->SetSolution(iPoint,Solution); if (dynamic) { - node[iPoint]->SetSolution_Vel(Solution); - node[iPoint]->SetSolution_Accel(Solution); - node[iPoint]->Set_Solution_time_n(Solution); - node[iPoint]->SetSolution_Vel_time_n(Solution); - node[iPoint]->SetSolution_Accel_time_n(Solution); + nodes->SetSolution_Vel(iPoint,Solution); + nodes->SetSolution_Accel(iPoint,Solution); + nodes->Set_Solution_time_n(iPoint,Solution); + nodes->SetSolution_Vel_time_n(iPoint,Solution); + nodes->SetSolution_Accel_time_n(iPoint,Solution); } /*--- Set and enforce 0 solution for mesh deformation ---*/ - node[iPoint]->SetBound_Disp(Solution); + nodes->SetBound_Disp(iPoint,Solution); LinSysSol.SetBlock(iPoint, Solution); LinSysReact.SetBlock(iPoint, Solution); @@ -2046,11 +2028,11 @@ void CFEASolver::BC_Clamped_Post(CGeometry *geometry, CNumerics *numerics, CConf Solution[0] = 0.0; Solution[1] = 0.0; Solution[2] = 0.0; } - node[iPoint]->SetSolution(Solution); + nodes->SetSolution(iPoint,Solution); if (dynamic) { - node[iPoint]->SetSolution_Vel(Solution); - node[iPoint]->SetSolution_Accel(Solution); + nodes->SetSolution_Vel(iPoint,Solution); + nodes->SetSolution_Accel(iPoint,Solution); } } @@ -2142,7 +2124,7 @@ void CFEASolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); // Nonlinear analysis. bool disc_adj_fem = (config->GetKind_Solver() == DISC_ADJ_FEM); - + if (disc_adj_fem) { if (nonlinear_analysis) { @@ -2211,7 +2193,6 @@ void CFEASolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, else { if (nonlinear_analysis){ - /*--- MPI solution ---*/ InitiateComms(geometry, config, SOLUTION_FEA); @@ -2331,7 +2312,7 @@ void CFEASolver::BC_Normal_Load(CGeometry *geometry, CNumerics *numerics, CConfi indexNode[iNode] = geometry->bound[val_marker][iElem]->GetNode(iNode); for (iDim = 0; iDim < nDim; iDim++) { val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim); - val_Sol = node[indexNode[iNode]]->GetSolution(iDim) + val_Coord; + val_Sol = nodes->GetSolution(indexNode[iNode],iDim) + val_Coord; /*--- Assign values to the container ---*/ nodeCoord_ref[iNode][iDim] = val_Coord; nodeCoord_curr[iNode][iDim] = val_Sol; @@ -2398,15 +2379,15 @@ void CFEASolver::BC_Normal_Load(CGeometry *geometry, CNumerics *numerics, CConfi Residual[0] = (1.0/2.0) * TotalLoad * Length_Elem_ref * normal_ref_unit[0]; Residual[1] = (1.0/2.0) * TotalLoad * Length_Elem_ref * normal_ref_unit[1]; - node[indexNode[0]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[1]]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(indexNode[0],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[1],Residual); } else if (nonlinear_analysis) { Residual[0] = (1.0/2.0) * TotalLoad * Length_Elem_curr * normal_curr_unit[0]; Residual[1] = (1.0/2.0) * TotalLoad * Length_Elem_curr * normal_curr_unit[1]; - node[indexNode[0]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[1]]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(indexNode[0],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[1],Residual); } } @@ -2468,18 +2449,18 @@ void CFEASolver::BC_Normal_Load(CGeometry *geometry, CNumerics *numerics, CConfi Residual[1] = (1.0/3.0) * TotalLoad * Area_Elem_ref * normal_ref_unit[1]; Residual[2] = (1.0/3.0) * TotalLoad * Area_Elem_ref * normal_ref_unit[2]; - node[indexNode[0]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[1]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[2]]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(indexNode[0],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[1],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[2],Residual); } else if (nonlinear_analysis) { Residual[0] = (1.0/3.0) * TotalLoad * Area_Elem_curr * normal_curr_unit[0]; Residual[1] = (1.0/3.0) * TotalLoad * Area_Elem_curr * normal_curr_unit[1]; Residual[2] = (1.0/3.0) * TotalLoad * Area_Elem_curr * normal_curr_unit[2]; - node[indexNode[0]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[1]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[2]]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(indexNode[0],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[1],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[2],Residual); } } @@ -2539,20 +2520,20 @@ void CFEASolver::BC_Normal_Load(CGeometry *geometry, CNumerics *numerics, CConfi Residual[1] = (1.0/4.0) * TotalLoad * Area_Elem_ref * normal_ref_unit[1]; Residual[2] = (1.0/4.0) * TotalLoad * Area_Elem_ref * normal_ref_unit[2]; - node[indexNode[0]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[1]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[2]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[3]]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(indexNode[0],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[1],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[2],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[3],Residual); } else if (nonlinear_analysis) { Residual[0] = (1.0/4.0) * TotalLoad * Area_Elem_curr * normal_curr_unit[0]; Residual[1] = (1.0/4.0) * TotalLoad * Area_Elem_curr * normal_curr_unit[1]; Residual[2] = (1.0/4.0) * TotalLoad * Area_Elem_curr * normal_curr_unit[2]; - node[indexNode[0]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[1]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[2]]->Add_SurfaceLoad_Res(Residual); - node[indexNode[3]]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(indexNode[0],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[1],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[2],Residual); + nodes->Add_SurfaceLoad_Res(indexNode[3],Residual); } } @@ -2659,8 +2640,8 @@ void CFEASolver::BC_Dir_Load(CGeometry *geometry, CNumerics *numerics, CConfig * Residual[0] = (1.0/2.0)*Length_Elem*TotalLoad*Load_Dir_Local[0]/Norm; Residual[1] = (1.0/2.0)*Length_Elem*TotalLoad*Load_Dir_Local[1]/Norm; - node[Point_0]->Add_SurfaceLoad_Res(Residual); - node[Point_1]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(Point_0,Residual); + nodes->Add_SurfaceLoad_Res(Point_1,Residual); } @@ -2671,9 +2652,9 @@ void CFEASolver::BC_Dir_Load(CGeometry *geometry, CNumerics *numerics, CConfig * Residual[1] = (1.0/3.0)*Area_Elem*TotalLoad*Load_Dir_Local[1]/Norm; Residual[2] = (1.0/3.0)*Area_Elem*TotalLoad*Load_Dir_Local[2]/Norm; - node[Point_0]->Add_SurfaceLoad_Res(Residual); - node[Point_1]->Add_SurfaceLoad_Res(Residual); - node[Point_2]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(Point_0,Residual); + nodes->Add_SurfaceLoad_Res(Point_1,Residual); + nodes->Add_SurfaceLoad_Res(Point_2,Residual); } else if (geometry->bound[val_marker][iElem]->GetVTK_Type() == QUADRILATERAL) { @@ -2682,10 +2663,10 @@ void CFEASolver::BC_Dir_Load(CGeometry *geometry, CNumerics *numerics, CConfig * Residual[1] = (1.0/4.0)*Area_Elem*TotalLoad*Load_Dir_Local[1]/Norm; Residual[2] = (1.0/4.0)*Area_Elem*TotalLoad*Load_Dir_Local[2]/Norm; - node[Point_0]->Add_SurfaceLoad_Res(Residual); - node[Point_1]->Add_SurfaceLoad_Res(Residual); - node[Point_2]->Add_SurfaceLoad_Res(Residual); - node[Point_3]->Add_SurfaceLoad_Res(Residual); + nodes->Add_SurfaceLoad_Res(Point_0,Residual); + nodes->Add_SurfaceLoad_Res(Point_1,Residual); + nodes->Add_SurfaceLoad_Res(Point_2,Residual); + nodes->Add_SurfaceLoad_Res(Point_3,Residual); } @@ -2717,11 +2698,11 @@ void CFEASolver::BC_Damper(CGeometry *geometry, CNumerics *numerics, CConfig *co for (iVar = 0; iVar < nVar; iVar++){ - dampValue = - 1.0 * dampC * node[Point_0]->GetSolution_Vel(iVar); - node[Point_0]->Set_SurfaceLoad_Res(iVar, dampValue); + dampValue = - 1.0 * dampC * nodes->GetSolution_Vel(Point_0,iVar); + nodes->Set_SurfaceLoad_Res(Point_0,iVar, dampValue); - dampValue = - 1.0 * dampC * node[Point_1]->GetSolution_Vel(iVar); - node[Point_1]->Set_SurfaceLoad_Res(iVar, dampValue); + dampValue = - 1.0 * dampC * nodes->GetSolution_Vel(Point_1,iVar); + nodes->Set_SurfaceLoad_Res(Point_1,iVar, dampValue); } if (nDim == 3) { @@ -2729,15 +2710,15 @@ void CFEASolver::BC_Damper(CGeometry *geometry, CNumerics *numerics, CConfig *co Point_2 = geometry->bound[val_marker][iElem]->GetNode(2); for (iVar = 0; iVar < nVar; iVar++){ - dampValue = - 1.0 * dampC * node[Point_2]->GetSolution_Vel(iVar); - node[Point_2]->Set_SurfaceLoad_Res(iVar, dampValue); + dampValue = - 1.0 * dampC * nodes->GetSolution_Vel(Point_2,iVar); + nodes->Set_SurfaceLoad_Res(Point_2,iVar, dampValue); } if (geometry->bound[val_marker][iElem]->GetVTK_Type() == QUADRILATERAL) { Point_3 = geometry->bound[val_marker][iElem]->GetNode(3); for (iVar = 0; iVar < nVar; iVar++){ - dampValue = - 1.0 * dampC * node[Point_3]->GetSolution_Vel(iVar); - node[Point_3]->Set_SurfaceLoad_Res(iVar, dampValue); + dampValue = - 1.0 * dampC * nodes->GetSolution_Vel(Point_3,iVar); + nodes->Set_SurfaceLoad_Res(Point_3,iVar, dampValue); } } @@ -2759,7 +2740,7 @@ void CFEASolver::BC_Deforming(CGeometry *geometry, CNumerics *numerics, CConfig iNode = geometry->vertex[val_marker][iVertex]->GetNode(); /*--- Retrieve the boundary displacement ---*/ - for (iDim = 0; iDim < nDim; iDim++) Solution[iDim] = node[iNode]->GetBound_Disp(iDim); + for (iDim = 0; iDim < nDim; iDim++) Solution[iDim] = nodes->GetBound_Disp(iNode,iDim); /*--- Set and enforce solution ---*/ LinSysSol.SetBlock(iNode, Solution); @@ -2794,16 +2775,16 @@ void CFEASolver::Integrate_FSI_Loads(CGeometry *geometry, CConfig *config) { for (iElem = 0; iElem < nElem; ++iElem) { /*--- Define the boundary element ---*/ - unsigned long nodes[4]; + unsigned long nodeList[4]; su2double coords[4][3]; bool quad = geometry->bound[iMarker][iElem]->GetVTK_Type() == QUADRILATERAL; nNode = quad? 4 : nDim; for (iNode = 0; iNode < nNode; ++iNode) { - nodes[iNode] = geometry->bound[iMarker][iElem]->GetNode(iNode); + nodeList[iNode] = geometry->bound[iMarker][iElem]->GetNode(iNode); for (iDim = 0; iDim < nDim; ++iDim) - coords[iNode][iDim] = geometry->node[nodes[iNode]]->GetCoord(iDim)+ - node[nodes[iNode]]->GetSolution(iDim); + coords[iNode][iDim] = geometry->node[nodeList[iNode]]->GetCoord(iDim)+ + nodes->GetSolution(nodeList[iNode],iDim); } /*--- Compute the area ---*/ @@ -2843,7 +2824,7 @@ void CFEASolver::Integrate_FSI_Loads(CGeometry *geometry, CConfig *config) { for (iNode = 0; iNode < nNode; ++iNode) for (iDim = 0; iDim < nDim; ++iDim) - force[iDim] += weight*area*node[nodes[iNode]]->Get_FlowTraction(iDim); + force[iDim] += weight*area*nodes->Get_FlowTraction(nodeList[iNode],iDim); for (iDim = 0; iDim < nDim; ++iDim) forces.push_back(force[iDim]); } @@ -2851,8 +2832,7 @@ void CFEASolver::Integrate_FSI_Loads(CGeometry *geometry, CConfig *config) { /*--- 2nd pass to set values. This is to account for overlap in the markers. ---*/ /*--- By putting the integrated values back into the nodes no changes have to be made elsewhere. ---*/ - for (iPoint = 0; iPoint < geometry->GetnPoint(); ++iPoint) - node[iPoint]->Clear_FlowTraction(); + nodes->Clear_FlowTraction(); vector::iterator force_it = forces.begin(); @@ -2876,7 +2856,7 @@ void CFEASolver::Integrate_FSI_Loads(CGeometry *geometry, CConfig *config) { for (iNode = 0; iNode < nNode; ++iNode) { iPoint = geometry->bound[iMarker][iElem]->GetNode(iNode); - node[iPoint]->Add_FlowTraction(force); + nodes->Add_FlowTraction(iPoint,force); } } } @@ -2913,7 +2893,7 @@ void CFEASolver::Integrate_FSI_Loads(CGeometry *geometry, CConfig *config) { halo_point_loc.push_back(iPoint); halo_point_glb.push_back(geometry->node[iPoint]->GetGlobalIndex()); for (iDim = 0; iDim < nDim; ++iDim) - halo_force.push_back(node[iPoint]->Get_FlowTraction(iDim)); + halo_force.push_back(nodes->Get_FlowTraction(iPoint,iDim)); } } } @@ -2946,7 +2926,7 @@ void CFEASolver::Integrate_FSI_Loads(CGeometry *geometry, CConfig *config) { ptrdiff_t pos = find(halo_point_glb.begin(),halo_point_glb.end(),iPoint_glb)-halo_point_glb.begin(); if (pos < long(halo_point_glb.size())) { unsigned long iPoint_loc = halo_point_loc[pos]; - node[iPoint_loc]->Add_FlowTraction(&halo_force_all[(offset+iPoint)*nDim]); + nodes->Add_FlowTraction(iPoint_loc,&halo_force_all[(offset+iPoint)*nDim]); } } } @@ -2970,7 +2950,7 @@ su2double CFEASolver::Compute_LoadCoefficient(su2double CurrentTime, su2double R su2double TransferTime = 1.0; bool restart = config->GetRestart(); // Restart analysis - bool fsi = (config->GetnMarker_Fluid_Load() > 0); // FSI simulation. + bool fsi = config->GetFSI_Simulation(); bool stat_fsi = !config->GetTime_Domain(); /*--- This offset introduces the ramp load in dynamic cases starting from the restart point. ---*/ @@ -3050,9 +3030,8 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver bool linear_analysis = (config->GetGeometricConditions() == SMALL_DEFORMATIONS); // Linear analysis. bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); // Nonlinear analysis. bool newton_raphson = (config->GetKind_SpaceIteScheme_FEA() == NEWTON_RAPHSON); // Newton-Raphson method - bool body_forces = config->GetDeadLoad(); // Body forces (dead loads). - + bool incremental_load = config->GetIncrementalLoad(); if (!dynamic) { @@ -3062,16 +3041,14 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver /*--- (the terms that are constant over the time step) ---*/ if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_Ext_Surf[iVar] = loadIncrement * node[iPoint]->Get_SurfaceLoad_Res(iVar); + Res_Ext_Surf[iVar] = loadIncrement * nodes->Get_SurfaceLoad_Res(iPoint,iVar); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_Ext_Surf[iVar] = node[iPoint]->Get_SurfaceLoad_Res(iVar); + Res_Ext_Surf[iVar] = nodes->Get_SurfaceLoad_Res(iPoint,iVar); } - //Res_Ext_Surf = node[iPoint]->Get_SurfaceLoad_Res(); } - LinSysRes.AddBlock(iPoint, Res_Ext_Surf); /*--- Add the contribution to the residual due to body forces ---*/ @@ -3079,32 +3056,31 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver if (body_forces) { if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_Dead_Load[iVar] = loadIncrement * node[iPoint]->Get_BodyForces_Res(iVar); + Res_Dead_Load[iVar] = loadIncrement * nodes->Get_BodyForces_Res(iPoint,iVar); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_Dead_Load[iVar] = node[iPoint]->Get_BodyForces_Res(iVar); + Res_Dead_Load[iVar] = nodes->Get_BodyForces_Res(iPoint,iVar); } } - LinSysRes.AddBlock(iPoint, Res_Dead_Load); } /*--- Add the contribution to the residual due to flow loads (FSI contribution) ---*/ - if (incremental_load){ - for (iVar = 0; iVar < nVar; iVar++){ - Res_FSI_Cont[iVar] = loadIncrement * node[iPoint]->Get_FlowTraction(iVar); - } + + if (incremental_load) { + for (iVar = 0; iVar < nVar; iVar++) + Res_FSI_Cont[iVar] = loadIncrement * nodes->Get_FlowTraction(iPoint,iVar); } else { - for (iVar = 0; iVar < nVar; iVar++){ - Res_FSI_Cont[iVar] = node[iPoint]->Get_FlowTraction(iVar); - } + for (iVar = 0; iVar < nVar; iVar++) + Res_FSI_Cont[iVar] = nodes->Get_FlowTraction(iPoint,iVar); } LinSysRes.AddBlock(iPoint, Res_FSI_Cont); + } - + } if (dynamic) { @@ -3138,10 +3114,10 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - Residual[iVar] = a_dt[0]*node[iPoint]->GetSolution_time_n(iVar) //a0*U(t) - - a_dt[0]*node[iPoint]->GetSolution(iVar) //a0*U(t+dt)(k-1) - + a_dt[2]*node[iPoint]->GetSolution_Vel_time_n(iVar) //a2*U'(t) - + a_dt[3]*node[iPoint]->GetSolution_Accel_time_n(iVar); //a3*U''(t) + Residual[iVar] = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) //a0*U(t) + - a_dt[0]*nodes->GetSolution(iPoint,iVar) //a0*U(t+dt)(k-1) + + a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) //a2*U'(t) + + a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); //a3*U''(t) } TimeRes_Aux.SetBlock(iPoint, Residual); } @@ -3161,14 +3137,14 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver /*--- External surface load contribution ---*/ if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_Ext_Surf[iVar] = loadIncrement * node[iPoint]->Get_SurfaceLoad_Res(iVar); + Res_Ext_Surf[iVar] = loadIncrement * nodes->Get_SurfaceLoad_Res(iPoint,iVar); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_Ext_Surf[iVar] = node[iPoint]->Get_SurfaceLoad_Res(iVar); + Res_Ext_Surf[iVar] = nodes->Get_SurfaceLoad_Res(iPoint,iVar); } - //Res_Ext_Surf = node[iPoint]->Get_SurfaceLoad_Res(); + //Res_Ext_Surf = nodes->Get_SurfaceLoad_Res(iPoint); } LinSysRes.AddBlock(iPoint, Res_Ext_Surf); @@ -3178,34 +3154,36 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CSolver **solver if (body_forces) { if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_Dead_Load[iVar] = loadIncrement * node[iPoint]->Get_BodyForces_Res(iVar); + Res_Dead_Load[iVar] = loadIncrement * nodes->Get_BodyForces_Res(iPoint,iVar); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_Dead_Load[iVar] = node[iPoint]->Get_BodyForces_Res(iVar); + Res_Dead_Load[iVar] = nodes->Get_BodyForces_Res(iPoint,iVar); } } - LinSysRes.AddBlock(iPoint, Res_Dead_Load); } - + + /*--- FSI contribution (flow loads) ---*/ + if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_FSI_Cont[iVar] = loadIncrement * node[iPoint]->Get_FlowTraction(iVar); + Res_FSI_Cont[iVar] = loadIncrement * nodes->Get_FlowTraction(iPoint,iVar); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_FSI_Cont[iVar] = node[iPoint]->Get_FlowTraction(iVar); + Res_FSI_Cont[iVar] = nodes->Get_FlowTraction(iPoint,iVar); } } LinSysRes.AddBlock(iPoint, Res_FSI_Cont); + } + } - - + } void CFEASolver::ImplicitNewmark_Update(CGeometry *geometry, CSolver **solver_container, CConfig *config) { @@ -3223,7 +3201,7 @@ void CFEASolver::ImplicitNewmark_Update(CGeometry *geometry, CSolver **solver_co /*--- Displacements component of the solution ---*/ - node[iPoint]->Add_DeltaSolution(iVar, LinSysSol[iPoint*nVar+iVar]); + nodes->Add_DeltaSolution(iPoint,iVar, LinSysSol[iPoint*nVar+iVar]); } @@ -3238,30 +3216,30 @@ void CFEASolver::ImplicitNewmark_Update(CGeometry *geometry, CSolver **solver_co /*--- Acceleration component of the solution ---*/ /*--- U''(t+dt) = a0*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ - Solution[iVar]=a_dt[0]*(node[iPoint]->GetSolution(iVar) - - node[iPoint]->GetSolution_time_n(iVar)) - - a_dt[2]* node[iPoint]->GetSolution_Vel_time_n(iVar) - - a_dt[3]* node[iPoint]->GetSolution_Accel_time_n(iVar); + Solution[iVar]=a_dt[0]*(nodes->GetSolution(iPoint,iVar) - + nodes->GetSolution_time_n(iPoint,iVar)) - + a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - + a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); } /*--- Set the acceleration in the node structure ---*/ - node[iPoint]->SetSolution_Accel(Solution); + nodes->SetSolution_Accel(iPoint,Solution); for (iVar = 0; iVar < nVar; iVar++) { /*--- Velocity component of the solution ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - Solution[iVar]=node[iPoint]->GetSolution_Vel_time_n(iVar)+ - a_dt[6]* node[iPoint]->GetSolution_Accel_time_n(iVar) + - a_dt[7]* node[iPoint]->GetSolution_Accel(iVar); + Solution[iVar]=nodes->GetSolution_Vel_time_n(iPoint,iVar)+ + a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + + a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); } /*--- Set the velocity in the node structure ---*/ - node[iPoint]->SetSolution_Vel(Solution); + nodes->SetSolution_Vel(iPoint,Solution); } @@ -3285,9 +3263,9 @@ void CFEASolver::ImplicitNewmark_Relaxation(CGeometry *geometry, CSolver **solve for (iPoint=0; iPoint < nPointDomain; iPoint++) { - valSolutionPred = node[iPoint]->GetSolution_Pred(); + valSolutionPred = nodes->GetSolution_Pred(iPoint); - node[iPoint]->SetSolution(valSolutionPred); + nodes->SetSolution(iPoint,valSolutionPred); } if (dynamic){ @@ -3301,30 +3279,30 @@ void CFEASolver::ImplicitNewmark_Relaxation(CGeometry *geometry, CSolver **solve /*--- Acceleration component of the solution ---*/ /*--- U''(t+dt) = a0*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ - Solution[iVar]=a_dt[0]*(node[iPoint]->GetSolution(iVar) - - node[iPoint]->GetSolution_time_n(iVar)) - - a_dt[2]* node[iPoint]->GetSolution_Vel_time_n(iVar) - - a_dt[3]* node[iPoint]->GetSolution_Accel_time_n(iVar); + Solution[iVar]=a_dt[0]*(nodes->GetSolution(iPoint,iVar) - + nodes->GetSolution_time_n(iPoint,iVar)) - + a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - + a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); } /*--- Set the acceleration in the node structure ---*/ - node[iPoint]->SetSolution_Accel(Solution); + nodes->SetSolution_Accel(iPoint,Solution); for (iVar = 0; iVar < nVar; iVar++) { /*--- Velocity component of the solution ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - Solution[iVar]=node[iPoint]->GetSolution_Vel_time_n(iVar)+ - a_dt[6]* node[iPoint]->GetSolution_Accel_time_n(iVar) + - a_dt[7]* node[iPoint]->GetSolution_Accel(iVar); + Solution[iVar]=nodes->GetSolution_Vel_time_n(iPoint,iVar)+ + a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + + a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); } /*--- Set the velocity in the node structure ---*/ - node[iPoint]->SetSolution_Vel(Solution); + nodes->SetSolution_Vel(iPoint,Solution); } @@ -3340,7 +3318,7 @@ void CFEASolver::ImplicitNewmark_Relaxation(CGeometry *geometry, CSolver **solve for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->SetSolution_Pred_Old(iVar,node[iPoint]->GetSolution(iVar)); + nodes->SetSolution_Pred_Old(iPoint,iVar,nodes->GetSolution(iPoint,iVar)); } } @@ -3358,7 +3336,6 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve bool linear_analysis = (config->GetGeometricConditions() == SMALL_DEFORMATIONS); // Linear analysis. bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); // Nonlinear analysis. bool newton_raphson = (config->GetKind_SpaceIteScheme_FEA() == NEWTON_RAPHSON); // Newton-Raphson method - bool body_forces = config->GetDeadLoad(); // Body forces (dead loads). su2double alpha_f = config->Get_Int_Coeffs(2); @@ -3372,14 +3349,14 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve /*--- (the terms that are constant over the time step) ---*/ if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_Ext_Surf[iVar] = loadIncrement * node[iPoint]->Get_SurfaceLoad_Res(iVar); + Res_Ext_Surf[iVar] = loadIncrement * nodes->Get_SurfaceLoad_Res(iPoint,iVar); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_Ext_Surf[iVar] = node[iPoint]->Get_SurfaceLoad_Res(iVar); + Res_Ext_Surf[iVar] = nodes->Get_SurfaceLoad_Res(iPoint,iVar); } - //Res_Ext_Surf = node[iPoint]->Get_SurfaceLoad_Res(); + //Res_Ext_Surf = nodes->Get_SurfaceLoad_Res(iPoint); } LinSysRes.AddBlock(iPoint, Res_Ext_Surf); @@ -3389,12 +3366,12 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve if (body_forces) { if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_Dead_Load[iVar] = loadIncrement * node[iPoint]->Get_BodyForces_Res(iVar); + Res_Dead_Load[iVar] = loadIncrement * nodes->Get_BodyForces_Res(iPoint,iVar); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_Dead_Load[iVar] = node[iPoint]->Get_BodyForces_Res(iVar); + Res_Dead_Load[iVar] = nodes->Get_BodyForces_Res(iPoint,iVar); } } @@ -3436,10 +3413,10 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - Residual[iVar] = a_dt[0]*node[iPoint]->GetSolution_time_n(iVar) //a0*U(t) - - a_dt[0]*node[iPoint]->GetSolution(iVar) //a0*U(t+dt)(k-1) - + a_dt[2]*node[iPoint]->GetSolution_Vel_time_n(iVar) //a2*U'(t) - + a_dt[3]*node[iPoint]->GetSolution_Accel_time_n(iVar); //a3*U''(t) + Residual[iVar] = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) //a0*U(t) + - a_dt[0]*nodes->GetSolution(iPoint,iVar) //a0*U(t+dt)(k-1) + + a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) //a2*U'(t) + + a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); //a3*U''(t) } TimeRes_Aux.SetBlock(iPoint, Residual); } @@ -3457,14 +3434,14 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve /*--- External surface load contribution ---*/ if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_Ext_Surf[iVar] = loadIncrement * ( (1 - alpha_f) * node[iPoint]->Get_SurfaceLoad_Res(iVar) + - alpha_f * node[iPoint]->Get_SurfaceLoad_Res_n(iVar) ); + Res_Ext_Surf[iVar] = loadIncrement * ( (1 - alpha_f) * nodes->Get_SurfaceLoad_Res(iPoint,iVar) + + alpha_f * nodes->Get_SurfaceLoad_Res_n(iPoint,iVar) ); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_Ext_Surf[iVar] = (1 - alpha_f) * node[iPoint]->Get_SurfaceLoad_Res(iVar) + - alpha_f * node[iPoint]->Get_SurfaceLoad_Res_n(iVar); + Res_Ext_Surf[iVar] = (1 - alpha_f) * nodes->Get_SurfaceLoad_Res(iPoint,iVar) + + alpha_f * nodes->Get_SurfaceLoad_Res_n(iPoint,iVar); } } LinSysRes.AddBlock(iPoint, Res_Ext_Surf); @@ -3475,12 +3452,12 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve if (body_forces) { if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_Dead_Load[iVar] = loadIncrement * node[iPoint]->Get_BodyForces_Res(iVar); + Res_Dead_Load[iVar] = loadIncrement * nodes->Get_BodyForces_Res(iPoint,iVar); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_Dead_Load[iVar] = node[iPoint]->Get_BodyForces_Res(iVar); + Res_Dead_Load[iVar] = nodes->Get_BodyForces_Res(iPoint,iVar); } } @@ -3488,22 +3465,25 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CSolver **solve } /*--- Add FSI contribution ---*/ + if (incremental_load) { for (iVar = 0; iVar < nVar; iVar++) { - Res_FSI_Cont[iVar] = loadIncrement * ( (1 - alpha_f) * node[iPoint]->Get_FlowTraction(iVar) + - alpha_f * node[iPoint]->Get_FlowTraction_n(iVar) ); + Res_FSI_Cont[iVar] = loadIncrement * ( (1 - alpha_f) * nodes->Get_FlowTraction(iPoint,iVar) + + alpha_f * nodes->Get_FlowTraction_n(iPoint,iVar) ); } } else { for (iVar = 0; iVar < nVar; iVar++) { - Res_FSI_Cont[iVar] = (1 - alpha_f) * node[iPoint]->Get_FlowTraction(iVar) + - alpha_f * node[iPoint]->Get_FlowTraction_n(iVar); + Res_FSI_Cont[iVar] = (1 - alpha_f) * nodes->Get_FlowTraction(iPoint,iVar) + + alpha_f * nodes->Get_FlowTraction_n(iPoint,iVar); } } LinSysRes.AddBlock(iPoint, Res_FSI_Cont); + } + } - + } void CFEASolver::GeneralizedAlpha_UpdateDisp(CGeometry *geometry, CSolver **solver_container, CConfig *config) { @@ -3519,7 +3499,7 @@ void CFEASolver::GeneralizedAlpha_UpdateDisp(CGeometry *geometry, CSolver **solv /*--- Displacements component of the solution ---*/ - node[iPoint]->Add_DeltaSolution(iVar, LinSysSol[iPoint*nVar+iVar]); + nodes->Add_DeltaSolution(iPoint,iVar, LinSysSol[iPoint*nVar+iVar]); } @@ -3548,50 +3528,50 @@ void CFEASolver::GeneralizedAlpha_UpdateSolution(CGeometry *geometry, CSolver ** /*--- Compute the solution from the previous time step and the solution computed at t+1-alpha_f ---*/ /*--- U(t+dt) = 1/alpha_f*(U(t+1-alpha_f)-alpha_f*U(t)) ---*/ - Solution[iVar]=(1 / (1 - alpha_f))*(node[iPoint]->GetSolution(iVar) - - alpha_f * node[iPoint]->GetSolution_time_n(iVar)); + Solution[iVar]=(1 / (1 - alpha_f))*(nodes->GetSolution(iPoint,iVar) - + alpha_f * nodes->GetSolution_time_n(iPoint,iVar)); } /*--- Set the solution in the node structure ---*/ - node[iPoint]->SetSolution(Solution); + nodes->SetSolution(iPoint,Solution); for (iVar = 0; iVar < nVar; iVar++) { /*--- Acceleration component of the solution ---*/ /*--- U''(t+dt-alpha_m) = a8*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ - Solution_Interm[iVar]=a_dt[8]*( node[iPoint]->GetSolution(iVar) - - node[iPoint]->GetSolution_time_n(iVar)) - - a_dt[2]* node[iPoint]->GetSolution_Vel_time_n(iVar) - - a_dt[3]* node[iPoint]->GetSolution_Accel_time_n(iVar); + Solution_Interm[iVar]=a_dt[8]*( nodes->GetSolution(iPoint,iVar) - + nodes->GetSolution_time_n(iPoint,iVar)) - + a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - + a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); /*--- Compute the solution from the previous time step and the solution computed at t+1-alpha_f ---*/ /*--- U''(t+dt) = 1/alpha_m*(U''(t+1-alpha_m)-alpha_m*U''(t)) ---*/ - Solution[iVar]=(1 / (1 - alpha_m))*(Solution_Interm[iVar] - alpha_m * node[iPoint]->GetSolution_Accel_time_n(iVar)); + Solution[iVar]=(1 / (1 - alpha_m))*(Solution_Interm[iVar] - alpha_m * nodes->GetSolution_Accel_time_n(iPoint,iVar)); } /*--- Set the acceleration in the node structure ---*/ - node[iPoint]->SetSolution_Accel(Solution); + nodes->SetSolution_Accel(iPoint,Solution); for (iVar = 0; iVar < nVar; iVar++) { /*--- Velocity component of the solution ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - Solution[iVar]=node[iPoint]->GetSolution_Vel_time_n(iVar)+ - a_dt[6]* node[iPoint]->GetSolution_Accel_time_n(iVar) + - a_dt[7]* node[iPoint]->GetSolution_Accel(iVar); + Solution[iVar]=nodes->GetSolution_Vel_time_n(iPoint,iVar)+ + a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + + a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); } /*--- Set the velocity in the node structure ---*/ - node[iPoint]->SetSolution_Vel(Solution); + nodes->SetSolution_Vel(iPoint,Solution); } @@ -3603,15 +3583,11 @@ void CFEASolver::GeneralizedAlpha_UpdateSolution(CGeometry *geometry, CSolver ** } void CFEASolver::GeneralizedAlpha_UpdateLoads(CGeometry *geometry, CSolver **solver_container, CConfig *config) { - - unsigned long iPoint; - + /*--- Set the load conditions of the time step n+1 as the load conditions for time step n ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->Set_SurfaceLoad_Res_n(); - node[iPoint]->Set_FlowTraction_n(); - } - + nodes->Set_SurfaceLoad_Res_n(); + nodes->Set_FlowTraction_n(); + } void CFEASolver::Solve_System(CGeometry *geometry, CConfig *config) { @@ -3654,12 +3630,12 @@ void CFEASolver::PredictStruct_Displacement(CGeometry **fea_geometry, //To nPointDomain: we need to communicate the predicted solution after setting it for (iPoint=0; iPoint < nPointDomain; iPoint++) { - if (predOrder==0) fea_solution[MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Pred(); + if (predOrder==0) fea_solution[MESH_0][FEA_SOL]->GetNodes()->SetSolution_Pred(iPoint); else if (predOrder==1) { - solDisp = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution(); - solVel = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Vel(); - valPred = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Pred(); + solDisp = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution(iPoint); + solVel = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Vel(iPoint); + valPred = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Pred(iPoint); for (iDim=0; iDim < nDim; iDim++) { valPred[iDim] = solDisp[iDim] + Delta_t*solVel[iDim]; @@ -3668,10 +3644,10 @@ void CFEASolver::PredictStruct_Displacement(CGeometry **fea_geometry, } else if (predOrder==2) { - solDisp = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution(); - solVel = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Vel(); - solVel_tn = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Vel_time_n(); - valPred = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Pred(); + solDisp = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution(iPoint); + solVel = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Vel(iPoint); + solVel_tn = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Vel_time_n(iPoint); + valPred = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Pred(iPoint); for (iDim=0; iDim < nDim; iDim++) { valPred[iDim] = solDisp[iDim] + 0.5*Delta_t*(3*solVel[iDim]-solVel_tn[iDim]); @@ -3680,7 +3656,7 @@ void CFEASolver::PredictStruct_Displacement(CGeometry **fea_geometry, } else { cout<< "Higher order predictor not implemented. Solving with order 0." << endl; - fea_solution[MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Pred(); + fea_solution[MESH_0][FEA_SOL]->GetNodes()->SetSolution_Pred(iPoint); } } @@ -3740,10 +3716,10 @@ void CFEASolver::ComputeAitken_Coefficient(CGeometry **fea_geometry, CConfig *fe // To nPointDomain; we need to communicate the values for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - dispPred = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Pred(); - dispPred_Old = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Pred_Old(); - dispCalc = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution(); - dispCalc_Old = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Old(); + dispPred = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Pred(iPoint); + dispPred_Old = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Pred_Old(iPoint); + dispCalc = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution(iPoint); + dispCalc_Old = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Old(iPoint); for (iDim = 0; iDim < nDim; iDim++) { @@ -3819,14 +3795,14 @@ void CFEASolver::SetAitken_Relaxation(CGeometry **fea_geometry, for (iPoint=0; iPoint < nPointDomain; iPoint++) { /*--- Retrieve pointers to the predicted and calculated solutions ---*/ - dispPred = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Pred(); - dispCalc = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution(); + dispPred = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Pred(iPoint); + dispCalc = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution(iPoint); /*--- Set predicted solution as the old predicted solution ---*/ - fea_solution[MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Pred_Old(); + fea_solution[MESH_0][FEA_SOL]->GetNodes()->SetSolution_Pred_Old(iPoint); /*--- Set calculated solution as the old solution (needed for dynamic Aitken relaxation) ---*/ - fea_solution[MESH_0][FEA_SOL]->node[iPoint]->SetSolution_Old(dispCalc); + fea_solution[MESH_0][FEA_SOL]->GetNodes()->SetSolution_Old(iPoint, dispCalc); /*--- Apply the Aitken relaxation ---*/ for (iDim=0; iDim < nDim; iDim++) { @@ -3846,9 +3822,9 @@ void CFEASolver::Update_StructSolution(CGeometry **fea_geometry, for (iPoint=0; iPoint < nPointDomain; iPoint++) { - valSolutionPred = fea_solution[MESH_0][FEA_SOL]->node[iPoint]->GetSolution_Pred(); + valSolutionPred = fea_solution[MESH_0][FEA_SOL]->GetNodes()->GetSolution_Pred(iPoint); - fea_solution[MESH_0][FEA_SOL]->node[iPoint]->SetSolution(valSolutionPred); + fea_solution[MESH_0][FEA_SOL]->GetNodes()->SetSolution(iPoint, valSolutionPred); } @@ -3872,7 +3848,7 @@ void CFEASolver::Compute_OFRefGeom(CGeometry *geometry, CSolver **solver_contain su2double reference_geometry = 0.0, current_solution = 0.0; - bool fsi = (config->GetnMarker_Fluid_Load() > 0); + bool fsi = config->GetFSI_Simulation(); su2double objective_function = 0.0, objective_function_reduce = 0.0; su2double weight_OF = 1.0; @@ -3892,10 +3868,10 @@ void CFEASolver::Compute_OFRefGeom(CGeometry *geometry, CSolver **solver_contain for (iVar = 0; iVar < nVar; iVar++){ /*--- Retrieve the value of the reference geometry ---*/ - reference_geometry = node[iPoint]->GetReference_Geometry(iVar); + reference_geometry = nodes->GetReference_Geometry(iPoint,iVar); /*--- Retrieve the value of the current solution ---*/ - current_solution = node[iPoint]->GetSolution(iVar); + current_solution = nodes->GetSolution(iPoint,iVar); /*--- The objective function is the sum of the difference between solution and difference, squared ---*/ objective_function += weight_OF * (current_solution - reference_geometry)*(current_solution - reference_geometry); @@ -4007,7 +3983,7 @@ void CFEASolver::Compute_OFRefNode(CGeometry *geometry, CSolver **solver_contain su2double reference_geometry = 0.0, current_solution = 0.0; - bool fsi = (config->GetnMarker_Fluid_Load() > 0); + bool fsi = config->GetFSI_Simulation(); su2double objective_function = 0.0, objective_function_reduce = 0.0; su2double distance_sq = 0.0 ; @@ -4031,7 +4007,7 @@ void CFEASolver::Compute_OFRefNode(CGeometry *geometry, CSolver **solver_contain reference_geometry = config->GetRefNode_Displacement(iVar); /*--- Retrieve the value of the current solution ---*/ - current_solution = node[iPoint]->GetSolution(iVar); + current_solution = nodes->GetSolution(iPoint,iVar); /*--- The objective function is the sum of the difference between solution and difference, squared ---*/ distance_sq += (current_solution - reference_geometry)*(current_solution - reference_geometry); @@ -4039,8 +4015,8 @@ void CFEASolver::Compute_OFRefNode(CGeometry *geometry, CSolver **solver_contain objective_function = weight_OF * sqrt(distance_sq); - difX = node[iPoint]->GetSolution(0) - config->GetRefNode_Displacement(0); - difY = node[iPoint]->GetSolution(1) - config->GetRefNode_Displacement(1); + difX = nodes->GetSolution(iPoint,0) - config->GetRefNode_Displacement(0); + difY = nodes->GetSolution(iPoint,1) - config->GetRefNode_Displacement(1); } @@ -4209,7 +4185,6 @@ void CFEASolver::Compute_OFCompliance(CGeometry *geometry, CSolver **solver_cont su2double nodalForce[3]; /*--- Types of loads to consider ---*/ - bool fsi = config->GetFSI_Simulation(); bool body_forces = config->GetDeadLoad(); /*--- If the loads are being applied incrementaly ---*/ @@ -4224,17 +4199,16 @@ void CFEASolver::Compute_OFCompliance(CGeometry *geometry, CSolver **solver_cont /*--- Initialize with loads speficied through config ---*/ for (iVar = 0; iVar < nVar; iVar++) - nodalForce[iVar] = node[iPoint]->Get_SurfaceLoad_Res(iVar); + nodalForce[iVar] = nodes->Get_SurfaceLoad_Res(iPoint,iVar); /*--- Add contributions due to body forces ---*/ if (body_forces) for (iVar = 0; iVar < nVar; iVar++) - nodalForce[iVar] += node[iPoint]->Get_BodyForces_Res(iVar); + nodalForce[iVar] += nodes->Get_BodyForces_Res(iPoint,iVar); /*--- Add contributions due to fluid loads---*/ - if (fsi) - for (iVar = 0; iVar < nVar; iVar++) - nodalForce[iVar] += node[iPoint]->Get_FlowTraction(iVar); + for (iVar = 0; iVar < nVar; iVar++) + nodalForce[iVar] += nodes->Get_FlowTraction(iPoint,iVar); /*--- Correct for incremental loading ---*/ if (incremental_load) @@ -4243,7 +4217,7 @@ void CFEASolver::Compute_OFCompliance(CGeometry *geometry, CSolver **solver_cont /*--- Add work contribution from this node ---*/ for (iVar = 0; iVar < nVar; iVar++) - Total_OFCompliance += nodalForce[iVar]*node[iPoint]->GetSolution(iVar); + Total_OFCompliance += nodalForce[iVar]*nodes->GetSolution(iPoint,iVar); } #ifdef HAVE_MPI @@ -4294,10 +4268,10 @@ void CFEASolver::Stiffness_Penalty(CGeometry *geometry, CSolver **solver, CNumer for (iNode = 0; iNode < nNodes; iNode++) { indexNode[iNode] = geometry->elem[iElem]->GetNode(iNode); for (iDim = 0; iDim < nDim; iDim++) { - val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim); - val_Sol = node[indexNode[iNode]]->GetSolution(iDim) + val_Coord; - element_container[FEA_TERM][EL_KIND]->SetRef_Coord(val_Coord, iNode, iDim); - element_container[FEA_TERM][EL_KIND]->SetCurr_Coord(val_Sol, iNode, iDim); + val_Coord = Get_ValCoord(geometry, indexNode[iNode], iDim); + val_Sol = nodes->GetSolution(indexNode[iNode],iDim) + val_Coord; + element_container[FEA_TERM][EL_KIND]->SetRef_Coord(val_Coord, iNode, iDim); + element_container[FEA_TERM][EL_KIND]->SetCurr_Coord(val_Sol, iNode, iDim); } } @@ -4350,7 +4324,7 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c string filename; bool dynamic = (config->GetTime_Domain()); - bool fluid_structure = (config->GetnMarker_Fluid_Load() > 0); + bool fluid_structure = config->GetFSI_Simulation(); bool discrete_adjoint = config->GetDiscrete_Adjoint(); if (dynamic) nSolVar = 3 * nVar; @@ -4399,20 +4373,20 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c for (iVar = 0; iVar < nSolVar; iVar++) Sol[iVar] = Restart_Data[index+iVar]; for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint_Local]->SetSolution(iVar, Sol[iVar]); + nodes->SetSolution(iPoint_Local,iVar, Sol[iVar]); if (dynamic) { - node[iPoint_Local]->Set_Solution_time_n(iVar, Sol[iVar]); - node[iPoint_Local]->SetSolution_Vel(iVar, Sol[iVar+nVar]); - node[iPoint_Local]->SetSolution_Vel_time_n(iVar, Sol[iVar+nVar]); - node[iPoint_Local]->SetSolution_Accel(iVar, Sol[iVar+2*nVar]); - node[iPoint_Local]->SetSolution_Accel_time_n(iVar, Sol[iVar+2*nVar]); + nodes->Set_Solution_time_n(iPoint_Local,iVar, Sol[iVar]); + nodes->SetSolution_Vel(iPoint_Local,iVar, Sol[iVar+nVar]); + nodes->SetSolution_Vel_time_n(iPoint_Local,iVar, Sol[iVar+nVar]); + nodes->SetSolution_Accel(iPoint_Local,iVar, Sol[iVar+2*nVar]); + nodes->SetSolution_Accel_time_n(iPoint_Local,iVar, Sol[iVar+2*nVar]); } - if (fluid_structure) { - node[iPoint_Local]->SetSolution_Pred(iVar, Sol[iVar]); - node[iPoint_Local]->SetSolution_Pred_Old(iVar, Sol[iVar]); + if (fluid_structure && !dynamic) { + nodes->SetSolution_Pred(iPoint_Local,iVar, Sol[iVar]); + nodes->SetSolution_Pred_Old(iPoint_Local,iVar, Sol[iVar]); } if (fluid_structure && discrete_adjoint){ - node[iPoint_Local]->SetSolution_Old(iVar, Sol[iVar]); + nodes->SetSolution_Old(iPoint_Local,iVar, Sol[iVar]); } } iPoint_Global_Local++; diff --git a/SU2_CFD/src/solver_direct_heat.cpp b/SU2_CFD/src/solver_direct_heat.cpp index c174d9037476..192b08013390 100644 --- a/SU2_CFD/src/solver_direct_heat.cpp +++ b/SU2_CFD/src/solver_direct_heat.cpp @@ -41,12 +41,13 @@ CHeatSolverFVM::CHeatSolverFVM(void) : CSolver() { ConjugateVar = NULL; + HeatFlux = NULL; } CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CSolver() { unsigned short iVar, iDim, nLineLets, iMarker; - unsigned long iPoint, iVertex; + unsigned long iVertex; bool multizone = config->GetMultizone_Problem(); @@ -80,7 +81,6 @@ CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned sh /*--- Define geometry constants in the solver structure ---*/ nDim = geometry->GetnDim(); - node = new CVariable*[nPoint]; nMarker = config->GetnMarker_All(); CurrentMesh = iMesh; @@ -162,13 +162,13 @@ CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned sh Cvector[iVar] = new su2double [nDim]; } - HeatFlux = new su2double*[nMarker]; - AvgTemperature = new su2double[nMarker]; - Surface_Areas = new su2double[config->GetnMarker_HeatFlux()]; + HeatFlux_per_Marker = new su2double[nMarker]; + AverageT_per_Marker = new su2double[nMarker]; + Surface_Areas = new su2double[config->GetnMarker_HeatFlux()]; for(iMarker = 0; iMarker < nMarker; iMarker++) { - HeatFlux[iMarker] = new su2double[geometry->GetnVertex(iMarker)]; - AvgTemperature[iMarker] = 0.0; + HeatFlux_per_Marker[iMarker] = 0.0; + AverageT_per_Marker[iMarker] = 0.0; } for(iMarker = 0; iMarker < config->GetnMarker_HeatFlux(); iMarker++) { Surface_Areas[iMarker] = 0.0; @@ -176,7 +176,7 @@ CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned sh Set_Heatflux_Areas(geometry, config); - /*--- Non-dimensionalization of heat equation */ + /*--- Set the reference values for temperature ---*/ su2double Temperature_FreeStream = config->GetInc_Temperature_Init(); config->SetTemperature_FreeStream(Temperature_FreeStream); @@ -194,17 +194,25 @@ CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned sh config->SetTemperature_Ref(Temperature_Ref); config->SetTemperature_FreeStreamND(config->GetTemperature_FreeStream()/config->GetTemperature_Ref()); - if (rank == MASTER_NODE) { - cout << "Weakly coupled heat solver's freestream temperature: " << config->GetTemperature_FreeStreamND() << endl; + + /*--- Set the reference values for heat fluxes. If the heat solver runs stand-alone, + * thermal conductivity is read directly from config file ---*/ + + if (heat_equation) { + + su2double rho_cp = config->GetDensity_Solid()*config->GetSpecific_Heat_Cp_Solid(); + + config->SetThermalDiffusivity_Solid(config->GetThermalConductivity_Solid() / rho_cp); + config->SetHeat_Flux_Ref(rho_cp*Temperature_Ref); } + else { - su2double Temperature_Solid_Freestream_ND = config->GetTemperature_Freestream_Solid()/config->GetTemperature_Ref(); - if (heat_equation && (rank == MASTER_NODE)) { - cout << "Heat solver freestream temperature in case for solids: " << Temperature_Solid_Freestream_ND << endl; + config->SetHeat_Flux_Ref(config->GetViscosity_Ref()*config->GetSpecific_Heat_Cp()); } /*--- Store the value of the temperature and the heat flux density at the boundaries, - used for IO with a donor cell ---*/ + used for communications with donor cells ---*/ + unsigned short nConjVariables = 4; ConjugateVar = new su2double** [nMarker]; @@ -220,11 +228,14 @@ CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned sh } } - /*--- If the heat solver runs stand-alone, we have to set the reference values ---*/ - if(heat_equation) { - su2double rho_cp = config->GetDensity_Solid()*config->GetSpecific_Heat_Cp_Solid(); - su2double thermal_diffusivity_solid = config->GetThermalConductivity_Solid() / rho_cp; - config->SetThermalDiffusivity_Solid(thermal_diffusivity_solid); + /*--- Heat flux in all the markers ---*/ + + HeatFlux = new su2double* [nMarker]; + for (iMarker = 0; iMarker < nMarker; iMarker++) { + HeatFlux[iMarker] = new su2double [geometry->nVertex[iMarker]]; + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { + HeatFlux[iMarker][iVertex] = 0.0; + } } if (multizone){ @@ -242,11 +253,14 @@ CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned sh } } - for (iPoint = 0; iPoint < nPoint; iPoint++) - if (flow) - node[iPoint] = new CHeatFVMVariable(config->GetTemperature_FreeStreamND(), nDim, nVar, config); - else - node[iPoint] = new CHeatFVMVariable(Temperature_Solid_Freestream_ND, nDim, nVar, config); + if (flow) { + nodes = new CHeatFVMVariable(config->GetTemperature_FreeStreamND(), nPoint, nDim, nVar, config); + } + else { + su2double Temperature_Solid_Freestream_ND = config->GetTemperature_Freestream_Solid()/config->GetTemperature_Ref(); + nodes = new CHeatFVMVariable(Temperature_Solid_Freestream_ND, nPoint, nDim, nVar, config); + } + SetBaseClassPointerToNodes(); /*--- MPI solution ---*/ @@ -254,11 +268,23 @@ CHeatSolverFVM::CHeatSolverFVM(CGeometry *geometry, CConfig *config, unsigned sh CompleteComms(geometry, config, SOLUTION); /*--- Add the solver name (max 8 characters) ---*/ + SolverName = "HEAT"; } -CHeatSolverFVM::~CHeatSolverFVM(void) { } - +CHeatSolverFVM::~CHeatSolverFVM(void) { + + unsigned short iMarker; + + if (HeatFlux != NULL) { + for (iMarker = 0; iMarker < nMarker; iMarker++) { + delete [] HeatFlux[iMarker]; + } + delete [] HeatFlux; + } + + if (nodes != nullptr) delete nodes; +} void CHeatSolverFVM::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { @@ -272,10 +298,12 @@ void CHeatSolverFVM::Preprocessing(CGeometry *geometry, CSolver **solver_contain for (iPoint = 0; iPoint < nPoint; iPoint ++) { /*--- Initialize the residual vector ---*/ + LinSysRes.SetBlock_Zero(iPoint); } /*--- Initialize the Jacobian matrices ---*/ + Jacobian.SetValZero(); if (config->GetReconstructionGradientRequired()) { @@ -292,6 +320,7 @@ void CHeatSolverFVM::Postprocessing(CGeometry *geometry, CSolver **solver_contai void CHeatSolverFVM::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo) { /*--- Restart the solution from file information ---*/ + unsigned short iDim, iVar, iMesh; unsigned long iPoint, index, iChildren, Point_Fine; @@ -364,7 +393,7 @@ void CHeatSolverFVM::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfi index = counter*Restart_Vars[1] + skipVars; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); iPoint_Global_Local++; /*--- Increment the overall counter for how many points have been loaded. ---*/ @@ -415,12 +444,12 @@ void CHeatSolverFVM::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfi for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver[iMesh-1][HEAT_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver[iMesh-1][HEAT_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver[iMesh][HEAT_SOL]->node[iPoint]->SetSolution(Solution); + solver[iMesh][HEAT_SOL]->GetNodes()->SetSolution(iPoint,Solution); } solver[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); solver[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); @@ -447,8 +476,7 @@ void CHeatSolverFVM::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config Diff = new su2double[nVar]; - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetUnd_LaplZero(); + nodes->SetUnd_LaplZero(); for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { @@ -458,7 +486,7 @@ void CHeatSolverFVM::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config /*--- Solution differences ---*/ for (iVar = 0; iVar < nVar; iVar++) - Diff[iVar] = node[iPoint]->GetSolution(iVar) - node[jPoint]->GetSolution(iVar); + Diff[iVar] = nodes->GetSolution(iPoint,iVar) - nodes->GetSolution(jPoint,iVar); boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); @@ -466,19 +494,19 @@ void CHeatSolverFVM::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config /*--- Both points inside the domain, or both in the boundary ---*/ if ((!boundary_i && !boundary_j) || (boundary_i && boundary_j)) { - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint,Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint,Diff); } /*--- iPoint inside the domain, jPoint on the boundary ---*/ if (!boundary_i && boundary_j) - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint,Diff); /*--- jPoint inside the domain, iPoint on the boundary ---*/ if (boundary_i && !boundary_j) - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint,Diff); } @@ -513,13 +541,13 @@ void CHeatSolverFVM::Centered_Residual(CGeometry *geometry, CSolver **solver_con numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); /*--- Primitive variables w/o reconstruction ---*/ - V_i = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); - V_j = solver_container[FLOW_SOL]->node[jPoint]->GetPrimitive(); + V_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); + V_j = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(jPoint); - Temp_i = node[iPoint]->GetSolution(0); - Temp_j = node[jPoint]->GetSolution(0); + Temp_i = nodes->GetSolution(iPoint,0); + Temp_j = nodes->GetSolution(jPoint,0); - numerics->SetUndivided_Laplacian(node[iPoint]->GetUndivided_Laplacian(), node[jPoint]->GetUndivided_Laplacian()); + numerics->SetUndivided_Laplacian(nodes->GetUndivided_Laplacian(iPoint), nodes->GetUndivided_Laplacian(jPoint)); numerics->SetNeighbor(geometry->node[iPoint]->GetnNeighbor(), geometry->node[jPoint]->GetnNeighbor()); numerics->SetPrimitive(V_i, V_j); @@ -564,15 +592,15 @@ void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); /*--- Primitive variables w/o reconstruction ---*/ - V_i = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); - V_j = solver_container[FLOW_SOL]->node[jPoint]->GetPrimitive(); + V_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); + V_j = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(jPoint); - Temp_i_Grad = node[iPoint]->GetGradient(); - Temp_j_Grad = node[jPoint]->GetGradient(); + Temp_i_Grad = nodes->GetGradient(iPoint); + Temp_j_Grad = nodes->GetGradient(jPoint); numerics->SetConsVarGradient(Temp_i_Grad, Temp_j_Grad); - Temp_i = node[iPoint]->GetSolution(0); - Temp_j = node[jPoint]->GetSolution(0); + Temp_i = nodes->GetSolution(iPoint,0); + Temp_j = nodes->GetSolution(jPoint,0); /* Second order reconstruction */ if (muscl) { @@ -582,10 +610,10 @@ void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta Vector_j[iDim] = 0.5*(geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim)); } - Gradient_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = solver_container[FLOW_SOL]->node[jPoint]->GetGradient_Reconstruction(); - Temp_i_Grad = node[iPoint]->GetGradient_Reconstruction(); - Temp_j_Grad = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Reconstruction(iPoint); + Gradient_j = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Reconstruction(jPoint); + Temp_i_Grad = nodes->GetGradient_Reconstruction(iPoint); + Temp_j_Grad = nodes->GetGradient_Reconstruction(jPoint); /*Loop to correct the flow variables*/ for (iVar = 0; iVar < nVarFlow; iVar++) { @@ -667,20 +695,20 @@ void CHeatSolverFVM::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont geometry->node[jPoint]->GetCoord()); numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); - Temp_i_Grad = node[iPoint]->GetGradient(); - Temp_j_Grad = node[jPoint]->GetGradient(); + Temp_i_Grad = nodes->GetGradient(iPoint); + Temp_j_Grad = nodes->GetGradient(jPoint); numerics->SetConsVarGradient(Temp_i_Grad, Temp_j_Grad); /*--- Primitive variables w/o reconstruction ---*/ - Temp_i = node[iPoint]->GetSolution(0); - Temp_j = node[jPoint]->GetSolution(0); + Temp_i = nodes->GetSolution(iPoint,0); + Temp_j = nodes->GetSolution(jPoint,0); numerics->SetTemperature(Temp_i, Temp_j); /*--- Eddy viscosity to compute thermal conductivity ---*/ if (flow) { if (turb) { - eddy_viscosity_i = solver_container[TURB_SOL]->node[iPoint]->GetmuT(); - eddy_viscosity_j = solver_container[TURB_SOL]->node[jPoint]->GetmuT(); + eddy_viscosity_i = solver_container[TURB_SOL]->GetNodes()->GetmuT(iPoint); + eddy_viscosity_j = solver_container[TURB_SOL]->GetNodes()->GetmuT(jPoint); } thermal_diffusivity_i = (laminar_viscosity/Prandtl_Lam) + (eddy_viscosity_i/Prandtl_Turb); thermal_diffusivity_j = (laminar_viscosity/Prandtl_Lam) + (eddy_viscosity_j/Prandtl_Turb); @@ -820,7 +848,7 @@ void CHeatSolverFVM::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_co dist_ij += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); dist_ij = sqrt(dist_ij); - dTdn = -(node[Point_Normal]->GetSolution(0) - Twall)/dist_ij; + dTdn = -(nodes->GetSolution(Point_Normal,0) - Twall)/dist_ij; if(flow) { thermal_diffusivity = laminar_viscosity/Prandtl_Lam; @@ -950,7 +978,7 @@ void CHeatSolverFVM::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve solution at this boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Retrieve the specified velocity for the inlet. ---*/ @@ -967,7 +995,7 @@ void CHeatSolverFVM::BC_Inlet(CGeometry *geometry, CSolver **solver_container, if (dynamic_grid) conv_numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), geometry->node[iPoint]->GetGridVel()); - conv_numerics->SetTemperature(node[iPoint]->GetSolution(0), config->GetInlet_Ttotal(Marker_Tag)/config->GetTemperature_Ref()); + conv_numerics->SetTemperature(nodes->GetSolution(iPoint,0), config->GetInlet_Ttotal(Marker_Tag)/config->GetTemperature_Ref()); /*--- Compute the residual using an upwind scheme ---*/ @@ -1001,7 +1029,7 @@ void CHeatSolverFVM::BC_Inlet(CGeometry *geometry, CSolver **solver_container, dist_ij += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); dist_ij = sqrt(dist_ij); - dTdn = -(node[Point_Normal]->GetSolution(0) - Twall)/dist_ij; + dTdn = -(nodes->GetSolution(Point_Normal,0) - Twall)/dist_ij; thermal_diffusivity = laminar_viscosity/Prandtl_Lam; @@ -1057,20 +1085,20 @@ void CHeatSolverFVM::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve solution at this boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Retrieve the specified velocity for the inlet. ---*/ V_outlet = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex); for (iDim = 0; iDim < nDim; iDim++) - V_outlet[iDim+1] = solver_container[FLOW_SOL]->node[Point_Normal]->GetPrimitive(iDim+1); + V_outlet[iDim+1] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(Point_Normal, iDim); conv_numerics->SetPrimitive(V_domain, V_outlet); if (dynamic_grid) conv_numerics->SetGridVel(geometry->node[iPoint]->GetGridVel(), geometry->node[iPoint]->GetGridVel()); - conv_numerics->SetTemperature(node[iPoint]->GetSolution(0), node[Point_Normal]->GetSolution(0)); + conv_numerics->SetTemperature(nodes->GetSolution(iPoint,0), nodes->GetSolution(Point_Normal,0)); /*--- Compute the residual using an upwind scheme ---*/ @@ -1098,8 +1126,8 @@ void CHeatSolverFVM::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **s unsigned long iVertex, iPoint, total_index; unsigned short iDim, iVar, iMarker; - su2double Area, rho_cp_solid, - Temperature_Ref, Tinterface, T_Conjugate, Tnormal_Conjugate, Conductance, HeatFluxDensity, HeatFluxValue; + su2double thermal_diffusivity, rho_cp_solid, Temperature_Ref, T_Conjugate, Tinterface, + Tnormal_Conjugate, HeatFluxDensity, HeatFlux, Area; bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); bool flow = ((config->GetKind_Solver() == INC_NAVIER_STOKES) @@ -1130,9 +1158,9 @@ void CHeatSolverFVM::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **s T_Conjugate = GetConjugateHeatVariable(iMarker, iVertex, 0)/Temperature_Ref; - node[iPoint]->SetSolution_Old(&T_Conjugate); + nodes->SetSolution_Old(iPoint,&T_Conjugate); LinSysRes.SetBlock_Zero(iPoint, 0); - node[iPoint]->SetRes_TruncErrorZero(); + nodes->SetRes_TruncErrorZero(iPoint); if (implicit) { for (iVar = 0; iVar < nVar; iVar++) { @@ -1161,20 +1189,28 @@ void CHeatSolverFVM::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **s for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt (Area); - Tinterface = node[iPoint]->GetSolution(0); - Tnormal_Conjugate = GetConjugateHeatVariable(iMarker, iVertex, 3)/Temperature_Ref; - Conductance = GetConjugateHeatVariable(iMarker, iVertex, 2)/rho_cp_solid; + thermal_diffusivity = GetConjugateHeatVariable(iMarker, iVertex, 2)/rho_cp_solid; + + if (config->GetCHT_Robin()) { + + Tinterface = nodes->GetSolution(iPoint,0); + Tnormal_Conjugate = GetConjugateHeatVariable(iMarker, iVertex, 3)/Temperature_Ref; - HeatFluxDensity = Conductance*(Tinterface - Tnormal_Conjugate); + HeatFluxDensity = thermal_diffusivity*(Tinterface - Tnormal_Conjugate); + HeatFlux = HeatFluxDensity * Area; + } + else { - HeatFluxValue = HeatFluxDensity * Area; + HeatFluxDensity = GetConjugateHeatVariable(iMarker, iVertex, 1)/config->GetHeat_Flux_Ref(); + HeatFlux = HeatFluxDensity*Area; + } - Res_Visc[0] = -HeatFluxValue; + Res_Visc[0] = -HeatFlux; LinSysRes.SubtractBlock(iPoint, Res_Visc); if (implicit) { - Jacobian_i[0][0] = Conductance*Area; + Jacobian_i[0][0] = thermal_diffusivity*Area; Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); } } @@ -1188,26 +1224,25 @@ void CHeatSolverFVM::Heat_Fluxes(CGeometry *geometry, CSolver **solver_container unsigned long iVertex, iPoint, iPointNormal; unsigned short Boundary, Monitoring, iMarker, iDim; - su2double *Coord, *Coord_Normal, *Normal, Area, dist, Twall, dTdn, cp_fluid, rho_cp_solid, - thermal_conductivity, thermal_diffusivity; + su2double *Coord, *Coord_Normal, *Normal, Area, dist, Twall, dTdn, thermal_diffusivity; string Marker_Tag, HeatFlux_Tag; + bool flow = ((config->GetKind_Solver() == INC_NAVIER_STOKES) || (config->GetKind_Solver() == INC_RANS) || (config->GetKind_Solver() == DISC_ADJ_INC_NAVIER_STOKES) || (config->GetKind_Solver() == DISC_ADJ_INC_RANS)); + #ifdef HAVE_MPI - su2double MyAllBound_HeatFlux, MyAllBound_AvgTemperature; + su2double MyAllBound_HeatFlux, MyAllBound_AverageT; #endif - cp_fluid = config->GetSpecific_Heat_Cp(); - rho_cp_solid = config->GetSpecific_Heat_Cp_Solid()*config->GetDensity_Solid(); - AllBound_HeatFlux = 0.0; - AllBound_AvgTemperature = 0.0; + AllBound_AverageT = 0.0; for ( iMarker = 0; iMarker < nMarker; iMarker++ ) { - AvgTemperature[iMarker] = 0.0; + AverageT_per_Marker[iMarker] = 0.0; + HeatFlux_per_Marker[iMarker] = 0.0; Boundary = config->GetMarker_All_KindBC(iMarker); Marker_Tag = config->GetMarker_All_TagBound(iMarker); @@ -1237,21 +1272,19 @@ void CHeatSolverFVM::Heat_Fluxes(CGeometry *geometry, CSolver **solver_container for (iDim = 0; iDim < nDim; iDim++) dist += (Coord_Normal[iDim]-Coord[iDim])*(Coord_Normal[iDim]-Coord[iDim]); dist = sqrt(dist); - dTdn = (Twall - node[iPointNormal]->GetSolution(0))/dist; + dTdn = (Twall - nodes->GetSolution(iPointNormal,0))/dist; if(flow) { thermal_diffusivity = config->GetViscosity_FreeStreamND()/config->GetPrandtl_Lam(); - thermal_conductivity = thermal_diffusivity*config->GetViscosity_Ref()*cp_fluid; } else { - thermal_conductivity = config->GetThermalDiffusivity_Solid()*rho_cp_solid; + thermal_diffusivity = config->GetThermalDiffusivity_Solid(); } - HeatFlux[iMarker][iVertex] = thermal_conductivity*dTdn*config->GetTemperature_Ref()*Area; + HeatFlux[iMarker][iVertex] = thermal_diffusivity*dTdn*config->GetHeat_Flux_Ref(); + + HeatFlux_per_Marker[iMarker] += HeatFlux[iMarker][iVertex]*Area; - if (Monitoring){ - AllBound_HeatFlux += HeatFlux[iMarker][iVertex]; - } } } } @@ -1265,7 +1298,7 @@ void CHeatSolverFVM::Heat_Fluxes(CGeometry *geometry, CSolver **solver_container iPointNormal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); - Twall = node[iPoint]->GetSolution(0); + Twall = nodes->GetSolution(iPoint,0); Coord = geometry->node[iPoint]->GetCoord(); Coord_Normal = geometry->node[iPointNormal]->GetCoord(); @@ -1279,51 +1312,50 @@ void CHeatSolverFVM::Heat_Fluxes(CGeometry *geometry, CSolver **solver_container for (iDim = 0; iDim < nDim; iDim++) dist += (Coord_Normal[iDim]-Coord[iDim])*(Coord_Normal[iDim]-Coord[iDim]); dist = sqrt(dist); - dTdn = (Twall - node[iPointNormal]->GetSolution(0))/dist; + dTdn = (Twall - nodes->GetSolution(iPointNormal,0))/dist; if(flow) { thermal_diffusivity = config->GetViscosity_FreeStreamND()/config->GetPrandtl_Lam(); - thermal_conductivity = thermal_diffusivity*config->GetViscosity_Ref()*cp_fluid; } else { - thermal_conductivity = config->GetThermalDiffusivity_Solid()*rho_cp_solid; + thermal_diffusivity = config->GetThermalDiffusivity_Solid(); } - HeatFlux[iMarker][iVertex] = thermal_conductivity*dTdn*config->GetTemperature_Ref()*Area; - - if (Monitoring){ - AllBound_HeatFlux += HeatFlux[iMarker][iVertex]; - } + HeatFlux[iMarker][iVertex] = thermal_diffusivity*dTdn*config->GetHeat_Flux_Ref(); + HeatFlux_per_Marker[iMarker] += HeatFlux[iMarker][iVertex]*Area; + /*--- We do only aim to compute averaged temperatures on the (interesting) heat flux walls ---*/ + if ( Boundary == HEAT_FLUX ) { - AvgTemperature[iMarker] += Twall*config->GetTemperature_Ref()*Area; + AverageT_per_Marker[iMarker] += Twall*config->GetTemperature_Ref()*Area; } } } } if (Monitoring == YES) { - AllBound_AvgTemperature += AvgTemperature[iMarker]; + + AllBound_HeatFlux += HeatFlux_per_Marker[iMarker]; + AllBound_AverageT += AverageT_per_Marker[iMarker]; } } #ifdef HAVE_MPI MyAllBound_HeatFlux = AllBound_HeatFlux; - MyAllBound_AvgTemperature = AllBound_AvgTemperature; + MyAllBound_AverageT = AllBound_AverageT; SU2_MPI::Allreduce(&MyAllBound_HeatFlux, &AllBound_HeatFlux, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - SU2_MPI::Allreduce(&MyAllBound_AvgTemperature, &AllBound_AvgTemperature, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); + SU2_MPI::Allreduce(&MyAllBound_AverageT, &AllBound_AverageT, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); #endif if (Total_HeatFlux_Areas_Monitor != 0.0) { - Total_AvgTemperature = AllBound_AvgTemperature/Total_HeatFlux_Areas_Monitor; + Total_AverageT = AllBound_AverageT/Total_HeatFlux_Areas_Monitor; } else { - Total_AvgTemperature = 0.0; + Total_AverageT = 0.0; } - Total_HeatFlux = AllBound_HeatFlux; } @@ -1358,8 +1390,8 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe CFL_Reduction = config->GetCFLRedCoeff_Turb(); for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->SetMax_Lambda_Inv(0.0); - node[iPoint]->SetMax_Lambda_Visc(0.0); + nodes->SetMax_Lambda_Inv(iPoint,0.0); + nodes->SetMax_Lambda_Visc(iPoint,0.0); } /*--- Loop interior edges ---*/ @@ -1376,14 +1408,14 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe /*--- Inviscid contribution ---*/ if (flow) { - Mean_ProjVel = 0.5 * (solver_container[FLOW_SOL]->node[iPoint]->GetProjVel(Normal) + solver_container[FLOW_SOL]->node[jPoint]->GetProjVel(Normal)); - Mean_BetaInc2 = 0.5 * (solver_container[FLOW_SOL]->node[iPoint]->GetBetaInc2() + solver_container[FLOW_SOL]->node[jPoint]->GetBetaInc2()); - Mean_DensityInc = 0.5 * (solver_container[FLOW_SOL]->node[iPoint]->GetDensity() + solver_container[FLOW_SOL]->node[jPoint]->GetDensity()); + Mean_ProjVel = 0.5 * (solver_container[FLOW_SOL]->GetNodes()->GetProjVel(iPoint,Normal) + solver_container[FLOW_SOL]->GetNodes()->GetProjVel(jPoint,Normal)); + Mean_BetaInc2 = 0.5 * (solver_container[FLOW_SOL]->GetNodes()->GetBetaInc2(iPoint) + solver_container[FLOW_SOL]->GetNodes()->GetBetaInc2(jPoint)); + Mean_DensityInc = 0.5 * (solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint) + solver_container[FLOW_SOL]->GetNodes()->GetDensity(jPoint)); Mean_SoundSpeed = sqrt(Mean_ProjVel*Mean_ProjVel + (Mean_BetaInc2/Mean_DensityInc)*Area*Area); Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Inv(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddMax_Lambda_Inv(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(iPoint, Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(jPoint, Lambda); } /*--- Viscous contribution ---*/ @@ -1391,15 +1423,15 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe thermal_diffusivity = config->GetThermalDiffusivity_Solid(); if(flow) { if(turb) { - eddy_viscosity = solver_container[TURB_SOL]->node[iPoint]->GetmuT(); + eddy_viscosity = solver_container[TURB_SOL]->GetNodes()->GetmuT(iPoint); } thermal_diffusivity = laminar_viscosity/Prandtl_Lam + eddy_viscosity/Prandtl_Turb; } Lambda = thermal_diffusivity*Area*Area; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Visc(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddMax_Lambda_Visc(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(iPoint, Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(jPoint, Lambda); } @@ -1417,13 +1449,13 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe /*--- Inviscid contribution ---*/ if (flow) { - Mean_ProjVel = solver_container[FLOW_SOL]->node[iPoint]->GetProjVel(Normal); - Mean_BetaInc2 = solver_container[FLOW_SOL]->node[iPoint]->GetBetaInc2(); - Mean_DensityInc = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); + Mean_ProjVel = solver_container[FLOW_SOL]->GetNodes()->GetProjVel(iPoint, Normal); + Mean_BetaInc2 = solver_container[FLOW_SOL]->GetNodes()->GetBetaInc2(iPoint); + Mean_DensityInc = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); Mean_SoundSpeed = sqrt(Mean_ProjVel*Mean_ProjVel + (Mean_BetaInc2/Mean_DensityInc)*Area*Area); Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Inv(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(iPoint, Lambda); } /*--- Viscous contribution ---*/ @@ -1431,14 +1463,14 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe thermal_diffusivity = config->GetThermalDiffusivity_Solid(); if(flow) { if(turb) { - eddy_viscosity = solver_container[TURB_SOL]->node[iPoint]->GetmuT(); + eddy_viscosity = solver_container[TURB_SOL]->GetNodes()->GetmuT(iPoint); } thermal_diffusivity = laminar_viscosity/Prandtl_Lam + eddy_viscosity/Prandtl_Turb; } Lambda = thermal_diffusivity*Area*Area; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Visc(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(iPoint, Lambda); } } @@ -1452,19 +1484,19 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe if (Vol != 0.0) { if(flow) { - Local_Delta_Time_Inv = config->GetCFL(iMesh)*Vol / node[iPoint]->GetMax_Lambda_Inv(); - Local_Delta_Time_Visc = config->GetCFL(iMesh)*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); + Local_Delta_Time_Inv = config->GetCFL(iMesh)*Vol / nodes->GetMax_Lambda_Inv(iPoint); + Local_Delta_Time_Visc = config->GetCFL(iMesh)*K_v*Vol*Vol/ nodes->GetMax_Lambda_Visc(iPoint); } else { Local_Delta_Time_Inv = config->GetMax_DeltaTime(); - Local_Delta_Time_Visc = config->GetCFL(iMesh)*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); - //Local_Delta_Time_Visc = 100.0*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); + Local_Delta_Time_Visc = config->GetCFL(iMesh)*K_v*Vol*Vol/ nodes->GetMax_Lambda_Visc(iPoint); + //Local_Delta_Time_Visc = 100.0*K_v*Vol*Vol/ nodes->GetMax_Lambda_Visc(iPoint); } /*--- Time step setting method ---*/ if (config->GetKind_TimeStep_Heat() == BYFLOW && flow) { - Local_Delta_Time = solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time(); + Local_Delta_Time = solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint); } else if (config->GetKind_TimeStep_Heat() == MINIMUM) { Local_Delta_Time = min(Local_Delta_Time_Inv, Local_Delta_Time_Visc); @@ -1484,10 +1516,10 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe if (Local_Delta_Time > config->GetMax_DeltaTime()) Local_Delta_Time = config->GetMax_DeltaTime(); - node[iPoint]->SetDelta_Time(CFL_Reduction*Local_Delta_Time); + nodes->SetDelta_Time(iPoint,CFL_Reduction*Local_Delta_Time); } else { - node[iPoint]->SetDelta_Time(0.0); + nodes->SetDelta_Time(iPoint,0.0); } } @@ -1517,7 +1549,7 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe Global_Delta_Time = rbuf_time; #endif for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetDelta_Time(Global_Delta_Time); + nodes->SetDelta_Time(iPoint,Global_Delta_Time); } /*--- Recompute the unsteady time step for the dual time strategy @@ -1540,8 +1572,8 @@ void CHeatSolverFVM::SetTime_Step(CGeometry *geometry, CSolver **solver_containe for (iPoint = 0; iPoint < nPointDomain; iPoint++) { if (!implicit) { cout << "Using unsteady time: " << config->GetDelta_UnstTimeND() << endl; - Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), node[iPoint]->GetDelta_Time()); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), nodes->GetDelta_Time(iPoint)); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } } } @@ -1563,15 +1595,15 @@ void CHeatSolverFVM::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solv for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Vol = geometry->node[iPoint]->GetVolume(); - Delta = node[iPoint]->GetDelta_Time() / Vol; + Delta = nodes->GetDelta_Time(iPoint) / Vol; - local_Res_TruncError = node[iPoint]->GetResTruncError(); + local_Res_TruncError = nodes->GetResTruncError(iPoint); local_Residual = LinSysRes.GetBlock(iPoint); if (!adjoint) { for (iVar = 0; iVar < nVar; iVar++) { Res = local_Residual[iVar] + local_Res_TruncError[iVar]; - node[iPoint]->AddSolution(iVar, -Res*Delta); + nodes->AddSolution(iPoint,iVar, -Res*Delta); AddRes_RMS(iVar, Res*Res); AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); } @@ -1615,7 +1647,7 @@ void CHeatSolverFVM::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv /*--- Read the residual ---*/ - local_Res_TruncError = node[iPoint]->GetResTruncError(); + local_Res_TruncError = nodes->GetResTruncError(iPoint); /*--- Read the volume ---*/ @@ -1623,14 +1655,14 @@ void CHeatSolverFVM::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - if (node[iPoint]->GetDelta_Time() != 0.0) { + if (nodes->GetDelta_Time(iPoint) != 0.0) { if(flow) { - Delta = Vol / node[iPoint]->GetDelta_Time(); + Delta = Vol / nodes->GetDelta_Time(iPoint); Jacobian.AddVal2Diag(iPoint, Delta); } else { - Delta = Vol / node[iPoint]->GetDelta_Time(); + Delta = Vol / nodes->GetDelta_Time(iPoint); Jacobian.AddVal2Diag(iPoint, Delta); } @@ -1670,7 +1702,7 @@ void CHeatSolverFVM::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv for (iPoint = 0; iPoint < nPointDomain; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddSolution(iVar, LinSysSol[iPoint*nVar+iVar]); + nodes->AddSolution(iPoint,iVar, LinSysSol[iPoint*nVar+iVar]); } } @@ -1708,12 +1740,12 @@ void CHeatSolverFVM::SetInitialCondition(CGeometry **geometry, CSolver ***solver for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver_container[iMesh-1][HEAT_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver_container[iMesh-1][HEAT_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver_container[iMesh][HEAT_SOL]->node[iPoint]->SetSolution(Solution); + solver_container[iMesh][HEAT_SOL]->GetNodes()->SetSolution(iPoint,Solution); } solver_container[iMesh][HEAT_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); solver_container[iMesh][HEAT_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); @@ -1729,10 +1761,8 @@ void CHeatSolverFVM::SetInitialCondition(CGeometry **geometry, CSolver ***solver for a 1st-order restart or when simply intitializing to freestream. ---*/ for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { - solver_container[iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n1(); - } + solver_container[iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n1(); } if ((restart && (long)TimeIter == (long)config->GetRestart_Iter()) && @@ -1745,9 +1775,7 @@ void CHeatSolverFVM::SetInitialCondition(CGeometry **geometry, CSolver ***solver /*--- Push back this new solution to time level N. ---*/ for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { - solver_container[iMesh][HEAT_SOL]->node[iPoint]->Set_Solution_time_n(); - } + solver_container[iMesh][HEAT_SOL]->GetNodes()->Set_Solution_time_n(); } } } @@ -1782,9 +1810,9 @@ void CHeatSolverFVM::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_ we are currently iterating on U^n+1 and that U^n & U^n-1 are fixed, previous solutions that are stored in memory. ---*/ - U_time_nM1 = node[iPoint]->GetSolution_time_n1(); - U_time_n = node[iPoint]->GetSolution_time_n(); - U_time_nP1 = node[iPoint]->GetSolution(); + U_time_nM1 = nodes->GetSolution_time_n1(iPoint); + U_time_n = nodes->GetSolution_time_n(iPoint); + U_time_nP1 = nodes->GetSolution(iPoint); /*--- CV volume at time n+1. As we are on a static mesh, the volume of the CV will remained fixed for all time steps. ---*/ @@ -1820,5 +1848,3 @@ void CHeatSolverFVM::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_ } } } - - diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index cffb9b1b1ffd..cdfae31bf270 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -166,7 +166,8 @@ CEulerSolver::CEulerSolver(void) : CSolver() { CkInflow = NULL; CkOutflow1 = NULL; CkOutflow2 = NULL; - + + nodes = nullptr; } CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CSolver() { @@ -390,10 +391,6 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short SetVerificationSolution(nDim, nVar, config); - /*--- Allocate the node variables ---*/ - - node = new CVariable*[nPoint]; - /*--- Define some auxiliary vectors related to the residual ---*/ Residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; @@ -804,8 +801,8 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Initialize the solution to the far-field state everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CEulerVariable(Density_Inf, Velocity_Inf, Energy_Inf, nDim, nVar, config); + nodes = new CEulerVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); /*--- Check that the initial solution is physical, report any non-physical nodes ---*/ @@ -813,13 +810,13 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short for (iPoint = 0; iPoint < nPoint; iPoint++) { - Density = node[iPoint]->GetSolution(0); + Density = nodes->GetDensity(iPoint); Velocity2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) - Velocity2 += (node[iPoint]->GetSolution(iDim+1)/Density)*(node[iPoint]->GetSolution(iDim+1)/Density); + Velocity2 += pow(nodes->GetSolution(iPoint,iDim+1)/Density,2); - StaticEnergy= node[iPoint]->GetSolution(nDim+1)/Density - 0.5*Velocity2; + StaticEnergy= nodes->GetEnergy(iPoint) - 0.5*Velocity2; FluidModel->SetTDState_rhoe(Density, StaticEnergy); Pressure= FluidModel->GetPressure(); @@ -832,8 +829,8 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short for (iDim = 0; iDim < nDim; iDim++) Solution[iDim+1] = Velocity_Inf[iDim]*Density_Inf; Solution[nDim+1] = Energy_Inf*Density_Inf; - node[iPoint]->SetSolution(Solution); - node[iPoint]->SetSolution_Old(Solution); + nodes->SetSolution(iPoint,Solution); + nodes->SetSolution_Old(iPoint,Solution); counter_local++; } @@ -898,7 +895,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->SetLocalCFL(CFL); + nodes->SetLocalCFL(iPoint, CFL); } Min_CFL_Local = CFL; Max_CFL_Local = CFL; @@ -1374,6 +1371,7 @@ CEulerSolver::~CEulerSolver(void) { delete [] CkOutflow2; } + if (nodes != nullptr) delete nodes; } void CEulerSolver::InitTurboContainers(CGeometry *geometry, CConfig *config){ @@ -1724,10 +1722,10 @@ void CEulerSolver::Set_MPI_ActDisk(CSolver **solver_container, CGeometry *geomet if ((iDomain == jDomain) && (geometry->node[iPoint]->GetDomain())) { for (iVar = 0; iVar < nPrimVar; iVar++) { - Buffer_Send_PrimVar[(nPrimVar_)*(PointTotal_Counter+iPointTotal)+iVar] = node[iPoint]->GetPrimitive(iVar); + Buffer_Send_PrimVar[(nPrimVar_)*(PointTotal_Counter+iPointTotal)+iVar] = nodes->GetPrimitive(iPoint,iVar); } if (rans) { - Buffer_Send_PrimVar[(nPrimVar_)*(PointTotal_Counter+iPointTotal)+nPrimVar] = solver_container[TURB_SOL]->node[iPoint]->GetSolution(0); + Buffer_Send_PrimVar[(nPrimVar_)*(PointTotal_Counter+iPointTotal)+nPrimVar] = solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); Buffer_Send_PrimVar[(nPrimVar_)*(PointTotal_Counter+iPointTotal)+(nPrimVar+1)] = 0.0; } @@ -2059,7 +2057,7 @@ void CEulerSolver::Set_MPI_Nearfield(CGeometry *geometry, CConfig *config) { jVertex = geometry->vertex[iMarker][iVertex]->GetDonorVertex(); jMarker = geometry->vertex[iMarker][iVertex]->GetDonorMarker(); for (iVar = 0; iVar < nPrimVar; iVar++) { - Buffer_Send_PrimVar[(nPrimVar+3)*(PointTotal_Counter+iPointTotal)+iVar] = node[iPoint]->GetPrimitive(iVar); + Buffer_Send_PrimVar[(nPrimVar+3)*(PointTotal_Counter+iPointTotal)+iVar] = nodes->GetPrimitive(iPoint,iVar); } Buffer_Send_PrimVar[(nPrimVar+3)*(PointTotal_Counter+iPointTotal)+(nPrimVar+0)] = su2double(iGlobalIndex); Buffer_Send_PrimVar[(nPrimVar+3)*(PointTotal_Counter+iPointTotal)+(nPrimVar+1)] = su2double(jVertex); @@ -2799,7 +2797,7 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c /* Set the pointers to the coordinates and solution of this DOF. */ const su2double *coor = geometry[iMesh]->node[iPoint]->GetCoord(); - su2double *solDOF = solver_container[iMesh][FLOW_SOL]->node[iPoint]->GetSolution(); + su2double *solDOF = solver_container[iMesh][FLOW_SOL]->GetNodes()->GetSolution(iPoint); /* Set the solution in this DOF to the initial condition provided by the verification solution class. This can be the exact solution, @@ -2910,15 +2908,15 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c if (Distance < Radius) { - solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(0, Density_CylND); + solver_container[iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint, 0, Density_CylND); for (iDim = 0; iDim < nDim; iDim++) - solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(iDim+1, Density_CylND*Velocity_CylND[iDim]); - solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(nVar-1, Density_CylND*Energy_CylND); + solver_container[iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint, iDim+1, Density_CylND*Velocity_CylND[iDim]); + solver_container[iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint, nVar-1, Density_CylND*Energy_CylND); - solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution_Old(0, Density_CylND); + solver_container[iMesh][FLOW_SOL]->GetNodes()->SetSolution_Old(iPoint, 0, Density_CylND); for (iDim = 0; iDim < nDim; iDim++) - solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution_Old(iDim+1, Density_CylND*Velocity_CylND[iDim]); - solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution_Old(nVar-1, Density_CylND*Energy_CylND); + solver_container[iMesh][FLOW_SOL]->GetNodes()->SetSolution_Old(iPoint, iDim+1, Density_CylND*Velocity_CylND[iDim]); + solver_container[iMesh][FLOW_SOL]->GetNodes()->SetSolution_Old(iPoint, nVar-1, Density_CylND*Energy_CylND); } @@ -2947,13 +2945,11 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c for a 1st-order restart or when simply intitializing to freestream. ---*/ for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { - solver_container[iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n1(); - if (rans) { - solver_container[iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n1(); - } + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(); + if (rans) { + solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(); } } @@ -2971,11 +2967,9 @@ void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_c /*--- Push back this new solution to time level N. ---*/ for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { - solver_container[iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - if (rans) { - solver_container[iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(); - } + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + if (rans) { + solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); } } } @@ -3098,8 +3092,8 @@ unsigned long CEulerSolver::SetPrimitive_Variables(CSolver **solver_container, C /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ - physical = node[iPoint]->SetPrimVar(FluidModel); - node[iPoint]->SetSecondaryVar(FluidModel); + physical = nodes->SetPrimVar(iPoint, FluidModel); + nodes->SetSecondaryVar(iPoint, FluidModel); /* Check for non-realizable states for reporting. */ @@ -3131,7 +3125,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetMax_Lambda_Inv(0.0); + nodes->SetMax_Lambda_Inv(iPoint,0.0); /*--- Loop interior edges ---*/ for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { @@ -3146,8 +3140,8 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Mean Values ---*/ - Mean_ProjVel = 0.5 * (node[iPoint]->GetProjVel(Normal) + node[jPoint]->GetProjVel(Normal)); - Mean_SoundSpeed = 0.5 * (node[iPoint]->GetSoundSpeed() + node[jPoint]->GetSoundSpeed()) * Area; + Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); + Mean_SoundSpeed = 0.5 * (nodes->GetSoundSpeed(iPoint) + nodes->GetSoundSpeed(jPoint)) * Area; /*--- Adjustment for grid movement ---*/ @@ -3165,8 +3159,8 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Inviscid contribution ---*/ Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Inv(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddMax_Lambda_Inv(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(iPoint,Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(jPoint,Lambda); } @@ -3185,8 +3179,8 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Mean Values ---*/ - Mean_ProjVel = node[iPoint]->GetProjVel(Normal); - Mean_SoundSpeed = node[iPoint]->GetSoundSpeed() * Area; + Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; /*--- Adjustment for grid movement ---*/ @@ -3201,7 +3195,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Inviscid contribution ---*/ Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; if (geometry->node[iPoint]->GetDomain()) { - node[iPoint]->AddMax_Lambda_Inv(Lambda); + nodes->AddMax_Lambda_Inv(iPoint,Lambda); } } } @@ -3214,16 +3208,16 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Vol = geometry->node[iPoint]->GetVolume(); if (Vol != 0.0) { - Local_Delta_Time = node[iPoint]->GetLocalCFL()*Vol / node[iPoint]->GetMax_Lambda_Inv(); + Local_Delta_Time = nodes->GetLocalCFL(iPoint)*Vol / nodes->GetMax_Lambda_Inv(iPoint); Global_Delta_Time = min(Global_Delta_Time, Local_Delta_Time); Min_Delta_Time = min(Min_Delta_Time, Local_Delta_Time); Max_Delta_Time = max(Max_Delta_Time, Local_Delta_Time); if (Local_Delta_Time > config->GetMax_DeltaTime()) Local_Delta_Time = config->GetMax_DeltaTime(); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } else { - node[iPoint]->SetDelta_Time(0.0); + nodes->SetDelta_Time(iPoint,0.0); } } @@ -3267,8 +3261,8 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Sets the regular CFL equal to the unsteady CFL ---*/ - node[iPoint]->SetLocalCFL(config->GetUnst_CFL()); - node[iPoint]->SetDelta_Time(Global_Delta_Time); + nodes->SetLocalCFL(iPoint, config->GetUnst_CFL()); + nodes->SetDelta_Time(iPoint, Global_Delta_Time); Min_Delta_Time = Global_Delta_Time; Max_Delta_Time = Global_Delta_Time; @@ -3282,7 +3276,7 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Global_Delta_UnstTimeND = 1e30; for (iPoint = 0; iPoint < nPointDomain; iPoint++){ - Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/node[iPoint]->GetLocalCFL()); + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } #ifdef HAVE_MPI @@ -3300,8 +3294,8 @@ void CEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, if (dual_time) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { if (!implicit) { - Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), node[iPoint]->GetDelta_Time()); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), nodes->GetDelta_Time(iPoint)); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } } @@ -3325,17 +3319,17 @@ void CEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Set primitive variables w/o reconstruction ---*/ - numerics->SetPrimitive(node[iPoint]->GetPrimitive(), node[jPoint]->GetPrimitive()); + numerics->SetPrimitive(nodes->GetPrimitive(iPoint), nodes->GetPrimitive(jPoint)); /*--- Set the largest convective eigenvalue ---*/ - numerics->SetLambda(node[iPoint]->GetLambda(), node[jPoint]->GetLambda()); + numerics->SetLambda(nodes->GetLambda(iPoint), nodes->GetLambda(jPoint)); /*--- Set undivided laplacian an pressure based sensor ---*/ if (jst_scheme) { - numerics->SetUndivided_Laplacian(node[iPoint]->GetUndivided_Laplacian(), node[jPoint]->GetUndivided_Laplacian()); - numerics->SetSensor(node[iPoint]->GetSensor(), node[jPoint]->GetSensor()); + numerics->SetUndivided_Laplacian(nodes->GetUndivided_Laplacian(iPoint), nodes->GetUndivided_Laplacian(jPoint)); + numerics->SetSensor(nodes->GetSensor(iPoint), nodes->GetSensor(jPoint)); } /*--- Grid movement ---*/ @@ -3412,8 +3406,8 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Get primitive variables ---*/ - V_i = node[iPoint]->GetPrimitive(); V_j = node[jPoint]->GetPrimitive(); - S_i = node[iPoint]->GetSecondary(); S_j = node[jPoint]->GetSecondary(); + V_i = nodes->GetPrimitive(iPoint); V_j = nodes->GetPrimitive(jPoint); + S_i = nodes->GetSecondary(iPoint); S_j = nodes->GetSecondary(jPoint); /*--- High order reconstruction using MUSCL strategy ---*/ @@ -3424,11 +3418,12 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Vector_j[iDim] = 0.5*(geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim)); } - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = nodes->GetGradient_Reconstruction(jPoint); + if (limiter) { - Limiter_i = node[iPoint]->GetLimiter_Primitive(); - Limiter_j = node[jPoint]->GetLimiter_Primitive(); + Limiter_i = nodes->GetLimiter_Primitive(iPoint); + Limiter_j = nodes->GetLimiter_Primitive(jPoint); } for (iVar = 0; iVar < nPrimVarGrad; iVar++) { @@ -3517,39 +3512,39 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Primitive_i[iVar] = V_i[iVar]; Primitive_j[iVar] = V_j[iVar]; } - node[iPoint]->SetNon_Physical(true); - node[jPoint]->SetNon_Physical(true); + nodes->SetNon_Physical(iPoint, true); + nodes->SetNon_Physical(iPoint, true); Secondary_i[0] = S_i[0]; Secondary_i[1] = S_i[1]; Secondary_j[0] = S_i[0]; Secondary_j[1] = S_i[1]; } if (neg_density_i || neg_pressure_i) { for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; - node[iPoint]->SetNon_Physical(true); + nodes->SetNon_Physical(iPoint, true); Secondary_i[0] = S_i[0]; Secondary_i[1] = S_i[1]; } if (neg_density_j || neg_pressure_j) { for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; - node[jPoint]->SetNon_Physical(true); + nodes->SetNon_Physical(jPoint, true); Secondary_j[0] = S_j[0]; Secondary_j[1] = S_j[1]; } if (!neg_sound_speed && !neg_density_i && !neg_pressure_i) - node[iPoint]->SetNon_Physical(false); + nodes->SetNon_Physical(iPoint, false); if (!neg_sound_speed && !neg_density_j && !neg_pressure_j) - node[jPoint]->SetNon_Physical(false); + nodes->SetNon_Physical(jPoint, false); /* Lastly, check for existing first-order points still active from previous iterations. */ - if (node[iPoint]->GetNon_Physical()) { + if (nodes->GetNon_Physical(iPoint)) { counter_local++; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; } - if (node[jPoint]->GetNon_Physical()) { + if (nodes->GetNon_Physical(jPoint)) { counter_local++; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; @@ -3572,13 +3567,13 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain if (kind_dissipation != NO_ROELOWDISS){ - Dissipation_i = node[iPoint]->GetRoe_Dissipation(); - Dissipation_j = node[jPoint]->GetRoe_Dissipation(); + Dissipation_i = nodes->GetRoe_Dissipation(iPoint); + Dissipation_j = nodes->GetRoe_Dissipation(jPoint); numerics->SetDissipation(Dissipation_i, Dissipation_j); if (kind_dissipation == FD_DUCROS || kind_dissipation == NTS_DUCROS){ - Sensor_i = node[iPoint]->GetSensor(); - Sensor_j = node[jPoint]->GetSensor(); + Sensor_i = nodes->GetSensor(iPoint); + Sensor_j = nodes->GetSensor(jPoint); numerics->SetSensor(Sensor_i, Sensor_j); } if (kind_dissipation == NTS || kind_dissipation == NTS_DUCROS){ @@ -3605,19 +3600,12 @@ void CEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_contain Jacobian.SubtractBlock(jPoint, iPoint, Jacobian_i); Jacobian.SubtractBlock(jPoint, jPoint, Jacobian_j); } - - /*--- Roe Turkel preconditioning, set the value of beta ---*/ - - if (roe_turkel) { - node[iPoint]->SetPreconditioner_Beta(numerics->GetPrecond_Beta()); - node[jPoint]->SetPreconditioner_Beta(numerics->GetPrecond_Beta()); - } - + /*--- Set the final value of the Roe dissipation coefficient ---*/ if (kind_dissipation != NO_ROELOWDISS){ - node[iPoint]->SetRoe_Dissipation(numerics->GetDissipation()); - node[jPoint]->SetRoe_Dissipation(numerics->GetDissipation()); + nodes->SetRoe_Dissipation(iPoint,numerics->GetDissipation()); + nodes->SetRoe_Dissipation(jPoint,numerics->GetDissipation()); } } @@ -3694,8 +3682,8 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the conservative variables ---*/ - numerics->SetConservative(node[iPoint]->GetSolution(), - node[iPoint]->GetSolution()); + numerics->SetConservative(nodes->GetSolution(iPoint), + nodes->GetSolution(iPoint)); /*--- Load the volume of the dual mesh cell ---*/ numerics->SetVolume(geometry->node[iPoint]->GetVolume()); @@ -3720,8 +3708,8 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the conservative variables ---*/ - numerics->SetConservative(node[iPoint]->GetSolution(), - node[iPoint]->GetSolution()); + numerics->SetConservative(nodes->GetSolution(iPoint), + nodes->GetSolution(iPoint)); /*--- Load the volume of the dual mesh cell ---*/ numerics->SetVolume(geometry->node[iPoint]->GetVolume()); @@ -3751,7 +3739,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Set solution ---*/ - numerics->SetConservative(node[iPoint]->GetSolution(), node[iPoint]->GetSolution()); + numerics->SetConservative(nodes->GetSolution(iPoint), nodes->GetSolution(iPoint)); /*--- Set control volume ---*/ numerics->SetVolume(geometry->node[iPoint]->GetVolume()); @@ -3777,7 +3765,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Set solution ---*/ - numerics->SetConservative(node[iPoint]->GetSolution(), node[iPoint]->GetSolution()); + numerics->SetConservative(nodes->GetSolution(iPoint), nodes->GetSolution(iPoint)); /*--- Set control volume ---*/ numerics->SetVolume(geometry->node[iPoint]->GetVolume()); @@ -3804,7 +3792,7 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Get stored time spectral source term ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Source = node[iPoint]->GetHarmonicBalance_Source(iVar); + Source = nodes->GetHarmonicBalance_Source(iPoint,iVar); Residual[iVar] = Source*Volume; } @@ -3820,13 +3808,13 @@ void CEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_contain for (iPoint = 0; iPoint < nPointDomain; iPoint++) { /*--- Load the wind gust ---*/ - numerics->SetWindGust(node[iPoint]->GetWindGust(), node[iPoint]->GetWindGust()); + numerics->SetWindGust(nodes->GetWindGust(iPoint), nodes->GetWindGust(iPoint)); /*--- Load the wind gust derivatives ---*/ - numerics->SetWindGustDer(node[iPoint]->GetWindGustDer(), node[iPoint]->GetWindGustDer()); + numerics->SetWindGustDer(nodes->GetWindGustDer(iPoint), nodes->GetWindGustDer(iPoint)); /*--- Load the primitive variables ---*/ - numerics->SetPrimitive(node[iPoint]->GetPrimitive(), node[iPoint]->GetPrimitive()); + numerics->SetPrimitive(nodes->GetPrimitive(iPoint), nodes->GetPrimitive(iPoint)); /*--- Load the volume of the dual mesh cell ---*/ numerics->SetVolume(geometry->node[iPoint]->GetVolume()); @@ -3887,9 +3875,9 @@ void CEulerSolver::Source_Template(CGeometry *geometry, CSolver **solver_contain /* Next we describe how to get access to some important quanties for this method */ /* Access to all points in the current geometric mesh by saying: nPointDomain */ - /* Get the vector of conservative variables at some point iPoint = node[iPoint]->GetSolution() */ - /* Get the volume (or area in 2D) associated with iPoint = node[iPoint]->GetVolume() */ - /* Get the vector of geometric coordinates of point iPoint = node[iPoint]->GetCoord() */ + /* Get the vector of conservative variables at some point iPoint = nodes->GetSolution(iPoint) */ + /* Get the volume (or area in 2D) associated with iPoint = nodes->GetVolume(iPoint) */ + /* Get the vector of geometric coordinates of point iPoint = nodes->GetCoord(iPoint) */ } @@ -3903,7 +3891,7 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->SetLambda(0.0); + nodes->SetLambda(iPoint,0.0); } /*--- Loop interior edges ---*/ @@ -3920,8 +3908,8 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Mean Values ---*/ - Mean_ProjVel = 0.5 * (node[iPoint]->GetProjVel(Normal) + node[jPoint]->GetProjVel(Normal)); - Mean_SoundSpeed = 0.5 * (node[iPoint]->GetSoundSpeed() + node[jPoint]->GetSoundSpeed()) * Area; + Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); + Mean_SoundSpeed = 0.5 * (nodes->GetSoundSpeed(iPoint) + nodes->GetSoundSpeed(jPoint)) * Area; /*--- Adjustment for grid movement ---*/ @@ -3939,8 +3927,8 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Inviscid contribution ---*/ Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddLambda(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddLambda(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddLambda(iPoint, Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddLambda(jPoint, Lambda); } @@ -3959,8 +3947,8 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Mean Values ---*/ - Mean_ProjVel = node[iPoint]->GetProjVel(Normal); - Mean_SoundSpeed = node[iPoint]->GetSoundSpeed() * Area; + Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; /*--- Adjustment for grid movement ---*/ @@ -3976,7 +3964,7 @@ void CEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; if (geometry->node[iPoint]->GetDomain()) { - node[iPoint]->AddLambda(Lambda); + nodes->AddLambda(iPoint,Lambda); } } } @@ -4005,8 +3993,7 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) Diff = new su2double[nVar]; - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetUnd_LaplZero(); + nodes->SetUnd_LaplZero(); for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { @@ -4016,13 +4003,13 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) /*--- Solution differences ---*/ for (iVar = 0; iVar < nVar; iVar++) - Diff[iVar] = node[iPoint]->GetSolution(iVar) - node[jPoint]->GetSolution(iVar); + Diff[iVar] = nodes->GetSolution(iPoint,iVar) - nodes->GetSolution(jPoint,iVar); /*--- Correction for compressible flows which use the enthalpy ---*/ - Pressure_i = node[iPoint]->GetPressure(); - Pressure_j = node[jPoint]->GetPressure(); - Diff[nVar-1] = (node[iPoint]->GetSolution(nVar-1) + Pressure_i) - (node[jPoint]->GetSolution(nVar-1) + Pressure_j); + Pressure_i = nodes->GetPressure(iPoint); + Pressure_j = nodes->GetPressure(jPoint); + Diff[nVar-1] = (nodes->GetSolution(iPoint,nVar-1) + Pressure_i) - (nodes->GetSolution(jPoint,nVar-1) + Pressure_j); boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); @@ -4030,19 +4017,19 @@ void CEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *config) /*--- Both points inside the domain, or both in the boundary ---*/ if ((!boundary_i && !boundary_j) || (boundary_i && boundary_j)) { - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint, Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint, Diff); } /*--- iPoint inside the domain, jPoint on the boundary ---*/ if (!boundary_i && boundary_j) - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint, Diff); /*--- jPoint inside the domain, iPoint on the boundary ---*/ if (boundary_i && !boundary_j) - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint, Diff); } @@ -4082,8 +4069,8 @@ void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig * iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Pressure_i = node[iPoint]->GetPressure(); - Pressure_j = node[jPoint]->GetPressure(); + Pressure_i = nodes->GetPressure(iPoint); + Pressure_j = nodes->GetPressure(jPoint); boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); @@ -4117,7 +4104,7 @@ void CEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfig * /*--- Set pressure switch for each point ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetSensor(fabs(iPoint_UndLapl[iPoint]) / jPoint_UndLapl[iPoint]); + nodes->SetSensor(iPoint,fabs(iPoint_UndLapl[iPoint]) / jPoint_UndLapl[iPoint]); /*--- MPI parallelization ---*/ @@ -4141,12 +4128,12 @@ void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config) uixi=0.0; for(iDim = 0; iDim < nDim; iDim++){ - uixi += node[iPoint]->GetGradient_Primitive(iDim+1, iDim); + uixi += nodes->GetGradient_Primitive(iPoint,iDim+1, iDim); } /*--- Compute norm of vorticity ---*/ - Vorticity = node[iPoint]->GetVorticity(); + Vorticity = nodes->GetVorticity(iPoint); Omega = 0.0; for (iDim = 0; iDim < nDim; iDim++){ Omega += Vorticity[iDim]*Vorticity[iDim]; @@ -4161,7 +4148,7 @@ void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config) Ducros_i = pow(uixi,2.0) /(pow(uixi,2.0)+ pow(Omega,2.0) + 1e-20); } - node[iPoint]->SetSensor(Ducros_i); + nodes->SetSensor(iPoint,Ducros_i); /*---- Ducros sensor for neighbor points of iPoint to avoid lower the dissipation in regions near the shock ---*/ @@ -4173,12 +4160,12 @@ void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config) uixi=0.0; for(iDim = 0; iDim < nDim; iDim++){ - uixi += node[jPoint]->GetGradient_Primitive(iDim+1, iDim); + uixi += nodes->GetGradient_Primitive(jPoint,iDim+1, iDim); } /*--- Compute norm of vorticity ---*/ - Vorticity = node[jPoint]->GetVorticity(); + Vorticity = nodes->GetVorticity(jPoint); Omega = 0.0; for (iDim = 0; iDim < nDim; iDim++){ Omega += Vorticity[iDim]*Vorticity[iDim]; @@ -4190,7 +4177,7 @@ void CEulerSolver::SetUpwind_Ducros_Sensor(CGeometry *geometry, CConfig *config) } else if (config->GetKind_RoeLowDiss() == NTS_DUCROS){ Ducros_j = pow(uixi,2.0) /(pow(uixi,2.0)+ pow(Omega,2.0) + 1e-20); } - node[iPoint]->SetSensor(max(node[iPoint]->GetSensor(), Ducros_j)); + nodes->SetSensor(iPoint, max(nodes->GetSensor(iPoint), Ducros_j)); } } @@ -4324,7 +4311,7 @@ void CEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Pressure = node[iPoint]->GetPressure(); + Pressure = nodes->GetPressure(iPoint); CPressure[iMarker][iVertex] = (Pressure - RefPressure)*factor*RefArea; @@ -4721,7 +4708,7 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Coord = geometry->node[iPoint]->GetCoord(); - Density = node[iPoint]->GetDensity(); + Density = nodes->GetDensity(iPoint); /*--- Quadratic objective function for the near-field. This uses the infinity pressure regardless of Mach number. ---*/ @@ -4730,7 +4717,7 @@ void CEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { MassFlow = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Velocity[iDim] = node[iPoint]->GetVelocity(iDim); + Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); MomentDist[iDim] = Coord[iDim] - Origin[iDim]; MassFlow -= Normal[iDim]*Velocity[iDim]*Density; } @@ -4994,15 +4981,15 @@ void CEulerSolver::ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver_co for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Vol = (geometry->node[iPoint]->GetVolume() + geometry->node[iPoint]->GetPeriodicVolume()); - Delta = node[iPoint]->GetDelta_Time() / Vol; + Delta = nodes->GetDelta_Time(iPoint) / Vol; - Res_TruncError = node[iPoint]->GetResTruncError(); + Res_TruncError = nodes->GetResTruncError(iPoint); Residual = LinSysRes.GetBlock(iPoint); if (!adjoint) { for (iVar = 0; iVar < nVar; iVar++) { Res = Residual[iVar] + Res_TruncError[iVar]; - node[iPoint]->AddSolution(iVar, -Res*Delta*RK_AlphaCoeff); + nodes->AddSolution(iPoint,iVar, -Res*Delta*RK_AlphaCoeff); AddRes_RMS(iVar, Res*Res); AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); } @@ -5048,9 +5035,9 @@ void CEulerSolver::ClassicalRK4_Iteration(CGeometry *geometry, CSolver **solver_ Vol = (geometry->node[iPoint]->GetVolume() + geometry->node[iPoint]->GetPeriodicVolume()); - Delta = node[iPoint]->GetDelta_Time() / Vol; + Delta = nodes->GetDelta_Time(iPoint) / Vol; - Res_TruncError = node[iPoint]->GetResTruncError(); + Res_TruncError = nodes->GetResTruncError(iPoint); Residual = LinSysRes.GetBlock(iPoint); tmp_time = -1.0*RK_TimeCoeff[iRKStep]*Delta; @@ -5061,12 +5048,12 @@ void CEulerSolver::ClassicalRK4_Iteration(CGeometry *geometry, CSolver **solver_ Res = Residual[iVar] + Res_TruncError[iVar]; if (iRKStep < 3) { /* Base Solution Update */ - node[iPoint]->AddSolution(iVar, tmp_time*Res); + nodes->AddSolution(iPoint,iVar, tmp_time*Res); /* New Solution Update */ - node[iPoint]->AddSolution_New(iVar, tmp_func*Res); + nodes->AddSolution_New(iPoint,iVar, tmp_func*Res); } else { - node[iPoint]->SetSolution(iVar, node[iPoint]->GetSolution_New(iVar) + tmp_func*Res); + nodes->SetSolution(iPoint, iVar, nodes->GetSolution_New(iPoint, iVar) + tmp_func*Res); } AddRes_RMS(iVar, Res*Res); @@ -5108,14 +5095,14 @@ void CEulerSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solver for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Vol = (geometry->node[iPoint]->GetVolume() + geometry->node[iPoint]->GetPeriodicVolume()); - Delta = node[iPoint]->GetDelta_Time() / Vol; + Delta = nodes->GetDelta_Time(iPoint) / Vol; - local_Res_TruncError = node[iPoint]->GetResTruncError(); + local_Res_TruncError = nodes->GetResTruncError(iPoint); local_Residual = LinSysRes.GetBlock(iPoint); if (!adjoint) { for (iVar = 0; iVar < nVar; iVar++) { Res = local_Residual[iVar] + local_Res_TruncError[iVar]; - node[iPoint]->AddSolution(iVar, -Res*Delta); + nodes->AddSolution(iPoint,iVar, -Res*Delta); AddRes_RMS(iVar, Res*Res); AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); } @@ -5161,7 +5148,7 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver /*--- Read the residual ---*/ - local_Res_TruncError = node[iPoint]->GetResTruncError(); + local_Res_TruncError = nodes->GetResTruncError(iPoint); /*--- Read the volume ---*/ @@ -5171,8 +5158,8 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - if (node[iPoint]->GetDelta_Time() != 0.0) { - Delta = Vol / node[iPoint]->GetDelta_Time(); + if (nodes->GetDelta_Time(iPoint) != 0.0) { + Delta = Vol / nodes->GetDelta_Time(iPoint); if (roe_turkel || low_mach_prec) { SetPreconditioner(config, iPoint); for (iVar = 0; iVar < nVar; iVar ++ ) @@ -5233,7 +5220,7 @@ void CEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver if (!adjoint) { for (iPoint = 0; iPoint < nPointDomain; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddSolution(iVar, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint*nVar+iVar]); + nodes->AddSolution(iPoint, iVar, nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint*nVar+iVar]); } } } @@ -5275,7 +5262,7 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CCon if ((iVar == 0) || (iVar == nVar-1)) { const unsigned long index = iPoint*nVar + iVar; - su2double ratio = fabs(LinSysSol[index])/(node[iPoint]->GetSolution(iVar)+EPS); + su2double ratio = fabs(LinSysSol[index])/(nodes->GetSolution(iPoint, iVar)+EPS); if (ratio > allowableRatio) { localUnderRelaxation = min(allowableRatio/ratio, localUnderRelaxation); } @@ -5286,7 +5273,7 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CCon between the mean flow and the turb model. */ if (config->GetKind_Turb_Model() != NONE) - localUnderRelaxation = min(localUnderRelaxation, solver_container[TURB_SOL]->node[iPoint]->GetUnderRelaxation()); + localUnderRelaxation = min(localUnderRelaxation, solver_container[TURB_SOL]->GetNodes()->GetUnderRelaxation(iPoint)); /* Threshold the relaxation factor in the event that there is a very small value. This helps avoid catastrophic crashes due @@ -5296,7 +5283,7 @@ void CEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CCon /* Store the under-relaxation factor for this point. */ - node[iPoint]->SetUnderRelaxation(localUnderRelaxation); + nodes->SetUnderRelaxation(iPoint, localUnderRelaxation); } @@ -5315,9 +5302,8 @@ void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config PrimVar_j = new su2double [nPrimVarGrad]; /*--- Set Gradient_Primitive to zero ---*/ - - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetGradient_PrimitiveZero(nPrimVarGrad); + + nodes->SetGradient_PrimitiveZero(); /*--- Loop interior edges ---*/ @@ -5326,8 +5312,8 @@ void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config jPoint = geometry->edge[iEdge]->GetNode(1); for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - PrimVar_i[iVar] = node[iPoint]->GetPrimitive(iVar); - PrimVar_j[iVar] = node[jPoint]->GetPrimitive(iVar); + PrimVar_i[iVar] = nodes->GetPrimitive(iPoint,iVar); + PrimVar_j[iVar] = nodes->GetPrimitive(jPoint,iVar); } Normal = geometry->edge[iEdge]->GetNormal(); @@ -5336,9 +5322,9 @@ void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config for (iDim = 0; iDim < nDim; iDim++) { Partial_Res = PrimVar_Average*Normal[iDim]; if (geometry->node[iPoint]->GetDomain()) - node[iPoint]->AddGradient_Primitive(iVar, iDim, Partial_Res); + nodes->AddGradient_Primitive(iPoint,iVar, iDim, Partial_Res); if (geometry->node[jPoint]->GetDomain()) - node[jPoint]->SubtractGradient_Primitive(iVar, iDim, Partial_Res); + nodes->SubtractGradient_Primitive(jPoint,iVar, iDim, Partial_Res); } } } @@ -5353,13 +5339,13 @@ void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config if (geometry->node[iPoint]->GetDomain()) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) - PrimVar_Vertex[iVar] = node[iPoint]->GetPrimitive(iVar); + PrimVar_Vertex[iVar] = nodes->GetPrimitive(iPoint,iVar); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); for (iVar = 0; iVar < nPrimVarGrad; iVar++) for (iDim = 0; iDim < nDim; iDim++) { Partial_Res = PrimVar_Vertex[iVar]*Normal[iDim]; - node[iPoint]->SubtractGradient_Primitive(iVar, iDim, Partial_Res); + nodes->SubtractGradient_Primitive(iPoint,iVar, iDim, Partial_Res); } } } @@ -5384,11 +5370,11 @@ void CEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *config for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - Partial_Gradient = node[iPoint]->GetGradient_Primitive(iVar, iDim)/Vol; + Partial_Gradient = nodes->GetGradient_Primitive(iPoint, iVar, iDim)/Vol; if (reconstruction) - node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Partial_Gradient); + nodes->SetGradient_Reconstruction(iPoint, iVar, iDim, Partial_Gradient); else - node[iPoint]->SetGradient_Primitive(iVar, iDim, Partial_Gradient); + nodes->SetGradient_Primitive(iPoint, iVar, iDim, Partial_Gradient); } } @@ -5423,6 +5409,10 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config } else if (config->GetKind_Gradient_Method() == LEAST_SQUARES) { weighted = false; } + + /*--- Clear Rmatrix and Primitive gradient ---*/ + nodes->SetRmatrixZero(); + nodes->SetGradient_PrimitiveZero(); /*--- Loop over points of the grid ---*/ @@ -5437,7 +5427,7 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config /*--- Get primitives from CVariable ---*/ - PrimVar_i = node[iPoint]->GetPrimitive(); + PrimVar_i = nodes->GetPrimitive(iPoint); /*--- Inizialization of variables ---*/ @@ -5448,9 +5438,6 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config /*--- Clear Rmatrix, which could eventually be computed once and stored for static meshes, as well as the prim gradient. ---*/ - node[iPoint]->SetRmatrixZero(); - node[iPoint]->SetGradient_PrimitiveZero(nPrimVarGrad); - AD::StartPreacc(); AD::SetPreaccIn(PrimVar_i, nPrimVarGrad); AD::SetPreaccIn(Coord_i, nDim); @@ -5459,7 +5446,7 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Coord_j = geometry->node[jPoint]->GetCoord(); - PrimVar_j = node[jPoint]->GetPrimitive(); + PrimVar_j = nodes->GetPrimitive(jPoint); AD::SetPreaccIn(Coord_j, nDim); AD::SetPreaccIn(PrimVar_j, nPrimVarGrad); @@ -5476,28 +5463,28 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config if (weight != 0.0) { - node[iPoint]->AddRmatrix(0, 0, (Coord_j[0]-Coord_i[0])*(Coord_j[0]-Coord_i[0])/weight); - node[iPoint]->AddRmatrix(0, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[1]-Coord_i[1])/weight); - node[iPoint]->AddRmatrix(1, 1, (Coord_j[1]-Coord_i[1])*(Coord_j[1]-Coord_i[1])/weight); + nodes->AddRmatrix(iPoint,0, 0, (Coord_j[0]-Coord_i[0])*(Coord_j[0]-Coord_i[0])/weight); + nodes->AddRmatrix(iPoint,0, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[1]-Coord_i[1])/weight); + nodes->AddRmatrix(iPoint,1, 1, (Coord_j[1]-Coord_i[1])*(Coord_j[1]-Coord_i[1])/weight); if (nDim == 3) { - node[iPoint]->AddRmatrix(0, 2, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(1, 2, (Coord_j[1]-Coord_i[1])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(2, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(2, 2, (Coord_j[2]-Coord_i[2])*(Coord_j[2]-Coord_i[2])/weight); + nodes->AddRmatrix(iPoint,0, 2, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); + nodes->AddRmatrix(iPoint,1, 2, (Coord_j[1]-Coord_i[1])*(Coord_j[2]-Coord_i[2])/weight); + nodes->AddRmatrix(iPoint,2, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); + nodes->AddRmatrix(iPoint,2, 2, (Coord_j[2]-Coord_i[2])*(Coord_j[2]-Coord_i[2])/weight); } /*--- Entries of c:= transpose(A)*b ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->AddGradient_Primitive(iVar,iDim, (Coord_j[iDim]-Coord_i[iDim])*(PrimVar_j[iVar]-PrimVar_i[iVar])/weight); + nodes->AddGradient_Primitive(iPoint,iVar,iDim, (Coord_j[iDim]-Coord_i[iDim])*(PrimVar_j[iVar]-PrimVar_i[iVar])/weight); } } } } - AD::SetPreaccOut(node[iPoint]->GetRmatrix(), nDim, nDim); - AD::SetPreaccOut(node[iPoint]->GetGradient_Primitive(), nPrimVarGrad, nDim); + AD::SetPreaccOut(nodes->GetRmatrix(iPoint), nDim, nDim); + AD::SetPreaccOut(nodes->GetGradient_Primitive(iPoint), nPrimVarGrad, nDim); AD::EndPreacc(); } @@ -5521,9 +5508,9 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config r11 = 0.0; r12 = 0.0; r13 = 0.0; r22 = 0.0; r23 = 0.0; r23_a = 0.0; r23_b = 0.0; r33 = 0.0; - r11 = node[iPoint]->GetRmatrix(0,0); - r12 = node[iPoint]->GetRmatrix(0,1); - r22 = node[iPoint]->GetRmatrix(1,1); + r11 = nodes->GetRmatrix(iPoint,0,0); + r12 = nodes->GetRmatrix(iPoint,0,1); + r22 = nodes->GetRmatrix(iPoint,1,1); AD::StartPreacc(); AD::SetPreaccIn(r11); @@ -5535,10 +5522,10 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config if (r22-r12*r12 >= 0.0) r22 = sqrt(r22-r12*r12); else r22 = 0.0; if (nDim == 3) { - r13 = node[iPoint]->GetRmatrix(0,2); - r23_a = node[iPoint]->GetRmatrix(1,2); - r23_b = node[iPoint]->GetRmatrix(2,1); - r33 = node[iPoint]->GetRmatrix(2,2); + r13 = nodes->GetRmatrix(iPoint,0,2); + r23_a = nodes->GetRmatrix(iPoint,1,2); + r23_b = nodes->GetRmatrix(iPoint,2,1); + r33 = nodes->GetRmatrix(iPoint,2,2); AD::SetPreaccIn(r13); AD::SetPreaccIn(r23_a); @@ -5596,7 +5583,7 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config for (iDim = 0; iDim < nDim; iDim++) { Cvector[iVar][iDim] = 0.0; for (jDim = 0; jDim < nDim; jDim++) { - Cvector[iVar][iDim] += Smatrix[iDim][jDim]*node[iPoint]->GetGradient_Primitive(iVar, jDim); + Cvector[iVar][iDim] += Smatrix[iDim][jDim]*nodes->GetGradient_Primitive(iPoint,iVar, jDim); } } } @@ -5604,9 +5591,9 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { if (reconstruction) - node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Cvector[iVar][iDim]); + nodes->SetGradient_Reconstruction(iPoint, iVar, iDim, Cvector[iVar][iDim]); else - node[iPoint]->SetGradient_Primitive(iVar, iDim, Cvector[iVar][iDim]); + nodes->SetGradient_Primitive(iPoint, iVar, iDim, Cvector[iVar][iDim]); } } @@ -5646,7 +5633,7 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - node[iPoint]->SetLimiter_Primitive(iVar, 1.0); + nodes->SetLimiter_Primitive(iPoint,iVar, 1.0); } } @@ -5658,9 +5645,9 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - node[iPoint]->SetSolution_Max(iVar, -EPS); - node[iPoint]->SetSolution_Min(iVar, EPS); - node[iPoint]->SetLimiter_Primitive(iVar, 2.0); + nodes->SetSolution_Max(iPoint,iVar, -EPS); + nodes->SetSolution_Min(iPoint,iVar, EPS); + nodes->SetLimiter_Primitive(iPoint,iVar, 2.0); } } @@ -5675,17 +5662,17 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { /*--- Get the primitive variables ---*/ - Primitive_i = node[iPoint]->GetPrimitive(); - Primitive_j = node[jPoint]->GetPrimitive(); + Primitive_i = nodes->GetPrimitive(iPoint); + Primitive_j = nodes->GetPrimitive(jPoint); /*--- Compute the maximum, and minimum values for nodes i & j ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) { du = (Primitive_j[iVar] - Primitive_i[iVar]); - node[iPoint]->SetSolution_Min(iVar, min(node[iPoint]->GetSolution_Min(iVar), du)); - node[iPoint]->SetSolution_Max(iVar, max(node[iPoint]->GetSolution_Max(iVar), du)); - node[jPoint]->SetSolution_Min(iVar, min(node[jPoint]->GetSolution_Min(iVar), -du)); - node[jPoint]->SetSolution_Max(iVar, max(node[jPoint]->GetSolution_Max(iVar), -du)); + nodes->SetSolution_Min(iPoint, iVar, min(nodes->GetSolution_Min(iPoint, iVar), du)); + nodes->SetSolution_Max(iPoint, iVar, max(nodes->GetSolution_Max(iPoint, iVar), du)); + nodes->SetSolution_Min(jPoint, iVar, min(nodes->GetSolution_Min(jPoint, iVar), -du)); + nodes->SetSolution_Max(jPoint, iVar, max(nodes->GetSolution_Max(jPoint, iVar), -du)); } } @@ -5707,8 +5694,8 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = nodes->GetGradient_Reconstruction(jPoint); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -5719,10 +5706,10 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - AD::SetPreaccIn(node[iPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[iPoint]->GetSolution_Min(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Min(iVar)); + AD::SetPreaccIn(nodes->GetSolution_Max(iPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Min(iPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Max(jPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Min(jPoint,iVar)); /*--- Calculate the interface left gradient, delta- (dm) ---*/ @@ -5732,14 +5719,14 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { if (dm == 0.0) { limiter = 2.0; } else { - if ( dm > 0.0 ) dp = node[iPoint]->GetSolution_Max(iVar); - else dp = node[iPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = nodes->GetSolution_Max(iPoint,iVar); + else dp = nodes->GetSolution_Min(iPoint,iVar); limiter = dp/dm; } - if (limiter < node[iPoint]->GetLimiter_Primitive(iVar)) { - node[iPoint]->SetLimiter_Primitive(iVar, limiter); - AD::SetPreaccOut(node[iPoint]->GetLimiter_Primitive()[iVar]); + if (limiter < nodes->GetLimiter_Primitive(iPoint,iVar)) { + nodes->SetLimiter_Primitive(iPoint,iVar, limiter); + AD::SetPreaccOut(nodes->GetLimiter_Primitive(iPoint)[iVar]); } /*--- Calculate the interface right gradient, delta+ (dp) ---*/ @@ -5750,14 +5737,14 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { if (dm == 0.0) { limiter = 2.0; } else { - if ( dm > 0.0 ) dp = node[jPoint]->GetSolution_Max(iVar); - else dp = node[jPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = nodes->GetSolution_Max(jPoint,iVar); + else dp = nodes->GetSolution_Min(jPoint,iVar); limiter = dp/dm; } - if (limiter < node[jPoint]->GetLimiter_Primitive(iVar)) { - node[jPoint]->SetLimiter_Primitive(iVar, limiter); - AD::SetPreaccOut(node[jPoint]->GetLimiter_Primitive()[iVar]); + if (limiter < nodes->GetLimiter_Primitive(jPoint,iVar)) { + nodes->SetLimiter_Primitive(jPoint,iVar, limiter); + AD::SetPreaccOut(nodes->GetLimiter_Primitive(jPoint)[iVar]); } } @@ -5768,9 +5755,9 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - y = node[iPoint]->GetLimiter_Primitive(iVar); + y = nodes->GetLimiter_Primitive(iPoint,iVar); limiter = (y*y + 2.0*y) / (y*y + y + 2.0); - node[iPoint]->SetLimiter_Primitive(iVar, limiter); + nodes->SetLimiter_Primitive(iPoint,iVar, limiter); } } @@ -5790,7 +5777,7 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { /*--- Compute the max value and min value of the solution ---*/ - Primitive = node[0]->GetPrimitive(); + Primitive = nodes->GetPrimitive(0); for (iVar = 0; iVar < nPrimVarGrad; iVar++) { LocalMinPrimitive[iVar] = Primitive[iVar]; LocalMaxPrimitive[iVar] = Primitive[iVar]; @@ -5800,7 +5787,7 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { /*--- Get the primitive variables ---*/ - Primitive = node[iPoint]->GetPrimitive(); + Primitive = nodes->GetPrimitive(iPoint); for (iVar = 0; iVar < nPrimVarGrad; iVar++) { LocalMinPrimitive[iVar] = min (LocalMinPrimitive[iVar], Primitive[iVar]); @@ -5824,8 +5811,8 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = nodes->GetGradient_Reconstruction(jPoint); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -5836,10 +5823,10 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { AD::SetPreaccIn(Gradient_j[iVar], nDim); AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(node[iPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[iPoint]->GetSolution_Min(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Min(iVar)); + AD::SetPreaccIn(nodes->GetSolution_Max(iPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Min(iPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Max(jPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Min(jPoint,iVar)); if (config->GetKind_SlopeLimit_Flow() == VENKATAKRISHNAN_WANG) { AD::SetPreaccIn(GlobalMaxPrimitive[iVar]); @@ -5860,14 +5847,14 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { /*--- Calculate the interface right gradient, delta+ (dp) ---*/ - if ( dm > 0.0 ) dp = node[iPoint]->GetSolution_Max(iVar); - else dp = node[iPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = nodes->GetSolution_Max(iPoint,iVar); + else dp = nodes->GetSolution_Min(iPoint,iVar); limiter = ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[iPoint]->GetLimiter_Primitive(iVar)) { - node[iPoint]->SetLimiter_Primitive(iVar, limiter); - AD::SetPreaccOut(node[iPoint]->GetLimiter_Primitive()[iVar]); + if (limiter < nodes->GetLimiter_Primitive(iPoint,iVar)) { + nodes->SetLimiter_Primitive(iPoint,iVar, limiter); + AD::SetPreaccOut(nodes->GetLimiter_Primitive(iPoint)[iVar]); } /*-- Repeat for point j on the edge ---*/ @@ -5876,14 +5863,14 @@ void CEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) { for (iDim = 0; iDim < nDim; iDim++) dm += 0.5*(Coord_i[iDim]-Coord_j[iDim])*Gradient_j[iVar][iDim]; - if ( dm > 0.0 ) dp = node[jPoint]->GetSolution_Max(iVar); - else dp = node[jPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = nodes->GetSolution_Max(jPoint,iVar); + else dp = nodes->GetSolution_Min(jPoint,iVar); limiter = ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[jPoint]->GetLimiter_Primitive(iVar)) { - node[jPoint]->SetLimiter_Primitive(iVar, limiter); - AD::SetPreaccOut(node[jPoint]->GetLimiter_Primitive()[iVar]); + if (limiter < nodes->GetLimiter_Primitive(jPoint,iVar)) { + nodes->SetLimiter_Primitive(jPoint,iVar, limiter); + AD::SetPreaccOut(nodes->GetLimiter_Primitive(jPoint)[iVar]); } AD::EndPreacc(); @@ -5922,7 +5909,7 @@ void CEulerSolver::SetPreconditioner(CConfig *config, unsigned long iPoint) { su2double Mach_infty2, Mach_lim2, aux, parameter; /*--- Variables to calculate the preconditioner parameter Beta ---*/ - local_Mach = sqrt(node[iPoint]->GetVelocity2())/node[iPoint]->GetSoundSpeed(); + local_Mach = sqrt(nodes->GetVelocity2(iPoint))/nodes->GetSoundSpeed(iPoint); /*--- Weiss and Smith Preconditioning---*/ Mach_infty2 = pow(config->GetMach(),2.0); @@ -5930,12 +5917,12 @@ void CEulerSolver::SetPreconditioner(CConfig *config, unsigned long iPoint) { aux = max(pow(local_Mach,2.0),Mach_lim2); parameter = min(1.0, max(aux,Beta_max*Mach_infty2)); - U_i = node[iPoint]->GetSolution(); + U_i = nodes->GetSolution(iPoint); rho = U_i[0]; - enthalpy = node[iPoint]->GetEnthalpy(); - soundspeed = node[iPoint]->GetSoundSpeed(); - sq_vel = node[iPoint]->GetVelocity2(); + enthalpy = nodes->GetEnthalpy(iPoint); + soundspeed = nodes->GetSoundSpeed(iPoint); + sq_vel = nodes->GetVelocity2(iPoint); /*---Calculating the inverse of the preconditioning matrix that multiplies the time derivative */ LowMach_Precontioner[0][0] = 0.5*sq_vel; @@ -6060,7 +6047,7 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns if (geometry->node[iPoint]->GetDomain()) { - V_inlet = node[iPoint]->GetPrimitive(); + V_inlet = nodes->GetPrimitive(iPoint); geometry->vertex[iMarker][iVertex]->GetNormal(Vector); @@ -6130,7 +6117,7 @@ void CEulerSolver::GetPower_Properties(CGeometry *geometry, CConfig *config, uns if (geometry->node[iPoint]->GetDomain()) { - V_outlet = node[iPoint]->GetPrimitive(); + V_outlet = nodes->GetPrimitive(iPoint); geometry->vertex[iMarker][iVertex]->GetNormal(Vector); @@ -7310,7 +7297,7 @@ void CEulerSolver::SetActDisk_BCThrust(CGeometry *geometry, CSolver **solver_con /*--- Use the inlet state to compute the Pressure and Temperature jumps ---*/ if (config->GetMarker_All_KindBC(iMarker) == ACTDISK_INLET) - V_inlet = node[iPoint]->GetPrimitive(); + V_inlet = nodes->GetPrimitive(iPoint); if (config->GetMarker_All_KindBC(iMarker) == ACTDISK_OUTLET) V_inlet = GetDonorPrimVar(iMarker, iVertex); @@ -8084,27 +8071,25 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, conv_numerics->SetNormal(Normal); /*--- Get current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Set the reflected state based on the boundary node. Scalars are copied and the velocity is mirrored along the symmetry boundary, i.e. the velocity in normal direction is substracted twice. ---*/ for(iVar = 0; iVar < nPrimVar; iVar++) - V_reflected[iVar] = node[iPoint]->GetPrimitive(iVar); + V_reflected[iVar] = nodes->GetPrimitive(iPoint,iVar); /*--- Compute velocity in normal direction (ProjVelcity_i=(v*n)) und substract twice from velocity in normal direction: v_r = v - 2 (v*n)n ---*/ - ProjVelocity_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity_i += node[iPoint]->GetVelocity(iDim)*UnitNormal[iDim]; + ProjVelocity_i = nodes->GetProjVel(iPoint,UnitNormal); for (iDim = 0; iDim < nDim; iDim++) - V_reflected[iDim+1] = node[iPoint]->GetVelocity(iDim) - 2.0 * ProjVelocity_i*UnitNormal[iDim]; + V_reflected[iDim+1] = nodes->GetVelocity(iPoint,iDim) - 2.0 * ProjVelocity_i*UnitNormal[iDim]; /*--- Set Primitive and Secondary for numerics class. ---*/ conv_numerics->SetPrimitive(V_domain, V_reflected); - conv_numerics->SetSecondary(node[iPoint]->GetSecondary(), - node[iPoint]->GetSecondary()); + conv_numerics->SetSecondary(nodes->GetSecondary(iPoint), + nodes->GetSecondary(iPoint)); /*--- Compute the residual using an upwind scheme. ---*/ conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); @@ -8135,8 +8120,8 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Set the primitive and Secondary variables. ---*/ visc_numerics->SetPrimitive(V_domain, V_reflected); - visc_numerics->SetSecondary(node[iPoint]->GetSecondary(), - node[iPoint]->GetSecondary()); + visc_numerics->SetSecondary(nodes->GetSecondary(iPoint), + nodes->GetSecondary(iPoint)); /*--- For viscous Fluxes also the gradients of the primitives need to be determined. 1. The gradients of scalars are mirrored along the sym plane just as velocity for the primitives @@ -8147,7 +8132,7 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Get gradients of primitives of boundary cell ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) for (iDim = 0; iDim < nDim; iDim++) - Grad_Reflected[iVar][iDim] = node[iPoint]->GetGradient_Primitive(iVar, iDim); + Grad_Reflected[iVar][iDim] = nodes->GetGradient_Primitive(iPoint, iVar, iDim); /*--- Reflect the gradients for all scalars including the velocity components. The gradients of the velocity components are set later with the @@ -8202,12 +8187,12 @@ void CEulerSolver::BC_Sym_Plane(CGeometry *geometry, Grad_Reflected[iVar+1][iDim] = GradNormVel[iDim]*UnitNormal[iVar] + GradTangVel[iDim]*Tangential[iVar]; /*--- Set the primitive gradients of the boundary and reflected state. ---*/ - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), Grad_Reflected); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), Grad_Reflected); /*--- Turbulent kinetic energy. ---*/ if (config->GetKind_Turb_Model() == SST) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), - solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), + solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Compute and update residual. Note that the viscous shear stress tensor is computed in the following routine based upon the velocity-component gradients. ---*/ @@ -8283,7 +8268,7 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, conv_numerics->SetNormal(Normal); /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Construct solution state at infinity for compressible flow by using Riemann invariants, and then impose a weak boundary condition @@ -8314,7 +8299,7 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, Vel2_Bound += Vel_Bound[iDim]*Vel_Bound[iDim]; Vn_Bound += Vel_Bound[iDim]*UnitNormal[iDim]; } - Pressure_Bound = node[iPoint]->GetPressure(); + Pressure_Bound = nodes->GetPressure(iPoint); SoundSpeed_Bound = sqrt(Gamma*Pressure_Bound/Density_Bound); Entropy_Bound = pow(Density_Bound, Gamma)/Pressure_Bound; @@ -8442,20 +8427,15 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); - - /*--- Roe Turkel preconditioning, set the value of beta ---*/ - - if (config->GetKind_Upwind() == TURKEL) - node[iPoint]->SetPreconditioner_Beta(conv_numerics->GetPrecond_Beta()); - + /*--- Viscous residual contribution ---*/ if (viscous) { /*--- Set laminar and eddy viscosity at the infinity ---*/ - V_infty[nDim+5] = node[iPoint]->GetLaminarViscosity(); - V_infty[nDim+6] = node[iPoint]->GetEddyViscosity(); + V_infty[nDim+5] = nodes->GetLaminarViscosity(iPoint); + V_infty[nDim+6] = nodes->GetEddyViscosity(iPoint); /*--- Set the normal vector and the coordinates ---*/ @@ -8466,14 +8446,14 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(V_domain, V_infty); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), - node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), + nodes->GetGradient_Primitive(iPoint)); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), - solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), + solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ @@ -8567,20 +8547,20 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, UnitNormal[iDim] = Normal[iDim]/Area; /*--- Retrieve solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Compute the internal state u_i ---*/ Velocity2_i = 0; for (iDim=0; iDim < nDim; iDim++) { - Velocity_i[iDim] = node[iPoint]->GetVelocity(iDim); + Velocity_i[iDim] = nodes->GetVelocity(iPoint,iDim); Velocity2_i += Velocity_i[iDim]*Velocity_i[iDim]; } - Density_i = node[iPoint]->GetDensity(); + Density_i = nodes->GetDensity(iPoint); - Energy_i = node[iPoint]->GetEnergy(); + Energy_i = nodes->GetEnergy(iPoint); StaticEnergy_i = Energy_i - 0.5*Velocity2_i; FluidModel->SetTDState_rhoe(Density_i, StaticEnergy_i); @@ -8899,10 +8879,6 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); - /*--- Roe Turkel preconditioning, set the value of beta ---*/ - if (config->GetKind_Upwind() == TURKEL) - node[iPoint]->SetPreconditioner_Beta(conv_numerics->GetPrecond_Beta()); - /*--- Viscous contribution ---*/ if (viscous) { @@ -8919,7 +8895,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, /*--- Set laminar and eddy viscosity at the infinity ---*/ V_boundary[nDim+5] = FluidModel->GetLaminarViscosity(); - V_boundary[nDim+6] = node[iPoint]->GetEddyViscosity(); + V_boundary[nDim+6] = nodes->GetEddyViscosity(iPoint); V_boundary[nDim+7] = FluidModel->GetThermalConductivity(); V_boundary[nDim+8] = FluidModel->GetCp(); @@ -8931,11 +8907,11 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(V_domain, V_boundary); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); /*--- Secondary variables ---*/ - S_domain = node[iPoint]->GetSecondary(); + S_domain = nodes->GetSecondary(iPoint); /*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/ @@ -8958,7 +8934,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ @@ -9079,19 +9055,19 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain geometry->turbovertex[val_marker][iSpan][iVertex]->GetTurboNormal(turboNormal); /*--- Retrieve solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /* --- Compute the internal state u_i --- */ Velocity2_i = 0; for (iDim=0; iDim < nDim; iDim++) { - Velocity_i[iDim] = node[iPoint]->GetVelocity(iDim); + Velocity_i[iDim] = nodes->GetVelocity(iPoint,iDim); Velocity2_i += Velocity_i[iDim]*Velocity_i[iDim]; } - Density_i = node[iPoint]->GetDensity(); + Density_i = nodes->GetDensity(iPoint); - Energy_i = node[iPoint]->GetEnergy(); + Energy_i = nodes->GetEnergy(iPoint); StaticEnergy_i = Energy_i - 0.5*Velocity2_i; FluidModel->SetTDState_rhoe(Density_i, StaticEnergy_i); @@ -9405,10 +9381,6 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); - /*--- Roe Turkel preconditioning, set the value of beta ---*/ - if (config->GetKind_Upwind() == TURKEL) - node[iPoint]->SetPreconditioner_Beta(conv_numerics->GetPrecond_Beta()); - /*--- Viscous contribution ---*/ if (viscous) { @@ -9425,7 +9397,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain /*--- Set laminar and eddy viscosity at the infinity ---*/ V_boundary[nDim+5] = FluidModel->GetLaminarViscosity(); - V_boundary[nDim+6] = node[iPoint]->GetEddyViscosity(); + V_boundary[nDim+6] = nodes->GetEddyViscosity(iPoint); V_boundary[nDim+7] = FluidModel->GetThermalConductivity(); V_boundary[nDim+8] = FluidModel->GetCp(); @@ -9437,11 +9409,11 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(V_domain, V_boundary); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); /*--- Secondary variables ---*/ - S_domain = node[iPoint]->GetSecondary(); + S_domain = nodes->GetSecondary(iPoint); /*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/ @@ -9464,7 +9436,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ @@ -9553,11 +9525,11 @@ void CEulerSolver::PreprocessBC_Giles(CGeometry *geometry, CConfig *config, CNum geometry->turbovertex[iMarker][iSpan][iVertex]->GetTurboNormal(turboNormal); /*--- Compute the internal state _i ---*/ - Pressure_i = node[iPoint]->GetPressure(); - Density_i = node[iPoint]->GetDensity(); + Pressure_i = nodes->GetPressure(iPoint); + Density_i = nodes->GetDensity(iPoint); for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = node[iPoint]->GetVelocity(iDim); + Velocity_i[iDim] = nodes->GetVelocity(iPoint,iDim); } ComputeTurboVelocity(Velocity_i, turboNormal, turboVelocity, marker_flag, config->GetKind_TurboMachinery(iZone)); @@ -10002,24 +9974,24 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, geometry->turbovertex[val_marker][iSpan][iVertex]->GetTurboNormal(turboNormal); /*--- Retrieve solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Retrieve domain Secondary variables ---*/ - S_domain = node[iPoint]->GetSecondary(); + S_domain = nodes->GetSecondary(iPoint); /*--- Compute the internal state u_i ---*/ Velocity2_i = 0; for (iDim = 0; iDim < nDim; iDim++) { - Velocity_i[iDim] = node[iPoint]->GetVelocity(iDim); + Velocity_i[iDim] = nodes->GetVelocity(iPoint,iDim); Velocity2_i += Velocity_i[iDim]*Velocity_i[iDim]; } - Density_i = node[iPoint]->GetDensity(); + Density_i = nodes->GetDensity(iPoint); - Energy_i = node[iPoint]->GetEnergy(); + Energy_i = nodes->GetEnergy(iPoint); StaticEnergy_i = Energy_i - 0.5*Velocity2_i; FluidModel->SetTDState_rhoe(Density_i, StaticEnergy_i); @@ -10310,11 +10282,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, /*--- Jacobian contribution for implicit integration ---*/ if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); - - /*--- Roe Turkel preconditioning, set the value of beta ---*/ - if (config->GetKind_Upwind() == TURKEL) - node[iPoint]->SetPreconditioner_Beta(conv_numerics->GetPrecond_Beta()); - + /*--- Viscous contribution ---*/ if (viscous) { @@ -10322,7 +10290,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, /*--- Set laminar and eddy viscosity at the infinity ---*/ V_boundary[nDim+5] = FluidModel->GetLaminarViscosity(); - V_boundary[nDim+6] = node[iPoint]->GetEddyViscosity(); + V_boundary[nDim+6] = nodes->GetEddyViscosity(iPoint); V_boundary[nDim+7] = FluidModel->GetThermalConductivity(); V_boundary[nDim+8] = FluidModel->GetCp(); @@ -10334,7 +10302,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(V_domain, V_boundary); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); /*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/ @@ -10358,7 +10326,7 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ @@ -10457,7 +10425,7 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Build the fictitious intlet state based on characteristics ---*/ @@ -10596,8 +10564,8 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Get primitives from current inlet state. ---*/ for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = node[iPoint]->GetVelocity(iDim); - Pressure = node[iPoint]->GetPressure(); + Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); + Pressure = nodes->GetPressure(iPoint); SoundSpeed2 = Gamma*Pressure/V_domain[nDim+2]; /*--- Compute the acoustic Riemann invariant that is extrapolated @@ -10656,20 +10624,15 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, if (implicit) Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); - - /*--- Roe Turkel preconditioning, set the value of beta ---*/ - - if (config->GetKind_Upwind() == TURKEL) - node[iPoint]->SetPreconditioner_Beta(conv_numerics->GetPrecond_Beta()); - + // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // if (viscous) { // // /*--- Set laminar and eddy viscosity at the infinity ---*/ // -// V_inlet[nDim+5] = node[iPoint]->GetLaminarViscosity(); -// V_inlet[nDim+6] = node[iPoint]->GetEddyViscosity(); +// V_inlet[nDim+5] = nodes->GetLaminarViscosity(iPoint); +// V_inlet[nDim+6] = nodes->GetEddyViscosity(iPoint); // // /*--- Set the normal vector and the coordinates ---*/ // @@ -10679,12 +10642,12 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, // /*--- Primitive variables, and gradient ---*/ // // visc_numerics->SetPrimitive(V_domain, V_inlet); -// visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); +// visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); // // /*--- Turbulent kinetic energy ---*/ // // if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) -// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); +// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // // /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ // @@ -10751,7 +10714,7 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, UnitNormal[iDim] = Normal[iDim]/Area; /*--- Current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Build the fictitious intlet state based on characteristics ---*/ @@ -10835,19 +10798,15 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, if (implicit) { Jacobian.AddBlock(iPoint, iPoint, Jacobian_i); } - - /*--- Roe Turkel preconditioning, set the value of beta ---*/ - if (config->GetKind_Upwind() == TURKEL) - node[iPoint]->SetPreconditioner_Beta(conv_numerics->GetPrecond_Beta()); - + // /*--- Viscous contribution, commented out because serious convergence problems ---*/ // // if (viscous) { // // /*--- Set laminar and eddy viscosity at the infinity ---*/ // -// V_outlet[nDim+5] = node[iPoint]->GetLaminarViscosity(); -// V_outlet[nDim+6] = node[iPoint]->GetEddyViscosity(); +// V_outlet[nDim+5] = nodes->GetLaminarViscosity(iPoint); +// V_outlet[nDim+6] = nodes->GetEddyViscosity(iPoint); // // /*--- Set the normal vector and the coordinates ---*/ // @@ -10857,12 +10816,12 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, // /*--- Primitive variables, and gradient ---*/ // // visc_numerics->SetPrimitive(V_domain, V_outlet); -// visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); +// visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); // // /*--- Turbulent kinetic energy ---*/ // // if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) -// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); +// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // // /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ // visc_numerics->SetTauWall(-1.0, -1.0); @@ -10954,7 +10913,7 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con /*--- Current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Normal vector for this vertex (negate for outward convention) ---*/ @@ -10986,8 +10945,8 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con // // /*--- Set laminar and eddy viscosity at the infinity ---*/ // -// V_inlet[nDim+5] = node[iPoint]->GetLaminarViscosity(); -// V_inlet[nDim+6] = node[iPoint]->GetEddyViscosity(); +// V_inlet[nDim+5] = nodes->GetLaminarViscosity(iPoint); +// V_inlet[nDim+6] = nodes->GetEddyViscosity(iPoint); // // /*--- Set the normal vector and the coordinates ---*/ // @@ -10997,12 +10956,12 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con // /*--- Primitive variables, and gradient ---*/ // // visc_numerics->SetPrimitive(V_domain, V_inlet); -// visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); +// visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); // // /*--- Turbulent kinetic energy ---*/ // // if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) -// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); +// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // // /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ // @@ -11055,7 +11014,7 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co /*--- Current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Allocate the value at the outlet ---*/ @@ -11072,7 +11031,7 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co /*--- Current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Normal vector for this vertex (negate for outward convention) ---*/ @@ -11104,8 +11063,8 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co // // /*--- Set laminar and eddy viscosity at the infinity ---*/ // - // V_outlet[nDim+5] = node[iPoint]->GetLaminarViscosity(); - // V_outlet[nDim+6] = node[iPoint]->GetEddyViscosity(); + // V_outlet[nDim+5] = nodes->GetLaminarViscosity(iPoint); + // V_outlet[nDim+6] = nodes->GetEddyViscosity(iPoint); // // /*--- Set the normal vector and the coordinates ---*/ // @@ -11115,12 +11074,12 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co // /*--- Primitive variables, and gradient ---*/ // // visc_numerics->SetPrimitive(V_domain, V_outlet); - // visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); + // visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); // // /*--- Turbulent kinetic energy ---*/ // // if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // // /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ // @@ -11252,7 +11211,7 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai /*--- Current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Subsonic nacelle inflow: there is one incoming characteristic, therefore one variable can be specified (back pressure) and is used @@ -11325,8 +11284,8 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai // // /*--- Set laminar and eddy viscosity at the infinity ---*/ // -// V_inflow[nDim+5] = node[iPoint]->GetLaminarViscosity(); -// V_inflow[nDim+6] = node[iPoint]->GetEddyViscosity(); +// V_inflow[nDim+5] = nodes->GetLaminarViscosity(iPoint); +// V_inflow[nDim+6] = nodes->GetEddyViscosity(iPoint); // // /*--- Set the normal vector and the coordinates ---*/ // @@ -11336,12 +11295,12 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai // /*--- Primitive variables, and gradient ---*/ // // visc_numerics->SetPrimitive(V_domain, V_inflow); -// visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); +// visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); // // /*--- Turbulent kinetic energy ---*/ // // if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) -// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); +// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // // /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ // @@ -11438,7 +11397,7 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta /*--- Current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Subsonic inflow: there is one outgoing characteristic (u-c), therefore we can specify all but one state variable at the inlet. @@ -11578,8 +11537,8 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta // // /*--- Set laminar and eddy viscosity at the infinity ---*/ // -// V_exhaust[nDim+5] = node[iPoint]->GetLaminarViscosity(); -// V_exhaust[nDim+6] = node[iPoint]->GetEddyViscosity(); +// V_exhaust[nDim+5] = nodes->GetLaminarViscosity(iPoint); +// V_exhaust[nDim+6] = nodes->GetEddyViscosity(iPoint); // // /*--- Set the normal vector and the coordinates ---*/ // @@ -11589,12 +11548,12 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta // /*--- Primitive variables, and gradient ---*/ // // visc_numerics->SetPrimitive(V_domain, V_exhaust); -// visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); +// visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); // // /*--- Turbulent kinetic energy ---*/ // // if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) -// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); +// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // // /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ // @@ -11619,7 +11578,6 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta } - void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config) { @@ -11660,7 +11618,7 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont Point_Normal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = node[iPoint]->GetPrimitive(iVar); + PrimVar_i[iVar] = nodes->GetPrimitive(iPoint,iVar); PrimVar_j[iVar] = GetSlidingState(iMarker, iVertex, iVar, jVertex); } @@ -11673,7 +11631,7 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont conv_numerics->SetPrimitive( PrimVar_i, PrimVar_j ); if( !( config->GetKind_FluidModel() == STANDARD_AIR || config->GetKind_FluidModel() == IDEAL_GAS ) ) { - Secondary_i = node[iPoint]->GetSecondary(); + Secondary_i = nodes->GetSecondary(iPoint); P_static = PrimVar_j[nDim+1]; rho_static = PrimVar_j[nDim+2]; @@ -11738,12 +11696,12 @@ void CEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_cont /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(PrimVar_i, PrimVar_j); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ @@ -11806,7 +11764,7 @@ void CEulerSolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_c /*--- Store the solution for both points ---*/ for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = node[iPoint]->GetPrimitive(iVar); + PrimVar_i[iVar] = nodes->GetPrimitive(iPoint,iVar); PrimVar_j[iVar] = GetDonorPrimVar(val_marker, iVertex, iVar); } @@ -11867,7 +11825,7 @@ void CEulerSolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_c /*--- Store the solution for both points ---*/ for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = node[iPoint]->GetPrimitive(iVar); + PrimVar_i[iVar] = nodes->GetPrimitive(iPoint,iVar); PrimVar_j[iVar] = GetDonorPrimVar(val_marker, iVertex, iVar); } @@ -11972,12 +11930,12 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C /*--- Current solution at this boundary node and jumps values ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); Target_Press_Jump = GetActDisk_DeltaP(val_marker, iVertex); Target_Temp_Jump = GetActDisk_DeltaT(val_marker, iVertex); if (val_inlet_surface) { - V_inlet = node[iPoint]->GetPrimitive(); + V_inlet = nodes->GetPrimitive(iPoint); V_outlet = GetDonorPrimVar(val_marker, iVertex); Pressure_out = V_outlet[nDim+1]; @@ -12014,7 +11972,7 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C else { P_static = V_outlet[nDim+1] - Target_Press_Jump; T_static = V_outlet[0] - Target_Temp_Jump; } } else { - V_outlet = node[iPoint]->GetPrimitive(); + V_outlet = nodes->GetPrimitive(iPoint); V_inlet = GetDonorPrimVar(val_marker, iVertex); Pressure_out = V_outlet[nDim+1]; @@ -12277,12 +12235,12 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C // /*--- Set laminar and eddy viscosity at the infinity ---*/ // // if (val_inlet_surface) { -// V_inlet[nDim+5] = node[iPoint]->GetLaminarViscosity(); -// V_inlet[nDim+6] = node[iPoint]->GetEddyViscosity(); +// V_inlet[nDim+5] = nodes->GetLaminarViscosity(iPoint); +// V_inlet[nDim+6] = nodes->GetEddyViscosity(iPoint); // } // else { -// V_outlet[nDim+5] = node[iPoint]->GetLaminarViscosity(); -// V_outlet[nDim+6] = node[iPoint]->GetEddyViscosity(); +// V_outlet[nDim+5] = nodes->GetLaminarViscosity(iPoint); +// V_outlet[nDim+6] = nodes->GetEddyViscosity(iPoint); // } // // /*--- Set the normal vector and the coordinates ---*/ @@ -12295,12 +12253,12 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C // if (val_inlet_surface) visc_numerics->SetPrimitive(V_domain, V_inlet); // else visc_numerics->SetPrimitive(V_domain, V_outlet); // -// visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); +// visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); // // /*--- Turbulent kinetic energy ---*/ // // if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) -// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); +// visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // // /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ // @@ -12392,9 +12350,9 @@ void CEulerSolver::BC_Custom(CGeometry *geometry, condition by setting the solution values at the boundary nodes directly and setting the residual to zero at those nodes. ---*/ - node[iPoint]->SetSolution_Old(Solution); - node[iPoint]->SetSolution(Solution); - node[iPoint]->SetRes_TruncErrorZero(); + nodes->SetSolution_Old(iPoint,Solution); + nodes->SetSolution(iPoint,Solution); + nodes->SetRes_TruncErrorZero(iPoint); LinSysRes.SetBlock_Zero(iPoint); /*--- Adjust rows of the Jacobian (includes 1 in the diagonal) ---*/ @@ -12448,9 +12406,9 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co we are currently iterating on U^n+1 and that U^n & U^n-1 are fixed, previous solutions that are stored in memory. ---*/ - U_time_nM1 = node[iPoint]->GetSolution_time_n1(); - U_time_n = node[iPoint]->GetSolution_time_n(); - U_time_nP1 = node[iPoint]->GetSolution(); + U_time_nM1 = nodes->GetSolution_time_n1(iPoint); + U_time_n = nodes->GetSolution_time_n(iPoint); + U_time_nP1 = nodes->GetSolution(iPoint); /*--- CV volume at time n+1. As we are on a static mesh, the volume of the CV will remained fixed for all time steps. ---*/ @@ -12518,14 +12476,14 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co /*--- Compute the GCL component of the source term for node i ---*/ - U_time_n = node[iPoint]->GetSolution_time_n(); + U_time_n = nodes->GetSolution_time_n(iPoint); for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = U_time_n[iVar]*Residual_GCL; LinSysRes.AddBlock(iPoint, Residual); /*--- Compute the GCL component of the source term for node j ---*/ - U_time_n = node[jPoint]->GetSolution_time_n(); + U_time_n = nodes->GetSolution_time_n(jPoint); for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = U_time_n[iVar]*Residual_GCL; LinSysRes.SubtractBlock(jPoint, Residual); @@ -12557,7 +12515,7 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co /*--- Compute the GCL component of the source term for node i ---*/ - U_time_n = node[iPoint]->GetSolution_time_n(); + U_time_n = nodes->GetSolution_time_n(iPoint); for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = U_time_n[iVar]*Residual_GCL; LinSysRes.AddBlock(iPoint, Residual); @@ -12575,9 +12533,9 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co we are currently iterating on U^n+1 and that U^n & U^n-1 are fixed, previous solutions that are stored in memory. ---*/ - U_time_nM1 = node[iPoint]->GetSolution_time_n1(); - U_time_n = node[iPoint]->GetSolution_time_n(); - U_time_nP1 = node[iPoint]->GetSolution(); + U_time_nM1 = nodes->GetSolution_time_n1(iPoint); + U_time_n = nodes->GetSolution_time_n(iPoint); + U_time_nP1 = nodes->GetSolution(iPoint); /*--- CV volume at time n-1 and n+1. In the case of dynamically deforming grids, the volumes will change. On rigidly transforming grids, the @@ -12616,7 +12574,6 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co } - void CEulerSolver::ComputeVerificationError(CGeometry *geometry, CConfig *config) { @@ -12654,7 +12611,7 @@ void CEulerSolver::ComputeVerificationError(CGeometry *geometry, /* Set the pointers to the coordinates and solution of this DOF. */ const su2double *coor = geometry->node[iPoint]->GetCoord(); - su2double *solDOF = node[iPoint]->GetSolution(); + su2double *solDOF = nodes->GetSolution(iPoint); /* Get local error from the verification solution class. */ vector error(nVar,0.0); @@ -12778,7 +12735,7 @@ void CEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig index = counter*Restart_Vars[1] + skipVars; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); iPoint_Global_Local++; /*--- For dynamic meshes, read in and store the @@ -12857,12 +12814,12 @@ void CEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver[iMesh-1][FLOW_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver[iMesh-1][FLOW_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(Solution); + solver[iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint,Solution); } solver[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); @@ -12954,11 +12911,11 @@ void CEulerSolver::SetFreeStream_Solution(CConfig *config) { unsigned short iDim; for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->SetSolution(0, Density_Inf); + nodes->SetSolution(iPoint,0, Density_Inf); for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->SetSolution(iDim+1, Density_Inf*Velocity_Inf[iDim]); + nodes->SetSolution(iPoint,iDim+1, Density_Inf*Velocity_Inf[iDim]); } - node[iPoint]->SetSolution(nVar-1, Density_Inf*Energy_Inf); + nodes->SetSolution(iPoint,nVar-1, Density_Inf*Energy_Inf); } } @@ -12993,14 +12950,14 @@ void CEulerSolver::SetFreeStream_TurboSolution(CConfig *config) { ComputeBackVelocity(turboVelocity, turboNormal, cartVelocity, INFLOW, config->GetKind_TurboMachinery(iZone)); for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->SetSolution(0, Density_Inf); + nodes->SetSolution(iPoint,0, Density_Inf); for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->SetSolution(iDim+1, Density_Inf*cartVelocity[iDim]); + nodes->SetSolution(iPoint,iDim+1, Density_Inf*cartVelocity[iDim]); } - node[iPoint]->SetSolution(nVar-1, Density_Inf*Energy_Inf); + nodes->SetSolution(iPoint,nVar-1, Density_Inf*Energy_Inf); - node[iPoint]->SetPrimVar(FluidModel); - node[iPoint]->SetSecondaryVar(FluidModel); + nodes->SetPrimVar(iPoint,FluidModel); + nodes->SetSecondaryVar(iPoint,FluidModel); } delete [] turboVelocity; @@ -13056,8 +13013,8 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon if (geometry->node[iPoint]->GetDomain()){ /*--- Compute the integral fluxes for the boundaries ---*/ - Pressure = node[iPoint]->GetPressure(); - Density = node[iPoint]->GetDensity(); + Pressure = nodes->GetPressure(iPoint); + Density = nodes->GetDensity(iPoint); /*--- Normal vector for this vertex (negate for outward convention) ---*/ geometry->turbovertex[iMarker][iSpan][iVertex]->GetNormal(UnitNormal); @@ -13066,7 +13023,7 @@ void CEulerSolver::PreprocessAverage(CSolver **solver, CGeometry *geometry, CCon VelSq = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Velocity[iDim] = node[iPoint]->GetPrimitive(iDim+1); + Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); VelSq += Velocity[iDim]*Velocity[iDim]; } @@ -13277,9 +13234,9 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC iPoint = geometry->turbovertex[iMarker][iSpan][iVertex]->GetNode(); /*--- Compute the integral fluxes for the boundaries ---*/ - Pressure = node[iPoint]->GetPressure(); - Density = node[iPoint]->GetDensity(); - Enthalpy = node[iPoint]->GetEnthalpy(); + Pressure = nodes->GetPressure(iPoint); + Density = nodes->GetDensity(iPoint); + Enthalpy = nodes->GetEnthalpy(iPoint); /*--- Normal vector for this vertex (negate for outward convention) ---*/ geometry->turbovertex[iMarker][iSpan][iVertex]->GetNormal(UnitNormal); @@ -13288,7 +13245,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC su2double VelNormal = 0.0, VelSq = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Velocity[iDim] = node[iPoint]->GetPrimitive(iDim+1); + Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); VelNormal += UnitNormal[iDim]*Velocity[iDim]; VelSq += Velocity[iDim]*Velocity[iDim]; } @@ -13323,11 +13280,11 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC if(turbulent){ if(menter_sst){ - Kine = solver[TURB_SOL]->node[iPoint]->GetSolution(0); - Omega = solver[TURB_SOL]->node[iPoint]->GetSolution(1); + Kine = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); + Omega = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,1); } if(spalart_allmaras){ - Nu = solver[TURB_SOL]->node[iPoint]->GetSolution(0); + Nu = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); } TotalKine += Kine; @@ -13352,9 +13309,9 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC iPoint = geometry->turbovertex[iMarker][jSpan][iVertex]->GetNode(); /*--- Compute the integral fluxes for the boundaries ---*/ - Pressure = node[iPoint]->GetPressure(); - Density = node[iPoint]->GetDensity(); - Enthalpy = node[iPoint]->GetEnthalpy(); + Pressure = nodes->GetPressure(iPoint); + Density = nodes->GetDensity(iPoint); + Enthalpy = nodes->GetEnthalpy(iPoint); /*--- Normal vector for this vertex (negate for outward convention) ---*/ geometry->turbovertex[iMarker][jSpan][iVertex]->GetNormal(UnitNormal); @@ -13363,7 +13320,7 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC su2double VelNormal = 0.0, VelSq = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Velocity[iDim] = node[iPoint]->GetPrimitive(iDim+1); + Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); VelNormal += UnitNormal[iDim]*Velocity[iDim]; VelSq += Velocity[iDim]*Velocity[iDim]; } @@ -13398,11 +13355,11 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC if(turbulent){ if(menter_sst){ - Kine = solver[TURB_SOL]->node[iPoint]->GetSolution(0); - Omega = solver[TURB_SOL]->node[iPoint]->GetSolution(1); + Kine = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); + Omega = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,1); } if(spalart_allmaras){ - Nu = solver[TURB_SOL]->node[iPoint]->GetSolution(0); + Nu = solver[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); } TotalKine += Kine; @@ -14274,9 +14231,6 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) SetVerificationSolution(nDim, nVar, config); - /*--- Allocate the node variables ---*/ - node = new CVariable*[nPoint]; - /*--- Define some auxiliar vector related with the residual ---*/ Residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; @@ -14805,8 +14759,8 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) /*--- Initialize the solution to the far-field state everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CNSVariable(Density_Inf, Velocity_Inf, Energy_Inf, nDim, nVar, config); + nodes = new CNSVariable(Density_Inf, Velocity_Inf, Energy_Inf, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); /*--- Check that the initial solution is physical, report any non-physical nodes ---*/ @@ -14814,13 +14768,13 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) for (iPoint = 0; iPoint < nPoint; iPoint++) { - Density = node[iPoint]->GetSolution(0); + Density = nodes->GetDensity(iPoint); Velocity2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) - Velocity2 += (node[iPoint]->GetSolution(iDim+1)/Density)*(node[iPoint]->GetSolution(iDim+1)/Density); + Velocity2 += pow(nodes->GetSolution(iPoint,iDim+1)/Density,2); - StaticEnergy= node[iPoint]->GetSolution(nDim+1)/Density - 0.5*Velocity2; + StaticEnergy= nodes->GetEnergy(iPoint) - 0.5*Velocity2; FluidModel->SetTDState_rhoe(Density, StaticEnergy); Pressure= FluidModel->GetPressure(); @@ -14833,8 +14787,8 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) for (iDim = 0; iDim < nDim; iDim++) Solution[iDim+1] = Velocity_Inf[iDim]*Density_Inf; Solution[nDim+1] = Energy_Inf*Density_Inf; - node[iPoint]->SetSolution(Solution); - node[iPoint]->SetSolution_Old(Solution); + nodes->SetSolution(iPoint,Solution); + nodes->SetSolution_Old(iPoint,Solution); counter_local++; } @@ -14899,7 +14853,7 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->SetLocalCFL(CFL); + nodes->SetLocalCFL(iPoint, CFL); } Min_CFL_Local = CFL; Max_CFL_Local = CFL; @@ -15077,14 +15031,13 @@ void CNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, C /*--- Evaluate the vorticity and strain rate magnitude ---*/ + solver_container[FLOW_SOL]->GetNodes()->SetVorticity_StrainMag(); + StrainMag_Max = 0.0; Omega_Max = 0.0; for (iPoint = 0; iPoint < nPoint; iPoint++) { - solver_container[FLOW_SOL]->node[iPoint]->SetVorticity(); - solver_container[FLOW_SOL]->node[iPoint]->SetStrainMag(); - - StrainMag = solver_container[FLOW_SOL]->node[iPoint]->GetStrainMag(); - Vorticity = solver_container[FLOW_SOL]->node[iPoint]->GetVorticity(); + StrainMag = solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint); + Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); Omega = sqrt(Vorticity[0]*Vorticity[0]+ Vorticity[1]*Vorticity[1]+ Vorticity[2]*Vorticity[2]); StrainMag_Max = max(StrainMag_Max, StrainMag); @@ -15139,18 +15092,18 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon /*--- Retrieve the value of the kinetic energy (if need it) ---*/ if (turb_model != NONE) { - eddy_visc = solver_container[TURB_SOL]->node[iPoint]->GetmuT(); - if (tkeNeeded) turb_ke = solver_container[TURB_SOL]->node[iPoint]->GetSolution(0); + eddy_visc = solver_container[TURB_SOL]->GetNodes()->GetmuT(iPoint); + if (tkeNeeded) turb_ke = solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); if (config->GetKind_HybridRANSLES() != NO_HYBRIDRANSLES){ - DES_LengthScale = solver_container[TURB_SOL]->node[iPoint]->GetDES_LengthScale(); + DES_LengthScale = solver_container[TURB_SOL]->GetNodes()->GetDES_LengthScale(iPoint); } } /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c, lamMu, eddyMu, ThCond, Cp) ---*/ - physical = node[iPoint]->SetPrimVar(eddy_visc, turb_ke, FluidModel); - node[iPoint]->SetSecondaryVar(FluidModel); + physical = static_cast(nodes)->SetPrimVar(iPoint,eddy_visc, turb_ke, FluidModel); + nodes->SetSecondaryVar(iPoint,FluidModel); /* Check for non-realizable states for reporting. */ @@ -15158,7 +15111,7 @@ unsigned long CNSSolver::SetPrimitive_Variables(CSolver **solver_container, CCon /*--- Set the DES length scale ---*/ - node[iPoint]->SetDES_LengthScale(DES_LengthScale); + nodes->SetDES_LengthScale(iPoint,DES_LengthScale); /*--- Initialize the convective, source and viscous residual vector ---*/ @@ -15186,8 +15139,8 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed and viscosity ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->SetMax_Lambda_Inv(0.0); - node[iPoint]->SetMax_Lambda_Visc(0.0); + nodes->SetMax_Lambda_Inv(iPoint,0.0); + nodes->SetMax_Lambda_Visc(iPoint,0.0); } /*--- Loop interior edges ---*/ @@ -15204,8 +15157,8 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC /*--- Mean Values ---*/ - Mean_ProjVel = 0.5 * (node[iPoint]->GetProjVel(Normal) + node[jPoint]->GetProjVel(Normal)); - Mean_SoundSpeed = 0.5 * (node[iPoint]->GetSoundSpeed() + node[jPoint]->GetSoundSpeed()) * Area; + Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); + Mean_SoundSpeed = 0.5 * (nodes->GetSoundSpeed(iPoint) + nodes->GetSoundSpeed(jPoint)) * Area; /*--- Adjustment for grid movement ---*/ @@ -15223,22 +15176,22 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC /*--- Inviscid contribution ---*/ Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed ; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Inv(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddMax_Lambda_Inv(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(iPoint,Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(jPoint,Lambda); /*--- Viscous contribution ---*/ - Mean_LaminarVisc = 0.5*(node[iPoint]->GetLaminarViscosity() + node[jPoint]->GetLaminarViscosity()); - Mean_EddyVisc = 0.5*(node[iPoint]->GetEddyViscosity() + node[jPoint]->GetEddyViscosity()); - Mean_Density = 0.5*(node[iPoint]->GetSolution(0) + node[jPoint]->GetSolution(0)); + Mean_LaminarVisc = 0.5*(nodes->GetLaminarViscosity(iPoint) + nodes->GetLaminarViscosity(jPoint)); + Mean_EddyVisc = 0.5*(nodes->GetEddyViscosity(iPoint) + nodes->GetEddyViscosity(jPoint)); + Mean_Density = 0.5*(nodes->GetDensity(iPoint) + nodes->GetDensity(jPoint)); Lambda_1 = (4.0/3.0)*(Mean_LaminarVisc + Mean_EddyVisc); //TODO (REAL_GAS) removing Gamma it cannot work with FLUIDPROP Lambda_2 = (1.0 + (Prandtl_Lam/Prandtl_Turb)*(Mean_EddyVisc/Mean_LaminarVisc))*(Gamma*Mean_LaminarVisc/Prandtl_Lam); Lambda = (Lambda_1 + Lambda_2)*Area*Area/Mean_Density; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Visc(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddMax_Lambda_Visc(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(iPoint, Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(jPoint, Lambda); } @@ -15257,8 +15210,8 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC /*--- Mean Values ---*/ - Mean_ProjVel = node[iPoint]->GetProjVel(Normal); - Mean_SoundSpeed = node[iPoint]->GetSoundSpeed() * Area; + Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + Mean_SoundSpeed = nodes->GetSoundSpeed(iPoint) * Area; /*--- Adjustment for grid movement ---*/ @@ -15274,20 +15227,20 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; if (geometry->node[iPoint]->GetDomain()) { - node[iPoint]->AddMax_Lambda_Inv(Lambda); + nodes->AddMax_Lambda_Inv(iPoint,Lambda); } /*--- Viscous contribution ---*/ - Mean_LaminarVisc = node[iPoint]->GetLaminarViscosity(); - Mean_EddyVisc = node[iPoint]->GetEddyViscosity(); - Mean_Density = node[iPoint]->GetSolution(0); + Mean_LaminarVisc = nodes->GetLaminarViscosity(iPoint); + Mean_EddyVisc = nodes->GetEddyViscosity(iPoint); + Mean_Density = nodes->GetDensity(iPoint); Lambda_1 = (4.0/3.0)*(Mean_LaminarVisc + Mean_EddyVisc); Lambda_2 = (1.0 + (Prandtl_Lam/Prandtl_Turb)*(Mean_EddyVisc/Mean_LaminarVisc))*(Gamma*Mean_LaminarVisc/Prandtl_Lam); Lambda = (Lambda_1 + Lambda_2)*Area*Area/Mean_Density; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Visc(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(iPoint, Lambda); } } @@ -15301,18 +15254,18 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC Vol = geometry->node[iPoint]->GetVolume(); if (Vol != 0.0) { - Local_Delta_Time = node[iPoint]->GetLocalCFL()*Vol / node[iPoint]->GetMax_Lambda_Inv(); - Local_Delta_Time_Visc = node[iPoint]->GetLocalCFL()*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); + Local_Delta_Time = nodes->GetLocalCFL(iPoint)*Vol / nodes->GetMax_Lambda_Inv(iPoint); + Local_Delta_Time_Visc = nodes->GetLocalCFL(iPoint)*K_v*Vol*Vol/ nodes->GetMax_Lambda_Visc(iPoint); Local_Delta_Time = min(Local_Delta_Time, Local_Delta_Time_Visc); Global_Delta_Time = min(Global_Delta_Time, Local_Delta_Time); Min_Delta_Time = min(Min_Delta_Time, Local_Delta_Time); Max_Delta_Time = max(Max_Delta_Time, Local_Delta_Time); if (Local_Delta_Time > config->GetMax_DeltaTime()) Local_Delta_Time = config->GetMax_DeltaTime(); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } else { - node[iPoint]->SetDelta_Time(0.0); + nodes->SetDelta_Time(iPoint,0.0); } } @@ -15355,8 +15308,8 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC /*--- Sets the regular CFL equal to the unsteady CFL ---*/ - node[iPoint]->SetLocalCFL(config->GetUnst_CFL()); - node[iPoint]->SetDelta_Time(Global_Delta_Time); + nodes->SetLocalCFL(iPoint, config->GetUnst_CFL()); + nodes->SetDelta_Time(iPoint, Global_Delta_Time); Min_Delta_Time = Global_Delta_Time; Max_Delta_Time = Global_Delta_Time; @@ -15369,7 +15322,7 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC Global_Delta_UnstTimeND = 1e30; for (iPoint = 0; iPoint < nPointDomain; iPoint++){ - Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/node[iPoint]->GetLocalCFL()); + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } #ifdef HAVE_MPI @@ -15386,8 +15339,8 @@ void CNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, CC if (dual_time) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { if (!implicit) { - Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), node[iPoint]->GetDelta_Time()); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), nodes->GetDelta_Time(iPoint)); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } } @@ -15411,22 +15364,22 @@ void CNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_container /*--- Primitive and secondary variables ---*/ - numerics->SetPrimitive(node[iPoint]->GetPrimitive(), node[jPoint]->GetPrimitive()); - numerics->SetSecondary(node[iPoint]->GetSecondary(), node[jPoint]->GetSecondary()); + numerics->SetPrimitive(nodes->GetPrimitive(iPoint), nodes->GetPrimitive(jPoint)); + numerics->SetSecondary(nodes->GetSecondary(iPoint), nodes->GetSecondary(jPoint)); /*--- Gradient and limiters ---*/ - numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[jPoint]->GetGradient_Primitive()); + numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(jPoint)); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), - solver_container[TURB_SOL]->node[jPoint]->GetSolution(0)); + numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), + solver_container[TURB_SOL]->GetNodes()->GetSolution(jPoint,0)); /*--- Wall shear stress values (wall functions) ---*/ - numerics->SetTauWall(node[iPoint]->GetTauWall(), node[iPoint]->GetTauWall()); + numerics->SetTauWall(nodes->GetTauWall(iPoint), nodes->GetTauWall(iPoint)); /*--- Compute and update residual ---*/ @@ -15568,13 +15521,13 @@ void CNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = nodes->GetGradient_Primitive(iPoint,iDim+1, jDim); } - Grad_Temp[iDim] = node[iPoint]->GetGradient_Primitive(0, iDim); + Grad_Temp[iDim] = nodes->GetGradient_Primitive(iPoint,0, iDim); } - Viscosity = node[iPoint]->GetLaminarViscosity(); - Density = node[iPoint]->GetDensity(); + Viscosity = nodes->GetLaminarViscosity(iPoint); + Density = nodes->GetDensity(iPoint); Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); @@ -16156,11 +16109,11 @@ void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container condition (Dirichlet). Fix the velocity and remove any contribution to the residual at this node. ---*/ - node[iPoint]->SetVelocity_Old(Vector); + nodes->SetVelocity_Old(iPoint,Vector); for (iDim = 0; iDim < nDim; iDim++) LinSysRes.SetBlock_Zero(iPoint, iDim+1); - node[iPoint]->SetVel_ResTruncError_Zero(); + nodes->SetVel_ResTruncError_Zero(iPoint); /*--- Apply a weak boundary condition for the energy equation. Compute the residual due to the prescribed heat flux. ---*/ @@ -16181,15 +16134,15 @@ void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container /*--- Retrieve other primitive quantities and viscosities ---*/ - Density = node[iPoint]->GetSolution(0); - Pressure = node[iPoint]->GetPressure(); - laminar_viscosity = node[iPoint]->GetLaminarViscosity(); - eddy_viscosity = node[iPoint]->GetEddyViscosity(); + Density = nodes->GetDensity(iPoint); + Pressure = nodes->GetPressure(iPoint); + laminar_viscosity = nodes->GetLaminarViscosity(iPoint); + eddy_viscosity = nodes->GetEddyViscosity(iPoint); total_viscosity = laminar_viscosity + eddy_viscosity; for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = nodes->GetGradient_Primitive(iPoint,iDim+1, jDim); } } @@ -16420,25 +16373,25 @@ void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_contain /*--- Set the residual, truncation error and velocity value on the boundary ---*/ - node[iPoint]->SetVelocity_Old(Vector); + nodes->SetVelocity_Old(iPoint,Vector); for (iDim = 0; iDim < nDim; iDim++) LinSysRes.SetBlock_Zero(iPoint, iDim+1); - node[iPoint]->SetVel_ResTruncError_Zero(); + nodes->SetVel_ResTruncError_Zero(iPoint); /*--- Compute the normal gradient in temperature using Twall ---*/ - dTdn = -(node[Point_Normal]->GetPrimitive(0) - Twall)/dist_ij; + dTdn = -(nodes->GetTemperature(Point_Normal) - Twall)/dist_ij; /*--- Get transport coefficients ---*/ - laminar_viscosity = node[iPoint]->GetLaminarViscosity(); - eddy_viscosity = node[iPoint]->GetEddyViscosity(); + laminar_viscosity = nodes->GetLaminarViscosity(iPoint); + eddy_viscosity = nodes->GetEddyViscosity(iPoint); thermal_conductivity = Cp * ( laminar_viscosity/Prandtl_Lam + eddy_viscosity/Prandtl_Turb); // work in progress on real-gases... - //thermal_conductivity = node[iPoint]->GetThermalConductivity(); - //Cp = node[iPoint]->GetSpecificHeatCp(); + //thermal_conductivity = nodes->GetThermalConductivity(iPoint); + //Cp = nodes->GetSpecificHeatCp(iPoint); //thermal_conductivity += Cp*eddy_viscosity/Prandtl_Turb; /*--- Apply a weak boundary condition for the energy equation. @@ -16456,10 +16409,10 @@ void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_contain /*--- Calculate useful quantities ---*/ - Density = node[iPoint]->GetPrimitive(nDim+2); + Density = nodes->GetDensity(iPoint); Vel2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) - Vel2 += node[iPoint]->GetPrimitive(iDim+1) * node[iPoint]->GetPrimitive(iDim+1); + Vel2 += pow(nodes->GetVelocity(iPoint,iDim),2); dTdrho = 1.0/Density * ( -Twall + (Gamma-1.0)/Gas_Constant*(Vel2/2.0) ); /*--- Enforce the no-slip boundary condition in a strong way ---*/ @@ -16494,16 +16447,16 @@ void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_contain /*--- Retrieve other primitive quantities and viscosities ---*/ - Density = node[iPoint]->GetSolution(0); - Pressure = node[iPoint]->GetPressure(); - laminar_viscosity = node[iPoint]->GetLaminarViscosity(); - eddy_viscosity = node[iPoint]->GetEddyViscosity(); + Density = nodes->GetDensity(iPoint); + Pressure = nodes->GetPressure(iPoint); + laminar_viscosity = nodes->GetLaminarViscosity(iPoint); + eddy_viscosity = nodes->GetEddyViscosity(iPoint); total_viscosity = laminar_viscosity + eddy_viscosity; for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = nodes->GetGradient_Primitive(iPoint,iDim+1, jDim); } } @@ -16636,13 +16589,13 @@ void CNSSolver::SetRoe_Dissipation(CGeometry *geometry, CConfig *config){ wall_distance = geometry->node[iPoint]->GetWall_Distance(); - node[iPoint]->SetRoe_Dissipation_FD(wall_distance); + nodes->SetRoe_Dissipation_FD(iPoint,wall_distance); } else if (kind_roe_dissipation == NTS || kind_roe_dissipation == NTS_DUCROS) { const su2double delta = geometry->node[iPoint]->GetMaxLength(); assert(delta > 0); // Delta must be initialized and non-negative - node[iPoint]->SetRoe_Dissipation_NTS(delta, config->GetConst_DES()); + nodes->SetRoe_Dissipation_NTS(iPoint,delta, config->GetConst_DES()); } } } @@ -16734,26 +16687,26 @@ void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver /*--- Set the residual, truncation error and velocity value on the boundary ---*/ - node[iPoint]->SetVelocity_Old(Vector); + nodes->SetVelocity_Old(iPoint,Vector); for (iDim = 0; iDim < nDim; iDim++) LinSysRes.SetBlock_Zero(iPoint, iDim+1); - node[iPoint]->SetVel_ResTruncError_Zero(); + nodes->SetVel_ResTruncError_Zero(iPoint); /*--- Get transport coefficients ---*/ - laminar_viscosity = node[iPoint]->GetLaminarViscosity(); - eddy_viscosity = node[iPoint]->GetEddyViscosity(); + laminar_viscosity = nodes->GetLaminarViscosity(iPoint); + eddy_viscosity = nodes->GetEddyViscosity(iPoint); thermal_conductivity = Cp * ( laminar_viscosity/Prandtl_Lam + eddy_viscosity/Prandtl_Turb); // work in progress on real-gases... - //thermal_conductivity = node[iPoint]->GetThermalConductivity(); - //Cp = node[iPoint]->GetSpecificHeatCp(); + //thermal_conductivity = nodes->GetThermalConductivity(iPoint); + //Cp = nodes->GetSpecificHeatCp(iPoint); //thermal_conductivity += Cp*eddy_viscosity/Prandtl_Turb; /*--- Compute the normal gradient in temperature using Twall ---*/ - There = node[Point_Normal]->GetPrimitive(0); + There = nodes->GetTemperature(Point_Normal); Tconjugate = GetConjugateHeatVariable(val_marker, iVertex, 0); HF_FactorHere = thermal_conductivity*config->GetViscosity_Ref()/dist_ij; @@ -16764,7 +16717,7 @@ void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver // this will be changed soon... Twall = GetConjugateHeatVariable(val_marker, iVertex, 0); - dTdn = -(node[Point_Normal]->GetPrimitive(0) - Twall)/dist_ij; + dTdn = -(There - Twall)/dist_ij; /*--- Apply a weak boundary condition for the energy equation. Compute the residual due to the prescribed heat flux. ---*/ @@ -16781,10 +16734,10 @@ void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver /*--- Calculate useful quantities ---*/ - Density = node[iPoint]->GetPrimitive(nDim+2); + Density = nodes->GetDensity(iPoint); Vel2 = 0.0; for (iDim = 0; iDim < nDim; iDim++) - Vel2 += node[iPoint]->GetPrimitive(iDim+1) * node[iPoint]->GetPrimitive(iDim+1); + Vel2 += pow(nodes->GetVelocity(iPoint,iDim),2); dTdrho = 1.0/Density * ( -Twall + (Gamma-1.0)/Gas_Constant*(Vel2/2.0) ); /*--- Enforce the no-slip boundary condition in a strong way ---*/ @@ -16819,16 +16772,16 @@ void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver /*--- Retrieve other primitive quantities and viscosities ---*/ - Density = node[iPoint]->GetSolution(0); - Pressure = node[iPoint]->GetPressure(); - laminar_viscosity = node[iPoint]->GetLaminarViscosity(); - eddy_viscosity = node[iPoint]->GetEddyViscosity(); + Density = nodes->GetDensity(iPoint); + Pressure = nodes->GetPressure(iPoint); + laminar_viscosity = nodes->GetLaminarViscosity(iPoint); + eddy_viscosity = nodes->GetEddyViscosity(iPoint); total_viscosity = laminar_viscosity + eddy_viscosity; for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = nodes->GetGradient_Primitive(iPoint,iDim+1, jDim); } } @@ -16956,7 +16909,7 @@ void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, C su2double Area, div_vel, UnitNormal[3], *Normal; su2double **grad_primvar, tau[3][3]; - su2double Vel[3], VelNormal, VelTang[3], VelTangMod, VelInfMod, WallDist[3], WallDistMod; + su2double Vel[3] = {0.0, 0.0, 0.0}, VelNormal, VelTang[3], VelTangMod, VelInfMod, WallDist[3], WallDistMod; su2double T_Normal, P_Normal; su2double Density_Wall, T_Wall, P_Wall, Lam_Visc_Wall, Tau_Wall = 0.0, Tau_Wall_Old = 0.0; su2double *Coord, *Coord_Normal; @@ -17032,9 +16985,9 @@ void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, C (normal) interior point. ---*/ for (iDim = 0; iDim < nDim; iDim++) - Vel[iDim] = node[Point_Normal]->GetVelocity(iDim); - P_Normal = node[Point_Normal]->GetPressure(); - T_Normal = node[Point_Normal]->GetTemperature(); + Vel[iDim] = nodes->GetVelocity(Point_Normal,iDim); + P_Normal = nodes->GetPressure(Point_Normal); + T_Normal = nodes->GetTemperature(Point_Normal); /*--- Compute the wall-parallel velocity at first point off the wall ---*/ @@ -17077,8 +17030,8 @@ void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, C /*--- Compute the shear stress at the wall in the regular fashion by using the stress tensor on the surface ---*/ - Lam_Visc_Wall = node[iPoint]->GetLaminarViscosity(); - grad_primvar = node[iPoint]->GetGradient_Primitive(); + Lam_Visc_Wall = nodes->GetLaminarViscosity(iPoint); + grad_primvar = nodes->GetGradient_Primitive(iPoint); div_vel = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -17166,7 +17119,7 @@ void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, C /*--- Store this value for the wall shear stress at the node. ---*/ - node[iPoint]->SetTauWall(Tau_Wall); + nodes->SetTauWall(iPoint,Tau_Wall); } diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index 2d68000a3fe5..d5a2ac0e38e0 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -97,7 +97,8 @@ CIncEulerSolver::CIncEulerSolver(void) : CSolver() { SlidingState = NULL; SlidingStateNodes = NULL; - + + nodes = nullptr; } CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CSolver() { @@ -253,10 +254,6 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned SetVerificationSolution(nDim, nVar, config); - /*--- Allocate the node variables ---*/ - - node = new CVariable*[nPoint]; - /*--- Define some auxiliary vectors related to the residual ---*/ Residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; @@ -578,8 +575,8 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned /*--- Initialize the solution to the far-field state everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CIncEulerVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nDim, nVar, config); + nodes = new CIncEulerVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); /*--- Initialize the BGS residuals in FSI problems. ---*/ if (fsi || multizone){ @@ -628,7 +625,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->SetLocalCFL(CFL); + nodes->SetLocalCFL(iPoint, CFL); } Min_CFL_Local = CFL; Max_CFL_Local = CFL; @@ -823,6 +820,8 @@ CIncEulerSolver::~CIncEulerSolver(void) { if (Cauchy_Serie != NULL) delete [] Cauchy_Serie; if (FluidModel != NULL) delete FluidModel; + + if (nodes != nullptr) delete nodes; } void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMesh) { @@ -1436,7 +1435,7 @@ void CIncEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve /* Set the pointers to the coordinates and solution of this DOF. */ const su2double *coor = geometry[iMesh]->node[iPoint]->GetCoord(); - su2double *solDOF = solver_container[iMesh][FLOW_SOL]->node[iPoint]->GetSolution(); + su2double *solDOF = solver_container[iMesh][FLOW_SOL]->GetNodes()->GetSolution(iPoint); /* Set the solution in this DOF to the initial condition provided by the verification solution class. This can be the exact solution, @@ -1459,12 +1458,12 @@ void CIncEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver_container[iMesh-1][FLOW_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver_container[iMesh-1][FLOW_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver_container[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(Solution); + solver_container[iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint,Solution); } solver_container[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); solver_container[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); @@ -1484,12 +1483,12 @@ void CIncEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver_container[iMesh-1][TURB_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver_container[iMesh-1][TURB_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar_Turb; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver_container[iMesh][TURB_SOL]->node[iPoint]->SetSolution(Solution); + solver_container[iMesh][TURB_SOL]->GetNodes()->SetSolution(iPoint,Solution); } solver_container[iMesh][TURB_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION_EDDY); solver_container[iMesh][TURB_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION_EDDY); @@ -1508,13 +1507,11 @@ void CIncEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve for a 1st-order restart or when simply intitializing to freestream. ---*/ for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { - solver_container[iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n1(); - if (rans) { - solver_container[iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(); - solver_container[iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n1(); - } + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n1(); + if (rans) { + solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); + solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(); } } @@ -1532,11 +1529,9 @@ void CIncEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solve /*--- Push back this new solution to time level N. ---*/ for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - for (iPoint = 0; iPoint < geometry[iMesh]->GetnPoint(); iPoint++) { - solver_container[iMesh][FLOW_SOL]->node[iPoint]->Set_Solution_time_n(); - if (rans) { - solver_container[iMesh][TURB_SOL]->node[iPoint]->Set_Solution_time_n(); - } + solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); + if (rans) { + solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); } } } @@ -1634,7 +1629,8 @@ unsigned long CIncEulerSolver::SetPrimitive_Variables(CSolver **solver_container /*--- Incompressible flow, primitive variables ---*/ - physical = node[iPoint]->SetPrimVar(FluidModel); + physical = nodes->SetPrimVar(iPoint,FluidModel); + /* Check for non-realizable states for reporting. */ @@ -1669,7 +1665,7 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetMax_Lambda_Inv(0.0); + nodes->SetMax_Lambda_Inv(iPoint,0.0); /*--- Loop interior edges ---*/ @@ -1688,8 +1684,8 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain /*--- Mean Values ---*/ - Mean_ProjVel = 0.5 * (node[iPoint]->GetProjVel(Normal) + node[jPoint]->GetProjVel(Normal)); - Mean_BetaInc2 = 0.5 * (node[iPoint]->GetBetaInc2() + node[jPoint]->GetBetaInc2()); + Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); + Mean_BetaInc2 = 0.5 * (nodes->GetBetaInc2(iPoint) + nodes->GetBetaInc2(jPoint)); Mean_SoundSpeed = sqrt(Mean_BetaInc2*Area*Area); /*--- Adjustment for grid movement ---*/ @@ -1708,8 +1704,8 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain /*--- Inviscid contribution ---*/ Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Inv(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddMax_Lambda_Inv(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(iPoint,Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(jPoint,Lambda); } @@ -1731,8 +1727,8 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain /*--- Mean Values ---*/ - Mean_ProjVel = node[iPoint]->GetProjVel(Normal); - Mean_BetaInc2 = node[iPoint]->GetBetaInc2(); + Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + Mean_BetaInc2 = nodes->GetBetaInc2(iPoint); Mean_SoundSpeed = sqrt(Mean_BetaInc2*Area*Area); /*--- Adjustment for grid movement ---*/ @@ -1749,7 +1745,7 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; if (geometry->node[iPoint]->GetDomain()) { - node[iPoint]->AddMax_Lambda_Inv(Lambda); + nodes->AddMax_Lambda_Inv(iPoint,Lambda); } } @@ -1764,16 +1760,16 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain Vol = geometry->node[iPoint]->GetVolume(); if (Vol != 0.0) { - Local_Delta_Time = node[iPoint]->GetLocalCFL()*Vol / node[iPoint]->GetMax_Lambda_Inv(); + Local_Delta_Time = nodes->GetLocalCFL(iPoint)*Vol / nodes->GetMax_Lambda_Inv(iPoint); Global_Delta_Time = min(Global_Delta_Time, Local_Delta_Time); Min_Delta_Time = min(Min_Delta_Time, Local_Delta_Time); Max_Delta_Time = max(Max_Delta_Time, Local_Delta_Time); if (Local_Delta_Time > config->GetMax_DeltaTime()) Local_Delta_Time = config->GetMax_DeltaTime(); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } else { - node[iPoint]->SetDelta_Time(0.0); + nodes->SetDelta_Time(iPoint,0.0); } } @@ -1817,11 +1813,11 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain /*--- Sets the regular CFL equal to the unsteady CFL ---*/ - node[iPoint]->SetLocalCFL(config->GetUnst_CFL()); - node[iPoint]->SetDelta_Time(Global_Delta_Time); + nodes->SetLocalCFL(iPoint, config->GetUnst_CFL()); + nodes->SetDelta_Time(iPoint, Global_Delta_Time); Min_Delta_Time = Global_Delta_Time; Max_Delta_Time = Global_Delta_Time; - + } } @@ -1832,7 +1828,7 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain Global_Delta_UnstTimeND = 1e30; for (iPoint = 0; iPoint < nPointDomain; iPoint++){ - Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/node[iPoint]->GetLocalCFL()); + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } #ifdef HAVE_MPI @@ -1850,8 +1846,8 @@ void CIncEulerSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_contain if (dual_time) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { if (!implicit) { - Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), node[iPoint]->GetDelta_Time()); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), nodes->GetDelta_Time(iPoint)); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } } @@ -1875,17 +1871,17 @@ void CIncEulerSolver::Centered_Residual(CGeometry *geometry, CSolver **solver_co /*--- Set primitive variables w/o reconstruction ---*/ - numerics->SetPrimitive(node[iPoint]->GetPrimitive(), node[jPoint]->GetPrimitive()); + numerics->SetPrimitive(nodes->GetPrimitive(iPoint), nodes->GetPrimitive(jPoint)); /*--- Set the largest convective eigenvalue ---*/ - numerics->SetLambda(node[iPoint]->GetLambda(), node[jPoint]->GetLambda()); + numerics->SetLambda(nodes->GetLambda(iPoint), nodes->GetLambda(jPoint)); /*--- Set undivided laplacian and pressure-based sensor ---*/ if (jst_scheme) { - numerics->SetUndivided_Laplacian(node[iPoint]->GetUndivided_Laplacian(), node[jPoint]->GetUndivided_Laplacian()); - numerics->SetSensor(node[iPoint]->GetSensor(), node[jPoint]->GetSensor()); + numerics->SetUndivided_Laplacian(nodes->GetUndivided_Laplacian(iPoint), nodes->GetUndivided_Laplacian(jPoint)); + numerics->SetSensor(nodes->GetSensor(iPoint), nodes->GetSensor(jPoint)); } /*--- Grid movement ---*/ @@ -1946,8 +1942,8 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Get primitive variables ---*/ - V_i = node[iPoint]->GetPrimitive(); V_j = node[jPoint]->GetPrimitive(); - S_i = node[iPoint]->GetSecondary(); S_j = node[jPoint]->GetSecondary(); + V_i = nodes->GetPrimitive(iPoint); V_j = nodes->GetPrimitive(jPoint); + S_i = nodes->GetSecondary(iPoint); S_j = nodes->GetSecondary(jPoint); /*--- High order reconstruction using MUSCL strategy ---*/ @@ -1958,11 +1954,12 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont Vector_j[iDim] = 0.5*(geometry->node[iPoint]->GetCoord(iDim) - geometry->node[jPoint]->GetCoord(iDim)); } - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = nodes->GetGradient_Reconstruction(jPoint); + if (limiter) { - Limiter_i = node[iPoint]->GetLimiter_Primitive(); - Limiter_j = node[jPoint]->GetLimiter_Primitive(); + Limiter_i = nodes->GetLimiter_Primitive(iPoint); + Limiter_j = nodes->GetLimiter_Primitive(jPoint); } for (iVar = 0; iVar < nPrimVarGrad; iVar++) { @@ -2005,26 +2002,26 @@ void CIncEulerSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_cont bool neg_density_j = (Primitive_j[nDim+2] < 0.0); if (neg_density_i || neg_temperature_i) { - node[iPoint]->SetNon_Physical(true); + nodes->SetNon_Physical(iPoint, true); } else { - node[iPoint]->SetNon_Physical(false); + nodes->SetNon_Physical(iPoint, false); } if (neg_density_j || neg_temperature_j) { - node[jPoint]->SetNon_Physical(true); + nodes->SetNon_Physical(jPoint, true); } else { - node[jPoint]->SetNon_Physical(false); + nodes->SetNon_Physical(jPoint, false); } /* Lastly, check for existing first-order points still active from previous iterations. */ - if (node[iPoint]->GetNon_Physical()) { + if (nodes->GetNon_Physical(iPoint)) { counter_local++; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_i[iVar] = V_i[iVar]; } - if (node[jPoint]->GetNon_Physical()) { + if (nodes->GetNon_Physical(jPoint)) { counter_local++; for (iVar = 0; iVar < nPrimVar; iVar++) Primitive_j[iVar] = V_j[iVar]; @@ -2099,13 +2096,13 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Load the conservative variables ---*/ - numerics->SetConservative(node[iPoint]->GetSolution(), - node[iPoint]->GetSolution()); + numerics->SetConservative(nodes->GetSolution(iPoint), + nodes->GetSolution(iPoint)); /*--- Set incompressible density ---*/ - numerics->SetDensity(node[iPoint]->GetDensity(), - node[iPoint]->GetDensity()); + numerics->SetDensity(nodes->GetDensity(iPoint), + nodes->GetDensity(iPoint)); /*--- Load the volume of the dual mesh cell ---*/ @@ -2130,13 +2127,13 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Load the conservative variables ---*/ - numerics->SetConservative(node[iPoint]->GetSolution(), - node[iPoint]->GetSolution()); + numerics->SetConservative(nodes->GetSolution(iPoint), + nodes->GetSolution(iPoint)); /*--- Set incompressible density ---*/ - numerics->SetDensity(node[iPoint]->GetDensity(), - node[iPoint]->GetDensity()); + numerics->SetDensity(nodes->GetDensity(iPoint), + nodes->GetDensity(iPoint)); /*--- Load the volume of the dual mesh cell ---*/ @@ -2158,14 +2155,14 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Loop over all points ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - - /*--- Load the primitive variables ---*/ - - numerics->SetPrimitive(node[iPoint]->GetPrimitive(), NULL); - + + /*--- Load the conservative variables ---*/ + + numerics->SetConservative(nodes->GetSolution(iPoint), NULL); + /*--- Set incompressible density ---*/ - numerics->SetDensity(node[iPoint]->GetDensity(), 0.0); + numerics->SetDensity(nodes->GetDensity(iPoint), 0.0); /*--- Load the volume of the dual mesh cell ---*/ @@ -2205,9 +2202,9 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont for (iPoint = 0; iPoint < nPoint; iPoint++) { yCoord = geometry->node[iPoint]->GetCoord(1); - yVelocity = node[iPoint]->GetVelocity(1); - Total_Viscosity = (node[iPoint]->GetLaminarViscosity() + - node[iPoint]->GetEddyViscosity()); + yVelocity = nodes->GetVelocity(iPoint,1); + Total_Viscosity = (nodes->GetLaminarViscosity(iPoint) + + nodes->GetEddyViscosity(iPoint)); if (yCoord > EPS) { AuxVar = Total_Viscosity*yVelocity/yCoord; @@ -2217,7 +2214,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Set the auxilairy variable for this node. ---*/ - node[iPoint]->SetAuxVar(AuxVar); + nodes->SetAuxVar(iPoint,AuxVar); } @@ -2238,12 +2235,12 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetPrimitive(node[iPoint]->GetPrimitive(), NULL); + numerics->SetPrimitive(nodes->GetPrimitive(iPoint), NULL); /*--- Set incompressible density ---*/ - numerics->SetDensity(node[iPoint]->GetDensity(), - node[iPoint]->GetDensity()); + numerics->SetDensity(nodes->GetDensity(iPoint), + nodes->GetDensity(iPoint)); /*--- Set control volume ---*/ @@ -2260,11 +2257,11 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont /*--- Gradient of the primitive variables ---*/ - numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), NULL); + numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), NULL); /*--- Load the aux variable gradient that we already computed. ---*/ - numerics->SetAuxVarGrad(node[iPoint]->GetAuxVarGradient(), NULL); + numerics->SetAuxVarGrad(nodes->GetAuxVarGradient(iPoint), NULL); } @@ -2327,9 +2324,9 @@ void CIncEulerSolver::Source_Template(CGeometry *geometry, CSolver **solver_cont /* Next we describe how to get access to some important quanties for this method */ /* Access to all points in the current geometric mesh by saying: nPointDomain */ - /* Get the vector of conservative variables at some point iPoint = node[iPoint]->GetSolution() */ - /* Get the volume (or area in 2D) associated with iPoint = node[iPoint]->GetVolume() */ - /* Get the vector of geometric coordinates of point iPoint = node[iPoint]->GetCoord() */ + /* Get the vector of conservative variables at some point iPoint = nodes->GetSolution(iPoint) */ + /* Get the volume (or area in 2D) associated with iPoint = nodes->GetVolume(iPoint) */ + /* Get the vector of geometric coordinates of point iPoint = nodes->GetCoord(iPoint) */ } @@ -2344,7 +2341,7 @@ void CIncEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->SetLambda(0.0); + nodes->SetLambda(iPoint,0.0); } /*--- Loop interior edges ---*/ @@ -2363,8 +2360,8 @@ void CIncEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Mean Values ---*/ - Mean_ProjVel = 0.5 * (node[iPoint]->GetProjVel(Normal) + node[jPoint]->GetProjVel(Normal)); - Mean_BetaInc2 = 0.5 * (node[iPoint]->GetBetaInc2() + node[jPoint]->GetBetaInc2()); + Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); + Mean_BetaInc2 = 0.5 * (nodes->GetBetaInc2(iPoint) + nodes->GetBetaInc2(jPoint)); Mean_SoundSpeed = sqrt(Mean_BetaInc2*Area*Area); /*--- Adjustment for grid movement ---*/ @@ -2383,8 +2380,8 @@ void CIncEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Inviscid contribution ---*/ Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddLambda(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddLambda(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddLambda(iPoint,Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddLambda(jPoint,Lambda); } @@ -2405,8 +2402,8 @@ void CIncEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { /*--- Mean Values ---*/ - Mean_ProjVel = node[iPoint]->GetProjVel(Normal); - Mean_BetaInc2 = node[iPoint]->GetBetaInc2(); + Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + Mean_BetaInc2 = nodes->GetBetaInc2(iPoint); Mean_SoundSpeed = sqrt(Mean_BetaInc2*Area*Area); /*--- Adjustment for grid movement ---*/ @@ -2423,7 +2420,7 @@ void CIncEulerSolver::SetMax_Eigenvalue(CGeometry *geometry, CConfig *config) { Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; if (geometry->node[iPoint]->GetDomain()) { - node[iPoint]->AddLambda(Lambda); + nodes->AddLambda(iPoint,Lambda); } } @@ -2453,8 +2450,7 @@ void CIncEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *confi Diff = new su2double[nVar]; - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetUnd_LaplZero(); + nodes->SetUnd_LaplZero(); for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { @@ -2464,7 +2460,7 @@ void CIncEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *confi /*--- Solution differences ---*/ for (iVar = 0; iVar < nVar; iVar++) - Diff[iVar] = node[iPoint]->GetSolution(iVar) - node[jPoint]->GetSolution(iVar); + Diff[iVar] = nodes->GetSolution(iPoint,iVar) - nodes->GetSolution(jPoint,iVar); boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); @@ -2472,19 +2468,19 @@ void CIncEulerSolver::SetUndivided_Laplacian(CGeometry *geometry, CConfig *confi /*--- Both points inside the domain, or both in the boundary ---*/ if ((!boundary_i && !boundary_j) || (boundary_i && boundary_j)) { - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint,Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint,Diff); } /*--- iPoint inside the domain, jPoint on the boundary ---*/ if (!boundary_i && boundary_j) - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->SubtractUnd_Lapl(Diff); + if (geometry->node[iPoint]->GetDomain()) nodes->SubtractUnd_Lapl(iPoint,Diff); /*--- jPoint inside the domain, iPoint on the boundary ---*/ if (boundary_i && !boundary_j) - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddUnd_Lapl(Diff); + if (geometry->node[jPoint]->GetDomain()) nodes->AddUnd_Lapl(jPoint,Diff); } @@ -2526,8 +2522,8 @@ void CIncEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfi /*--- Get the pressure, or density for incompressible solvers ---*/ - Pressure_i = node[iPoint]->GetDensity(); - Pressure_j = node[jPoint]->GetDensity(); + Pressure_i = nodes->GetDensity(iPoint); + Pressure_j = nodes->GetDensity(jPoint); boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); boundary_j = geometry->node[jPoint]->GetPhysicalBoundary(); @@ -2576,7 +2572,7 @@ void CIncEulerSolver::SetCentered_Dissipation_Sensor(CGeometry *geometry, CConfi /*--- Set pressure switch for each point ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetSensor(fabs(iPoint_UndLapl[iPoint]) / jPoint_UndLapl[iPoint]); + nodes->SetSensor(iPoint,fabs(iPoint_UndLapl[iPoint]) / jPoint_UndLapl[iPoint]); /*--- MPI parallelization ---*/ @@ -2715,7 +2711,7 @@ void CIncEulerSolver::Pressure_Forces(CGeometry *geometry, CConfig *config) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - Pressure = node[iPoint]->GetPressure(); + Pressure = nodes->GetPressure(iPoint); CPressure[iMarker][iVertex] = (Pressure - RefPressure)*factor*RefArea; @@ -3097,7 +3093,7 @@ void CIncEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); Coord = geometry->node[iPoint]->GetCoord(); - Density = node[iPoint]->GetDensity(); + Density = nodes->GetDensity(iPoint); Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -3106,7 +3102,7 @@ void CIncEulerSolver::Momentum_Forces(CGeometry *geometry, CConfig *config) { MassFlow = 0.0; for (iDim = 0; iDim < nDim; iDim++) { - Velocity[iDim] = node[iPoint]->GetVelocity(iDim); + Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); MomentDist[iDim] = Coord[iDim] - Origin[iDim]; MassFlow -= Normal[iDim]*Velocity[iDim]*Density; } @@ -3374,9 +3370,9 @@ void CIncEulerSolver::ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Vol = (geometry->node[iPoint]->GetVolume() + geometry->node[iPoint]->GetPeriodicVolume()); - Delta = node[iPoint]->GetDelta_Time() / Vol; + Delta = nodes->GetDelta_Time(iPoint) / Vol; - Res_TruncError = node[iPoint]->GetResTruncError(); + Res_TruncError = nodes->GetResTruncError(iPoint); Residual = LinSysRes.GetBlock(iPoint); if (!adjoint) { @@ -3385,7 +3381,7 @@ void CIncEulerSolver::ExplicitRK_Iteration(CGeometry *geometry, CSolver **solver Res = 0.0; for (jVar = 0; jVar < nVar; jVar ++ ) Res += Preconditioner[iVar][jVar]*(Residual[jVar] + Res_TruncError[jVar]); - node[iPoint]->AddSolution(iVar, -Res*Delta*RK_AlphaCoeff); + nodes->AddSolution(iPoint,iVar, -Res*Delta*RK_AlphaCoeff); AddRes_RMS(iVar, Res*Res); AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); } @@ -3425,9 +3421,9 @@ void CIncEulerSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **sol for (iPoint = 0; iPoint < nPointDomain; iPoint++) { Vol = (geometry->node[iPoint]->GetVolume() + geometry->node[iPoint]->GetPeriodicVolume()); - Delta = node[iPoint]->GetDelta_Time() / Vol; + Delta = nodes->GetDelta_Time(iPoint) / Vol; - local_Res_TruncError = node[iPoint]->GetResTruncError(); + local_Res_TruncError = nodes->GetResTruncError(iPoint); local_Residual = LinSysRes.GetBlock(iPoint); @@ -3437,7 +3433,7 @@ void CIncEulerSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **sol Res = 0.0; for (jVar = 0; jVar < nVar; jVar ++ ) Res += Preconditioner[iVar][jVar]*(local_Residual[jVar] + local_Res_TruncError[jVar]); - node[iPoint]->AddSolution(iVar, -Res*Delta); + nodes->AddSolution(iPoint,iVar, -Res*Delta); AddRes_RMS(iVar, Res*Res); AddRes_Max(iVar, fabs(Res), geometry->node[iPoint]->GetGlobalIndex(), geometry->node[iPoint]->GetCoord()); } @@ -3480,7 +3476,7 @@ void CIncEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol /*--- Read the residual ---*/ - local_Res_TruncError = node[iPoint]->GetResTruncError(); + local_Res_TruncError = nodes->GetResTruncError(iPoint); /*--- Read the volume ---*/ @@ -3489,8 +3485,8 @@ void CIncEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol /*--- Apply the preconditioner and add to the diagonal. ---*/ - if (node[iPoint]->GetDelta_Time() != 0.0) { - Delta = Vol / node[iPoint]->GetDelta_Time(); + if (nodes->GetDelta_Time(iPoint) != 0.0) { + Delta = Vol / nodes->GetDelta_Time(iPoint); SetPreconditioner(config, iPoint); for (iVar = 0; iVar < nVar; iVar ++ ) { for (jVar = 0; jVar < nVar; jVar ++ ) { @@ -3546,7 +3542,7 @@ void CIncEulerSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **sol if (!adjoint) { for (iPoint = 0; iPoint < nPointDomain; iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddSolution(iVar, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint*nVar+iVar]); + nodes->AddSolution(iPoint, iVar, nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint*nVar+iVar]); } } } @@ -3599,7 +3595,7 @@ void CIncEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, C between the mean flow and the turb model. */ if (config->GetKind_Turb_Model() != NONE) - localUnderRelaxation = min(localUnderRelaxation, solver_container[TURB_SOL]->node[iPoint]->GetUnderRelaxation()); + localUnderRelaxation = min(localUnderRelaxation, solver_container[TURB_SOL]->GetNodes()->GetUnderRelaxation(iPoint)); /* Threshold the relaxation factor in the event that there is a very small value. This helps avoid catastrophic crashes due @@ -3609,7 +3605,7 @@ void CIncEulerSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, C /* Store the under-relaxation factor for this point. */ - node[iPoint]->SetUnderRelaxation(localUnderRelaxation); + nodes->SetUnderRelaxation(iPoint, localUnderRelaxation); } @@ -3628,8 +3624,7 @@ void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *con PrimVar_j = new su2double [nPrimVarGrad]; /*--- Set Gradient_Primitive to zero ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++) - node[iPoint]->SetGradient_PrimitiveZero(nPrimVarGrad); + nodes->SetGradient_PrimitiveZero(); /*--- Loop interior edges ---*/ for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { @@ -3637,8 +3632,8 @@ void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *con jPoint = geometry->edge[iEdge]->GetNode(1); for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - PrimVar_i[iVar] = node[iPoint]->GetPrimitive(iVar); - PrimVar_j[iVar] = node[jPoint]->GetPrimitive(iVar); + PrimVar_i[iVar] = nodes->GetPrimitive(iPoint,iVar); + PrimVar_j[iVar] = nodes->GetPrimitive(jPoint,iVar); } Normal = geometry->edge[iEdge]->GetNormal(); @@ -3647,9 +3642,9 @@ void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *con for (iDim = 0; iDim < nDim; iDim++) { Partial_Res = PrimVar_Average*Normal[iDim]; if (geometry->node[iPoint]->GetDomain()) - node[iPoint]->AddGradient_Primitive(iVar, iDim, Partial_Res); + nodes->AddGradient_Primitive(iPoint,iVar, iDim, Partial_Res); if (geometry->node[jPoint]->GetDomain()) - node[jPoint]->SubtractGradient_Primitive(iVar, iDim, Partial_Res); + nodes->SubtractGradient_Primitive(jPoint,iVar, iDim, Partial_Res); } } } @@ -3663,13 +3658,13 @@ void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *con if (geometry->node[iPoint]->GetDomain()) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) - PrimVar_Vertex[iVar] = node[iPoint]->GetPrimitive(iVar); + PrimVar_Vertex[iVar] = nodes->GetPrimitive(iPoint,iVar); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); for (iVar = 0; iVar < nPrimVarGrad; iVar++) for (iDim = 0; iDim < nDim; iDim++) { Partial_Res = PrimVar_Vertex[iVar]*Normal[iDim]; - node[iPoint]->SubtractGradient_Primitive(iVar, iDim, Partial_Res); + nodes->SubtractGradient_Primitive(iPoint,iVar, iDim, Partial_Res); } } } @@ -3693,11 +3688,11 @@ void CIncEulerSolver::SetPrimitive_Gradient_GG(CGeometry *geometry, CConfig *con for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - Partial_Gradient = node[iPoint]->GetGradient_Primitive(iVar, iDim)/Vol; + Partial_Gradient = nodes->GetGradient_Primitive(iPoint, iVar, iDim)/Vol; if (reconstruction) - node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Partial_Gradient); + nodes->SetGradient_Reconstruction(iPoint, iVar, iDim, Partial_Gradient); else - node[iPoint]->SetGradient_Primitive(iVar, iDim, Partial_Gradient); + nodes->SetGradient_Primitive(iPoint, iVar, iDim, Partial_Gradient); } } } @@ -3732,6 +3727,12 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con weighted = false; } + /*--- Clear Rmatrix, which could eventually be computed once + and stored for static meshes, as well as the prim gradient. ---*/ + + nodes->SetRmatrixZero(); + nodes->SetGradient_PrimitiveZero(); + /*--- Loop over points of the grid ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { @@ -3745,7 +3746,7 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con /*--- Get primitives from CVariable ---*/ - PrimVar_i = node[iPoint]->GetPrimitive(); + PrimVar_i = nodes->GetPrimitive(iPoint); /*--- Inizialization of variables ---*/ @@ -3756,9 +3757,6 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con /*--- Clear Rmatrix, which could eventually be computed once and stored for static meshes, as well as the prim gradient. ---*/ - node[iPoint]->SetRmatrixZero(); - node[iPoint]->SetGradient_PrimitiveZero(nPrimVarGrad); - AD::StartPreacc(); AD::SetPreaccIn(PrimVar_i, nPrimVarGrad); AD::SetPreaccIn(Coord_i, nDim); @@ -3767,7 +3765,7 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Coord_j = geometry->node[jPoint]->GetCoord(); - PrimVar_j = node[jPoint]->GetPrimitive(); + PrimVar_j = nodes->GetPrimitive(jPoint); AD::SetPreaccIn(Coord_j, nDim); AD::SetPreaccIn(PrimVar_j, nPrimVarGrad); @@ -3784,29 +3782,29 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con if (weight != 0.0) { - node[iPoint]->AddRmatrix(0, 0, (Coord_j[0]-Coord_i[0])*(Coord_j[0]-Coord_i[0])/weight); - node[iPoint]->AddRmatrix(0, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[1]-Coord_i[1])/weight); - node[iPoint]->AddRmatrix(1, 1, (Coord_j[1]-Coord_i[1])*(Coord_j[1]-Coord_i[1])/weight); + nodes->AddRmatrix(iPoint,0, 0, (Coord_j[0]-Coord_i[0])*(Coord_j[0]-Coord_i[0])/weight); + nodes->AddRmatrix(iPoint,0, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[1]-Coord_i[1])/weight); + nodes->AddRmatrix(iPoint,1, 1, (Coord_j[1]-Coord_i[1])*(Coord_j[1]-Coord_i[1])/weight); if (nDim == 3) { - node[iPoint]->AddRmatrix(0, 2, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(1, 2, (Coord_j[1]-Coord_i[1])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(2, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(2, 2, (Coord_j[2]-Coord_i[2])*(Coord_j[2]-Coord_i[2])/weight); + nodes->AddRmatrix(iPoint,0, 2, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); + nodes->AddRmatrix(iPoint,1, 2, (Coord_j[1]-Coord_i[1])*(Coord_j[2]-Coord_i[2])/weight); + nodes->AddRmatrix(iPoint,2, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); + nodes->AddRmatrix(iPoint,2, 2, (Coord_j[2]-Coord_i[2])*(Coord_j[2]-Coord_i[2])/weight); } /*--- Entries of c:= transpose(A)*b ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->AddGradient_Primitive(iVar,iDim, (Coord_j[iDim]-Coord_i[iDim])*(PrimVar_j[iVar]-PrimVar_i[iVar])/weight); + nodes->AddGradient_Primitive(iPoint,iVar,iDim, (Coord_j[iDim]-Coord_i[iDim])*(PrimVar_j[iVar]-PrimVar_i[iVar])/weight); } } } } - AD::SetPreaccOut(node[iPoint]->GetRmatrix(), nDim, nDim); - AD::SetPreaccOut(node[iPoint]->GetGradient_Primitive(), nPrimVarGrad, nDim); + AD::SetPreaccOut(nodes->GetRmatrix(iPoint), nDim, nDim); + AD::SetPreaccOut(nodes->GetGradient_Primitive(iPoint), nPrimVarGrad, nDim); AD::EndPreacc(); } @@ -3830,9 +3828,9 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con r11 = 0.0; r12 = 0.0; r13 = 0.0; r22 = 0.0; r23 = 0.0; r23_a = 0.0; r23_b = 0.0; r33 = 0.0; - r11 = node[iPoint]->GetRmatrix(0,0); - r12 = node[iPoint]->GetRmatrix(0,1); - r22 = node[iPoint]->GetRmatrix(1,1); + r11 = nodes->GetRmatrix(iPoint,0,0); + r12 = nodes->GetRmatrix(iPoint,0,1); + r22 = nodes->GetRmatrix(iPoint,1,1); AD::StartPreacc(); AD::SetPreaccIn(r11); @@ -3844,10 +3842,10 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con if (r22-r12*r12 >= 0.0) r22 = sqrt(r22-r12*r12); else r22 = 0.0; if (nDim == 3) { - r13 = node[iPoint]->GetRmatrix(0,2); - r23_a = node[iPoint]->GetRmatrix(1,2); - r23_b = node[iPoint]->GetRmatrix(2,1); - r33 = node[iPoint]->GetRmatrix(2,2); + r13 = nodes->GetRmatrix(iPoint,0,2); + r23_a = nodes->GetRmatrix(iPoint,1,2); + r23_b = nodes->GetRmatrix(iPoint,2,1); + r33 = nodes->GetRmatrix(iPoint,2,2); AD::SetPreaccIn(r13); AD::SetPreaccIn(r23_a); @@ -3905,7 +3903,7 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con for (iDim = 0; iDim < nDim; iDim++) { Cvector[iVar][iDim] = 0.0; for (jDim = 0; jDim < nDim; jDim++) { - Cvector[iVar][iDim] += Smatrix[iDim][jDim]*node[iPoint]->GetGradient_Primitive(iVar, jDim); + Cvector[iVar][iDim] += Smatrix[iDim][jDim]*nodes->GetGradient_Primitive(iPoint,iVar, jDim); } } } @@ -3913,9 +3911,9 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { if (reconstruction) - node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Cvector[iVar][iDim]); + nodes->SetGradient_Reconstruction(iPoint, iVar, iDim, Cvector[iVar][iDim]); else - node[iPoint]->SetGradient_Primitive(iVar, iDim, Cvector[iVar][iDim]); + nodes->SetGradient_Primitive(iPoint, iVar, iDim, Cvector[iVar][iDim]); } } @@ -3955,7 +3953,7 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - node[iPoint]->SetLimiter_Primitive(iVar, 1.0); + nodes->SetLimiter_Primitive(iPoint,iVar, 1.0); } } @@ -3967,9 +3965,9 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - node[iPoint]->SetSolution_Max(iVar, -EPS); - node[iPoint]->SetSolution_Min(iVar, EPS); - node[iPoint]->SetLimiter_Primitive(iVar, 2.0); + nodes->SetSolution_Max(iPoint,iVar, -EPS); + nodes->SetSolution_Min(iPoint,iVar, EPS); + nodes->SetLimiter_Primitive(iPoint,iVar, 2.0); } } @@ -3984,17 +3982,17 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) /*--- Get the primitive variables ---*/ - Primitive_i = node[iPoint]->GetPrimitive(); - Primitive_j = node[jPoint]->GetPrimitive(); + Primitive_i = nodes->GetPrimitive(iPoint); + Primitive_j = nodes->GetPrimitive(jPoint); /*--- Compute the maximum, and minimum values for nodes i & j ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) { du = (Primitive_j[iVar] - Primitive_i[iVar]); - node[iPoint]->SetSolution_Min(iVar, min(node[iPoint]->GetSolution_Min(iVar), du)); - node[iPoint]->SetSolution_Max(iVar, max(node[iPoint]->GetSolution_Max(iVar), du)); - node[jPoint]->SetSolution_Min(iVar, min(node[jPoint]->GetSolution_Min(iVar), -du)); - node[jPoint]->SetSolution_Max(iVar, max(node[jPoint]->GetSolution_Max(iVar), -du)); + nodes->SetSolution_Min(iPoint, iVar, min(nodes->GetSolution_Min(iPoint, iVar), du)); + nodes->SetSolution_Max(iPoint, iVar, max(nodes->GetSolution_Max(iPoint, iVar), du)); + nodes->SetSolution_Min(jPoint, iVar, min(nodes->GetSolution_Min(jPoint, iVar), -du)); + nodes->SetSolution_Max(jPoint, iVar, max(nodes->GetSolution_Max(jPoint, iVar), -du)); } } @@ -4017,8 +4015,8 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = nodes->GetGradient_Reconstruction(jPoint); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -4029,10 +4027,10 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - AD::SetPreaccIn(node[iPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[iPoint]->GetSolution_Min(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Min(iVar)); + AD::SetPreaccIn(nodes->GetSolution_Max(iPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Min(iPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Max(jPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Min(jPoint,iVar)); /*--- Calculate the interface left gradient, delta- (dm) ---*/ @@ -4042,14 +4040,14 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) if (dm == 0.0) { limiter = 2.0; } else { - if ( dm > 0.0 ) dp = node[iPoint]->GetSolution_Max(iVar); - else dp = node[iPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = nodes->GetSolution_Max(iPoint,iVar); + else dp = nodes->GetSolution_Min(iPoint,iVar); limiter = dp/dm; } - if (limiter < node[iPoint]->GetLimiter_Primitive(iVar)) { - node[iPoint]->SetLimiter_Primitive(iVar, limiter); - AD::SetPreaccOut(node[iPoint]->GetLimiter_Primitive()[iVar]); + if (limiter < nodes->GetLimiter_Primitive(iPoint,iVar)) { + nodes->SetLimiter_Primitive(iPoint,iVar, limiter); + AD::SetPreaccOut(nodes->GetLimiter_Primitive(iPoint)[iVar]); } /*--- Calculate the interface right gradient, delta+ (dp) ---*/ @@ -4060,14 +4058,14 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) if (dm == 0.0) { limiter = 2.0; } else { - if ( dm > 0.0 ) dp = node[jPoint]->GetSolution_Max(iVar); - else dp = node[jPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = nodes->GetSolution_Max(jPoint,iVar); + else dp = nodes->GetSolution_Min(jPoint,iVar); limiter = dp/dm; } - if (limiter < node[jPoint]->GetLimiter_Primitive(iVar)) { - node[jPoint]->SetLimiter_Primitive(iVar, limiter); - AD::SetPreaccOut(node[jPoint]->GetLimiter_Primitive()[iVar]); + if (limiter < nodes->GetLimiter_Primitive(jPoint,iVar)) { + nodes->SetLimiter_Primitive(jPoint,iVar, limiter); + AD::SetPreaccOut(nodes->GetLimiter_Primitive(jPoint)[iVar]); } } @@ -4078,9 +4076,9 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - y = node[iPoint]->GetLimiter_Primitive(iVar); + y = nodes->GetLimiter_Primitive(iPoint,iVar); limiter = (y*y + 2.0*y) / (y*y + y + 2.0); - node[iPoint]->SetLimiter_Primitive(iVar, limiter); + nodes->SetLimiter_Primitive(iPoint,iVar, limiter); } } @@ -4100,7 +4098,7 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) /*--- Compute the max value and min value of the solution ---*/ - Primitive = node[0]->GetPrimitive(); + Primitive = nodes->GetPrimitive(0); for (iVar = 0; iVar < nPrimVarGrad; iVar++) { LocalMinPrimitive[iVar] = Primitive[iVar]; LocalMaxPrimitive[iVar] = Primitive[iVar]; @@ -4110,7 +4108,7 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) /*--- Get the primitive variables ---*/ - Primitive = node[iPoint]->GetPrimitive(); + Primitive = nodes->GetPrimitive(iPoint); for (iVar = 0; iVar < nPrimVarGrad; iVar++) { LocalMinPrimitive[iVar] = min (LocalMinPrimitive[iVar], Primitive[iVar]); @@ -4134,8 +4132,8 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = nodes->GetGradient_Reconstruction(jPoint); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -4146,10 +4144,10 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) AD::SetPreaccIn(Gradient_j[iVar], nDim); AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(node[iPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[iPoint]->GetSolution_Min(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Min(iVar)); + AD::SetPreaccIn(nodes->GetSolution_Max(iPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Min(iPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Max(jPoint,iVar)); + AD::SetPreaccIn(nodes->GetSolution_Min(jPoint,iVar)); if (config->GetKind_SlopeLimit_Flow() == VENKATAKRISHNAN_WANG) { AD::SetPreaccIn(GlobalMaxPrimitive[iVar]); @@ -4170,14 +4168,14 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) /*--- Calculate the interface right gradient, delta+ (dp) ---*/ - if ( dm > 0.0 ) dp = node[iPoint]->GetSolution_Max(iVar); - else dp = node[iPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = nodes->GetSolution_Max(iPoint,iVar); + else dp = nodes->GetSolution_Min(iPoint,iVar); limiter = ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[iPoint]->GetLimiter_Primitive(iVar)){ - node[iPoint]->SetLimiter_Primitive(iVar, limiter); - AD::SetPreaccOut(node[iPoint]->GetLimiter_Primitive()[iVar]); + if (limiter < nodes->GetLimiter_Primitive(iPoint,iVar)){ + nodes->SetLimiter_Primitive(iPoint,iVar, limiter); + AD::SetPreaccOut(nodes->GetLimiter_Primitive(iPoint)[iVar]); } /*-- Repeat for point j on the edge ---*/ @@ -4186,14 +4184,14 @@ void CIncEulerSolver::SetPrimitive_Limiter(CGeometry *geometry, CConfig *config) for (iDim = 0; iDim < nDim; iDim++) dm += 0.5*(Coord_i[iDim]-Coord_j[iDim])*Gradient_j[iVar][iDim]; - if ( dm > 0.0 ) dp = node[jPoint]->GetSolution_Max(iVar); - else dp = node[jPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = nodes->GetSolution_Max(jPoint,iVar); + else dp = nodes->GetSolution_Min(jPoint,iVar); limiter = ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[jPoint]->GetLimiter_Primitive(iVar)){ - node[jPoint]->SetLimiter_Primitive(iVar, limiter); - AD::SetPreaccOut(node[jPoint]->GetLimiter_Primitive()[iVar]); + if (limiter < nodes->GetLimiter_Primitive(jPoint,iVar)){ + nodes->SetLimiter_Primitive(jPoint,iVar, limiter); + AD::SetPreaccOut(nodes->GetLimiter_Primitive(jPoint)[iVar]); } AD::EndPreacc(); @@ -4630,8 +4628,8 @@ void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_co /*--- Store the local maximum of the squared velocity in the field. ---*/ - if (node[iPoint]->GetVelocity2() > maxVel2) - maxVel2 = node[iPoint]->GetVelocity2(); + if (nodes->GetVelocity2(iPoint) > maxVel2) + maxVel2 = nodes->GetVelocity2(iPoint); } @@ -4652,7 +4650,7 @@ void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_co epsilon2 = max(epsilon2_default,epsilon2); for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint]->SetBetaInc2(epsilon2*config->GetMax_Vel2()); + nodes->SetBetaInc2(iPoint,epsilon2*config->GetMax_Vel2()); } @@ -4669,14 +4667,14 @@ void CIncEulerSolver::SetPreconditioner(CConfig *config, unsigned long iPoint) { /*--- Access the primitive variables at this node. ---*/ - Density = node[iPoint]->GetDensity(); - BetaInc2 = node[iPoint]->GetBetaInc2(); - Cp = node[iPoint]->GetSpecificHeatCp(); + Density = nodes->GetDensity(iPoint); + BetaInc2 = nodes->GetBetaInc2(iPoint); + Cp = nodes->GetSpecificHeatCp(iPoint); oneOverCp = 1.0/Cp; - Temperature = node[iPoint]->GetTemperature(); + Temperature = nodes->GetTemperature(iPoint); for (iDim = 0; iDim < nDim; iDim++) - Velocity[iDim] = node[iPoint]->GetVelocity(iDim); + Velocity[iDim] = nodes->GetVelocity(iPoint,iDim); /*--- We need the derivative of the equation of state to build the preconditioning matrix. For now, the only option is the ideal gas @@ -4754,7 +4752,6 @@ void CIncEulerSolver::SetPreconditioner(CConfig *config, unsigned long iPoint) { } - void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { @@ -4793,7 +4790,7 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Recompute and store the velocity in the primitive variable vector. ---*/ @@ -4814,11 +4811,11 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Beta coefficient stored at the node ---*/ - V_infty[nDim+3] = node[iPoint]->GetBetaInc2(); + V_infty[nDim+3] = nodes->GetBetaInc2(iPoint); /*--- Cp is needed for Temperature equation. ---*/ - V_infty[nDim+7] = node[iPoint]->GetSpecificHeatCp(); + V_infty[nDim+7] = nodes->GetSpecificHeatCp(iPoint); /*--- Set various quantities in the numerics class ---*/ @@ -4847,9 +4844,9 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Set transport properties at infinity. ---*/ - V_infty[nDim+4] = node[iPoint]->GetLaminarViscosity(); - V_infty[nDim+5] = node[iPoint]->GetEddyViscosity(); - V_infty[nDim+6] = node[iPoint]->GetThermalConductivity(); + V_infty[nDim+4] = nodes->GetLaminarViscosity(iPoint); + V_infty[nDim+5] = nodes->GetEddyViscosity(iPoint); + V_infty[nDim+6] = nodes->GetThermalConductivity(iPoint); /*--- Set the normal vector and the coordinates ---*/ @@ -4860,14 +4857,14 @@ void CIncEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contain /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(V_domain, V_infty); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), - node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), + nodes->GetGradient_Primitive(iPoint)); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), - solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), + solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Compute and update viscous residual ---*/ @@ -4954,11 +4951,11 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve solution at this boundary node. ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Neumann condition for dynamic pressure ---*/ - V_inlet[0] = node[iPoint]->GetPressure(); + V_inlet[0] = nodes->GetPressure(iPoint); /*--- The velocity is either prescribed or computed from total pressure. ---*/ @@ -4993,7 +4990,7 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Store the current static pressure for clarity. ---*/ - P_domain = node[iPoint]->GetPressure(); + P_domain = nodes->GetPressure(iPoint); /*--- Check for back flow through the inlet. ---*/ @@ -5021,13 +5018,13 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Neumann condition for the temperature. ---*/ - V_inlet[nDim+1] = node[iPoint]->GetTemperature(); + V_inlet[nDim+1] = nodes->GetTemperature(iPoint); } else { /*--- Update the velocity magnitude using the total pressure. ---*/ - Vel_Mag = sqrt((P_total - P_domain)/(0.5*node[iPoint]->GetDensity())); + Vel_Mag = sqrt((P_total - P_domain)/(0.5*nodes->GetDensity(iPoint))); /*--- If requested, use the local boundary normal (negative), instead of the prescribed flow direction in the config. ---*/ @@ -5062,15 +5059,15 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, construction, or will be set fixed implicitly by the temperature and equation of state. ---*/ - V_inlet[nDim+2] = node[iPoint]->GetDensity(); + V_inlet[nDim+2] = nodes->GetDensity(iPoint); /*--- Beta coefficient from the config file ---*/ - V_inlet[nDim+3] = node[iPoint]->GetBetaInc2(); + V_inlet[nDim+3] = nodes->GetBetaInc2(iPoint); /*--- Cp is needed for Temperature equation. ---*/ - V_inlet[nDim+7] = node[iPoint]->GetSpecificHeatCp(); + V_inlet[nDim+7] = nodes->GetSpecificHeatCp(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -5099,9 +5096,9 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Set transport properties at the inlet ---*/ - V_inlet[nDim+4] = node[iPoint]->GetLaminarViscosity(); - V_inlet[nDim+5] = node[iPoint]->GetEddyViscosity(); - V_inlet[nDim+6] = node[iPoint]->GetThermalConductivity(); + V_inlet[nDim+4] = nodes->GetLaminarViscosity(iPoint); + V_inlet[nDim+5] = nodes->GetEddyViscosity(iPoint); + V_inlet[nDim+6] = nodes->GetThermalConductivity(iPoint); /*--- Set the normal vector and the coordinates ---*/ @@ -5112,14 +5109,14 @@ void CIncEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(V_domain, V_inlet); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), - node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), + nodes->GetGradient_Primitive(iPoint)); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), - solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), + solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Compute and update residual ---*/ @@ -5190,11 +5187,11 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Store the current static pressure for clarity. ---*/ - P_domain = node[iPoint]->GetPressure(); + P_domain = nodes->GetPressure(iPoint); /*--- Compute a boundary value for the pressure depending on whether we are prescribing a back pressure or a mass flow target. ---*/ @@ -5216,7 +5213,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Neumann condition for the velocity. ---*/ for (iDim = 0; iDim < nDim; iDim++) { - V_outlet[iDim+1] = node[iPoint]->GetPrimitive(iDim+1); + V_outlet[iDim+1] = nodes->GetVelocity(iPoint,iDim); } break; @@ -5255,7 +5252,7 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Neumann condition for the velocity ---*/ for (iDim = 0; iDim < nDim; iDim++) { - V_outlet[iDim+1] = node[iPoint]->GetPrimitive(iDim+1); + V_outlet[iDim+1] = nodes->GetVelocity(iPoint,iDim); } break; @@ -5264,21 +5261,21 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Neumann condition for the temperature. ---*/ - V_outlet[nDim+1] = node[iPoint]->GetTemperature(); + V_outlet[nDim+1] = nodes->GetTemperature(iPoint); /*--- Access density at the interior node. This is either constant by construction, or will be set fixed implicitly by the temperature and equation of state. ---*/ - V_outlet[nDim+2] = node[iPoint]->GetDensity(); + V_outlet[nDim+2] = nodes->GetDensity(iPoint); /*--- Beta coefficient from the config file ---*/ - V_outlet[nDim+3] = node[iPoint]->GetBetaInc2(); + V_outlet[nDim+3] = nodes->GetBetaInc2(iPoint); /*--- Cp is needed for Temperature equation. ---*/ - V_outlet[nDim+7] = node[iPoint]->GetSpecificHeatCp(); + V_outlet[nDim+7] = nodes->GetSpecificHeatCp(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -5308,9 +5305,9 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Set transport properties at the outlet. ---*/ - V_outlet[nDim+4] = node[iPoint]->GetLaminarViscosity(); - V_outlet[nDim+5] = node[iPoint]->GetEddyViscosity(); - V_outlet[nDim+6] = node[iPoint]->GetThermalConductivity(); + V_outlet[nDim+4] = nodes->GetLaminarViscosity(iPoint); + V_outlet[nDim+5] = nodes->GetEddyViscosity(iPoint); + V_outlet[nDim+6] = nodes->GetThermalConductivity(iPoint); /*--- Set the normal vector and the coordinates ---*/ @@ -5321,14 +5318,14 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(V_domain, V_outlet); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), - node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), + nodes->GetGradient_Primitive(iPoint)); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), - solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), + solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Compute and update residual ---*/ @@ -5488,28 +5485,25 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, conv_numerics->SetNormal(Normal); /*--- Get current solution at this boundary node ---*/ - V_domain = node[iPoint]->GetPrimitive(); + V_domain = nodes->GetPrimitive(iPoint); /*--- Set the reflected state based on the boundary node. Scalars are copied and the velocity is mirrored along the symmetry boundary, i.e. the velocity in normal direction is substracted twice. ---*/ for(iVar = 0; iVar < nPrimVar; iVar++) - V_reflected[iVar] = node[iPoint]->GetPrimitive(iVar); + V_reflected[iVar] = nodes->GetPrimitive(iPoint,iVar); /*--- Compute velocity in normal direction (ProjVelcity_i=(v*n)) und substract twice from velocity in normal direction: v_r = v - 2 (v*n)n ---*/ - ProjVelocity_i = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVelocity_i += node[iPoint]->GetVelocity(iDim)*UnitNormal[iDim]; + ProjVelocity_i = nodes->GetProjVel(iPoint,UnitNormal); for (iDim = 0; iDim < nDim; iDim++) - V_reflected[iDim+1] = node[iPoint]->GetVelocity(iDim) - 2.0 * ProjVelocity_i*UnitNormal[iDim]; + V_reflected[iDim+1] = nodes->GetVelocity(iPoint,iDim) - 2.0 * ProjVelocity_i*UnitNormal[iDim]; /*--- Set Primitive and Secondary for numerics class. ---*/ conv_numerics->SetPrimitive(V_domain, V_reflected); - conv_numerics->SetSecondary(node[iPoint]->GetSecondary(), - node[iPoint]->GetSecondary()); - + conv_numerics->SetSecondary(nodes->GetSecondary(iPoint), nodes->GetSecondary(iPoint)); + /*--- Compute the residual using an upwind scheme. ---*/ conv_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); @@ -5539,8 +5533,7 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Set the primitive and Secondary variables. ---*/ visc_numerics->SetPrimitive(V_domain, V_reflected); - visc_numerics->SetSecondary(node[iPoint]->GetSecondary(), - node[iPoint]->GetSecondary()); + visc_numerics->SetSecondary(nodes->GetSecondary(iPoint), nodes->GetSecondary(iPoint)); /*--- For viscous Fluxes also the gradients of the primitives need to be determined. 1. The gradients of scalars are mirrored along the sym plane just as velocity for the primitives @@ -5551,7 +5544,7 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, /*--- Get gradients of primitives of boundary cell ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) for (iDim = 0; iDim < nDim; iDim++) - Grad_Reflected[iVar][iDim] = node[iPoint]->GetGradient_Primitive(iVar, iDim); + Grad_Reflected[iVar][iDim] = nodes->GetGradient_Primitive(iPoint,iVar, iDim); /*--- Reflect the gradients for all scalars including the velocity components. The gradients of the velocity components are set later with the @@ -5606,12 +5599,12 @@ void CIncEulerSolver::BC_Sym_Plane(CGeometry *geometry, Grad_Reflected[iVar+1][iDim] = GradNormVel[iDim]*UnitNormal[iVar] + GradTangVel[iDim]*Tangential[iVar]; /*--- Set the primitive gradients of the boundary and reflected state. ---*/ - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), Grad_Reflected); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), Grad_Reflected); /*--- Turbulent kinetic energy. ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), - solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), + solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Compute and update residual. Note that the viscous shear stress tensor is computed in the following routine based upon the velocity-component gradients. ---*/ @@ -5678,7 +5671,7 @@ void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_c Point_Normal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = node[iPoint]->GetPrimitive(iVar); + PrimVar_i[iVar] = nodes->GetPrimitive(iPoint,iVar); PrimVar_j[iVar] = GetSlidingState(iMarker, iVertex, iVar, jVertex); } @@ -5743,12 +5736,12 @@ void CIncEulerSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_c /*--- Primitive variables, and gradient ---*/ visc_numerics->SetPrimitive(PrimVar_i, PrimVar_j); - visc_numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), node[iPoint]->GetGradient_Primitive()); + visc_numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nodes->GetGradient_Primitive(iPoint)); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), solver_container[TURB_SOL]->node[iPoint]->GetSolution(0)); + visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ @@ -5847,9 +5840,9 @@ void CIncEulerSolver::BC_Custom(CGeometry *geometry, condition by setting the solution values at the boundary nodes directly and setting the residual to zero at those nodes. ---*/ - node[iPoint]->SetSolution_Old(Solution); - node[iPoint]->SetSolution(Solution); - node[iPoint]->SetRes_TruncErrorZero(); + nodes->SetSolution_Old(iPoint,Solution); + nodes->SetSolution(iPoint,Solution); + nodes->SetRes_TruncErrorZero(iPoint); LinSysRes.SetBlock_Zero(iPoint); /*--- Adjust rows of the Jacobian (includes 1 in the diagonal) ---*/ @@ -5917,14 +5910,14 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver previous solutions that are stored in memory. These are actually the primitive values, but we will convert to conservatives. ---*/ - V_time_nM1 = node[iPoint]->GetSolution_time_n1(); - V_time_n = node[iPoint]->GetSolution_time_n(); - V_time_nP1 = node[iPoint]->GetSolution(); + V_time_nM1 = nodes->GetSolution_time_n1(iPoint); + V_time_n = nodes->GetSolution_time_n(iPoint); + V_time_nP1 = nodes->GetSolution(iPoint); /*--- Access the density and Cp at this node (constant for now). ---*/ - - Density = node[iPoint]->GetDensity(); - Cp = node[iPoint]->GetSpecificHeatCp(); + + Density = nodes->GetDensity(iPoint); + Cp = nodes->GetSpecificHeatCp(iPoint); /*--- Compute the conservative variable vector for all time levels. ---*/ @@ -5968,6 +5961,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver LinSysRes.AddBlock(iPoint, Residual); if (implicit) { + SetPreconditioner(config, iPoint); for (iVar = 0; iVar < nVar; iVar++) { for (jVar = 0; jVar < nVar; jVar++) { @@ -6034,13 +6028,13 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver /*--- Compute the GCL component of the source term for node i ---*/ - V_time_n = node[iPoint]->GetSolution_time_n(); + V_time_n = nodes->GetSolution_time_n(iPoint); /*--- Access the density and Cp at this node (constant for now). ---*/ - - Density = node[iPoint]->GetDensity(); - Cp = node[iPoint]->GetSpecificHeatCp(); - + + Density = nodes->GetDensity(iPoint); + Cp = nodes->GetSpecificHeatCp(iPoint); + /*--- Compute the conservative variable vector for all time levels. ---*/ U_time_n[0] = Density; @@ -6057,7 +6051,7 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver /*--- Compute the GCL component of the source term for node j ---*/ - V_time_n = node[jPoint]->GetSolution_time_n(); + V_time_n = nodes->GetSolution_time_n(jPoint); U_time_n[0] = Density; for (iDim = 0; iDim < nDim; iDim++) { @@ -6102,12 +6096,12 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver /*--- Compute the GCL component of the source term for node i ---*/ - V_time_n = node[iPoint]->GetSolution_time_n(); + V_time_n = nodes->GetSolution_time_n(iPoint); /*--- Access the density and Cp at this node (constant for now). ---*/ - Density = node[iPoint]->GetDensity(); - Cp = node[iPoint]->GetSpecificHeatCp(); + Density = nodes->GetDensity(iPoint); + Cp = nodes->GetSpecificHeatCp(iPoint); U_time_n[0] = Density; for (iDim = 0; iDim < nDim; iDim++) { @@ -6144,14 +6138,14 @@ void CIncEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver we are currently iterating on U^n+1 and that U^n & U^n-1 are fixed, previous solutions that are stored in memory. ---*/ - V_time_nM1 = node[iPoint]->GetSolution_time_n1(); - V_time_n = node[iPoint]->GetSolution_time_n(); - V_time_nP1 = node[iPoint]->GetSolution(); + V_time_nM1 = nodes->GetSolution_time_n1(iPoint); + V_time_n = nodes->GetSolution_time_n(iPoint); + V_time_nP1 = nodes->GetSolution(iPoint); /*--- Access the density and Cp at this node (constant for now). ---*/ - Density = node[iPoint]->GetDensity(); - Cp = node[iPoint]->GetSpecificHeatCp(); + Density = nodes->GetDensity(iPoint); + Cp = nodes->GetSpecificHeatCp(iPoint); /*--- Compute the conservative variable vector for all time levels. ---*/ @@ -6277,7 +6271,7 @@ void CIncEulerSolver::GetOutlet_Properties(CGeometry *geometry, CConfig *config, if (geometry->node[iPoint]->GetDomain()) { - V_outlet = node[iPoint]->GetPrimitive(); + V_outlet = nodes->GetPrimitive(iPoint); geometry->vertex[iMarker][iVertex]->GetNormal(Vector); @@ -6473,7 +6467,7 @@ void CIncEulerSolver::ComputeVerificationError(CGeometry *geometry, /* Set the pointers to the coordinates and solution of this DOF. */ const su2double *coor = geometry->node[iPoint]->GetCoord(); - su2double *solDOF = node[iPoint]->GetSolution(); + su2double *solDOF = nodes->GetSolution(iPoint); /* Get local error from the verification solution class. */ vector error(nVar,0.0); @@ -6611,7 +6605,7 @@ void CIncEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf index = counter*Restart_Vars[1] + skipVars; for (iVar = 0; iVar < nVar_Restart; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); iPoint_Global_Local++; /*--- For dynamic meshes, read in and store the @@ -6694,12 +6688,12 @@ void CIncEulerSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver[iMesh-1][FLOW_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver[iMesh-1][FLOW_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver[iMesh][FLOW_SOL]->node[iPoint]->SetSolution(Solution); + solver[iMesh][FLOW_SOL]->GetNodes()->SetSolution(iPoint,Solution); } solver[iMesh][FLOW_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION); solver[iMesh][FLOW_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION); @@ -6786,11 +6780,11 @@ void CIncEulerSolver::SetFreeStream_Solution(CConfig *config){ unsigned short iDim; for (iPoint = 0; iPoint < nPoint; iPoint++){ - node[iPoint]->SetSolution(0, Pressure_Inf); + nodes->SetSolution(iPoint,0, Pressure_Inf); for (iDim = 0; iDim < nDim; iDim++){ - node[iPoint]->SetSolution(iDim+1, Velocity_Inf[iDim]); + nodes->SetSolution(iPoint,iDim+1, Velocity_Inf[iDim]); } - node[iPoint]->SetSolution(nDim+1, Temperature_Inf); + nodes->SetSolution(iPoint,nDim+1, Temperature_Inf); } } @@ -6936,9 +6930,6 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short SetVerificationSolution(nDim, nVar, config); - /*--- Allocate the node variables ---*/ - node = new CVariable*[nPoint]; - /*--- Define some auxiliar vector related with the residual ---*/ Residual = new su2double[nVar]; for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = 0.0; @@ -7357,8 +7348,8 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short /*--- Initialize the solution to the far-field state everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nDim, nVar, config); + nodes = new CIncNSVariable(Pressure_Inf, Velocity_Inf, Temperature_Inf, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); /*--- Initialize the BGS residuals in FSI problems. ---*/ if (config->GetMultizone_Residual()){ @@ -7407,7 +7398,7 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->SetLocalCFL(CFL); + nodes->SetLocalCFL(iPoint, CFL); } Min_CFL_Local = CFL; Max_CFL_Local = CFL; @@ -7554,14 +7545,13 @@ if (config->GetReconstructionGradientRequired() && (iMesh == MESH_0)) { /*--- Evaluate the vorticity and strain rate magnitude ---*/ + solver_container[FLOW_SOL]->GetNodes()->SetVorticity_StrainMag(); + StrainMag_Max = 0.0; Omega_Max = 0.0; for (iPoint = 0; iPoint < nPoint; iPoint++) { - solver_container[FLOW_SOL]->node[iPoint]->SetVorticity(); - solver_container[FLOW_SOL]->node[iPoint]->SetStrainMag(); - - StrainMag = solver_container[FLOW_SOL]->node[iPoint]->GetStrainMag(); - Vorticity = solver_container[FLOW_SOL]->node[iPoint]->GetVorticity(); + StrainMag = solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint); + Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); Omega = sqrt(Vorticity[0]*Vorticity[0]+ Vorticity[1]*Vorticity[1]+ Vorticity[2]*Vorticity[2]); StrainMag_Max = max(StrainMag_Max, StrainMag); @@ -7611,25 +7601,25 @@ unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, C /*--- Retrieve the value of the kinetic energy (if needed) ---*/ if (turb_model != NONE) { - eddy_visc = solver_container[TURB_SOL]->node[iPoint]->GetmuT(); - if (tkeNeeded) turb_ke = solver_container[TURB_SOL]->node[iPoint]->GetSolution(0); + eddy_visc = solver_container[TURB_SOL]->GetNodes()->GetmuT(iPoint); + if (tkeNeeded) turb_ke = solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0); if (config->GetKind_HybridRANSLES() != NO_HYBRIDRANSLES){ - DES_LengthScale = solver_container[TURB_SOL]->node[iPoint]->GetDES_LengthScale(); + DES_LengthScale = solver_container[TURB_SOL]->GetNodes()->GetDES_LengthScale(iPoint); } } /*--- Incompressible flow, primitive variables --- */ - physical = node[iPoint]->SetPrimVar(eddy_visc, turb_ke, FluidModel); + physical = static_cast(nodes)->SetPrimVar(iPoint,eddy_visc, turb_ke, FluidModel); /* Check for non-realizable states for reporting. */ if (!physical) nonPhysicalPoints++; - + /*--- Set the DES length scale ---*/ - node[iPoint]->SetDES_LengthScale(DES_LengthScale); + nodes->SetDES_LengthScale(iPoint,DES_LengthScale); /*--- Initialize the convective, source and viscous residual vector ---*/ @@ -7659,8 +7649,8 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Set maximum inviscid eigenvalue to zero, and compute sound speed and viscosity ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->SetMax_Lambda_Inv(0.0); - node[iPoint]->SetMax_Lambda_Visc(0.0); + nodes->SetMax_Lambda_Inv(iPoint,0.0); + nodes->SetMax_Lambda_Visc(iPoint,0.0); } /*--- Loop interior edges ---*/ @@ -7677,9 +7667,9 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Mean Values ---*/ - Mean_ProjVel = 0.5 * (node[iPoint]->GetProjVel(Normal) + node[jPoint]->GetProjVel(Normal)); - Mean_BetaInc2 = 0.5 * (node[iPoint]->GetBetaInc2() + node[jPoint]->GetBetaInc2()); - Mean_Density = 0.5 * (node[iPoint]->GetDensity() + node[jPoint]->GetDensity()); + Mean_ProjVel = 0.5 * (nodes->GetProjVel(iPoint,Normal) + nodes->GetProjVel(jPoint,Normal)); + Mean_BetaInc2 = 0.5 * (nodes->GetBetaInc2(iPoint) + nodes->GetBetaInc2(jPoint)); + Mean_Density = 0.5 * (nodes->GetDensity(iPoint) + nodes->GetDensity(jPoint)); Mean_SoundSpeed = sqrt(Mean_BetaInc2*Area*Area); /*--- Adjustment for grid movement ---*/ @@ -7698,24 +7688,24 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Inviscid contribution ---*/ Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Inv(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddMax_Lambda_Inv(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(iPoint,Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Inv(jPoint,Lambda); /*--- Viscous contribution ---*/ - Mean_LaminarVisc = 0.5*(node[iPoint]->GetLaminarViscosity() + node[jPoint]->GetLaminarViscosity()); - Mean_EddyVisc = 0.5*(node[iPoint]->GetEddyViscosity() + node[jPoint]->GetEddyViscosity()); - Mean_Density = 0.5*(node[iPoint]->GetDensity() + node[jPoint]->GetDensity()); - Mean_Thermal_Conductivity = 0.5*(node[iPoint]->GetThermalConductivity() + node[jPoint]->GetThermalConductivity()); - Mean_Cv = 0.5*(node[iPoint]->GetSpecificHeatCv() + node[jPoint]->GetSpecificHeatCv()); + Mean_LaminarVisc = 0.5*(nodes->GetLaminarViscosity(iPoint) + nodes->GetLaminarViscosity(jPoint)); + Mean_EddyVisc = 0.5*(nodes->GetEddyViscosity(iPoint) + nodes->GetEddyViscosity(jPoint)); + Mean_Density = 0.5*(nodes->GetDensity(iPoint) + nodes->GetDensity(jPoint)); + Mean_Thermal_Conductivity = 0.5*(nodes->GetThermalConductivity(iPoint) + nodes->GetThermalConductivity(jPoint)); + Mean_Cv = 0.5*(nodes->GetSpecificHeatCv(iPoint) + nodes->GetSpecificHeatCv(jPoint)); Lambda_1 = (4.0/3.0)*(Mean_LaminarVisc + Mean_EddyVisc); Lambda_2 = 0.0; if (energy) Lambda_2 = (1.0/Mean_Cv)*Mean_Thermal_Conductivity; Lambda = (Lambda_1 + Lambda_2)*Area*Area/Mean_Density; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Visc(Lambda); - if (geometry->node[jPoint]->GetDomain()) node[jPoint]->AddMax_Lambda_Visc(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(iPoint,Lambda); + if (geometry->node[jPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(jPoint,Lambda); } @@ -7734,9 +7724,9 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Mean Values ---*/ - Mean_ProjVel = node[iPoint]->GetProjVel(Normal); - Mean_BetaInc2 = node[iPoint]->GetBetaInc2(); - Mean_Density = node[iPoint]->GetDensity(); + Mean_ProjVel = nodes->GetProjVel(iPoint,Normal); + Mean_BetaInc2 = nodes->GetBetaInc2(iPoint); + Mean_Density = nodes->GetDensity(iPoint); Mean_SoundSpeed = sqrt(Mean_BetaInc2*Area*Area); /*--- Adjustment for grid movement ---*/ @@ -7753,23 +7743,23 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Lambda = fabs(Mean_ProjVel) + Mean_SoundSpeed; if (geometry->node[iPoint]->GetDomain()) { - node[iPoint]->AddMax_Lambda_Inv(Lambda); + nodes->AddMax_Lambda_Inv(iPoint,Lambda); } /*--- Viscous contribution ---*/ - Mean_LaminarVisc = node[iPoint]->GetLaminarViscosity(); - Mean_EddyVisc = node[iPoint]->GetEddyViscosity(); - Mean_Density = node[iPoint]->GetDensity(); - Mean_Thermal_Conductivity = node[iPoint]->GetThermalConductivity(); - Mean_Cv = node[iPoint]->GetSpecificHeatCv(); + Mean_LaminarVisc = nodes->GetLaminarViscosity(iPoint); + Mean_EddyVisc = nodes->GetEddyViscosity(iPoint); + Mean_Density = nodes->GetDensity(iPoint); + Mean_Thermal_Conductivity = nodes->GetThermalConductivity(iPoint); + Mean_Cv = nodes->GetSpecificHeatCv(iPoint); Lambda_1 = (4.0/3.0)*(Mean_LaminarVisc + Mean_EddyVisc); Lambda_2 = 0.0; if (energy) Lambda_2 = (1.0/Mean_Cv)*Mean_Thermal_Conductivity; Lambda = (Lambda_1 + Lambda_2)*Area*Area/Mean_Density; - if (geometry->node[iPoint]->GetDomain()) node[iPoint]->AddMax_Lambda_Visc(Lambda); + if (geometry->node[iPoint]->GetDomain()) nodes->AddMax_Lambda_Visc(iPoint,Lambda); } } @@ -7782,18 +7772,18 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Vol = geometry->node[iPoint]->GetVolume(); if (Vol != 0.0) { - Local_Delta_Time = node[iPoint]->GetLocalCFL()*Vol / node[iPoint]->GetMax_Lambda_Inv(); - Local_Delta_Time_Visc = node[iPoint]->GetLocalCFL()*K_v*Vol*Vol/ node[iPoint]->GetMax_Lambda_Visc(); + Local_Delta_Time = nodes->GetLocalCFL(iPoint)*Vol / nodes->GetMax_Lambda_Inv(iPoint); + Local_Delta_Time_Visc = nodes->GetLocalCFL(iPoint)*K_v*Vol*Vol/ nodes->GetMax_Lambda_Visc(iPoint); Local_Delta_Time = min(Local_Delta_Time, Local_Delta_Time_Visc); Global_Delta_Time = min(Global_Delta_Time, Local_Delta_Time); Min_Delta_Time = min(Min_Delta_Time, Local_Delta_Time); Max_Delta_Time = max(Max_Delta_Time, Local_Delta_Time); if (Local_Delta_Time > config->GetMax_DeltaTime()) Local_Delta_Time = config->GetMax_DeltaTime(); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } else { - node[iPoint]->SetDelta_Time(0.0); + nodes->SetDelta_Time(iPoint,0.0); } } @@ -7835,8 +7825,8 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, /*--- Sets the regular CFL equal to the unsteady CFL ---*/ - node[iPoint]->SetLocalCFL(config->GetUnst_CFL()); - node[iPoint]->SetDelta_Time(Global_Delta_Time); + nodes->SetLocalCFL(iPoint, config->GetUnst_CFL()); + nodes->SetDelta_Time(iPoint, Global_Delta_Time); Min_Delta_Time = Global_Delta_Time; Max_Delta_Time = Global_Delta_Time; @@ -7849,7 +7839,7 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, Global_Delta_UnstTimeND = 1e30; for (iPoint = 0; iPoint < nPointDomain; iPoint++){ - Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/node[iPoint]->GetLocalCFL()); + Global_Delta_UnstTimeND = min(Global_Delta_UnstTimeND,config->GetUnst_CFL()*Global_Delta_Time/nodes->GetLocalCFL(iPoint)); } #ifdef HAVE_MPI @@ -7866,8 +7856,8 @@ void CIncNSSolver::SetTime_Step(CGeometry *geometry, CSolver **solver_container, if (dual_time) for (iPoint = 0; iPoint < nPointDomain; iPoint++) { if (!implicit) { - Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), node[iPoint]->GetDelta_Time()); - node[iPoint]->SetDelta_Time(Local_Delta_Time); + Local_Delta_Time = min((2.0/3.0)*config->GetDelta_UnstTimeND(), nodes->GetDelta_Time(iPoint)); + nodes->SetDelta_Time(iPoint,Local_Delta_Time); } } @@ -7892,19 +7882,19 @@ void CIncNSSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Primitive and secondary variables ---*/ - numerics->SetPrimitive(node[iPoint]->GetPrimitive(), - node[jPoint]->GetPrimitive()); + numerics->SetPrimitive(nodes->GetPrimitive(iPoint), + nodes->GetPrimitive(jPoint)); /*--- Gradient and limiters ---*/ - numerics->SetPrimVarGradient(node[iPoint]->GetGradient_Primitive(), - node[jPoint]->GetGradient_Primitive()); + numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), + nodes->GetGradient_Primitive(jPoint)); /*--- Turbulent kinetic energy ---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->node[iPoint]->GetSolution(0), - solver_container[TURB_SOL]->node[jPoint]->GetSolution(0)); + numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), + solver_container[TURB_SOL]->GetNodes()->GetSolution(jPoint,0)); /*--- Compute and update residual ---*/ @@ -8047,13 +8037,13 @@ void CIncNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = nodes->GetGradient_Primitive(iPoint,iDim+1, jDim); } - Grad_Temp[iDim] = node[iPoint]->GetGradient_Primitive(nDim+1, iDim); + Grad_Temp[iDim] = nodes->GetGradient_Primitive(iPoint,nDim+1, iDim); } - Viscosity = node[iPoint]->GetLaminarViscosity(); - Density = node[iPoint]->GetDensity(); + Viscosity = nodes->GetLaminarViscosity(iPoint); + Density = nodes->GetDensity(iPoint); Area = 0.0; for (iDim = 0; iDim < nDim; iDim++) Area += Normal[iDim]*Normal[iDim]; Area = sqrt(Area); for (iDim = 0; iDim < nDim; iDim++) { @@ -8109,7 +8099,7 @@ void CIncNSSolver::Friction_Forces(CGeometry *geometry, CConfig *config) { GradTemperature -= Grad_Temp[iDim]*UnitNormal[iDim]; } - thermal_conductivity = node[iPoint]->GetThermalConductivity(); + thermal_conductivity = nodes->GetThermalConductivity(iPoint); HeatFlux[iMarker][iVertex] = -thermal_conductivity*GradTemperature*RefHeatFlux; HF_Visc[iMarker] += HeatFlux[iMarker][iVertex]*Area; MaxHF_Visc[iMarker] += pow(HeatFlux[iMarker][iVertex], MaxNorm); @@ -8455,11 +8445,11 @@ void CIncNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_contai condition (Dirichlet). Fix the velocity and remove any contribution to the residual at this node. ---*/ - node[iPoint]->SetVelocity_Old(Vector); + nodes->SetVelocity_Old(iPoint,Vector); for (iDim = 0; iDim < nDim; iDim++) LinSysRes.SetBlock_Zero(iPoint, iDim+1); - node[iPoint]->SetVel_ResTruncError_Zero(); + nodes->SetVel_ResTruncError_Zero(iPoint); if (energy) { @@ -8551,11 +8541,11 @@ void CIncNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont condition (Dirichlet). Fix the velocity and remove any contribution to the residual at this node. ---*/ - node[iPoint]->SetVelocity_Old(Vector); + nodes->SetVelocity_Old(iPoint,Vector); for (iDim = 0; iDim < nDim; iDim++) LinSysRes.SetBlock_Zero(iPoint, iDim+1); - node[iPoint]->SetVel_ResTruncError_Zero(); + nodes->SetVel_ResTruncError_Zero(iPoint); if (energy) { @@ -8583,11 +8573,11 @@ void CIncNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont /*--- Compute the normal gradient in temperature using Twall ---*/ - dTdn = -(node[Point_Normal]->GetTemperature() - Twall)/dist_ij; + dTdn = -(nodes->GetTemperature(Point_Normal) - Twall)/dist_ij; /*--- Get thermal conductivity ---*/ - thermal_conductivity = node[iPoint]->GetThermalConductivity(); + thermal_conductivity = nodes->GetThermalConductivity(iPoint); /*--- Apply a weak boundary condition for the energy equation. Compute the residual due to the prescribed heat flux. ---*/ @@ -8636,12 +8626,9 @@ void CIncNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CConfig *config, unsigned short val_marker) { unsigned short iVar, jVar, iDim, Wall_Function; - unsigned long iVertex, iPoint, Point_Normal, total_index; + unsigned long iVertex, iPoint, total_index; - su2double *GridVel; - su2double *Normal, *Coord_i, *Coord_j, Area, dist_ij; - su2double Tconjugate, dTdn; - su2double thermal_conductivity; + su2double *GridVel, Tconjugate; su2double Temperature_Ref = config->GetTemperature_Ref(); bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); @@ -8691,73 +8678,21 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol condition (Dirichlet). Fix the velocity and remove any contribution to the residual at this node. ---*/ - node[iPoint]->SetVelocity_Old(Vector); + nodes->SetVelocity_Old(iPoint,Vector); for (iDim = 0; iDim < nDim; iDim++) LinSysRes.SetBlock_Zero(iPoint, iDim+1); - node[iPoint]->SetVel_ResTruncError_Zero(); + nodes->SetVel_ResTruncError_Zero(iPoint); if (energy) { Tconjugate = GetConjugateHeatVariable(val_marker, iVertex, 0)/Temperature_Ref; -// node[iPoint]->SetSolution_Old(nDim+1, Tconjugate); -// node[iPoint]->SetEnergy_ResTruncError_Zero(); - - Normal = geometry->vertex[val_marker][iVertex]->GetNormal(); - - Area = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - Area += Normal[iDim]*Normal[iDim]; - Area = sqrt (Area); - - /*--- Compute closest normal neighbor ---*/ - - Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); - - /*--- Get coordinates of i & nearest normal and compute distance ---*/ - - Coord_i = geometry->node[iPoint]->GetCoord(); - Coord_j = geometry->node[Point_Normal]->GetCoord(); - dist_ij = 0; - for (iDim = 0; iDim < nDim; iDim++) - dist_ij += (Coord_j[iDim]-Coord_i[iDim])*(Coord_j[iDim]-Coord_i[iDim]); - dist_ij = sqrt(dist_ij); + /*--- Strong imposition of the temperature on the fluid zone. ---*/ - /*--- Compute the normal gradient in temperature using Twall ---*/ - - dTdn = -(node[Point_Normal]->GetTemperature() - Tconjugate)/dist_ij; - - /*--- Get thermal conductivity ---*/ - - thermal_conductivity = node[iPoint]->GetThermalConductivity(); - - /*--- Apply a weak boundary condition for the energy equation. - Compute the residual due to the prescribed heat flux. ---*/ - - Res_Visc[nDim+1] = thermal_conductivity*dTdn*Area; - - /*--- Jacobian contribution for temperature equation. ---*/ - - if (implicit) { - su2double Edge_Vector[3]; - su2double dist_ij_2 = 0, proj_vector_ij = 0; - for (iDim = 0; iDim < nDim; iDim++) { - Edge_Vector[iDim] = Coord_j[iDim]-Coord_i[iDim]; - dist_ij_2 += Edge_Vector[iDim]*Edge_Vector[iDim]; - proj_vector_ij += Edge_Vector[iDim]*Normal[iDim]; - } - if (dist_ij_2 == 0.0) proj_vector_ij = 0.0; - else proj_vector_ij = proj_vector_ij/dist_ij_2; - - Jacobian_i[nDim+1][nDim+1] = -thermal_conductivity*proj_vector_ij; - - Jacobian.SubtractBlock(iPoint, iPoint, Jacobian_i); - } - - /*--- Viscous contribution to the residual at the wall ---*/ - - LinSysRes.SubtractBlock(iPoint, Res_Visc); + LinSysRes.SetBlock_Zero(iPoint, nDim+1); + nodes->SetSolution_Old(iPoint, nDim+1, Tconjugate); + nodes->SetEnergy_ResTruncError_Zero(iPoint); } @@ -8769,10 +8704,10 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol total_index = iPoint*nVar+iVar; Jacobian.DeleteValsRowi(total_index); } -// if(energy) { -// total_index = iPoint*nVar+nDim+1; -// Jacobian.DeleteValsRowi(total_index); -// } + if(energy) { + total_index = iPoint*nVar+nDim+1; + Jacobian.DeleteValsRowi(total_index); + } } } diff --git a/SU2_CFD/src/solver_direct_transition.cpp b/SU2_CFD/src/solver_direct_transition.cpp index cadbd68c84bb..c2e2952b9c56 100644 --- a/SU2_CFD/src/solver_direct_transition.cpp +++ b/SU2_CFD/src/solver_direct_transition.cpp @@ -44,7 +44,7 @@ CTransLMSolver::CTransLMSolver(void) : CTurbSolver() {} CTransLMSolver::CTransLMSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) : CTurbSolver() { unsigned short iVar, iDim, nLineLets; unsigned long iPoint, index; - su2double Density_Inf, Viscosity_Inf, tu_Inf, nu_tilde_Inf, Factor_nu_Inf, dull_val, rey; + su2double tu_Inf, dull_val, rey; ifstream restart_file; char *cstr; string text_line; @@ -60,8 +60,6 @@ CTransLMSolver::CTransLMSolver(CGeometry *geometry, CConfig *config, unsigned sh nPoint = geometry->GetnPoint(); nPointDomain = geometry->GetnPointDomain(); - node = new CVariable*[geometry->GetnPoint()]; - /*--- Dimension of the problem --> 2 Transport equations (intermittency, Reth) ---*/ nVar = 2; @@ -126,42 +124,27 @@ CTransLMSolver::CTransLMSolver(CGeometry *geometry, CConfig *config, unsigned sh for (iVar = 0; iVar < nVar; iVar++) Cvector[iVar] = new su2double [nDim]; } - - /*--- Read farfield conditions from config ---*/ - Density_Inf = config->GetDensity_FreeStreamND(); - Viscosity_Inf = config->GetViscosity_FreeStreamND(); - Intermittency_Inf = config->GetIntermittency_FreeStream(); - tu_Inf = config->GetTurbulenceIntensity_FreeStream(); - - /*-- Initialize REth from correlation --*/ - if (tu_Inf <= 1.3) { - REth_Inf = (1173.51-589.428*tu_Inf+0.2196/(tu_Inf*tu_Inf)); - } else { - REth_Inf = 331.5*pow(tu_Inf-0.5658,-0.671); - } - rey = config->GetReynolds(); -// REth_Inf *= mach/rey; - cout << "REth_Inf = " << REth_Inf << ", rey: "<< rey << " -AA" << endl; - - /*--- Factor_nu_Inf in [3.0, 5.0] ---*/ - Factor_nu_Inf = config->GetNuFactor_FreeStream(); - nu_tilde_Inf = Factor_nu_Inf*Viscosity_Inf/Density_Inf; + /*--- Read farfield conditions from config ---*/ + Intermittency_Inf = config->GetIntermittency_FreeStream(); + tu_Inf = config->GetTurbulenceIntensity_FreeStream(); - /*--- Restart the solution from file information ---*/ - if (!restart) { - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - // TODO: Erase this bubble of specially initialized points -AA -// if (iPoint == 9745||iPoint == 9746||iPoint == 9608||iPoint == 9609) { -// node[iPoint] = new CTransLMVariable(nu_tilde_Inf, 0.0, 1100.0, nDim, nVar, config); -// } else { - node[iPoint] = new CTransLMVariable(nu_tilde_Inf, Intermittency_Inf, REth_Inf, nDim, nVar, config); - // } - } + /*-- Initialize REth from correlation --*/ + if (tu_Inf <= 1.3) { + REth_Inf = (1173.51-589.428*tu_Inf+0.2196/(tu_Inf*tu_Inf)); + } else { + REth_Inf = 331.5*pow(tu_Inf-0.5658,-0.671); } + rey = config->GetReynolds(); - } - else { + // REth_Inf *= mach/rey; + cout << "REth_Inf = " << REth_Inf << ", rey: "<< rey << " -AA" << endl; + + /*--- Restart the solution from file information ---*/ + if (!restart) nodes = new CTransLMVariable(Intermittency_Inf, REth_Inf, nPoint, nDim, nVar, config); + + } else { /*--- Coarse levels ---*/ + cout << "No LM restart yet!!" << endl; // TODO, Aniket int j; cin >> j; @@ -173,15 +156,20 @@ CTransLMSolver::CTransLMSolver(CGeometry *geometry, CConfig *config, unsigned sh SU2_MPI::Error("There is no turbulent restart file.", CURRENT_FUNCTION); } + nodes = new CTurbSAVariable(0.0, 0.0, nPoint, nDim, nVar, config); + for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { getline(restart_file, text_line); istringstream point_line(text_line); if (nDim == 2) point_line >> index >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> Solution[0]; if (nDim == 3) point_line >> index >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> dull_val >> Solution[0]; - node[iPoint] = new CTurbSAVariable(Solution[0], 0, nDim, nVar, config); + nodes->SetSolution(iPoint,0,Solution[0]); + nodes->SetSolution_Old(iPoint,0,Solution[0]); } restart_file.close(); } + + SetBaseClassPointerToNodes(); /*--- Add the solver name (max 8 characters) ---*/ SolverName = "TRANS"; @@ -207,7 +195,7 @@ void CTransLMSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai /*--- Correction for separation-induced transition, Replace intermittency with gamma_eff ---*/ for (unsigned int iPoint = 0; iPoint < geometry->GetnPoint(); iPoint ++) - node[iPoint]->SetGammaEff(); + nodes->SetGammaEff(iPoint); } void CTransLMSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { @@ -231,7 +219,7 @@ void CTransLMSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - Delta_flow = Vol / (solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time()); + Delta_flow = Vol / (solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint)); Delta = Delta_flow; Jacobian.AddVal2Diag(iPoint, Delta); @@ -265,7 +253,7 @@ void CTransLMSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solv for (iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) { for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->AddSolution(iVar, LinSysSol[iPoint*nVar+iVar]); + nodes->AddSolution(iPoint,iVar, LinSysSol[iPoint*nVar+iVar]); } /*--- MPI solution ---*/ @@ -291,13 +279,13 @@ void CTransLMSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_conta numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); /*--- Conservative variables w/o reconstruction ---*/ - U_i = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); - U_j = solver_container[FLOW_SOL]->node[jPoint]->GetSolution(); + U_i = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); + U_j = solver_container[FLOW_SOL]->GetNodes()->GetSolution(jPoint); numerics->SetConservative(U_i, U_j); /*--- Transition variables w/o reconstruction ---*/ - trans_var_i = node[iPoint]->GetSolution(); - trans_var_j = node[jPoint]->GetSolution(); + trans_var_i = nodes->GetSolution(iPoint); + trans_var_j = nodes->GetSolution(jPoint); numerics->SetTransVar(trans_var_i, trans_var_j); /*--- Add and subtract Residual ---*/ @@ -333,22 +321,23 @@ void CTransLMSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_cont numerics->SetNormal(geometry->edge[iEdge]->GetNormal()); /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetConservative(solver_container[FLOW_SOL]->node[iPoint]->GetSolution(), - solver_container[FLOW_SOL]->node[jPoint]->GetSolution()); + numerics->SetConservative(solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetSolution(jPoint)); /*--- Laminar Viscosity ---*/ - numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(), - solver_container[FLOW_SOL]->node[jPoint]->GetLaminarViscosity()); + numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint)); /*--- Eddy Viscosity ---*/ - numerics->SetEddyViscosity(solver_container[FLOW_SOL]->node[iPoint]->GetEddyViscosity(), - solver_container[FLOW_SOL]->node[jPoint]->GetEddyViscosity()); + numerics->SetEddyViscosity(solver_container[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetEddyViscosity(jPoint)); /*--- Transition variables w/o reconstruction, and its gradients ---*/ - numerics->SetTransVar(node[iPoint]->GetSolution(), node[jPoint]->GetSolution()); - numerics->SetTransVarGradient(node[iPoint]->GetGradient(), node[jPoint]->GetGradient()); + numerics->SetTransVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); + numerics->SetTransVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(jPoint)); - numerics->SetConsVarGradient(solver_container[FLOW_SOL]->node[iPoint]->GetGradient(), - solver_container[FLOW_SOL]->node[jPoint]->GetGradient()); +// ToDo: The flow solvers do not use the conservative variable gradients +// numerics->SetConsVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient(iPoint), +// solver_container[FLOW_SOL]->GetNodes()->GetGradient(jPoint)); /*--- Compute residual, and Jacobians ---*/ @@ -378,21 +367,21 @@ void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetConservative(solver_container[FLOW_SOL]->node[iPoint]->GetSolution(), NULL); + numerics->SetConservative(solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint), NULL); /*--- Gradient of the primitive and conservative variables ---*/ - numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(), NULL); + numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint), NULL); /*--- Laminar and eddy viscosity ---*/ - numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(), 0.0); - numerics->SetEddyViscosity(solver_container[FLOW_SOL]->node[iPoint]->GetEddyViscosity(),0.0); + numerics->SetLaminarViscosity(solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint), 0.0); + numerics->SetEddyViscosity(solver_container[FLOW_SOL]->GetNodes()->GetEddyViscosity(iPoint),0.0); /*--- Turbulent variables w/o reconstruction, and its gradient ---*/ - numerics->SetTransVar(node[iPoint]->GetSolution(), NULL); - // numerics->SetTransVarGradient(node[iPoint]->GetGradient(), NULL); // Is this needed?? + numerics->SetTransVar(nodes->GetSolution(iPoint), NULL); + // numerics->SetTransVarGradient(nodes->GetGradient(iPoint), NULL); // Is this needed?? /*--- Set volume ---*/ @@ -408,7 +397,7 @@ void CTransLMSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*-- Store gamma_sep in variable class --*/ - node[iPoint]->SetGammaSep(gamma_sep); + nodes->SetGammaSep(iPoint,gamma_sep); /*--- Subtract residual and the Jacobian ---*/ @@ -447,14 +436,14 @@ void CTransLMSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont /*--- Set both interior and exterior point to current value ---*/ for (iVar=0; iVar < nVar; iVar++) { - U_domain[iVar] = node[iPoint]->GetSolution(iVar); - U_wall[iVar] = node[iPoint]->GetSolution(iVar); + U_domain[iVar] = nodes->GetSolution(iPoint,iVar); + U_wall[iVar] = nodes->GetSolution(iPoint,iVar); } /*--- Set various quantities in the solver class ---*/ numerics->SetNormal(Normal); numerics->SetTransVar(U_domain,U_wall); - U_i = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); + U_i = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint); numerics->SetConservative(U_i, U_i); /*--- Compute the residual using an upwind scheme ---*/ @@ -483,7 +472,7 @@ void CTransLMSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont // /*--- Impose boundary values (Dirichlet) ---*/ // Solution[0] = 0.0; // Solution[1] = 0.0; -// node[iPoint]->SetSolution_Old(Solution); +// nodes->SetSolution_Old(iPoint,Solution); // LinSysRes.SetBlock_Zero(iPoint); // // /*--- includes 1 in the diagonal ---*/ @@ -516,7 +505,7 @@ void CTransLMSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_containe /*--- Impose boundary values (Dirichlet) ---*/ Solution[0] = Intermittency_Inf; Solution[1] = REth_Inf; - node[iPoint]->SetSolution_Old(Solution); + nodes->SetSolution_Old(iPoint,Solution); LinSysRes.SetBlock_Zero(iPoint); /*--- includes 1 in the diagonal ---*/ diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index 9265a633269b..f2f577b98830 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -48,7 +48,7 @@ CTurbSolver::CTurbSolver(void) : CSolver() { nVertex = NULL; nMarker = 0; Inlet_TurbVars = NULL; - + snode = nullptr; } CTurbSolver::CTurbSolver(CGeometry* geometry, CConfig *config) : CSolver() { @@ -91,6 +91,7 @@ CTurbSolver::~CTurbSolver(void) { if (lowerlimit != NULL) delete [] lowerlimit; if (upperlimit != NULL) delete [] upperlimit; + if (nodes != nullptr) delete nodes; } void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { @@ -112,14 +113,14 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe /*--- Primitive variables w/o reconstruction ---*/ - V_i = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); - V_j = solver_container[FLOW_SOL]->node[jPoint]->GetPrimitive(); + V_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); + V_j = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(jPoint); numerics->SetPrimitive(V_i, V_j); /*--- Turbulent variables w/o reconstruction ---*/ - Turb_i = node[iPoint]->GetSolution(); - Turb_j = node[jPoint]->GetSolution(); + Turb_i = nodes->GetSolution(iPoint); + Turb_j = nodes->GetSolution(jPoint); numerics->SetTurbVar(Turb_i, Turb_j); /*--- Grid Movement ---*/ @@ -136,11 +137,11 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe /*--- Mean flow primitive variables using gradient reconstruction and limiters ---*/ - Gradient_i = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = solver_container[FLOW_SOL]->node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Reconstruction(iPoint); + Gradient_j = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Reconstruction(jPoint); if (limiter) { - Limiter_i = solver_container[FLOW_SOL]->node[iPoint]->GetLimiter_Primitive(); - Limiter_j = solver_container[FLOW_SOL]->node[jPoint]->GetLimiter_Primitive(); + Limiter_i = solver_container[FLOW_SOL]->GetNodes()->GetLimiter_Primitive(iPoint); + Limiter_j = solver_container[FLOW_SOL]->GetNodes()->GetLimiter_Primitive(jPoint); } for (iVar = 0; iVar < solver_container[FLOW_SOL]->GetnPrimVarGrad(); iVar++) { @@ -163,11 +164,11 @@ void CTurbSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe /*--- Turbulent variables using gradient reconstruction and limiters ---*/ - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = nodes->GetGradient_Reconstruction(jPoint); if (limiter) { - Limiter_i = node[iPoint]->GetLimiter(); - Limiter_j = node[jPoint]->GetLimiter(); + Limiter_i = nodes->GetLimiter(iPoint); + Limiter_j = nodes->GetLimiter(jPoint); } for (iVar = 0; iVar < nVar; iVar++) { @@ -227,17 +228,17 @@ void CTurbSolver::Viscous_Residual(CGeometry *geometry, CSolver **solver_contain /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetPrimitive(solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(), - solver_container[FLOW_SOL]->node[jPoint]->GetPrimitive()); + numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), + solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(jPoint)); /*--- Turbulent variables w/o reconstruction, and its gradients ---*/ - numerics->SetTurbVar(node[iPoint]->GetSolution(), node[jPoint]->GetSolution()); - numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[jPoint]->GetGradient()); + numerics->SetTurbVar(nodes->GetSolution(iPoint), nodes->GetSolution(jPoint)); + numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(jPoint)); /*--- Menter's first blending function (only SST)---*/ if ((config->GetKind_Turb_Model() == SST) || (config->GetKind_Turb_Model() == SST_SUST)) - numerics->SetF1blending(node[iPoint]->GetF1blending(), node[jPoint]->GetF1blending()); + numerics->SetF1blending(nodes->GetF1blending(iPoint), nodes->GetF1blending(jPoint)); /*--- Compute residual, and Jacobians ---*/ @@ -378,7 +379,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ /*--- Modify matrix diagonal to assure diagonal dominance ---*/ - Delta = Vol / ((node[iPoint]->GetLocalCFL()/solver_container[FLOW_SOL]->node[iPoint]->GetLocalCFL())*solver_container[FLOW_SOL]->node[iPoint]->GetDelta_Time()); + Delta = Vol / ((nodes->GetLocalCFL(iPoint)/solver_container[FLOW_SOL]->GetNodes()->GetLocalCFL(iPoint))*solver_container[FLOW_SOL]->GetNodes()->GetDelta_Time(iPoint)); Jacobian.AddVal2Diag(iPoint, Delta); /*--- Right hand side of the system (-Residual) and initial guess (x = 0) ---*/ @@ -424,7 +425,7 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ case SA: case SA_E: case SA_COMP: case SA_E_COMP: case SA_NEG: for (iPoint = 0; iPoint < nPointDomain; iPoint++) { - node[iPoint]->AddSolution(0, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint]); + nodes->AddSolution(iPoint, 0, nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint]); } break; @@ -434,16 +435,16 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ for (iPoint = 0; iPoint < nPointDomain; iPoint++) { if (compressible) { - density_old = solver_container[FLOW_SOL]->node[iPoint]->GetSolution_Old(0); - density = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); + density_old = solver_container[FLOW_SOL]->GetNodes()->GetSolution_Old(iPoint,0); + density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); } if (incompressible) { - density_old = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - density = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); + density_old = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); } for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->AddConservativeSolution(iVar, node[iPoint]->GetUnderRelaxation()*LinSysSol[iPoint*nVar+iVar], density, density_old, lowerlimit[iVar], upperlimit[iVar]); + nodes->AddConservativeSolution(iPoint, iVar, nodes->GetUnderRelaxation(iPoint)*LinSysSol[iPoint*nVar+iVar], density, density_old, lowerlimit[iVar], upperlimit[iVar]); } } @@ -508,7 +509,7 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf /* Choose the minimum factor between mean flow and turbulence. */ - localUnderRelaxation = min(localUnderRelaxation, solver_container[FLOW_SOL]->node[iPoint]->GetUnderRelaxation()); + localUnderRelaxation = min(localUnderRelaxation, solver_container[FLOW_SOL]->GetNodes()->GetUnderRelaxation(iPoint)); /* Threshold the relaxation factor in the event that there is a very small value. This helps avoid catastrophic crashes due @@ -518,7 +519,7 @@ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConf /* Store the under-relaxation factor for this point. */ - node[iPoint]->SetUnderRelaxation(localUnderRelaxation); + nodes->SetUnderRelaxation(iPoint, localUnderRelaxation); } @@ -558,9 +559,9 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con we are currently iterating on U^n+1 and that U^n & U^n-1 are fixed, previous solutions that are stored in memory. ---*/ - U_time_nM1 = node[iPoint]->GetSolution_time_n1(); - U_time_n = node[iPoint]->GetSolution_time_n(); - U_time_nP1 = node[iPoint]->GetSolution(); + U_time_nM1 = nodes->GetSolution_time_n1(iPoint); + U_time_n = nodes->GetSolution_time_n(iPoint); + U_time_nP1 = nodes->GetSolution(iPoint); /*--- CV volume at time n+1. As we are on a static mesh, the volume of the CV will remained fixed for all time steps. ---*/ @@ -579,14 +580,14 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con density could also be temperature dependent, but as it is not a part of the solution vector it's neither stored for previous time steps nor updated with the solution at the end of each iteration. */ - Density_nM1 = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - Density_n = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - Density_nP1 = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); + Density_nM1 = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + Density_n = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + Density_nP1 = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); } else{ - Density_nM1 = solver_container[FLOW_SOL]->node[iPoint]->GetSolution_time_n1()[0]; - Density_n = solver_container[FLOW_SOL]->node[iPoint]->GetSolution_time_n()[0]; - Density_nP1 = solver_container[FLOW_SOL]->node[iPoint]->GetSolution()[0]; + Density_nM1 = solver_container[FLOW_SOL]->GetNodes()->GetSolution_time_n1(iPoint)[0]; + Density_n = solver_container[FLOW_SOL]->GetNodes()->GetSolution_time_n(iPoint,0); + Density_nP1 = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint,0); } for (iVar = 0; iVar < nVar; iVar++) { @@ -656,13 +657,13 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Compute the GCL component of the source term for node i ---*/ - U_time_n = node[iPoint]->GetSolution_time_n(); + U_time_n = nodes->GetSolution_time_n(iPoint); /*--- Multiply by density at node i for the SST model ---*/ if ((turbModel == SST) || (turbModel == SST_SUST)) { - if (incompressible) Density_n = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); // Temporary fix - else Density_n = solver_container[FLOW_SOL]->node[iPoint]->GetSolution_time_n()[0]; + if (incompressible) Density_n = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); // Temporary fix + else Density_n = solver_container[FLOW_SOL]->GetNodes()->GetSolution_time_n(iPoint,0); for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; } else { @@ -673,13 +674,13 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Compute the GCL component of the source term for node j ---*/ - U_time_n = node[jPoint]->GetSolution_time_n(); + U_time_n = nodes->GetSolution_time_n(jPoint); /*--- Multiply by density at node j for the SST model ---*/ if ((turbModel == SST) || (turbModel == SST_SUST)) { - if (incompressible) Density_n = solver_container[FLOW_SOL]->node[jPoint]->GetDensity(); // Temporary fix - else Density_n = solver_container[FLOW_SOL]->node[jPoint]->GetSolution_time_n()[0]; + if (incompressible) Density_n = solver_container[FLOW_SOL]->GetNodes()->GetDensity(jPoint); // Temporary fix + else Density_n = solver_container[FLOW_SOL]->GetNodes()->GetSolution_time_n(jPoint)[0]; for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; } else { @@ -715,13 +716,13 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con /*--- Compute the GCL component of the source term for node i ---*/ - U_time_n = node[iPoint]->GetSolution_time_n(); + U_time_n = nodes->GetSolution_time_n(iPoint); /*--- Multiply by density at node i for the SST model ---*/ if ((turbModel == SST) || (turbModel == SST_SUST)) { - if (incompressible) Density_n = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); // Temporary fix - else Density_n = solver_container[FLOW_SOL]->node[iPoint]->GetSolution_time_n()[0]; + if (incompressible) Density_n = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); // Temporary fix + else Density_n = solver_container[FLOW_SOL]->GetNodes()->GetSolution_time_n(iPoint,0); for (iVar = 0; iVar < nVar; iVar++) Residual[iVar] = Density_n*U_time_n[iVar]*Residual_GCL; } else { @@ -743,9 +744,9 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con we are currently iterating on U^n+1 and that U^n & U^n-1 are fixed, previous solutions that are stored in memory. ---*/ - U_time_nM1 = node[iPoint]->GetSolution_time_n1(); - U_time_n = node[iPoint]->GetSolution_time_n(); - U_time_nP1 = node[iPoint]->GetSolution(); + U_time_nM1 = nodes->GetSolution_time_n1(iPoint); + U_time_n = nodes->GetSolution_time_n(iPoint); + U_time_nP1 = nodes->GetSolution(iPoint); /*--- CV volume at time n-1 and n+1. In the case of dynamically deforming grids, the volumes will change. On rigidly transforming grids, the @@ -767,14 +768,14 @@ void CTurbSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_con density could also be temperature dependent, but as it is not a part of the solution vector it's neither stored for previous time steps nor updated with the solution at the end of each iteration. */ - Density_nM1 = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - Density_n = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - Density_nP1 = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); + Density_nM1 = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + Density_n = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + Density_nP1 = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); } else{ - Density_nM1 = solver_container[FLOW_SOL]->node[iPoint]->GetSolution_time_n1()[0]; - Density_n = solver_container[FLOW_SOL]->node[iPoint]->GetSolution_time_n()[0]; - Density_nP1 = solver_container[FLOW_SOL]->node[iPoint]->GetSolution()[0]; + Density_nM1 = solver_container[FLOW_SOL]->GetNodes()->GetSolution_time_n1(iPoint)[0]; + Density_n = solver_container[FLOW_SOL]->GetNodes()->GetSolution_time_n(iPoint,0); + Density_nP1 = solver_container[FLOW_SOL]->GetNodes()->GetSolution(iPoint,0); } for (iVar = 0; iVar < nVar; iVar++) { @@ -875,7 +876,7 @@ void CTurbSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * index = counter*Restart_Vars[1] + skipVars; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); iPoint_Global_Local++; /*--- Increment the overall counter for how many points have been loaded. ---*/ @@ -915,12 +916,12 @@ void CTurbSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); Area_Children = geometry[iMesh-1]->node[Point_Fine]->GetVolume(); - Solution_Fine = solver[iMesh-1][TURB_SOL]->node[Point_Fine]->GetSolution(); + Solution_Fine = solver[iMesh-1][TURB_SOL]->GetNodes()->GetSolution(Point_Fine); for (iVar = 0; iVar < nVar; iVar++) { Solution[iVar] += Solution_Fine[iVar]*Area_Children/Area_Parent; } } - solver[iMesh][TURB_SOL]->node[iPoint]->SetSolution(Solution); + solver[iMesh][TURB_SOL]->GetNodes()->SetSolution(iPoint,Solution); } solver[iMesh][TURB_SOL]->InitiateComms(geometry[iMesh], config, SOLUTION_EDDY); solver[iMesh][TURB_SOL]->CompleteComms(geometry[iMesh], config, SOLUTION_EDDY); @@ -967,7 +968,6 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor /*--- Define geometry constants in the solver structure ---*/ nDim = geometry->GetnDim(); - node = new CVariable*[nPoint]; /*--- Single grid simulation ---*/ @@ -1098,8 +1098,8 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor /*--- Initialize the solution to the far-field state everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CTurbSAVariable(nu_tilde_Inf, muT_Inf, nDim, nVar, config); + nodes = new CTurbSAVariable(nu_tilde_Inf, muT_Inf, nPoint, nDim, nVar, config); + SetBaseClassPointerToNodes(); /*--- MPI solution ---*/ @@ -1155,7 +1155,7 @@ CTurbSASolver::CTurbSASolver(CGeometry *geometry, CConfig *config, unsigned shor const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->SetLocalCFL(CFL); + nodes->SetLocalCFL(iPoint, CFL); } Min_CFL_Local = CFL; Max_CFL_Local = CFL; @@ -1238,10 +1238,10 @@ void CTurbSASolver::Preprocessing(CGeometry *geometry, CSolver **solver_containe if (kind_hybridRANSLES == SA_EDDES){ for (iPoint = 0; iPoint < nPoint; iPoint++){ - PrimGrad_Flow = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); - Vorticity = solver_container[FLOW_SOL]->node[iPoint]->GetVorticity(); - Laminar_Viscosity = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); - node[iPoint]->SetVortex_Tilting(PrimGrad_Flow, Vorticity, Laminar_Viscosity); + PrimGrad_Flow = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); + Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); + Laminar_Viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + nodes->SetVortex_Tilting(iPoint,PrimGrad_Flow, Vorticity, Laminar_Viscosity); } } @@ -1264,11 +1264,11 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain for (iPoint = 0; iPoint < nPoint; iPoint ++) { - rho = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - mu = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); + rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); nu = mu/rho; - nu_hat = node[iPoint]->GetSolution(); + nu_hat = nodes->GetSolution(iPoint); Ji = nu_hat[0]/nu; Ji_3 = Ji*Ji*Ji; @@ -1278,7 +1278,7 @@ void CTurbSASolver::Postprocessing(CGeometry *geometry, CSolver **solver_contain if (neg_spalart_allmaras && (muT < 0.0)) muT = 0.0; - node[iPoint]->SetmuT(muT); + nodes->SetmuT(iPoint,muT); } @@ -1296,28 +1296,28 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetPrimitive(solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(), NULL); + numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), NULL); /*--- Gradient of the primitive and conservative variables ---*/ - numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(), NULL); + numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint), NULL); /*--- Set vorticity and strain rate magnitude ---*/ - numerics->SetVorticity(solver_container[FLOW_SOL]->node[iPoint]->GetVorticity(), NULL); + numerics->SetVorticity(solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint), NULL); - numerics->SetStrainMag(solver_container[FLOW_SOL]->node[iPoint]->GetStrainMag(), 0.0); + numerics->SetStrainMag(solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint), 0.0); /*--- Set intermittency ---*/ if (transition) { - numerics->SetIntermittency(solver_container[TRANS_SOL]->node[iPoint]->GetIntermittency()); + numerics->SetIntermittency(solver_container[TRANS_SOL]->GetNodes()->GetIntermittency(iPoint)); } /*--- Turbulent variables w/o reconstruction, and its gradient ---*/ - numerics->SetTurbVar(node[iPoint]->GetSolution(), NULL); - numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), NULL); + numerics->SetTurbVar(nodes->GetSolution(iPoint), NULL); + numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), NULL); /*--- Set volume ---*/ @@ -1335,7 +1335,7 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Set DES length scale ---*/ - numerics->SetDistance(node[iPoint]->GetDES_LengthScale(), 0.0); + numerics->SetDistance(nodes->GetDES_LengthScale(iPoint), 0.0); } @@ -1346,7 +1346,7 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Store the intermittency ---*/ if (transition_BC) { - node[iPoint]->SetGammaBC(numerics->GetGammaBC()); + nodes->SetGammaBC(iPoint,numerics->GetGammaBC()); } /*--- Subtract residual and the Jacobian ---*/ @@ -1373,7 +1373,7 @@ void CTurbSASolver::Source_Residual(CGeometry *geometry, CSolver **solver_contai /*--- Access stored harmonic balance source term ---*/ for (unsigned short iVar = 0; iVar < nVar_Turb; iVar++) { - Source = node[iPoint]->GetHarmonicBalance_Source(iVar); + Source = nodes->GetHarmonicBalance_Source(iPoint,iVar); Residual[iVar] = Source*Volume; } @@ -1413,7 +1413,7 @@ void CTurbSASolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_conta for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - node[iPoint]->SetSolution_Old(Solution); + nodes->SetSolution_Old(iPoint,Solution); LinSysRes.SetBlock_Zero(iPoint); /*--- Includes 1 in the diagonal ---*/ @@ -1448,7 +1448,7 @@ void CTurbSASolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_con for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - node[iPoint]->SetSolution_Old(Solution); + nodes->SetSolution_Old(iPoint,Solution); LinSysRes.SetBlock_Zero(iPoint); /*--- Includes 1 in the diagonal ---*/ @@ -1481,7 +1481,7 @@ void CTurbSASolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Grid Movement ---*/ @@ -1493,7 +1493,7 @@ void CTurbSASolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container /*--- Set turbulent variable at the wall, and at infinity ---*/ for (iVar = 0; iVar < nVar; iVar++) - Solution_i[iVar] = node[iPoint]->GetSolution(iVar); + Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); Solution_j[0] = nu_tilde_Inf; conv_numerics->SetTurbVar(Solution_i, Solution_j); @@ -1551,7 +1551,7 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -1559,7 +1559,7 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN /*--- Set the turbulent variable states (prescribed for an inflow) ---*/ - Solution_i[0] = node[iPoint]->GetSolution(0); + Solution_i[0] = nodes->GetSolution(iPoint,0); /*--- Load the inlet turbulence variable (uniform by default). ---*/ @@ -1638,7 +1638,7 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -1651,8 +1651,8 @@ void CTurbSASolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, C Solution_j --> TurbVar_outlet ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Solution_i[iVar] = node[iPoint]->GetSolution(iVar); - Solution_j[iVar] = node[iPoint]->GetSolution(iVar); + Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); + Solution_j[iVar] = nodes->GetSolution(iPoint,iVar); } conv_numerics->SetTurbVar(Solution_i, Solution_j); @@ -1732,7 +1732,7 @@ void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_conta /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -1742,7 +1742,7 @@ void CTurbSASolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_conta that the turbulent variable is copied from the interior of the domain to the outlet before computing the residual. ---*/ - conv_numerics->SetTurbVar(node[iPoint]->GetSolution(), node[iPoint]->GetSolution()); + conv_numerics->SetTurbVar(nodes->GetSolution(iPoint), nodes->GetSolution(iPoint)); /*--- Set Normal (negate for outward convention) ---*/ @@ -1830,7 +1830,7 @@ void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_cont /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -1838,7 +1838,7 @@ void CTurbSASolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_cont /*--- Set the turbulent variable states (prescribed for an inflow) ---*/ - Solution_i[0] = node[iPoint]->GetSolution(0); + Solution_i[0] = nodes->GetSolution(iPoint,0); Solution_j[0] = nu_tilde_Engine; conv_numerics->SetTurbVar(Solution_i, Solution_j); @@ -1948,7 +1948,7 @@ void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Check the flow direction. Project the flow into the normal to the inlet face ---*/ @@ -1982,10 +1982,10 @@ void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, domain to the outlet before computing the residual. or set the turbulent variable states (prescribed for an inflow) ----*/ - Solution_i[0] = node[iPoint]->GetSolution(0); + Solution_i[0] = nodes->GetSolution(iPoint,0); - // if (val_inlet_surface) Solution_j[0] = 0.5*(node[iPoint]->GetSolution(0)+V_outlet [nDim+9]); - // else Solution_j[0] = 0.5*(node[iPoint]->GetSolution(0)+V_inlet [nDim+9]); + // if (val_inlet_surface) Solution_j[0] = 0.5*(nodes->GetSolution(iPoint,0)+V_outlet [nDim+9]); + // else Solution_j[0] = 0.5*(nodes->GetSolution(iPoint,0)+V_inlet [nDim+9]); // /*--- Inflow analysis (interior extrapolation) ---*/ // if (((val_inlet_surface) && (!ReverseFlow)) || ((!val_inlet_surface) && (ReverseFlow))) { @@ -2000,7 +2000,7 @@ void CTurbSASolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, /*--- Inflow analysis (interior extrapolation) ---*/ if (((val_inlet_surface) && (!ReverseFlow)) || ((!val_inlet_surface) && (ReverseFlow))) { - Solution_j[0] = node[iPoint]->GetSolution(0); + Solution_j[0] = nodes->GetSolution(iPoint,0); } /*--- Outflow analysis ---*/ @@ -2099,7 +2099,7 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -2107,7 +2107,7 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Set the turbulent variable states (prescribed for an inflow) ---*/ - Solution_i[0] = node[iPoint]->GetSolution(0); + Solution_i[0] = nodes->GetSolution(iPoint,0); Solution_j[0] = extAverageNu; conv_numerics->SetTurbVar(Solution_i, Solution_j); @@ -2147,7 +2147,7 @@ void CTurbSASolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_c /*--- Turbulent variables w/o reconstruction, and its gradients ---*/ visc_numerics->SetTurbVar(Solution_i, Solution_j); - visc_numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute residual, and Jacobians ---*/ @@ -2216,7 +2216,7 @@ void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contain /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -2224,7 +2224,7 @@ void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contain /*--- Set the turbulent variable states (prescribed for an inflow) ---*/ - Solution_i[0] = node[iPoint]->GetSolution(0); + Solution_i[0] = nodes->GetSolution(iPoint,0); Solution_j[0] = nu_tilde; conv_numerics->SetTurbVar(Solution_i, Solution_j); @@ -2264,7 +2264,7 @@ void CTurbSASolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contain /*--- Turbulent variables w/o reconstruction, and its gradients ---*/ visc_numerics->SetTurbVar(Solution_i, Solution_j); - visc_numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute residual, and Jacobians ---*/ @@ -2305,8 +2305,8 @@ void CTurbSASolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_ // // /*--- Store the solution for both points ---*/ // for (iVar = 0; iVar < nVar; iVar++) { - // Solution_i[iVar] = node[iPoint]->GetSolution(iVar); - // Solution_j[iVar] = node[jPoint]->GetSolution(iVar); + // Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); + // Solution_j[iVar] = nodes->GetSolution(jPoint,iVar); // } // // /*--- Set Conservative Variables ---*/ @@ -2362,7 +2362,7 @@ void CTurbSASolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_ // /*--- We only send the information that belong to other boundary ---*/ // if ((jProcessor != rank) && compute) { // - // Conserv_Var = node[iPoint]->GetSolution(); + // Conserv_Var = nodes->GetSolution(iPoint); // Flow_Var = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); // // for (iVar = 0; iVar < nVar; iVar++) @@ -2399,7 +2399,7 @@ void CTurbSASolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_ // else { // // for (iVar = 0; iVar < nVar; iVar++) - // Buffer_Receive_U[iVar] = node[jPoint]->GetSolution(iVar); + // Buffer_Receive_U[iVar] = nodes->GetSolution(jPoint,iVar); // // for (iVar = 0; iVar < solver_container[FLOW_SOL]->GetnVar(); iVar++) // Buffer_Send_U[nVar+iVar] = solver_container[FLOW_SOL]->node[jPoint]->GetSolution(iVar); @@ -2408,7 +2408,7 @@ void CTurbSASolver::BC_Interface_Boundary(CGeometry *geometry, CSolver **solver_ // // /*--- Store the solution for both points ---*/ // for (iVar = 0; iVar < nVar; iVar++) { - // Solution_i[iVar] = node[iPoint]->GetSolution(iVar); + // Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); // Solution_j[iVar] = Buffer_Receive_U[iVar]; // } // @@ -2487,7 +2487,7 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con for (iDim = 0; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim]; for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(iVar); + PrimVar_i[iVar] = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint,iVar); PrimVar_j[iVar] = solver_container[FLOW_SOL]->GetSlidingState(iMarker, iVertex, iVar, jVertex); } @@ -2500,7 +2500,7 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con conv_numerics->SetPrimitive( PrimVar_i, PrimVar_j ); /*--- Set the turbulent variable states ---*/ - Solution_i[0] = node[iPoint]->GetSolution(0); + Solution_i[0] = nodes->GetSolution(iPoint,0); Solution_j[0] = GetSlidingState(iMarker, iVertex, 0, jVertex); conv_numerics->SetTurbVar(Solution_i, Solution_j); @@ -2541,7 +2541,7 @@ void CTurbSASolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_con /*--- Turbulent variables and its gradients ---*/ visc_numerics->SetTurbVar(Solution_i, Solution_j); - visc_numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute and update residual ---*/ @@ -2589,8 +2589,8 @@ void CTurbSASolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_ // // /*--- Store the solution for both points ---*/ // for (iVar = 0; iVar < nVar; iVar++) { - // Solution_i[iVar] = node[iPoint]->GetSolution(iVar); - // Solution_j[iVar] = node[jPoint]->GetSolution(iVar); + // Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); + // Solution_j[iVar] = nodes->GetSolution(jPoint,iVar); // } // // /*--- Set Conservative Variables ---*/ @@ -2646,7 +2646,7 @@ void CTurbSASolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_ // /*--- We only send the information that belong to other boundary ---*/ // if ((jProcessor != rank) && compute) { // - // Conserv_Var = node[iPoint]->GetSolution(); + // Conserv_Var = nodes->GetSolution(iPoint); // Flow_Var = solver_container[FLOW_SOL]->node[iPoint]->GetSolution(); // // for (iVar = 0; iVar < nVar; iVar++) @@ -2683,7 +2683,7 @@ void CTurbSASolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_ // else { // // for (iVar = 0; iVar < nVar; iVar++) - // Buffer_Receive_U[iVar] = node[jPoint]->GetSolution(iVar); + // Buffer_Receive_U[iVar] = nodes->GetSolution(jPoint,iVar); // // for (iVar = 0; iVar < solver_container[FLOW_SOL]->GetnVar(); iVar++) // Buffer_Send_U[nVar+iVar] = solver_container[FLOW_SOL]->node[jPoint]->GetSolution(iVar); @@ -2692,7 +2692,7 @@ void CTurbSASolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_ // // /*--- Store the solution for both points ---*/ // for (iVar = 0; iVar < nVar; iVar++) { - // Solution_i[iVar] = node[iPoint]->GetSolution(iVar); + // Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); // Solution_j[iVar] = Buffer_Receive_U[iVar]; // } // @@ -2819,9 +2819,9 @@ void CTurbSASolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_containe (normal) interior point. ---*/ for (iDim = 0; iDim < nDim; iDim++) - Vel[iDim] = solver_container[FLOW_SOL]->node[iPoint_Neighbor]->GetVelocity(iDim); - P_Normal = solver_container[FLOW_SOL]->node[iPoint_Neighbor]->GetPressure(); - T_Normal = solver_container[FLOW_SOL]->node[iPoint_Neighbor]->GetTemperature(); + Vel[iDim] = solver_container[FLOW_SOL]->GetNodes()->GetVelocity(iPoint_Neighbor,iDim); + P_Normal = solver_container[FLOW_SOL]->GetNodes()->GetPressure(iPoint_Neighbor); + T_Normal = solver_container[FLOW_SOL]->GetNodes()->GetTemperature(iPoint_Neighbor); /*--- Compute the wall-parallel velocity at first point off the wall ---*/ @@ -2864,8 +2864,8 @@ void CTurbSASolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_containe /*--- Compute the shear stress at the wall in the regular fashion by using the stress tensor on the surface ---*/ - Lam_Visc_Wall = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); - grad_primvar = solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); + Lam_Visc_Wall = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + grad_primvar = solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); div_vel = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -2951,8 +2951,8 @@ void CTurbSASolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_containe /*--- Now compute the Eddy viscosity at the first point off of the wall ---*/ - Lam_Visc_Normal = solver_container[FLOW_SOL]->node[iPoint_Neighbor]->GetLaminarViscosity(); - Density_Normal = solver_container[FLOW_SOL]->node[iPoint_Neighbor]->GetDensity(); + Lam_Visc_Normal = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint_Neighbor); + Density_Normal = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint_Neighbor); Kin_Visc_Normal = Lam_Visc_Normal/Density_Normal; dypw_dyp = 2.0*Y_Plus_White*(kappa*sqrt(Gam)/Q)*sqrt(1.0 - pow(2.0*Gam*U_Plus - Beta,2.0)/(Q*Q)); @@ -2968,7 +2968,7 @@ void CTurbSASolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_containe /*--- Solve for the new value of nu_tilde given the eddy viscosity and using a Newton method ---*/ nu_til_old = 0.0; nu_til = 0.0; cv1_3 = 7.1*7.1*7.1; - nu_til_old = node[iPoint]->GetSolution(0); + nu_til_old = nodes->GetSolution(iPoint,0); counter = 0; diff = 1.0; while (diff > tol) { @@ -2991,7 +2991,7 @@ void CTurbSASolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_containe for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = nu_til; - node[iPoint_Neighbor]->SetSolution_Old(Solution); + nodes->SetSolution_Old(iPoint_Neighbor,Solution); LinSysRes.SetBlock_Zero(iPoint_Neighbor); /*--- includes 1 in the diagonal ---*/ @@ -3031,11 +3031,11 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC coord_i = geometry->node[iPoint]->GetCoord(); nNeigh = geometry->node[iPoint]->GetnPoint(); wallDistance = geometry->node[iPoint]->GetWall_Distance(); - primVarGrad = solver[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(); - vorticity = solver[FLOW_SOL]->node[iPoint]->GetVorticity(); - density = solver[FLOW_SOL]->node[iPoint]->GetDensity(); - laminarViscosity = solver[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); - eddyViscosity = solver[TURB_SOL]->node[iPoint]->GetmuT(); + primVarGrad = solver[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint); + vorticity = solver[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); + density = solver[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + laminarViscosity = solver[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + eddyViscosity = solver[TURB_SOL]->GetNodes()->GetmuT(iPoint); kinematicViscosity = laminarViscosity/density; kinematicViscosityTurb = eddyViscosity/density; @@ -3050,7 +3050,7 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC /*--- Low Reynolds number correction term ---*/ - nu_hat = node[iPoint]->GetSolution()[0]; + nu_hat = nodes->GetSolution(iPoint,0); Ji = nu_hat/kinematicViscosity; Ji_2 = Ji * Ji; Ji_3 = Ji*Ji*Ji; @@ -3137,7 +3137,7 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC Flow Turbulence Combust - 2015 ---*/ - vortexTiltingMeasure = node[iPoint]->GetVortex_Tilting(); + vortexTiltingMeasure = nodes->GetVortex_Tilting(iPoint); omega = sqrt(vorticity[0]*vorticity[0] + vorticity[1]*vorticity[1] + @@ -3161,7 +3161,7 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC ln[2] = delta[0]*ratioOmega[1] - delta[1]*ratioOmega[0]; aux_ln = sqrt(ln[0]*ln[0] + ln[1]*ln[1] + ln[2]*ln[2]); ln_max = max(ln_max,aux_ln); - vortexTiltingMeasure += node[jPoint]->GetVortex_Tilting(); + vortexTiltingMeasure += nodes->GetVortex_Tilting(jPoint); } vortexTiltingMeasure = (vortexTiltingMeasure/fabs(nNeigh + 1.0)); @@ -3183,7 +3183,7 @@ void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CC } - node[iPoint]->SetDES_LengthScale(lengthScale); + nodes->SetDES_LengthScale(iPoint,lengthScale); } } @@ -3303,7 +3303,6 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- Define geometry constants in the solver structure ---*/ nDim = geometry->GetnDim(); - node = new CVariable*[nPoint]; /*--- Single grid simulation ---*/ @@ -3437,8 +3436,8 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh /*--- Initialize the solution to the far-field state everywhere. ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++) - node[iPoint] = new CTurbSSTVariable(kine_Inf, omega_Inf, muT_Inf, nDim, nVar, constants, config); + nodes = new CTurbSSTVariable(kine_Inf, omega_Inf, muT_Inf, nPoint, nDim, nVar, constants, config); + SetBaseClassPointerToNodes(); /*--- MPI solution ---*/ @@ -3495,7 +3494,7 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh const su2double CFL = config->GetCFL(MGLevel); for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->SetLocalCFL(CFL); + nodes->SetLocalCFL(iPoint, CFL); } Min_CFL_Local = CFL; Max_CFL_Local = CFL; @@ -3592,24 +3591,24 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai /*--- Compute blending functions and cross diffusion ---*/ - rho = solver_container[FLOW_SOL]->node[iPoint]->GetDensity(); - mu = solver_container[FLOW_SOL]->node[iPoint]->GetLaminarViscosity(); + rho = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + mu = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); dist = geometry->node[iPoint]->GetWall_Distance(); - strMag = solver_container[FLOW_SOL]->node[iPoint]->GetStrainMag(); + strMag = solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint); - node[iPoint]->SetBlendingFunc(mu, dist, rho); + nodes->SetBlendingFunc(iPoint,mu, dist, rho); - F2 = node[iPoint]->GetF2blending(); + F2 = nodes->GetF2blending(iPoint); /*--- Compute the eddy viscosity ---*/ - kine = node[iPoint]->GetSolution(0); - omega = node[iPoint]->GetSolution(1); + kine = nodes->GetSolution(iPoint,0); + omega = nodes->GetSolution(iPoint,1); zeta = min(1.0/omega, a1/(strMag*F2)); muT = min(max(rho*kine*zeta,0.0),1.0); - node[iPoint]->SetmuT(muT); + nodes->SetmuT(iPoint,muT); } @@ -3623,16 +3622,16 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Conservative variables w/o reconstruction ---*/ - numerics->SetPrimitive(solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(), NULL); + numerics->SetPrimitive(solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint), NULL); /*--- Gradient of the primitive and conservative variables ---*/ - numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->node[iPoint]->GetGradient_Primitive(), NULL); + numerics->SetPrimVarGradient(solver_container[FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint), NULL); /*--- Turbulent variables w/o reconstruction, and its gradient ---*/ - numerics->SetTurbVar(node[iPoint]->GetSolution(), NULL); - numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), NULL); + numerics->SetTurbVar(nodes->GetSolution(iPoint), NULL); + numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), NULL); /*--- Set volume ---*/ @@ -3644,21 +3643,21 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta /*--- Menter's first blending function ---*/ - numerics->SetF1blending(node[iPoint]->GetF1blending(),0.0); + numerics->SetF1blending(nodes->GetF1blending(iPoint),0.0); /*--- Menter's second blending function ---*/ - numerics->SetF2blending(node[iPoint]->GetF2blending(),0.0); + numerics->SetF2blending(nodes->GetF2blending(iPoint),0.0); /*--- Set vorticity and strain rate magnitude ---*/ - numerics->SetVorticity(solver_container[FLOW_SOL]->node[iPoint]->GetVorticity(), NULL); + numerics->SetVorticity(solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint), NULL); - numerics->SetStrainMag(solver_container[FLOW_SOL]->node[iPoint]->GetStrainMag(), 0.0); + numerics->SetStrainMag(solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint), 0.0); /*--- Cross diffusion ---*/ - numerics->SetCrossDiff(node[iPoint]->GetCrossDiff(),0.0); + numerics->SetCrossDiff(nodes->GetCrossDiff(iPoint),0.0); /*--- Compute the source term ---*/ @@ -3701,8 +3700,8 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont /*--- Set wall values ---*/ - density = solver_container[FLOW_SOL]->node[jPoint]->GetDensity(); - laminar_viscosity = solver_container[FLOW_SOL]->node[jPoint]->GetLaminarViscosity(); + density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(jPoint); + laminar_viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint); beta_1 = constants[4]; @@ -3710,8 +3709,8 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont Solution[1] = 60.0*laminar_viscosity/(density*beta_1*distance*distance); /*--- Set the solution values and zero the residual ---*/ - node[iPoint]->SetSolution_Old(Solution); - node[iPoint]->SetSolution(Solution); + nodes->SetSolution_Old(iPoint,Solution); + nodes->SetSolution(iPoint,Solution); LinSysRes.SetBlock_Zero(iPoint); /*--- Change rows of the Jacobian (includes 1 in the diagonal) ---*/ @@ -3749,8 +3748,8 @@ void CTurbSSTSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_co /*--- Set wall values ---*/ - density = solver_container[FLOW_SOL]->node[jPoint]->GetDensity(); - laminar_viscosity = solver_container[FLOW_SOL]->node[jPoint]->GetLaminarViscosity(); + density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(jPoint); + laminar_viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint); beta_1 = constants[4]; @@ -3758,8 +3757,8 @@ void CTurbSSTSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_co Solution[1] = 60.0*laminar_viscosity/(density*beta_1*distance*distance); /*--- Set the solution values and zero the residual ---*/ - node[iPoint]->SetSolution_Old(Solution); - node[iPoint]->SetSolution(Solution); + nodes->SetSolution_Old(iPoint,Solution); + nodes->SetSolution(iPoint,Solution); LinSysRes.SetBlock_Zero(iPoint); /*--- Change rows of the Jacobian (includes 1 in the diagonal) ---*/ @@ -3795,14 +3794,14 @@ void CTurbSSTSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_containe /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); conv_numerics->SetPrimitive(V_domain, V_infty); /*--- Set turbulent variable at the wall, and at infinity ---*/ for (iVar = 0; iVar < nVar; iVar++) - Solution_i[iVar] = node[iPoint]->GetSolution(iVar); + Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); Solution_j[0] = kine_Inf; Solution_j[1] = omega_Inf; @@ -3869,7 +3868,7 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -3879,7 +3878,7 @@ void CTurbSSTSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, C values for the turbulent state at the inflow. ---*/ for (iVar = 0; iVar < nVar; iVar++) - Solution_i[iVar] = node[iPoint]->GetSolution(iVar); + Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Load the inlet turbulence variables (uniform by default). ---*/ @@ -3965,7 +3964,7 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -3978,8 +3977,8 @@ void CTurbSSTSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, Solution_j --> TurbVar_outlet ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Solution_i[iVar] = node[iPoint]->GetSolution(iVar); - Solution_j[iVar] = node[iPoint]->GetSolution(iVar); + Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); + Solution_j[iVar] = nodes->GetSolution(iPoint,iVar); } conv_numerics->SetTurbVar(Solution_i, Solution_j); @@ -4082,7 +4081,7 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ @@ -4091,7 +4090,7 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ /*--- Set the turbulent variable states (prescribed for an inflow) ---*/ for (iVar = 0; iVar < nVar; iVar++) - Solution_i[iVar] = node[iPoint]->GetSolution(iVar); + Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); Solution_j[0]= extAverageKine; Solution_j[1]= extAverageOmega; @@ -4121,10 +4120,10 @@ void CTurbSSTSolver::BC_Inlet_MixingPlane(CGeometry *geometry, CSolver **solver_ /*--- Turbulent variables w/o reconstruction, and its gradients ---*/ visc_numerics->SetTurbVar(Solution_i, Solution_j); - visc_numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Menter's first blending function ---*/ - visc_numerics->SetF1blending(node[iPoint]->GetF1blending(), node[iPoint]->GetF1blending()); + visc_numerics->SetF1blending(nodes->GetF1blending(iPoint), nodes->GetF1blending(iPoint)); /*--- Compute residual, and Jacobians ---*/ visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); @@ -4207,14 +4206,14 @@ void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contai /*--- Retrieve solution at the farfield boundary node ---*/ - V_domain = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(); + V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint); /*--- Set various quantities in the solver class ---*/ conv_numerics->SetPrimitive(V_domain, V_inlet); for (iVar = 0; iVar < nVar; iVar++) - Solution_i[iVar] = node[iPoint]->GetSolution(iVar); + Solution_i[iVar] = nodes->GetSolution(iPoint,iVar); /*--- Set the turbulent variable states. Use average span-wise values values for the turbulent state at the inflow. ---*/ @@ -4247,10 +4246,10 @@ void CTurbSSTSolver::BC_Inlet_Turbo(CGeometry *geometry, CSolver **solver_contai /*--- Turbulent variables w/o reconstruction, and its gradients ---*/ visc_numerics->SetTurbVar(Solution_i, Solution_j); - visc_numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Menter's first blending function ---*/ - visc_numerics->SetF1blending(node[iPoint]->GetF1blending(), node[iPoint]->GetF1blending()); + visc_numerics->SetF1blending(nodes->GetF1blending(iPoint), nodes->GetF1blending(iPoint)); /*--- Compute residual, and Jacobians ---*/ visc_numerics->ComputeResidual(Residual, Jacobian_i, Jacobian_j, config); @@ -4310,7 +4309,7 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co for (iDim = 0; iDim < nDim; iDim++) Normal[iDim] = -Normal[iDim]; for (iVar = 0; iVar < nPrimVar; iVar++) { - PrimVar_i[iVar] = solver_container[FLOW_SOL]->node[iPoint]->GetPrimitive(iVar); + PrimVar_i[iVar] = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint,iVar); PrimVar_j[iVar] = solver_container[FLOW_SOL]->GetSlidingState(iMarker, iVertex, iVar, jVertex); } @@ -4323,8 +4322,8 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co conv_numerics->SetPrimitive( PrimVar_i, PrimVar_j ); /*--- Set the turbulent variable states ---*/ - Solution_i[0] = node[iPoint]->GetSolution(0); - Solution_i[1] = node[iPoint]->GetSolution(1); + Solution_i[0] = nodes->GetSolution(iPoint,0); + Solution_i[1] = nodes->GetSolution(iPoint,1); Solution_j[0] = GetSlidingState(iMarker, iVertex, 0, jVertex); Solution_j[1] = GetSlidingState(iMarker, iVertex, 1, jVertex); @@ -4365,7 +4364,7 @@ void CTurbSSTSolver::BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_co /*--- Turbulent variables and its gradients ---*/ visc_numerics->SetTurbVar(Solution_i, Solution_j); - visc_numerics->SetTurbVarGradient(node[iPoint]->GetGradient(), node[iPoint]->GetGradient()); + visc_numerics->SetTurbVarGradient(nodes->GetGradient(iPoint), nodes->GetGradient(iPoint)); /*--- Compute and update residual ---*/ diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 82683523665f..d295a069b505 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -57,6 +57,8 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { rank = SU2_MPI::GetRank(); size = SU2_MPI::GetSize(); + + adjoint = false; /*--- Set the multigrid level to the finest grid. This can be overwritten in the constructors of the derived classes. ---*/ @@ -101,7 +103,7 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { Cvector = NULL; Restart_Vars = NULL; Restart_Data = NULL; - node = NULL; + base_nodes = nullptr; nOutputVariables = 0; ResLinSolver = 0.0; @@ -144,21 +146,14 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { CSolver::~CSolver(void) { unsigned short iVar, iDim; - unsigned long iPoint, iMarker, iVertex; - + unsigned long iMarker, iVertex; + /*--- Public variables, may be accessible outside ---*/ if ( OutputHeadingNames != NULL) { delete [] OutputHeadingNames; } - if (node != NULL) { - for (iPoint = 0; iPoint < nPoint; iPoint++) { - delete node[iPoint]; - } - delete [] node; - } - /*--- Private ---*/ if (Residual_RMS != NULL) delete [] Residual_RMS; @@ -545,7 +540,7 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Load the time step for the current point. ---*/ - bufDSend[buf_offset] = node[iPoint]->GetDelta_Time(); + bufDSend[buf_offset] = base_nodes->GetDelta_Time(iPoint); buf_offset++; /*--- For implicit calculations, we will communicate the @@ -605,27 +600,27 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, linear solve. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); } /*--- Rotate the momentum components of the solution array. ---*/ if (rotate_periodic) { if (nDim == 2) { - bufDSend[buf_offset+1] = (rotMatrix[0][0]*node[iPoint]->GetSolution(1) + - rotMatrix[0][1]*node[iPoint]->GetSolution(2)); - bufDSend[buf_offset+2] = (rotMatrix[1][0]*node[iPoint]->GetSolution(1) + - rotMatrix[1][1]*node[iPoint]->GetSolution(2)); + bufDSend[buf_offset+1] = (rotMatrix[0][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetSolution(iPoint,2)); + bufDSend[buf_offset+2] = (rotMatrix[1][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetSolution(iPoint,2)); } else { - bufDSend[buf_offset+1] = (rotMatrix[0][0]*node[iPoint]->GetSolution(1) + - rotMatrix[0][1]*node[iPoint]->GetSolution(2) + - rotMatrix[0][2]*node[iPoint]->GetSolution(3)); - bufDSend[buf_offset+2] = (rotMatrix[1][0]*node[iPoint]->GetSolution(1) + - rotMatrix[1][1]*node[iPoint]->GetSolution(2) + - rotMatrix[1][2]*node[iPoint]->GetSolution(3)); - bufDSend[buf_offset+3] = (rotMatrix[2][0]*node[iPoint]->GetSolution(1) + - rotMatrix[2][1]*node[iPoint]->GetSolution(2) + - rotMatrix[2][2]*node[iPoint]->GetSolution(3)); + bufDSend[buf_offset+1] = (rotMatrix[0][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetSolution(iPoint,2) + + rotMatrix[0][2]*base_nodes->GetSolution(iPoint,3)); + bufDSend[buf_offset+2] = (rotMatrix[1][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetSolution(iPoint,2) + + rotMatrix[1][2]*base_nodes->GetSolution(iPoint,3)); + bufDSend[buf_offset+3] = (rotMatrix[2][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[2][1]*base_nodes->GetSolution(iPoint,2) + + rotMatrix[2][2]*base_nodes->GetSolution(iPoint,3)); } } @@ -651,16 +646,16 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Solution differences ---*/ for (iVar = 0; iVar < nVar; iVar++) - Diff[iVar] = (node[iPoint]->GetSolution(iVar) - - node[jPoint]->GetSolution(iVar)); + Diff[iVar] = (base_nodes->GetSolution(iPoint, iVar) - + base_nodes->GetSolution(jPoint,iVar)); /*--- Correction for compressible flows (use enthalpy) ---*/ if (!(config->GetKind_Regime() == INCOMPRESSIBLE)) { - Pressure_i = node[iPoint]->GetPressure(); - Pressure_j = node[jPoint]->GetPressure(); - Diff[nVar-1] = ((node[iPoint]->GetSolution(nVar-1) + Pressure_i) - - (node[jPoint]->GetSolution(nVar-1) + Pressure_j)); + Pressure_i = base_nodes->GetPressure(iPoint); + Pressure_j = base_nodes->GetPressure(jPoint); + Diff[nVar-1] = ((base_nodes->GetSolution(iPoint,nVar-1) + Pressure_i) - + (base_nodes->GetSolution(jPoint,nVar-1) + Pressure_j)); } boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); @@ -720,7 +715,7 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Simple summation of eig calc on both periodic faces. ---*/ - bufDSend[buf_offset] = node[iPoint]->GetLambda(); + bufDSend[buf_offset] = base_nodes->GetLambda(iPoint); break; @@ -742,11 +737,11 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Use density instead of pressure for incomp. flows. ---*/ if ((config->GetKind_Regime() == INCOMPRESSIBLE)) { - Pressure_i = node[iPoint]->GetDensity(); - Pressure_j = node[jPoint]->GetDensity(); + Pressure_i = base_nodes->GetDensity(iPoint); + Pressure_j = base_nodes->GetDensity(jPoint); } else { - Pressure_i = node[iPoint]->GetPressure(); - Pressure_j = node[jPoint]->GetPressure(); + Pressure_i = base_nodes->GetPressure(iPoint); + Pressure_j = base_nodes->GetPressure(jPoint); } boundary_i = geometry->node[iPoint]->GetPhysicalBoundary(); @@ -792,8 +787,8 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, for (iVar = 0; iVar < nVar; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - jacBlock[iVar][iDim] = node[iPoint]->GetGradient(iVar, iDim); - rotBlock[iVar][iDim] = node[iPoint]->GetGradient(iVar, iDim); + jacBlock[iVar][iDim] = base_nodes->GetGradient(iPoint, iVar, iDim); + rotBlock[iVar][iDim] = base_nodes->GetGradient(iPoint, iVar, iDim); } } @@ -837,8 +832,8 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++){ - jacBlock[iVar][iDim] = node[iPoint]->GetGradient_Primitive(iVar, iDim); - rotBlock[iVar][iDim] = node[iPoint]->GetGradient_Primitive(iVar, iDim); + jacBlock[iVar][iDim] = base_nodes->GetGradient_Primitive(iPoint, iVar, iDim); + rotBlock[iVar][iDim] = base_nodes->GetGradient_Primitive(iPoint, iVar, iDim); } } @@ -909,25 +904,25 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Get conservative solution and rotate if necessary. ---*/ for (iVar = 0; iVar < nVar; iVar++) - rotPrim_i[iVar] = node[iPoint]->GetSolution(iVar); + rotPrim_i[iVar] = base_nodes->GetSolution(iPoint, iVar); if (rotate_periodic) { if (nDim == 2) { - rotPrim_i[1] = (rotMatrix[0][0]*node[iPoint]->GetSolution(1) + - rotMatrix[0][1]*node[iPoint]->GetSolution(2)); - rotPrim_i[2] = (rotMatrix[1][0]*node[iPoint]->GetSolution(1) + - rotMatrix[1][1]*node[iPoint]->GetSolution(2)); + rotPrim_i[1] = (rotMatrix[0][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetSolution(iPoint,2)); + rotPrim_i[2] = (rotMatrix[1][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetSolution(iPoint,2)); } else { - rotPrim_i[1] = (rotMatrix[0][0]*node[iPoint]->GetSolution(1) + - rotMatrix[0][1]*node[iPoint]->GetSolution(2) + - rotMatrix[0][2]*node[iPoint]->GetSolution(3)); - rotPrim_i[2] = (rotMatrix[1][0]*node[iPoint]->GetSolution(1) + - rotMatrix[1][1]*node[iPoint]->GetSolution(2) + - rotMatrix[1][2]*node[iPoint]->GetSolution(3)); - rotPrim_i[3] = (rotMatrix[2][0]*node[iPoint]->GetSolution(1) + - rotMatrix[2][1]*node[iPoint]->GetSolution(2) + - rotMatrix[2][2]*node[iPoint]->GetSolution(3)); + rotPrim_i[1] = (rotMatrix[0][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetSolution(iPoint,2) + + rotMatrix[0][2]*base_nodes->GetSolution(iPoint,3)); + rotPrim_i[2] = (rotMatrix[1][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetSolution(iPoint,2) + + rotMatrix[1][2]*base_nodes->GetSolution(iPoint,3)); + rotPrim_i[3] = (rotMatrix[2][0]*base_nodes->GetSolution(iPoint,1) + + rotMatrix[2][1]*base_nodes->GetSolution(iPoint,2) + + rotMatrix[2][2]*base_nodes->GetSolution(iPoint,3)); } } @@ -976,25 +971,25 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Get conservative solution and rotte if necessary. ---*/ for (iVar = 0; iVar < nVar; iVar++) - rotPrim_j[iVar] = node[jPoint]->GetSolution(iVar); + rotPrim_j[iVar] = base_nodes->GetSolution(jPoint,iVar); if (rotate_periodic) { if (nDim == 2) { - rotPrim_j[1] = (rotMatrix[0][0]*node[jPoint]->GetSolution(1) + - rotMatrix[0][1]*node[jPoint]->GetSolution(2)); - rotPrim_j[2] = (rotMatrix[1][0]*node[jPoint]->GetSolution(1) + - rotMatrix[1][1]*node[jPoint]->GetSolution(2)); + rotPrim_j[1] = (rotMatrix[0][0]*base_nodes->GetSolution(jPoint,1) + + rotMatrix[0][1]*base_nodes->GetSolution(jPoint,2)); + rotPrim_j[2] = (rotMatrix[1][0]*base_nodes->GetSolution(jPoint,1) + + rotMatrix[1][1]*base_nodes->GetSolution(jPoint,2)); } else { - rotPrim_j[1] = (rotMatrix[0][0]*node[jPoint]->GetSolution(1) + - rotMatrix[0][1]*node[jPoint]->GetSolution(2) + - rotMatrix[0][2]*node[jPoint]->GetSolution(3)); - rotPrim_j[2] = (rotMatrix[1][0]*node[jPoint]->GetSolution(1) + - rotMatrix[1][1]*node[jPoint]->GetSolution(2) + - rotMatrix[1][2]*node[jPoint]->GetSolution(3)); - rotPrim_j[3] = (rotMatrix[2][0]*node[jPoint]->GetSolution(1) + - rotMatrix[2][1]*node[jPoint]->GetSolution(2) + - rotMatrix[2][2]*node[jPoint]->GetSolution(3)); + rotPrim_j[1] = (rotMatrix[0][0]*base_nodes->GetSolution(jPoint,1) + + rotMatrix[0][1]*base_nodes->GetSolution(jPoint,2) + + rotMatrix[0][2]*base_nodes->GetSolution(jPoint,3)); + rotPrim_j[2] = (rotMatrix[1][0]*base_nodes->GetSolution(jPoint,1) + + rotMatrix[1][1]*base_nodes->GetSolution(jPoint,2) + + rotMatrix[1][2]*base_nodes->GetSolution(jPoint,3)); + rotPrim_j[3] = (rotMatrix[2][0]*base_nodes->GetSolution(jPoint,1) + + rotMatrix[2][1]*base_nodes->GetSolution(jPoint,2) + + rotMatrix[2][2]*base_nodes->GetSolution(jPoint,3)); } } @@ -1107,25 +1102,25 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Get primitives and rotate if necessary. ---*/ for (iVar = 0; iVar < nPrimVar; iVar++) - rotPrim_i[iVar] = node[iPoint]->GetPrimitive(iVar); + rotPrim_i[iVar] = base_nodes->GetPrimitive(iPoint, iVar); if (rotate_periodic) { if (nDim == 2) { - rotPrim_i[1] = (rotMatrix[0][0]*node[iPoint]->GetPrimitive(1) + - rotMatrix[0][1]*node[iPoint]->GetPrimitive(2)); - rotPrim_i[2] = (rotMatrix[1][0]*node[iPoint]->GetPrimitive(1) + - rotMatrix[1][1]*node[iPoint]->GetPrimitive(2)); + rotPrim_i[1] = (rotMatrix[0][0]*base_nodes->GetPrimitive(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetPrimitive(iPoint,2)); + rotPrim_i[2] = (rotMatrix[1][0]*base_nodes->GetPrimitive(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetPrimitive(iPoint,2)); } else { - rotPrim_i[1] = (rotMatrix[0][0]*node[iPoint]->GetPrimitive(1) + - rotMatrix[0][1]*node[iPoint]->GetPrimitive(2) + - rotMatrix[0][2]*node[iPoint]->GetPrimitive(3)); - rotPrim_i[2] = (rotMatrix[1][0]*node[iPoint]->GetPrimitive(1) + - rotMatrix[1][1]*node[iPoint]->GetPrimitive(2) + - rotMatrix[1][2]*node[iPoint]->GetPrimitive(3)); - rotPrim_i[3] = (rotMatrix[2][0]*node[iPoint]->GetPrimitive(1) + - rotMatrix[2][1]*node[iPoint]->GetPrimitive(2) + - rotMatrix[2][2]*node[iPoint]->GetPrimitive(3)); + rotPrim_i[1] = (rotMatrix[0][0]*base_nodes->GetPrimitive(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetPrimitive(iPoint,2) + + rotMatrix[0][2]*base_nodes->GetPrimitive(iPoint,3)); + rotPrim_i[2] = (rotMatrix[1][0]*base_nodes->GetPrimitive(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetPrimitive(iPoint,2) + + rotMatrix[1][2]*base_nodes->GetPrimitive(iPoint,3)); + rotPrim_i[3] = (rotMatrix[2][0]*base_nodes->GetPrimitive(iPoint,1) + + rotMatrix[2][1]*base_nodes->GetPrimitive(iPoint,2) + + rotMatrix[2][2]*base_nodes->GetPrimitive(iPoint,3)); } } @@ -1174,25 +1169,25 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Get primitives from CVariable ---*/ for (iVar = 0; iVar < nPrimVar; iVar++) - rotPrim_j[iVar] = node[jPoint]->GetPrimitive(iVar); + rotPrim_j[iVar] = base_nodes->GetPrimitive(jPoint,iVar); if (rotate_periodic) { if (nDim == 2) { - rotPrim_j[1] = (rotMatrix[0][0]*node[jPoint]->GetPrimitive(1) + - rotMatrix[0][1]*node[jPoint]->GetPrimitive(2)); - rotPrim_j[2] = (rotMatrix[1][0]*node[jPoint]->GetPrimitive(1) + - rotMatrix[1][1]*node[jPoint]->GetPrimitive(2)); + rotPrim_j[1] = (rotMatrix[0][0]*base_nodes->GetPrimitive(jPoint,1) + + rotMatrix[0][1]*base_nodes->GetPrimitive(jPoint,2)); + rotPrim_j[2] = (rotMatrix[1][0]*base_nodes->GetPrimitive(jPoint,1) + + rotMatrix[1][1]*base_nodes->GetPrimitive(jPoint,2)); } else { - rotPrim_j[1] = (rotMatrix[0][0]*node[jPoint]->GetPrimitive(1) + - rotMatrix[0][1]*node[jPoint]->GetPrimitive(2) + - rotMatrix[0][2]*node[jPoint]->GetPrimitive(3)); - rotPrim_j[2] = (rotMatrix[1][0]*node[jPoint]->GetPrimitive(1) + - rotMatrix[1][1]*node[jPoint]->GetPrimitive(2) + - rotMatrix[1][2]*node[jPoint]->GetPrimitive(3)); - rotPrim_j[3] = (rotMatrix[2][0]*node[jPoint]->GetPrimitive(1) + - rotMatrix[2][1]*node[jPoint]->GetPrimitive(2) + - rotMatrix[2][2]*node[jPoint]->GetPrimitive(3)); + rotPrim_j[1] = (rotMatrix[0][0]*base_nodes->GetPrimitive(jPoint,1) + + rotMatrix[0][1]*base_nodes->GetPrimitive(jPoint,2) + + rotMatrix[0][2]*base_nodes->GetPrimitive(jPoint,3)); + rotPrim_j[2] = (rotMatrix[1][0]*base_nodes->GetPrimitive(jPoint,1) + + rotMatrix[1][1]*base_nodes->GetPrimitive(jPoint,2) + + rotMatrix[1][2]*base_nodes->GetPrimitive(jPoint,3)); + rotPrim_j[3] = (rotMatrix[2][0]*base_nodes->GetPrimitive(jPoint,1) + + rotMatrix[2][1]*base_nodes->GetPrimitive(jPoint,2) + + rotMatrix[2][2]*base_nodes->GetPrimitive(jPoint,3)); } } @@ -1275,11 +1270,11 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, among all nodes adjacent to periodic faces. ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Sol_Min[iVar] = node[iPoint]->GetSolution_Min(iVar); - Sol_Max[iVar] = node[iPoint]->GetSolution_Max(iVar); + Sol_Min[iVar] = base_nodes->GetSolution_Min(iPoint, iVar); + Sol_Max[iVar] = base_nodes->GetSolution_Max(iPoint, iVar); - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution_Min(iVar); - bufDSend[buf_offset+nPrimVarGrad+iVar] = node[iPoint]->GetSolution_Max(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution_Min(iPoint, iVar); + bufDSend[buf_offset+nPrimVarGrad+iVar] = base_nodes->GetSolution_Max(iPoint, iVar); } /*--- Rotate the momentum components of the min/max. ---*/ @@ -1328,27 +1323,27 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, found for a node on a periodic face and stores it. ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - bufDSend[buf_offset+iVar] = node[iPoint]->GetLimiter_Primitive(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetLimiter_Primitive(iPoint, iVar); } if (rotate_periodic) { if (nDim == 2) { - bufDSend[buf_offset+1] = (rotMatrix[0][0]*node[iPoint]->GetLimiter_Primitive(1) + - rotMatrix[0][1]*node[iPoint]->GetLimiter_Primitive(2)); - bufDSend[buf_offset+2] = (rotMatrix[1][0]*node[iPoint]->GetLimiter_Primitive(1) + - rotMatrix[1][1]*node[iPoint]->GetLimiter_Primitive(2)); + bufDSend[buf_offset+1] = (rotMatrix[0][0]*base_nodes->GetLimiter_Primitive(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetLimiter_Primitive(iPoint,2)); + bufDSend[buf_offset+2] = (rotMatrix[1][0]*base_nodes->GetLimiter_Primitive(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetLimiter_Primitive(iPoint,2)); } else { - bufDSend[buf_offset+1] = (rotMatrix[0][0]*node[iPoint]->GetLimiter_Primitive(1) + - rotMatrix[0][1]*node[iPoint]->GetLimiter_Primitive(2) + - rotMatrix[0][2]*node[iPoint]->GetLimiter_Primitive(3)); - bufDSend[buf_offset+2] = (rotMatrix[1][0]*node[iPoint]->GetLimiter_Primitive(1) + - rotMatrix[1][1]*node[iPoint]->GetLimiter_Primitive(2) + - rotMatrix[1][2]*node[iPoint]->GetLimiter_Primitive(3)); - bufDSend[buf_offset+3] = (rotMatrix[2][0]*node[iPoint]->GetLimiter_Primitive(1) + - rotMatrix[2][1]*node[iPoint]->GetLimiter_Primitive(2) + - rotMatrix[2][2]*node[iPoint]->GetLimiter_Primitive(3)); + bufDSend[buf_offset+1] = (rotMatrix[0][0]*base_nodes->GetLimiter_Primitive(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetLimiter_Primitive(iPoint,2) + + rotMatrix[0][2]*base_nodes->GetLimiter_Primitive(iPoint,3)); + bufDSend[buf_offset+2] = (rotMatrix[1][0]*base_nodes->GetLimiter_Primitive(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetLimiter_Primitive(iPoint,2) + + rotMatrix[1][2]*base_nodes->GetLimiter_Primitive(iPoint,3)); + bufDSend[buf_offset+3] = (rotMatrix[2][0]*base_nodes->GetLimiter_Primitive(iPoint,1) + + rotMatrix[2][1]*base_nodes->GetLimiter_Primitive(iPoint,2) + + rotMatrix[2][2]*base_nodes->GetLimiter_Primitive(iPoint,3)); } } @@ -1361,11 +1356,11 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, among all nodes adjacent to periodic faces. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Sol_Min[iVar] = node[iPoint]->GetSolution_Min(iVar); - Sol_Max[iVar] = node[iPoint]->GetSolution_Max(iVar); + Sol_Min[iVar] = base_nodes->GetSolution_Min(iPoint, iVar); + Sol_Max[iVar] = base_nodes->GetSolution_Max(iPoint, iVar); - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution_Min(iVar); - bufDSend[buf_offset+nVar+iVar] = node[iPoint]->GetSolution_Max(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution_Min(iPoint, iVar); + bufDSend[buf_offset+nVar+iVar] = base_nodes->GetSolution_Max(iPoint, iVar); } /*--- Rotate the momentum components of the min/max. ---*/ @@ -1417,27 +1412,27 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, found for a node on a periodic face and stores it. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - bufDSend[buf_offset+iVar] = node[iPoint]->GetLimiter(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetLimiter(iPoint, iVar); } if (rotate_periodic) { if (nDim == 2) { - bufDSend[buf_offset+1] = (rotMatrix[0][0]*node[iPoint]->GetLimiter(1) + - rotMatrix[0][1]*node[iPoint]->GetLimiter(2)); - bufDSend[buf_offset+2] = (rotMatrix[1][0]*node[iPoint]->GetLimiter(1) + - rotMatrix[1][1]*node[iPoint]->GetLimiter(2)); + bufDSend[buf_offset+1] = (rotMatrix[0][0]*base_nodes->GetLimiter(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetLimiter(iPoint,2)); + bufDSend[buf_offset+2] = (rotMatrix[1][0]*base_nodes->GetLimiter(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetLimiter(iPoint,2)); } else { - bufDSend[buf_offset+1] = (rotMatrix[0][0]*node[iPoint]->GetLimiter(1) + - rotMatrix[0][1]*node[iPoint]->GetLimiter(2) + - rotMatrix[0][2]*node[iPoint]->GetLimiter(3)); - bufDSend[buf_offset+2] = (rotMatrix[1][0]*node[iPoint]->GetLimiter(1) + - rotMatrix[1][1]*node[iPoint]->GetLimiter(2) + - rotMatrix[1][2]*node[iPoint]->GetLimiter(3)); - bufDSend[buf_offset+3] = (rotMatrix[2][0]*node[iPoint]->GetLimiter(1) + - rotMatrix[2][1]*node[iPoint]->GetLimiter(2) + - rotMatrix[2][2]*node[iPoint]->GetLimiter(3)); + bufDSend[buf_offset+1] = (rotMatrix[0][0]*base_nodes->GetLimiter(iPoint,1) + + rotMatrix[0][1]*base_nodes->GetLimiter(iPoint,2) + + rotMatrix[0][2]*base_nodes->GetLimiter(iPoint,3)); + bufDSend[buf_offset+2] = (rotMatrix[1][0]*base_nodes->GetLimiter(iPoint,1) + + rotMatrix[1][1]*base_nodes->GetLimiter(iPoint,2) + + rotMatrix[1][2]*base_nodes->GetLimiter(iPoint,3)); + bufDSend[buf_offset+3] = (rotMatrix[2][0]*base_nodes->GetLimiter(iPoint,1) + + rotMatrix[2][1]*base_nodes->GetLimiter(iPoint,2) + + rotMatrix[2][2]*base_nodes->GetLimiter(iPoint,3)); } } @@ -1590,9 +1585,9 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, /*--- Check the computed time step against the donor value and keep the minimum in order to be conservative. ---*/ - Time_Step = node[iPoint]->GetDelta_Time(); + Time_Step = base_nodes->GetDelta_Time(iPoint); if (bufDRecv[buf_offset] < Time_Step) - node[iPoint]->SetDelta_Time(bufDRecv[buf_offset]); + base_nodes->SetDelta_Time(iPoint,bufDRecv[buf_offset]); buf_offset++; /*--- Access the Jacobian from the donor if implicit. ---*/ @@ -1657,8 +1652,8 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, face that is provided from the master. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->SetSolution(iVar, Solution[iVar]); - node[iPoint]->SetSolution_Old(iVar, Solution[iVar]); + base_nodes->SetSolution(iPoint, iVar, Solution[iVar]); + base_nodes->SetSolution_Old(iPoint, iVar, Solution[iVar]); } } @@ -1673,7 +1668,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, for (iVar = 0; iVar < nVar; iVar++) Diff[iVar] = bufDRecv[buf_offset+iVar]; - node[iPoint]->AddUnd_Lapl(Diff); + base_nodes->AddUnd_Lapl(iPoint,Diff); break; @@ -1681,7 +1676,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, /*--- Simple accumulation of the max eig on periodic faces. ---*/ - node[iPoint]->AddLambda(bufDRecv[buf_offset]); + base_nodes->AddLambda(iPoint,bufDRecv[buf_offset]); break; @@ -1701,7 +1696,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, for (iVar = 0; iVar < nVar; iVar++) for (iDim = 0; iDim < nDim; iDim++) - node[iPoint]->SetGradient(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim] + node[iPoint]->GetGradient(iVar, iDim)); + base_nodes->SetGradient(iPoint, iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim] + base_nodes->GetGradient(iPoint, iVar, iDim)); break; @@ -1712,7 +1707,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, for (iVar = 0; iVar < nPrimVarGrad; iVar++) for (iDim = 0; iDim < nDim; iDim++) - node[iPoint]->SetGradient_Primitive(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim] + node[iPoint]->GetGradient_Primitive(iVar, iDim)); + base_nodes->SetGradient_Primitive(iPoint, iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim] + base_nodes->GetGradient_Primitive(iPoint, iVar, iDim)); break; case PERIODIC_SOL_LS: @@ -1723,13 +1718,13 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0; jDim < nDim; jDim++) { - node[iPoint]->AddRmatrix(iDim,jDim,bufDRecv[buf_offset]); + base_nodes->AddRmatrix(iPoint, iDim,jDim,bufDRecv[buf_offset]); buf_offset++; } } for (iVar = 0; iVar < nVar; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->AddGradient(iVar, iDim, bufDRecv[buf_offset]); + base_nodes->AddGradient(iPoint, iVar, iDim, bufDRecv[buf_offset]); buf_offset++; } } @@ -1744,13 +1739,13 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0; jDim < nDim; jDim++) { - node[iPoint]->AddRmatrix(iDim,jDim,bufDRecv[buf_offset]); + base_nodes->AddRmatrix(iPoint, iDim,jDim,bufDRecv[buf_offset]); buf_offset++; } } for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->AddGradient_Primitive(iVar, iDim, bufDRecv[buf_offset]); + base_nodes->AddGradient_Primitive(iPoint, iVar, iDim, bufDRecv[buf_offset]); buf_offset++; } } @@ -1764,8 +1759,8 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, and max for this point. ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - node[iPoint]->SetSolution_Min(iVar, min(node[iPoint]->GetSolution_Min(iVar), bufDRecv[buf_offset+iVar])); - node[iPoint]->SetSolution_Max(iVar, max(node[iPoint]->GetSolution_Max(iVar), bufDRecv[buf_offset+nPrimVarGrad+iVar])); + base_nodes->SetSolution_Min(iPoint, iVar, min(base_nodes->GetSolution_Min(iPoint, iVar), bufDRecv[buf_offset+iVar])); + base_nodes->SetSolution_Max(iPoint, iVar, max(base_nodes->GetSolution_Max(iPoint, iVar), bufDRecv[buf_offset+nPrimVarGrad+iVar])); } break; @@ -1776,7 +1771,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, faces for the limiter, and store the proper min value. ---*/ for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - node[iPoint]->SetLimiter_Primitive(iVar, min(node[iPoint]->GetLimiter_Primitive(iVar), bufDRecv[buf_offset+iVar])); + base_nodes->SetLimiter_Primitive(iPoint, iVar, min(base_nodes->GetLimiter_Primitive(iPoint, iVar), bufDRecv[buf_offset+iVar])); } break; @@ -1791,15 +1786,15 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, /*--- Solution minimum. ---*/ - Solution_Min = min(node[iPoint]->GetSolution_Min(iVar), + Solution_Min = min(base_nodes->GetSolution_Min(iPoint, iVar), bufDRecv[buf_offset+iVar]); - node[iPoint]->SetSolution_Min(iVar, Solution_Min); + base_nodes->SetSolution_Min(iPoint, iVar, Solution_Min); /*--- Solution maximum. ---*/ - Solution_Max = max(node[iPoint]->GetSolution_Max(iVar), + Solution_Max = max(base_nodes->GetSolution_Max(iPoint, iVar), bufDRecv[buf_offset+nVar+iVar]); - node[iPoint]->SetSolution_Max(iVar, Solution_Max); + base_nodes->SetSolution_Max(iPoint, iVar, Solution_Max); } @@ -1811,9 +1806,9 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, faces for the limiter, and store the proper min value. ---*/ for (iVar = 0; iVar < nVar; iVar++) { - Limiter_Min = min(node[iPoint]->GetLimiter_Primitive(iVar), + Limiter_Min = min(base_nodes->GetLimiter_Primitive(iPoint, iVar), bufDRecv[buf_offset+iVar]); - node[iPoint]->SetLimiter_Primitive(iVar, Limiter_Min); + base_nodes->SetLimiter_Primitive(iPoint, iVar, Limiter_Min); } break; @@ -1981,97 +1976,97 @@ void CSolver::InitiateComms(CGeometry *geometry, switch (commType) { case SOLUTION: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); break; case SOLUTION_OLD: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution_Old(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution_Old(iPoint, iVar); break; case SOLUTION_EDDY: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution(iVar); - bufDSend[buf_offset+nVar] = node[iPoint]->GetmuT(); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); + bufDSend[buf_offset+nVar] = base_nodes->GetmuT(iPoint); break; case UNDIVIDED_LAPLACIAN: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetUndivided_Laplacian(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetUndivided_Laplacian(iPoint, iVar); break; case SOLUTION_LIMITER: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetLimiter(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetLimiter(iPoint, iVar); break; case MAX_EIGENVALUE: - bufDSend[buf_offset] = node[iPoint]->GetLambda(); + bufDSend[buf_offset] = base_nodes->GetLambda(iPoint); break; case SENSOR: - bufDSend[buf_offset] = node[iPoint]->GetSensor(); + bufDSend[buf_offset] = base_nodes->GetSensor(iPoint); break; case SOLUTION_GRADIENT: for (iVar = 0; iVar < nVar; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - bufDSend[buf_offset+iVar*nDim+iDim] = node[iPoint]->GetGradient(iVar, iDim); - bufDSend[buf_offset+iVar*nDim+iDim+nDim*nVar] = node[iPoint]->GetGradient_Reconstruction(iVar, iDim); + bufDSend[buf_offset+iVar*nDim+iDim] = base_nodes->GetGradient(iPoint, iVar, iDim); + bufDSend[buf_offset+iVar*nDim+iDim+nDim*nVar] = base_nodes->GetGradient_Reconstruction(iPoint, iVar, iDim); } } break; case PRIMITIVE_GRADIENT: for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - bufDSend[buf_offset+iVar*nDim+iDim] = node[iPoint]->GetGradient_Primitive(iVar, iDim); - bufDSend[buf_offset+iVar*nDim+iDim+nDim*nPrimVarGrad] = node[iPoint]->GetGradient_Reconstruction(iVar, iDim); + bufDSend[buf_offset+iVar*nDim+iDim] = base_nodes->GetGradient_Primitive(iPoint, iVar, iDim); + bufDSend[buf_offset+iVar*nDim+iDim+nDim*nPrimVarGrad] = base_nodes->GetGradient_Reconstruction(iPoint, iVar, iDim); } } break; case PRIMITIVE_LIMITER: for (iVar = 0; iVar < nPrimVarGrad; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetLimiter_Primitive(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetLimiter_Primitive(iPoint, iVar); break; case AUXVAR_GRADIENT: for (iDim = 0; iDim < nDim; iDim++) - bufDSend[buf_offset+iDim] = node[iPoint]->GetAuxVarGradient(iDim); + bufDSend[buf_offset+iDim] = base_nodes->GetAuxVarGradient(iPoint, iDim); break; case SOLUTION_FEA: for (iVar = 0; iVar < nVar; iVar++) { - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); if (config->GetTime_Domain()) { - bufDSend[buf_offset+nVar+iVar] = node[iPoint]->GetSolution_Vel(iVar); - bufDSend[buf_offset+nVar*2+iVar] = node[iPoint]->GetSolution_Accel(iVar); + bufDSend[buf_offset+nVar+iVar] = base_nodes->GetSolution_Vel(iPoint, iVar); + bufDSend[buf_offset+nVar*2+iVar] = base_nodes->GetSolution_Accel(iPoint, iVar); } } break; case SOLUTION_FEA_OLD: for (iVar = 0; iVar < nVar; iVar++) { - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution_time_n(iVar); - bufDSend[buf_offset+nVar+iVar] = node[iPoint]->GetSolution_Vel_time_n(iVar); - bufDSend[buf_offset+nVar*2+iVar] = node[iPoint]->GetSolution_Accel_time_n(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution_time_n(iPoint, iVar); + bufDSend[buf_offset+nVar+iVar] = base_nodes->GetSolution_Vel_time_n(iPoint, iVar); + bufDSend[buf_offset+nVar*2+iVar] = base_nodes->GetSolution_Accel_time_n(iPoint, iVar); } break; case SOLUTION_DISPONLY: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); break; case SOLUTION_PRED: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution_Pred(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution_Pred(iPoint, iVar); break; case SOLUTION_PRED_OLD: for (iVar = 0; iVar < nVar; iVar++) { - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution_Old(iVar); - bufDSend[buf_offset+nVar+iVar] = node[iPoint]->GetSolution_Pred(iVar); - bufDSend[buf_offset+nVar*2+iVar] = node[iPoint]->GetSolution_Pred_Old(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution_Old(iPoint, iVar); + bufDSend[buf_offset+nVar+iVar] = base_nodes->GetSolution_Pred(iPoint, iVar); + bufDSend[buf_offset+nVar*2+iVar] = base_nodes->GetSolution_Pred_Old(iPoint, iVar); } break; case MESH_DISPLACEMENTS: for (iDim = 0; iDim < nDim; iDim++) - bufDSend[buf_offset+iDim] = node[iPoint]->GetBound_Disp(iDim); + bufDSend[buf_offset+iDim] = base_nodes->GetBound_Disp(iPoint, iDim); break; case SOLUTION_TIME_N: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution_time_n(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution_time_n(iPoint, iVar); break; case SOLUTION_TIME_N1: for (iVar = 0; iVar < nVar; iVar++) - bufDSend[buf_offset+iVar] = node[iPoint]->GetSolution_time_n1(iVar); + bufDSend[buf_offset+iVar] = base_nodes->GetSolution_time_n1(iPoint, iVar); break; default: SU2_MPI::Error("Unrecognized quantity for point-to-point MPI comms.", @@ -2149,97 +2144,97 @@ void CSolver::CompleteComms(CGeometry *geometry, switch (commType) { case SOLUTION: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->SetSolution(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; case SOLUTION_OLD: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->SetSolution_Old(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetSolution_Old(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; case SOLUTION_EDDY: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->SetSolution(iVar, bufDRecv[buf_offset+iVar]); - node[iPoint]->SetmuT(bufDRecv[buf_offset+nVar]); + base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetmuT(iPoint,bufDRecv[buf_offset+nVar]); break; case UNDIVIDED_LAPLACIAN: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->SetUndivided_Laplacian(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetUndivided_Laplacian(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; case SOLUTION_LIMITER: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->SetLimiter(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetLimiter(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; case MAX_EIGENVALUE: - node[iPoint]->SetLambda(bufDRecv[buf_offset]); + base_nodes->SetLambda(iPoint,bufDRecv[buf_offset]); break; case SENSOR: - node[iPoint]->SetSensor(bufDRecv[buf_offset]); + base_nodes->SetSensor(iPoint,bufDRecv[buf_offset]); break; case SOLUTION_GRADIENT: for (iVar = 0; iVar < nVar; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->SetGradient(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim]); - node[iPoint]->SetGradient_Reconstruction(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim+nDim*nVar]); + base_nodes->SetGradient(iPoint, iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim]); + base_nodes->SetGradient_Reconstruction(iPoint, iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim+nDim*nVar]); } } break; case PRIMITIVE_GRADIENT: for (iVar = 0; iVar < nPrimVarGrad; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->SetGradient_Primitive(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim]); - node[iPoint]->SetGradient_Reconstruction(iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim+nDim*nPrimVarGrad]); + base_nodes->SetGradient_Primitive(iPoint, iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim]); + base_nodes->SetGradient_Reconstruction(iPoint, iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim+nDim*nPrimVarGrad]); } } break; case PRIMITIVE_LIMITER: for (iVar = 0; iVar < nPrimVarGrad; iVar++) - node[iPoint]->SetLimiter_Primitive(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetLimiter_Primitive(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; case AUXVAR_GRADIENT: for (iDim = 0; iDim < nDim; iDim++) - node[iPoint]->SetAuxVarGradient(iDim, bufDRecv[buf_offset+iDim]); + base_nodes->SetAuxVarGradient(iPoint, iDim, bufDRecv[buf_offset+iDim]); break; case SOLUTION_FEA: for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->SetSolution(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); if (config->GetTime_Domain()) { - node[iPoint]->SetSolution_Vel(iVar, bufDRecv[buf_offset+nVar+iVar]); - node[iPoint]->SetSolution_Accel(iVar, bufDRecv[buf_offset+nVar*2+iVar]); + base_nodes->SetSolution_Vel(iPoint, iVar, bufDRecv[buf_offset+nVar+iVar]); + base_nodes->SetSolution_Accel(iPoint, iVar, bufDRecv[buf_offset+nVar*2+iVar]); } } break; case SOLUTION_FEA_OLD: for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->Set_Solution_time_n(iVar, bufDRecv[buf_offset+iVar]); - node[iPoint]->SetSolution_Vel_time_n(iVar, bufDRecv[buf_offset+nVar+iVar]); - node[iPoint]->SetSolution_Accel_time_n(iVar, bufDRecv[buf_offset+nVar*2+iVar]); + base_nodes->Set_Solution_time_n(iPoint, iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetSolution_Vel_time_n(iPoint, iVar, bufDRecv[buf_offset+nVar+iVar]); + base_nodes->SetSolution_Accel_time_n(iPoint, iVar, bufDRecv[buf_offset+nVar*2+iVar]); } break; case SOLUTION_DISPONLY: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->SetSolution(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; case SOLUTION_PRED: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->SetSolution_Pred(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetSolution_Pred(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; case SOLUTION_PRED_OLD: for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->SetSolution_Old(iVar, bufDRecv[buf_offset+iVar]); - node[iPoint]->SetSolution_Pred(iVar, bufDRecv[buf_offset+nVar+iVar]); - node[iPoint]->SetSolution_Pred_Old(iVar, bufDRecv[buf_offset+nVar*2+iVar]); + base_nodes->SetSolution_Old(iPoint, iVar, bufDRecv[buf_offset+iVar]); + base_nodes->SetSolution_Pred(iPoint, iVar, bufDRecv[buf_offset+nVar+iVar]); + base_nodes->SetSolution_Pred_Old(iPoint, iVar, bufDRecv[buf_offset+nVar*2+iVar]); } break; case MESH_DISPLACEMENTS: for (iDim = 0; iDim < nDim; iDim++) - node[iPoint]->SetBound_Disp(iDim, bufDRecv[buf_offset+iDim]); + base_nodes->SetBound_Disp(iPoint, iDim, bufDRecv[buf_offset+iDim]); break; case SOLUTION_TIME_N: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->Set_Solution_time_n(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->Set_Solution_time_n(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; case SOLUTION_TIME_N1: for (iVar = 0; iVar < nVar; iVar++) - node[iPoint]->Set_Solution_time_n1(iVar, bufDRecv[buf_offset+iVar]); + base_nodes->Set_Solution_time_n1(iPoint, iVar, bufDRecv[buf_offset+iVar]); break; default: SU2_MPI::Error("Unrecognized quantity for point-to-point MPI comms.", @@ -2366,17 +2361,17 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, /* Get the current local flow CFL number at this point. */ - su2double CFL = solverFlow->node[iPoint]->GetLocalCFL(); + su2double CFL = solverFlow->GetNodes()->GetLocalCFL(iPoint); /* Get the current under-relaxation parameters that were computed during the previous nonlinear update. If we have a turbulence model, take the minimum under-relaxation parameter between the mean flow and turbulence systems. */ - su2double underRelaxationFlow = solverFlow->node[iPoint]->GetUnderRelaxation(); + su2double underRelaxationFlow = solverFlow->GetNodes()->GetUnderRelaxation(iPoint); su2double underRelaxationTurb = 1.0; if ((iMesh == MESH_0) && (config->GetKind_Turb_Model() != NONE)) - underRelaxationTurb = solverTurb->node[iPoint]->GetUnderRelaxation(); + underRelaxationTurb = solverTurb->GetNodes()->GetUnderRelaxation(iPoint); const su2double underRelaxation = min(underRelaxationFlow,underRelaxationTurb); /* If we apply a small under-relaxation parameter for stability, @@ -2414,9 +2409,9 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry, /* Apply the adjustment to the CFL and store local values. */ CFL *= CFLFactor; - solverFlow->node[iPoint]->SetLocalCFL(CFL); + solverFlow->GetNodes()->SetLocalCFL(iPoint, CFL); if ((iMesh == MESH_0) && (config->GetKind_Turb_Model() != NONE)) { - solverTurb->node[iPoint]->SetLocalCFL(CFL); + solverTurb->GetNodes()->SetLocalCFL(iPoint, CFL); } /* Store min and max CFL for reporting on fine grid. */ @@ -2667,8 +2662,8 @@ void CSolver::SetRotatingFrame_GCL(CGeometry *geometry, CConfig *config) { /*--- Solution at each edge point ---*/ - su2double *Solution_i = node[iPoint]->GetSolution(); - su2double *Solution_j = node[jPoint]->GetSolution(); + su2double *Solution_i = base_nodes->GetSolution(iPoint); + su2double *Solution_j = base_nodes->GetSolution(jPoint); for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.5* (Solution_i[iVar] + Solution_j[iVar]); @@ -2708,7 +2703,7 @@ void CSolver::SetRotatingFrame_GCL(CGeometry *geometry, CConfig *config) { /*--- Solution at each edge point ---*/ - su2double *Solution = node[Point]->GetSolution(); + su2double *Solution = base_nodes->GetSolution(Point); /*--- Grid Velocity at each edge point ---*/ @@ -2741,8 +2736,9 @@ void CSolver::SetAuxVar_Gradient_GG(CGeometry *geometry, CConfig *config) { su2double AuxVar_Vertex, AuxVar_i, AuxVar_j, AuxVar_Average; su2double *Gradient, DualArea, Partial_Res, Grad_Val, *Normal; - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) - node[iPoint]->SetAuxVarGradientZero(); // Set Gradient to Zero + /*--- Set Gradient to Zero ---*/ + + base_nodes->SetAuxVarGradientZero(); /*--- Loop interior edges ---*/ @@ -2750,15 +2746,15 @@ void CSolver::SetAuxVar_Gradient_GG(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - AuxVar_i = node[iPoint]->GetAuxVar(); - AuxVar_j = node[jPoint]->GetAuxVar(); + AuxVar_i = base_nodes->GetAuxVar(iPoint); + AuxVar_j = base_nodes->GetAuxVar(jPoint); Normal = geometry->edge[iEdge]->GetNormal(); AuxVar_Average = 0.5 * ( AuxVar_i + AuxVar_j); for (iDim = 0; iDim < nDim; iDim++) { Partial_Res = AuxVar_Average*Normal[iDim]; - node[iPoint]->AddAuxVarGradient(iDim, Partial_Res); - node[jPoint]->SubtractAuxVarGradient(iDim, Partial_Res); + base_nodes->AddAuxVarGradient(iPoint, iDim, Partial_Res); + base_nodes->SubtractAuxVarGradient(jPoint,iDim, Partial_Res); } } @@ -2769,21 +2765,21 @@ void CSolver::SetAuxVar_Gradient_GG(CGeometry *geometry, CConfig *config) { (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { Point = geometry->vertex[iMarker][iVertex]->GetNode(); - AuxVar_Vertex = node[Point]->GetAuxVar(); + AuxVar_Vertex = base_nodes->GetAuxVar(Point); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); for (iDim = 0; iDim < nDim; iDim++) { Partial_Res = AuxVar_Vertex*Normal[iDim]; - node[Point]->SubtractAuxVarGradient(iDim, Partial_Res); + base_nodes->SubtractAuxVarGradient(Point,iDim, Partial_Res); } } } for (iPoint=0; iPointGetnPoint(); iPoint++) for (iDim = 0; iDim < nDim; iDim++) { - Gradient = node[iPoint]->GetAuxVarGradient(); + Gradient = base_nodes->GetAuxVarGradient(iPoint); DualArea = geometry->node[iPoint]->GetVolume(); Grad_Val = Gradient[iDim]/(DualArea+EPS); - node[iPoint]->SetAuxVarGradient(iDim, Grad_Val); + base_nodes->SetAuxVarGradient(iPoint, iDim, Grad_Val); } /*--- Gradient MPI ---*/ @@ -2809,7 +2805,7 @@ void CSolver::SetAuxVar_Gradient_LS(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { Coord_i = geometry->node[iPoint]->GetCoord(); - AuxVar_i = node[iPoint]->GetAuxVar(); + AuxVar_i = base_nodes->GetAuxVar(iPoint); /*--- Inizialization of variables ---*/ for (iDim = 0; iDim < nDim; iDim++) @@ -2821,7 +2817,7 @@ void CSolver::SetAuxVar_Gradient_LS(CGeometry *geometry, CConfig *config) { for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); iNeigh++) { jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Coord_j = geometry->node[jPoint]->GetCoord(); - AuxVar_j = node[jPoint]->GetAuxVar(); + AuxVar_j = base_nodes->GetAuxVar(jPoint); weight = 0.0; for (iDim = 0; iDim < nDim; iDim++) @@ -2906,7 +2902,7 @@ void CSolver::SetAuxVar_Gradient_LS(CGeometry *geometry, CConfig *config) { for (jDim = 0; jDim < nDim; jDim++) product += Smatrix[iDim][jDim]*Cvector[jDim]; if (geometry->node[iPoint]->GetDomain()) - node[iPoint]->SetAuxVarGradient(iDim, product); + base_nodes->SetAuxVarGradient(iPoint, iDim, product); } } @@ -2926,25 +2922,24 @@ void CSolver::SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config, bool Partial_Res, Grad_Val, *Normal, Vol; /*--- Set Gradient to Zero ---*/ - for (iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) - node[iPoint]->SetGradientZero(); + base_nodes->SetGradientZero(); /*--- Loop interior edges ---*/ for (iEdge = 0; iEdge < geometry->GetnEdge(); iEdge++) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Solution_i = node[iPoint]->GetSolution(); - Solution_j = node[jPoint]->GetSolution(); + Solution_i = base_nodes->GetSolution(iPoint); + Solution_j = base_nodes->GetSolution(jPoint); Normal = geometry->edge[iEdge]->GetNormal(); for (iVar = 0; iVar< nVar; iVar++) { Solution_Average = 0.5 * (Solution_i[iVar] + Solution_j[iVar]); for (iDim = 0; iDim < nDim; iDim++) { Partial_Res = Solution_Average*Normal[iDim]; if (geometry->node[iPoint]->GetDomain()) - node[iPoint]->AddGradient(iVar, iDim, Partial_Res); + base_nodes->AddGradient(iPoint, iVar, iDim, Partial_Res); if (geometry->node[jPoint]->GetDomain()) - node[jPoint]->SubtractGradient(iVar, iDim, Partial_Res); + base_nodes->SubtractGradient(jPoint,iVar, iDim, Partial_Res); } } } @@ -2955,13 +2950,13 @@ void CSolver::SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config, bool (config->GetMarker_All_KindBC(iMarker) != PERIODIC_BOUNDARY)) { for (iVertex = 0; iVertex < geometry->GetnVertex(iMarker); iVertex++) { Point = geometry->vertex[iMarker][iVertex]->GetNode(); - Solution_Vertex = node[Point]->GetSolution(); + Solution_Vertex = base_nodes->GetSolution(Point); Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); for (iVar = 0; iVar < nVar; iVar++) for (iDim = 0; iDim < nDim; iDim++) { Partial_Res = Solution_Vertex[iVar]*Normal[iDim]; if (geometry->node[Point]->GetDomain()) - node[Point]->SubtractGradient(iVar, iDim, Partial_Res); + base_nodes->SubtractGradient(Point,iVar, iDim, Partial_Res); } } } @@ -2984,12 +2979,12 @@ void CSolver::SetSolution_Gradient_GG(CGeometry *geometry, CConfig *config, bool for (iVar = 0; iVar < nVar; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - Gradient = node[iPoint]->GetGradient(); + Gradient = base_nodes->GetGradient(iPoint); Grad_Val = Gradient[iVar][iDim] / (Vol+EPS); if (reconstruction) - node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Grad_Val); + base_nodes->SetGradient_Reconstruction(iPoint, iVar, iDim, Grad_Val); else - node[iPoint]->SetGradient(iVar, iDim, Grad_Val); + base_nodes->SetGradient(iPoint, iVar, iDim, Grad_Val); } } @@ -3021,6 +3016,12 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool weighted = false; } + /*--- Clear Rmatrix, which could eventually be computed once + and stored for static meshes, as well as the gradient. ---*/ + + base_nodes->SetRmatrixZero(); + base_nodes->SetGradientZero(); + /*--- Loop over points of the grid ---*/ for (iPoint = 0; iPoint < geometry->GetnPointDomain(); iPoint++) { @@ -3034,25 +3035,19 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool /*--- Get consevative solution ---*/ - Solution_i = node[iPoint]->GetSolution(); + Solution_i = base_nodes->GetSolution(iPoint); /*--- Inizialization of variables ---*/ for (iVar = 0; iVar < nVar; iVar++) for (iDim = 0; iDim < nDim; iDim++) Cvector[iVar][iDim] = 0.0; - - /*--- Clear Rmatrix, which could eventually be computed once - and stored for static meshes, as well as the prim gradient. ---*/ - - node[iPoint]->SetRmatrixZero(); - node[iPoint]->SetGradientZero(); for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); iNeigh++) { jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Coord_j = geometry->node[jPoint]->GetCoord(); - Solution_j = node[jPoint]->GetSolution(); + Solution_j = base_nodes->GetSolution(jPoint); if (weighted) { weight = 0.0; @@ -3066,22 +3061,22 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool if (weight != 0.0) { - node[iPoint]->AddRmatrix(0, 0, (Coord_j[0]-Coord_i[0])*(Coord_j[0]-Coord_i[0])/weight); - node[iPoint]->AddRmatrix(0, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[1]-Coord_i[1])/weight); - node[iPoint]->AddRmatrix(1, 1, (Coord_j[1]-Coord_i[1])*(Coord_j[1]-Coord_i[1])/weight); + base_nodes->AddRmatrix(iPoint,0, 0, (Coord_j[0]-Coord_i[0])*(Coord_j[0]-Coord_i[0])/weight); + base_nodes->AddRmatrix(iPoint,0, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[1]-Coord_i[1])/weight); + base_nodes->AddRmatrix(iPoint,1, 1, (Coord_j[1]-Coord_i[1])*(Coord_j[1]-Coord_i[1])/weight); if (nDim == 3) { - node[iPoint]->AddRmatrix(0, 2, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(1, 2, (Coord_j[1]-Coord_i[1])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(2, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); - node[iPoint]->AddRmatrix(2, 2, (Coord_j[2]-Coord_i[2])*(Coord_j[2]-Coord_i[2])/weight); + base_nodes->AddRmatrix(iPoint,0, 2, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); + base_nodes->AddRmatrix(iPoint,1, 2, (Coord_j[1]-Coord_i[1])*(Coord_j[2]-Coord_i[2])/weight); + base_nodes->AddRmatrix(iPoint,2, 1, (Coord_j[0]-Coord_i[0])*(Coord_j[2]-Coord_i[2])/weight); + base_nodes->AddRmatrix(iPoint,2, 2, (Coord_j[2]-Coord_i[2])*(Coord_j[2]-Coord_i[2])/weight); } /*--- Entries of c:= transpose(A)*b ---*/ for (iVar = 0; iVar < nVar; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { - node[iPoint]->AddGradient(iVar,iDim, (Coord_j[iDim]-Coord_i[iDim])*(Solution_j[iVar]-Solution_i[iVar])/weight); + base_nodes->AddGradient(iPoint, iVar,iDim, (Coord_j[iDim]-Coord_i[iDim])*(Solution_j[iVar]-Solution_i[iVar])/weight); } } @@ -3109,9 +3104,9 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool r11 = 0.0; r12 = 0.0; r13 = 0.0; r22 = 0.0; r23 = 0.0; r23_a = 0.0; r23_b = 0.0; r33 = 0.0; - r11 = node[iPoint]->GetRmatrix(0,0); - r12 = node[iPoint]->GetRmatrix(0,1); - r22 = node[iPoint]->GetRmatrix(1,1); + r11 = base_nodes->GetRmatrix(iPoint,0,0); + r12 = base_nodes->GetRmatrix(iPoint,0,1); + r22 = base_nodes->GetRmatrix(iPoint,1,1); /*--- Entries of upper triangular matrix R ---*/ @@ -3120,10 +3115,10 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool if (r22-r12*r12 >= 0.0) r22 = sqrt(r22-r12*r12); else r22 = 0.0; if (nDim == 3) { - r13 = node[iPoint]->GetRmatrix(0,2); - r23_a = node[iPoint]->GetRmatrix(1,2); - r23_b = node[iPoint]->GetRmatrix(2,1); - r33 = node[iPoint]->GetRmatrix(2,2); + r13 = base_nodes->GetRmatrix(iPoint,0,2); + r23_a = base_nodes->GetRmatrix(iPoint,1,2); + r23_b = base_nodes->GetRmatrix(iPoint,2,1); + r33 = base_nodes->GetRmatrix(iPoint,2,2); if (r11 != 0.0) r13 = r13/r11; else r13 = 0.0; if ((r22 != 0.0) && (r11*r22 != 0.0)) r23 = r23_a/r22 - r23_b*r12/(r11*r22); else r23 = 0.0; @@ -3174,7 +3169,7 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool for (iDim = 0; iDim < nDim; iDim++) { Cvector[iVar][iDim] = 0.0; for (jDim = 0; jDim < nDim; jDim++) { - Cvector[iVar][iDim] += Smatrix[iDim][jDim]*node[iPoint]->GetGradient(iVar, jDim); + Cvector[iVar][iDim] += Smatrix[iDim][jDim]*base_nodes->GetGradient(iPoint, iVar, jDim); } } } @@ -3182,9 +3177,9 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool for (iVar = 0; iVar < nVar; iVar++) { for (iDim = 0; iDim < nDim; iDim++) { if (reconstruction) - node[iPoint]->SetGradient_Reconstruction(iVar, iDim, Cvector[iVar][iDim]); + base_nodes->SetGradient_Reconstruction(iPoint, iVar, iDim, Cvector[iVar][iDim]); else - node[iPoint]->SetGradient(iVar, iDim, Cvector[iVar][iDim]); + base_nodes->SetGradient(iPoint, iVar, iDim, Cvector[iVar][iDim]); } } @@ -3197,6 +3192,24 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool } +void CSolver::Add_ExternalOld_To_Solution(CGeometry *geometry) { + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + base_nodes->AddSolution(iPoint, base_nodes->Get_ExternalOld(iPoint)); + } +} + +void CSolver::Add_Solution_To_External(CGeometry *geometry) { + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + base_nodes->Add_External(iPoint, base_nodes->GetSolution(iPoint)); + } +} + +void CSolver::Add_Solution_To_ExternalOld(CGeometry *geometry) { + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + base_nodes->Add_ExternalOld(iPoint, base_nodes->GetSolution(iPoint)); + } +} + void CSolver::SetGridVel_Gradient(CGeometry *geometry, CConfig *config) { unsigned short iDim, jDim, iVar, iNeigh; unsigned long iPoint, jPoint; @@ -3329,7 +3342,7 @@ void CSolver::SetAuxVar_Surface_Gradient(CGeometry *geometry, CConfig *config) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); if (geometry->node[iPoint]->GetDomain()) { Coord_i = geometry->node[iPoint]->GetCoord(); - AuxVar_i = node[iPoint]->GetAuxVar(); + AuxVar_i = base_nodes->GetAuxVar(iPoint); /*--- Inizialization of variables ---*/ for (iDim = 0; iDim < nDim; iDim++) @@ -3339,7 +3352,7 @@ void CSolver::SetAuxVar_Surface_Gradient(CGeometry *geometry, CConfig *config) { for (iNeigh = 0; iNeigh < geometry->node[iPoint]->GetnPoint(); iNeigh++) { jPoint = geometry->node[iPoint]->GetPoint(iNeigh); Coord_j = geometry->node[jPoint]->GetCoord(); - AuxVar_j = node[jPoint]->GetAuxVar(); + AuxVar_j = base_nodes->GetAuxVar(jPoint); su2double weight = 0; for (iDim = 0; iDim < nDim; iDim++) @@ -3403,7 +3416,7 @@ void CSolver::SetAuxVar_Surface_Gradient(CGeometry *geometry, CConfig *config) { product = 0.0; for (jDim = 0; jDim < nDim; jDim++) product += Smatrix[iDim][jDim]*Cvector[jDim]; - node[iPoint]->SetAuxVarGradient(iDim, product); + base_nodes->SetAuxVarGradient(iPoint, iDim, product); } } } /*--- End of loop over surface points ---*/ @@ -3447,7 +3460,7 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->SetLimiter(iVar, 1.0); + base_nodes->SetLimiter(iPoint, iVar, 1.0); } } @@ -3459,9 +3472,9 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - node[iPoint]->SetSolution_Max(iVar, -EPS); - node[iPoint]->SetSolution_Min(iVar, EPS); - node[iPoint]->SetLimiter(iVar, 2.0); + base_nodes->SetSolution_Max(iPoint, iVar, -EPS); + base_nodes->SetSolution_Min(iPoint, iVar, EPS); + base_nodes->SetLimiter(iPoint, iVar, 2.0); } } @@ -3476,17 +3489,17 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { /*--- Get the conserved variables ---*/ - Solution_i = node[iPoint]->GetSolution(); - Solution_j = node[jPoint]->GetSolution(); + Solution_i = base_nodes->GetSolution(iPoint); + Solution_j = base_nodes->GetSolution(jPoint); /*--- Compute the maximum, and minimum values for nodes i & j ---*/ for (iVar = 0; iVar < nVar; iVar++) { du = (Solution_j[iVar] - Solution_i[iVar]); - node[iPoint]->SetSolution_Min(iVar, min(node[iPoint]->GetSolution_Min(iVar), du)); - node[iPoint]->SetSolution_Max(iVar, max(node[iPoint]->GetSolution_Max(iVar), du)); - node[jPoint]->SetSolution_Min(iVar, min(node[jPoint]->GetSolution_Min(iVar), -du)); - node[jPoint]->SetSolution_Max(iVar, max(node[jPoint]->GetSolution_Max(iVar), -du)); + base_nodes->SetSolution_Min(iPoint, iVar, min(base_nodes->GetSolution_Min(iPoint, iVar), du)); + base_nodes->SetSolution_Max(iPoint, iVar, max(base_nodes->GetSolution_Max(iPoint, iVar), du)); + base_nodes->SetSolution_Min(jPoint, iVar, min(base_nodes->GetSolution_Min(jPoint, iVar), -du)); + base_nodes->SetSolution_Max(jPoint, iVar, max(base_nodes->GetSolution_Max(jPoint, iVar), -du)); } } @@ -3508,8 +3521,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = base_nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = base_nodes->GetGradient_Reconstruction(jPoint); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -3520,10 +3533,10 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { for (iVar = 0; iVar < nVar; iVar++) { - AD::SetPreaccIn(node[iPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[iPoint]->GetSolution_Min(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Min(iVar)); + AD::SetPreaccIn(base_nodes->GetSolution_Max(iPoint, iVar)); + AD::SetPreaccIn(base_nodes->GetSolution_Min(iPoint, iVar)); + AD::SetPreaccIn(base_nodes->GetSolution_Max(jPoint,iVar)); + AD::SetPreaccIn(base_nodes->GetSolution_Min(jPoint,iVar)); /*--- Calculate the interface left gradient, delta- (dm) ---*/ @@ -3533,14 +3546,14 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { if (dm == 0.0) { limiter = 2.0; } else { - if ( dm > 0.0 ) dp = node[iPoint]->GetSolution_Max(iVar); - else dp = node[iPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = base_nodes->GetSolution_Max(iPoint, iVar); + else dp = base_nodes->GetSolution_Min(iPoint, iVar); limiter = dp/dm; } - if (limiter < node[iPoint]->GetLimiter(iVar)) { - node[iPoint]->SetLimiter(iVar, limiter); - AD::SetPreaccOut(node[iPoint]->GetLimiter()[iVar]); + if (limiter < base_nodes->GetLimiter(iPoint, iVar)) { + base_nodes->SetLimiter(iPoint, iVar, limiter); + AD::SetPreaccOut(base_nodes->GetLimiter(iPoint)[iVar]); } /*--- Calculate the interface right gradient, delta+ (dp) ---*/ @@ -3551,14 +3564,14 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { if (dm == 0.0) { limiter = 2.0; } else { - if ( dm > 0.0 ) dp = node[jPoint]->GetSolution_Max(iVar); - else dp = node[jPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = base_nodes->GetSolution_Max(jPoint,iVar); + else dp = base_nodes->GetSolution_Min(jPoint,iVar); limiter = dp/dm; } - if (limiter < node[jPoint]->GetLimiter(iVar)) { - node[jPoint]->SetLimiter(iVar, limiter); - AD::SetPreaccOut(node[jPoint]->GetLimiter()[iVar]); + if (limiter < base_nodes->GetLimiter(jPoint,iVar)) { + base_nodes->SetLimiter(jPoint,iVar, limiter); + AD::SetPreaccOut(base_nodes->GetLimiter(jPoint)[iVar]); } } @@ -3570,9 +3583,9 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { for (iVar = 0; iVar < nVar; iVar++) { - y = node[iPoint]->GetLimiter(iVar); + y = base_nodes->GetLimiter(iPoint, iVar); limiter = (y*y + 2.0*y) / (y*y + y + 2.0); - node[iPoint]->SetLimiter(iVar, limiter); + base_nodes->SetLimiter(iPoint, iVar, limiter); } } @@ -3591,7 +3604,7 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { /*--- Compute the max value and min value of the solution ---*/ - Solution = node[iPoint]->GetSolution(); + Solution = base_nodes->GetSolution(iPoint); for (iVar = 0; iVar < nVar; iVar++) { LocalMinSolution[iVar] = Solution[iVar]; LocalMaxSolution[iVar] = Solution[iVar]; @@ -3601,7 +3614,7 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { /*--- Get the solution variables ---*/ - Solution = node[iPoint]->GetSolution(); + Solution = base_nodes->GetSolution(iPoint); for (iVar = 0; iVar < nVar; iVar++) { LocalMinSolution[iVar] = min (LocalMinSolution[iVar], Solution[iVar]); @@ -3625,8 +3638,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = base_nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = base_nodes->GetGradient_Reconstruction(jPoint); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -3642,10 +3655,10 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { AD::SetPreaccIn(Gradient_j[iVar], nDim); AD::SetPreaccIn(Coord_i, nDim); AD::SetPreaccIn(Coord_j, nDim); - AD::SetPreaccIn(node[iPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[iPoint]->GetSolution_Min(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Max(iVar)); - AD::SetPreaccIn(node[jPoint]->GetSolution_Min(iVar)); + AD::SetPreaccIn(base_nodes->GetSolution_Max(iPoint, iVar)); + AD::SetPreaccIn(base_nodes->GetSolution_Min(iPoint, iVar)); + AD::SetPreaccIn(base_nodes->GetSolution_Max(jPoint,iVar)); + AD::SetPreaccIn(base_nodes->GetSolution_Min(jPoint,iVar)); if (config->GetKind_SlopeLimit_Flow() == VENKATAKRISHNAN_WANG) { AD::SetPreaccIn(GlobalMaxSolution[iVar]); @@ -3666,14 +3679,14 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { /*--- Calculate the interface right gradient, delta+ (dp) ---*/ - if ( dm > 0.0 ) dp = node[iPoint]->GetSolution_Max(iVar); - else dp = node[iPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = base_nodes->GetSolution_Max(iPoint, iVar); + else dp = base_nodes->GetSolution_Min(iPoint, iVar); limiter = ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[iPoint]->GetLimiter(iVar)) { - node[iPoint]->SetLimiter(iVar, limiter); - AD::SetPreaccOut(node[iPoint]->GetLimiter()[iVar]); + if (limiter < base_nodes->GetLimiter(iPoint, iVar)) { + base_nodes->SetLimiter(iPoint, iVar, limiter); + AD::SetPreaccOut(base_nodes->GetLimiter(iPoint)[iVar]); } /*-- Repeat for point j on the edge ---*/ @@ -3682,14 +3695,14 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { for (iDim = 0; iDim < nDim; iDim++) dm += 0.5*(Coord_i[iDim]-Coord_j[iDim])*Gradient_j[iVar][iDim]; - if ( dm > 0.0 ) dp = node[jPoint]->GetSolution_Max(iVar); - else dp = node[jPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = base_nodes->GetSolution_Max(jPoint,iVar); + else dp = base_nodes->GetSolution_Min(jPoint,iVar); limiter = ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[jPoint]->GetLimiter(iVar)) { - node[jPoint]->SetLimiter(iVar, limiter); - AD::SetPreaccOut(node[jPoint]->GetLimiter()[iVar]); + if (limiter < base_nodes->GetLimiter(jPoint,iVar)) { + base_nodes->SetLimiter(jPoint,iVar, limiter); + AD::SetPreaccOut(base_nodes->GetLimiter(jPoint)[iVar]); } AD::EndPreacc(); @@ -3718,8 +3731,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = base_nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = base_nodes->GetGradient_Reconstruction(jPoint); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -3733,8 +3746,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { /*--- Calculate the interface right gradient, delta+ (dp) ---*/ - if ( dm > 0.0 ) dp = node[iPoint]->GetSolution_Max(iVar); - else dp = node[iPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = base_nodes->GetSolution_Max(iPoint, iVar); + else dp = base_nodes->GetSolution_Min(iPoint, iVar); /*--- Compute the distance to a sharp edge ---*/ @@ -3746,8 +3759,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { limiter = ds * ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[iPoint]->GetLimiter(iVar)) - node[iPoint]->SetLimiter(iVar, limiter); + if (limiter < base_nodes->GetLimiter(iPoint, iVar)) + base_nodes->SetLimiter(iPoint, iVar, limiter); /*-- Repeat for point j on the edge ---*/ @@ -3755,8 +3768,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { for (iDim = 0; iDim < nDim; iDim++) dm += 0.5*(Coord_i[iDim]-Coord_j[iDim])*Gradient_j[iVar][iDim]; - if ( dm > 0.0 ) dp = node[jPoint]->GetSolution_Max(iVar); - else dp = node[jPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = base_nodes->GetSolution_Max(jPoint,iVar); + else dp = base_nodes->GetSolution_Min(jPoint,iVar); /*--- Compute the distance to a sharp edge ---*/ @@ -3768,8 +3781,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { limiter = ds * ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[jPoint]->GetLimiter(iVar)) - node[jPoint]->SetLimiter(iVar, limiter); + if (limiter < base_nodes->GetLimiter(jPoint,iVar)) + base_nodes->SetLimiter(jPoint,iVar, limiter); } } @@ -3790,8 +3803,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { iPoint = geometry->edge[iEdge]->GetNode(0); jPoint = geometry->edge[iEdge]->GetNode(1); - Gradient_i = node[iPoint]->GetGradient_Reconstruction(); - Gradient_j = node[jPoint]->GetGradient_Reconstruction(); + Gradient_i = base_nodes->GetGradient_Reconstruction(iPoint); + Gradient_j = base_nodes->GetGradient_Reconstruction(jPoint); Coord_i = geometry->node[iPoint]->GetCoord(); Coord_j = geometry->node[jPoint]->GetCoord(); @@ -3805,8 +3818,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { /*--- Calculate the interface right gradient, delta+ (dp) ---*/ - if ( dm > 0.0 ) dp = node[iPoint]->GetSolution_Max(iVar); - else dp = node[iPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = base_nodes->GetSolution_Max(iPoint, iVar); + else dp = base_nodes->GetSolution_Min(iPoint, iVar); /*--- Compute the distance to a sharp edge ---*/ @@ -3818,8 +3831,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { limiter = ds * ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[iPoint]->GetLimiter(iVar)) - node[iPoint]->SetLimiter(iVar, limiter); + if (limiter < base_nodes->GetLimiter(iPoint, iVar)) + base_nodes->SetLimiter(iPoint, iVar, limiter); /*-- Repeat for point j on the edge ---*/ @@ -3827,8 +3840,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { for (iDim = 0; iDim < nDim; iDim++) dm += 0.5*(Coord_i[iDim]-Coord_j[iDim])*Gradient_j[iVar][iDim]; - if ( dm > 0.0 ) dp = node[jPoint]->GetSolution_Max(iVar); - else dp = node[jPoint]->GetSolution_Min(iVar); + if ( dm > 0.0 ) dp = base_nodes->GetSolution_Max(jPoint,iVar); + else dp = base_nodes->GetSolution_Min(jPoint,iVar); /*--- Compute the distance to a sharp edge ---*/ @@ -3840,8 +3853,8 @@ void CSolver::SetSolution_Limiter(CGeometry *geometry, CConfig *config) { limiter = ds * ( dp*dp + 2.0*dp*dm + eps2 )/( dp*dp + dp*dm + 2.0*dm*dm + eps2); - if (limiter < node[jPoint]->GetLimiter(iVar)) - node[jPoint]->SetLimiter(iVar, limiter); + if (limiter < base_nodes->GetLimiter(jPoint,iVar)) + base_nodes->SetLimiter(jPoint,iVar, limiter); } } @@ -5280,7 +5293,7 @@ void CSolver::ComputeVertexTractions(CGeometry *geometry, CConfig *config){ if (geometry->node[iPoint]->GetDomain()) { // Retrieve the values of pressure - Pn = node[iPoint]->GetPressure(); + Pn = base_nodes->GetPressure(iPoint); // Calculate tn in the fluid nodes for the inviscid term --> Units of force (non-dimensional). for (iDim = 0; iDim < nDim; iDim++) @@ -5289,11 +5302,11 @@ void CSolver::ComputeVertexTractions(CGeometry *geometry, CConfig *config){ // Calculate tn in the fluid nodes for the viscous term if (viscous_flow) { - Viscosity = node[iPoint]->GetLaminarViscosity(); + Viscosity = base_nodes->GetLaminarViscosity(iPoint); for (iDim = 0; iDim < nDim; iDim++) { for (jDim = 0 ; jDim < nDim; jDim++) { - Grad_Vel[iDim][jDim] = node[iPoint]->GetGradient_Primitive(iDim+1, jDim); + Grad_Vel[iDim][jDim] = base_nodes->GetGradient_Primitive(iPoint, iDim+1, jDim); } } @@ -5442,17 +5455,17 @@ void CSolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig *config){ /*--- Set Residuals to zero ---*/ for (iVar = 0; iVar < nVar; iVar++){ - SetRes_BGS(iVar,0.0); - SetRes_Max_BGS(iVar,0.0,0); + SetRes_BGS(iVar,0.0); + SetRes_Max_BGS(iVar,0.0,0); } /*--- Set the residuals ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ - residual = node[iPoint]->GetSolution(iVar) - node[iPoint]->Get_BGSSolution_k(iVar); - AddRes_BGS(iVar,residual*residual); - AddRes_Max_BGS(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); - } + for (iVar = 0; iVar < nVar; iVar++){ + residual = base_nodes->GetSolution(iPoint,iVar) - base_nodes->Get_BGSSolution_k(iPoint,iVar); + AddRes_BGS(iVar,residual*residual); + AddRes_Max_BGS(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); + } } SetResidual_BGS(geometry, config); @@ -5462,24 +5475,14 @@ void CSolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig *config){ void CSolver::UpdateSolution_BGS(CGeometry *geometry, CConfig *config){ - unsigned long iPoint; - /*--- To nPoint: The solution must be communicated beforehand ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - - node[iPoint]->Set_BGSSolution_k(); - - } - + base_nodes->Set_BGSSolution_k(); } CBaselineSolver::CBaselineSolver(void) : CSolver() { } CBaselineSolver::CBaselineSolver(CGeometry *geometry, CConfig *config) { - unsigned long iPoint; - unsigned short iVar; - nPoint = geometry->GetnPoint(); /*--- Define geometry constants in the solver structure ---*/ @@ -5493,49 +5496,27 @@ CBaselineSolver::CBaselineSolver(CGeometry *geometry, CConfig *config) { /*--- Initialize a zero solution and instantiate the CVariable class. ---*/ Solution = new su2double[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = 0.0; - } + for (unsigned short iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 0.0; - node = new CVariable*[geometry->GetnPoint()]; - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - node[iPoint] = new CBaselineVariable(Solution, nVar, config); - } + nodes = new CBaselineVariable(nPoint, nVar, config); + SetBaseClassPointerToNodes(); dynamic_grid = config->GetDynamic_Grid(); - } CBaselineSolver::CBaselineSolver(CGeometry *geometry, CConfig *config, unsigned short val_nvar, vector field_names) { - unsigned long iPoint; - unsigned short iVar; - - nVar = val_nvar; - - nPoint = geometry->GetnPoint(); - - fields = field_names; - - Solution = new su2double[nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = 0.0; - } - /*--- Define geometry constants in the solver structure ---*/ + nPoint = geometry->GetnPoint(); nDim = geometry->GetnDim(); + nVar = val_nvar; + fields = field_names; /*--- Allocate the node variables ---*/ - node = new CVariable*[geometry->GetnPoint()]; - - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - - node[iPoint] = new CBaselineVariable(Solution, nVar, config); - - } + nodes = new CBaselineVariable(nPoint, nVar, config); + SetBaseClassPointerToNodes(); dynamic_grid = config->GetDynamic_Grid(); @@ -5880,7 +5861,7 @@ void CBaselineSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConf index = counter*Restart_Vars[1]; for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); /*--- For dynamic meshes, read in and store the grid coordinates and grid velocities for each node. ---*/ @@ -6009,7 +5990,7 @@ void CBaselineSolver::LoadRestart_FSI(CGeometry *geometry, CConfig *config, int index = counter*Restart_Vars[1]; for (iVar = 0; iVar < nVar_Local; iVar++) Solution[iVar] = Restart_Data[index+iVar]; - node[iPoint_Local]->SetSolution(Solution); + nodes->SetSolution(iPoint_Local,Solution); /*--- Increment the overall counter for how many points have been loaded. ---*/ @@ -6023,7 +6004,9 @@ void CBaselineSolver::LoadRestart_FSI(CGeometry *geometry, CConfig *config, int } -CBaselineSolver::~CBaselineSolver(void) { } +CBaselineSolver::~CBaselineSolver(void) { + if (nodes != nullptr) delete nodes; +} CBaselineSolver_FEM::CBaselineSolver_FEM(void) : CSolver() { } diff --git a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp index c9a66616f636..9bc6bd107216 100644 --- a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp @@ -37,7 +37,6 @@ #include "../../include/solvers/CDiscAdjMeshSolver.hpp" -#include "../../include/variables/CDiscAdjMeshVariable.hpp" #include "../../include/variables/CDiscAdjMeshBoundVariable.hpp" CDiscAdjMeshSolver::CDiscAdjMeshSolver(void) : CSolver (){ @@ -56,10 +55,7 @@ CDiscAdjMeshSolver::CDiscAdjMeshSolver(CGeometry *geometry, CConfig *config) : CDiscAdjMeshSolver::CDiscAdjMeshSolver(CGeometry *geometry, CConfig *config, CSolver *direct_solver) : CSolver(){ - unsigned short iVar, iMarker, iDim; - unsigned long iPoint; - long iVertex; - bool isVertex; + unsigned short iVar, iDim; nVar = geometry->GetnDim(); nDim = geometry->GetnDim(); @@ -108,32 +104,29 @@ CDiscAdjMeshSolver::CDiscAdjMeshSolver(CGeometry *geometry, CConfig *config, CSo for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = 1e-16; /*--- Initialize the node structure ---*/ - node = new CVariable*[nPoint]; - for (iPoint = 0; iPoint < nPoint; iPoint++){ - - /*--- In principle, the node is not at the boundary ---*/ - isVertex = false; - /*--- Looping over all markers ---*/ - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - - /*--- If the marker is flagged as moving, retrieve the node vertex ---*/ - if (config->GetMarker_All_Deform_Mesh(iMarker) == YES) iVertex = geometry->node[iPoint]->GetVertex(iMarker); - else iVertex = -1; - - if (iVertex != -1){isVertex = true; break;} + nodes = new CDiscAdjMeshBoundVariable(nPoint,nDim,config); + SetBaseClassPointerToNodes(); + + /*--- Set which points are vertices and allocate boundary data. ---*/ + + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { + + nodes->SetSolution(iPoint,Solution); + + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + long iVertex = geometry->node[iPoint]->GetVertex(iMarker); + if (iVertex >= 0) { + nodes->Set_isVertex(iPoint,true); + break; + } } - - /*--- The MeshBound variable includes the displacements at the boundaries ---*/ - if (isVertex) node[iPoint] = new CDiscAdjMeshBoundVariable(Solution, nDim, config); - else node[iPoint] = new CDiscAdjMeshVariable(Solution, nDim, config); - } - + static_cast(nodes)->AllocateBoundaryVariables(config); } CDiscAdjMeshSolver::~CDiscAdjMeshSolver(void){ - + if (nodes != nullptr) delete nodes; } @@ -148,8 +141,8 @@ void CDiscAdjMeshSolver::SetRecording(CGeometry* geometry, CConfig *config){ unsigned long iPoint; /*--- Reset the solution to the initial (converged) solution ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->SetBound_Disp(node[iPoint]->GetBoundDisp_Direct()); + for (iPoint = 0; iPoint < nPoint; iPoint++) { + direct_solver->GetNodes()->SetBound_Disp(iPoint,nodes->GetBoundDisp_Direct(iPoint)); } /*--- Set indices to zero ---*/ @@ -160,29 +153,17 @@ void CDiscAdjMeshSolver::SetRecording(CGeometry* geometry, CConfig *config){ void CDiscAdjMeshSolver::RegisterSolution(CGeometry *geometry, CConfig *config){ - unsigned long iPoint, nPoint = geometry->GetnPoint(); - bool input = true; - /*--- Register reference mesh coordinates ---*/ - - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->Register_MeshCoord(input); - } + bool input = true; + direct_solver->GetNodes()->Register_MeshCoord(input); } void CDiscAdjMeshSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset){ /*--- Register boundary displacements as input ---*/ - - unsigned long iPoint, nPoint = geometry->GetnPoint(); bool input = true; - - /*--- Register reference mesh coordinates ---*/ - - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->node[iPoint]->Register_BoundDisp(input); - } + direct_solver->GetNodes()->Register_BoundDisp(input); } @@ -196,11 +177,11 @@ void CDiscAdjMeshSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *c /*--- Extract the adjoint solution from the original mesh coordinates ---*/ - direct_solver->node[iPoint]->GetAdjoint_MeshCoord(Solution); + direct_solver->GetNodes()->GetAdjoint_MeshCoord(iPoint,Solution); /*--- Store the adjoint solution (the container is reused) ---*/ - node[iPoint]->SetSolution(Solution); + nodes->SetSolution(iPoint,Solution); } @@ -216,11 +197,11 @@ void CDiscAdjMeshSolver::ExtractAdjoint_Variables(CGeometry *geometry, CConfig * /*--- Extract the adjoint solution of the boundary displacements ---*/ - direct_solver->node[iPoint]->GetAdjoint_BoundDisp(Solution); + direct_solver->GetNodes()->GetAdjoint_BoundDisp(iPoint,Solution); /*--- Store the sensitivities of the boundary displacements ---*/ - node[iPoint]->SetBoundDisp_Sens(Solution); + nodes->SetBoundDisp_Sens(iPoint,Solution); } @@ -245,7 +226,7 @@ void CDiscAdjMeshSolver::SetSensitivity(CGeometry *geometry, CSolver **solver, C for (iDim = 0; iDim < nDim; iDim++) { /*--- The sensitivity was extracted using ExtractAdjoint_Solution ---*/ - Sensitivity = node[iPoint]->GetSolution(iDim); + Sensitivity = nodes->GetSolution(iPoint,iDim); /*--- If sharp edge, set the sensitivity to 0 on that region ---*/ if (config->GetSens_Remove_Sharp()) { @@ -256,9 +237,10 @@ void CDiscAdjMeshSolver::SetSensitivity(CGeometry *geometry, CSolver **solver, C /*--- Store the sensitivities ---*/ if (!time_stepping) { - solver[ADJFLOW_SOL]->node[iPoint]->SetSensitivity(iDim, Sensitivity); + solver[ADJFLOW_SOL]->GetNodes()->SetSensitivity(iPoint, iDim, Sensitivity); } else { - solver[ADJFLOW_SOL]->node[iPoint]->SetSensitivity(iDim, solver[ADJFLOW_SOL]->node[iPoint]->GetSensitivity(iDim) + Sensitivity); + solver[ADJFLOW_SOL]->GetNodes()->SetSensitivity(iPoint, iDim, + solver[ADJFLOW_SOL]->GetNodes()->GetSensitivity(iPoint, iDim) + Sensitivity); } } } @@ -268,6 +250,8 @@ void CDiscAdjMeshSolver::SetSensitivity(CGeometry *geometry, CSolver **solver, C void CDiscAdjMeshSolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig *config){ + // ToDo: Can this be made generic to use the CSolver impl + unsigned short iVar; unsigned long iPoint; su2double residual; @@ -275,19 +259,19 @@ void CDiscAdjMeshSolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig /*--- Set Residuals to zero ---*/ for (iVar = 0; iVar < nVar; iVar++){ - SetRes_BGS(iVar,0.0); - SetRes_Max_BGS(iVar,0.0,0); + SetRes_BGS(iVar,0.0); + SetRes_Max_BGS(iVar,0.0,0); } /*--- Set the residuals ---*/ for (iPoint = 0; iPoint < nPointDomain; iPoint++){ /*--- Only for the boundary vertices ---*/ - if (node[iPoint]->Get_isVertex()){ + if (nodes->Get_isVertex(iPoint)){ for (iVar = 0; iVar < nVar; iVar++){ - /*--- Compute only for the sensitivities of the boundary displacements ---*/ - residual = node[iPoint]->GetBoundDisp_Sens(iVar) - node[iPoint]->Get_BGSSolution_k(iVar); - AddRes_BGS(iVar,residual*residual); - AddRes_Max_BGS(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); + /*--- Compute only for the sensitivities of the boundary displacements ---*/ + residual = nodes->GetBoundDisp_Sens(iPoint,iVar) - nodes->Get_BGSSolution_k(iPoint,iVar); + AddRes_BGS(iVar,residual*residual); + AddRes_Max_BGS(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); } } } @@ -296,19 +280,6 @@ void CDiscAdjMeshSolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig } - -void CDiscAdjMeshSolver::UpdateSolution_BGS(CGeometry *geometry, CConfig *config){ - - unsigned long iPoint; - - /*--- To nPoint: The solution must be communicated beforehand ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - if (node[iPoint]->Get_isVertex()) node[iPoint]->Set_BGSSolution_k(); - } - -} - - void CDiscAdjMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo) { } diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 628f63f1a7b4..a68d8224bc41 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -37,7 +37,6 @@ #include "../../../Common/include/adt_structure.hpp" #include "../../include/solvers/CMeshSolver.hpp" -#include "../../include/variables/CMeshVariable.hpp" #include "../../include/variables/CMeshBoundVariable.hpp" #include "../../include/variables/CMeshElement.hpp" @@ -78,33 +77,28 @@ CMeshSolver::CMeshSolver(CGeometry *geometry, CConfig *config) : CFEASolver(true MaxVolume_Curr = 0.0; /*--- Initialize the node structure ---*/ - bool isVertex; - long iVertex; - Coordinate = new su2double[nDim]; - node = new CVariable*[nPoint]; - for (iPoint = 0; iPoint < nPoint; iPoint++){ - /*--- We store directly the reference coordinates ---*/ - for (iDim = 0; iDim < nDim; iDim++) - Coordinate[iDim] = geometry->node[iPoint]->GetCoord(iDim); + Coordinate = new su2double[nDim]; + nodes = new CMeshBoundVariable(nPoint, nDim, config); + SetBaseClassPointerToNodes(); + + /*--- Set which points are vertices and allocate boundary data. ---*/ - /*--- In principle, the node is not at the boundary ---*/ - isVertex = false; - /*--- Looping over all markers ---*/ - for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + for (iPoint = 0; iPoint < nPoint; iPoint++) { - /*--- If the marker is flagged as deforming, retrieve the node vertex ---*/ - if (config->GetMarker_All_Deform_Mesh(iMarker) == YES) iVertex = geometry->node[iPoint]->GetVertex(iMarker); - else iVertex = -1; + for (iDim = 0; iDim < nDim; ++iDim) + nodes->SetMesh_Coord(iPoint, iDim, geometry->node[iPoint]->GetCoord(iDim)); - if (iVertex != -1){isVertex = true; break;} + for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + long iVertex = geometry->node[iPoint]->GetVertex(iMarker); + if (iVertex >= 0) { + nodes->Set_isVertex(iPoint,true); + break; + } } - - /*--- Temporarily, keep everything the same ---*/ - if (isVertex) node[iPoint] = new CMeshBoundVariable(Coordinate, nDim, config); - else node[iPoint] = new CMeshVariable(Coordinate, nDim, config); - } + static_cast(nodes)->AllocateBoundaryVariables(config); + /*--- Initialize the element structure ---*/ element = new CMeshElement[nElement]; @@ -244,9 +238,9 @@ void CMeshSolver::SetMinMaxVolume(CGeometry *geometry, CConfig *config, bool upd /*--- Compute the volume with the reference or with the current coordinates ---*/ for (iDim = 0; iDim < nDim; iDim++) { - if (updated) val_Coord = node[indexNode[iNode]]->GetMesh_Coord(iDim) - + node[indexNode[iNode]]->GetSolution(iDim); - else val_Coord = node[indexNode[iNode]]->GetMesh_Coord(iDim); + if (updated) val_Coord = nodes->GetMesh_Coord(indexNode[iNode],iDim) + + nodes->GetSolution(indexNode[iNode],iDim); + else val_Coord = nodes->GetMesh_Coord(indexNode[iNode],iDim); element_container[FEA_TERM][EL_KIND]->SetRef_Coord(val_Coord, iNode, iDim); } } @@ -347,7 +341,7 @@ void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) { iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); PointIDs[jj++] = iPoint; for (iDim=0; iDimGetMesh_Coord(iDim); + Coord_bound[ii++] = nodes->GetMesh_Coord(iPoint,iDim); } } } @@ -378,9 +372,9 @@ void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) { for(iPoint=0; iPoint< nPoint; ++iPoint) { - WallADT.DetermineNearestNode(node[iPoint]->GetMesh_Coord(), dist, + WallADT.DetermineNearestNode(nodes->GetMesh_Coord(iPoint), dist, pointID, rankID); - node[iPoint]->SetWallDistance(dist); + nodes->SetWallDistance(iPoint,dist); MaxDistance = max(MaxDistance, dist); @@ -405,8 +399,8 @@ void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) { /*--- Normalize distance from 0 to 1 ---*/ for (iPoint=0; iPoint < nPoint; ++iPoint) { - nodeDist = node[iPoint]->GetWallDistance()/MaxDistance; - node[iPoint]->SetWallDistance(nodeDist); + nodeDist = nodes->GetWallDistance(iPoint)/MaxDistance; + nodes->SetWallDistance(iPoint,nodeDist); } /*--- Compute the element distances ---*/ @@ -428,7 +422,7 @@ void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) { ElemDist = 0.0; for (iNodes = 0; iNodes < nNodes; iNodes++){ - ElemDist += node[PointCorners[iNodes]]->GetWallDistance(); + ElemDist += nodes->GetWallDistance(PointCorners[iNodes]); } ElemDist = ElemDist/(su2double)nNodes; @@ -464,7 +458,7 @@ void CMeshSolver::SetMesh_Stiffness(CGeometry **geometry, CNumerics **numerics, void CMeshSolver::DeformMesh(CGeometry **geometry, CNumerics **numerics, CConfig *config){ - if (multizone) SetSolution_Old(); + if (multizone) nodes->Set_BGSSolution_k(); /*--- Initialize sparse matrix ---*/ Jacobian.SetValZero(); @@ -530,9 +524,9 @@ void CMeshSolver::UpdateGridCoord(CGeometry *geometry, CConfig *config){ /*--- Retrieve the displacement from the solution of the linear system ---*/ val_disp = LinSysSol[total_index]; /*--- Store the displacement of the mesh node ---*/ - node[iPoint]->SetSolution(iDim, val_disp); + nodes->SetSolution(iPoint, iDim, val_disp); /*--- Compute the current coordinate as Mesh_Coord + Displacement ---*/ - val_coord = node[iPoint]->GetMesh_Coord(iDim) + val_disp; + val_coord = nodes->GetMesh_Coord(iPoint,iDim) + val_disp; /*--- Update the geometry container ---*/ geometry->node[iPoint]->SetCoord(iDim, val_coord); } @@ -578,9 +572,9 @@ void CMeshSolver::ComputeGridVelocity(CGeometry *geometry, CConfig *config){ /*--- Coordinates of the current point at n+1, n, & n-1 time levels ---*/ - Disp_nM1 = node[iPoint]->GetSolution_time_n1(); - Disp_n = node[iPoint]->GetSolution_time_n(); - Disp_nP1 = node[iPoint]->GetSolution(); + Disp_nM1 = nodes->GetSolution_time_n1(iPoint); + Disp_n = nodes->GetSolution_time_n(iPoint); + Disp_nP1 = nodes->GetSolution(iPoint); /*--- Unsteady time step ---*/ @@ -671,39 +665,8 @@ void CMeshSolver::SetBoundaryDisplacements(CGeometry *geometry, CNumerics *numer void CMeshSolver::SetDualTime_Mesh(void){ - unsigned long iPoint; - - for (iPoint = 0; iPoint < nPoint; iPoint++) { - node[iPoint]->Set_Solution_time_n1(); - node[iPoint]->Set_Solution_time_n(); - } - -} - -void CMeshSolver::ComputeResidual_Multizone(CGeometry *geometry, CConfig *config){ - - unsigned short iVar; - unsigned long iPoint; - su2double residual; - - /*--- Set Residuals to zero ---*/ - - for (iVar = 0; iVar < nVar; iVar++){ - SetRes_BGS(iVar,0.0); - SetRes_Max_BGS(iVar,0.0,0); - } - - /*--- Set the residuals ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ - residual = node[iPoint]->GetSolution(iVar) - node[iPoint]->GetSolution_Old(iVar); - AddRes_BGS(iVar,residual*residual); - AddRes_Max_BGS(iVar,fabs(residual),geometry->node[iPoint]->GetGlobalIndex(),geometry->node[iPoint]->GetCoord()); - } - } - - SetResidual_BGS(geometry, config); - + nodes->Set_Solution_time_n1(); + nodes->Set_Solution_time_n(); } void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo) { @@ -755,8 +718,8 @@ void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * geometry[MESH_0]->node[iPoint_Local]->SetCoord(iDim, curr_coord); /*--- Store the displacements computed as the current coordinates minus the coordinates of the reference mesh file ---*/ - displ = curr_coord - node[iPoint_Local]->GetMesh_Coord(iDim); - node[iPoint_Local]->SetSolution(iDim, displ); + displ = curr_coord - nodes->GetMesh_Coord(iPoint_Local, iDim); + nodes->SetSolution(iPoint_Local, iDim, displ); } iPoint_Global_Local++; @@ -823,10 +786,10 @@ void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * /*--- Store it into the current displacement. ---*/ for (iDim = 0; iDim < nDim; iDim++){ - VarCoord[iDim] = node[iNode]->GetSolution(iDim); + VarCoord[iDim] = nodes->GetSolution(iNode,iDim); } - node[iNode]->SetBound_Disp(VarCoord); + nodes->SetBound_Disp(iNode,VarCoord); } @@ -902,8 +865,8 @@ void CMeshSolver::Restart_OldGeometry(CGeometry *geometry, CConfig *config) { index = counter*Restart_Vars[1]; for (iDim = 0; iDim < nDim; iDim++){ curr_coord = Restart_Data[index+iDim]; - displ = curr_coord - node[iPoint_Local]->GetMesh_Coord(iDim); - node[iPoint_Local]->Set_Solution_time_n(iDim, displ); + displ = curr_coord - nodes->GetMesh_Coord(iPoint_Local,iDim); + nodes->Set_Solution_time_n(iPoint_Local, iDim, displ); } iPoint_Global_Local++; @@ -978,8 +941,8 @@ void CMeshSolver::Restart_OldGeometry(CGeometry *geometry, CConfig *config) { index = counter*Restart_Vars[1]; for (iDim = 0; iDim < nDim; iDim++){ curr_coord = Restart_Data[index+iDim]; - displ = curr_coord - node[iPoint_Local]->GetMesh_Coord(iDim); - node[iPoint_Local]->Set_Solution_time_n1(iDim, displ); + displ = curr_coord - nodes->GetMesh_Coord(iPoint_Local, iDim); + nodes->Set_Solution_time_n1(iPoint_Local, iDim, displ); } iPoint_Global_Local++; diff --git a/SU2_CFD/src/variables/CAdjEulerVariable.cpp b/SU2_CFD/src/variables/CAdjEulerVariable.cpp index 1f5113416914..f44e7668d730 100644 --- a/SU2_CFD/src/variables/CAdjEulerVariable.cpp +++ b/SU2_CFD/src/variables/CAdjEulerVariable.cpp @@ -37,247 +37,90 @@ #include "../../include/variables/CAdjEulerVariable.hpp" -CAdjEulerVariable::CAdjEulerVariable(void) : CVariable() { +CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2double psie, unsigned long npoint, unsigned long ndim, + unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { - /*--- Array initialization ---*/ - Psi = NULL; - ForceProj_Vector = NULL; - ObjFuncSource = NULL; - IntBoundary_Jump = NULL; - HB_Source = NULL; - GradReconAllocated = false; - -} - -CAdjEulerVariable::CAdjEulerVariable(su2double val_psirho, su2double *val_phi, su2double val_psie, - unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : - CVariable(val_nDim, val_nvar, config) { - - unsigned short iVar, iDim, iMesh, nMGSmooth = 0; - - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - - /*--- Array initialization ---*/ - Psi = NULL; - ForceProj_Vector = NULL; - ObjFuncSource = NULL; - IntBoundary_Jump = NULL; - HB_Source = NULL; - GradReconAllocated = false; + bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND); /*--- Allocate residual structures ---*/ - Res_TruncError = new su2double [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Res_TruncError[iVar] = 0.0; - } + Res_TruncError.resize(nPoint,nVar) = su2double(0.0); /*--- Only for residual smoothing (multigrid) ---*/ - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) - nMGSmooth += config->GetMG_CorrecSmooth(iMesh); - - if (nMGSmooth > 0) { - Residual_Sum = new su2double [nVar]; - Residual_Old = new su2double [nVar]; - } - - /*--- Allocate undivided laplacian (centered) and limiter (upwind)---*/ - if (config->GetKind_ConvNumScheme_AdjFlow() == SPACE_CENTERED) - Undivided_Laplacian = new su2double [nVar]; - - /*--- Always allocate the slope limiter, - and the auxiliar variables (check the logic - JST with 2nd order Turb model - ) ---*/ - Limiter = new su2double [nVar]; - Solution_Max = new su2double [nVar]; - Solution_Min = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Limiter[iVar] = 0.0; - Solution_Max[iVar] = 0.0; - Solution_Min[iVar] = 0.0; - } - - /*--- Allocate and initialize solution ---*/ - Solution[0] = val_psirho; Solution_Old[0] = val_psirho; - Solution[nVar-1] = val_psie; Solution_Old[nVar-1] = val_psie; - for (iDim = 0; iDim < nDim; iDim++) { - Solution[iDim+1] = val_phi[iDim]; - Solution_Old[iDim+1] = val_phi[iDim]; - } - - /*--- Allocate and initialize solution for dual time strategy ---*/ - if (dual_time) { - Solution_time_n[0] = val_psirho; - Solution_time_n1[0] = val_psirho; - for (iDim = 0; iDim < nDim; iDim++) { - Solution_time_n[iDim+1] = val_phi[iDim]; - Solution_time_n1[iDim+1] = val_phi[iDim]; + for (unsigned long iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + if (config->GetMG_CorrecSmooth(iMesh) > 0) { + Residual_Sum.resize(nPoint,nVar); + Residual_Old.resize(nPoint,nVar); + break; } - Solution_time_n[nVar-1] = val_psie; - Solution_time_n1[nVar-1] = val_psie; - - - } - - if (config->GetReconstructionGradientRequired()) { - GradReconAllocated = true; - Gradient_Reconstruction = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Gradient_Reconstruction[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; - } - } else { - Gradient_Reconstruction = Gradient; - } - - /*--- Allocate auxiliar vector for sensitivity computation ---*/ - Grad_AuxVar = new su2double [nDim]; - - /*--- Allocate and initialize projection vector for wall boundary condition ---*/ - ForceProj_Vector = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - ForceProj_Vector[iDim] = 0.0; - - /*--- Allocate and initialize interior boundary jump vector for near field boundary condition ---*/ - IntBoundary_Jump = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - IntBoundary_Jump[iVar] = 0.0; - - /*--- Allocate space for the harmonic balance source terms ---*/ - if (config->GetTime_Marching() == HARMONIC_BALANCE) { - HB_Source = new su2double[nVar]; - for (iVar = 0; iVar < nVar; iVar++) - HB_Source[iVar] = 0.0; } - if (config->GetMultizone_Problem()) - Set_BGSSolution_k(); -} - -CAdjEulerVariable::CAdjEulerVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CVariable(val_nDim, val_nvar, config) { + Gradient.resize(nPoint,nVar,nDim,0.0); - unsigned short iVar, iDim, iMesh, nMGSmooth = 0; - - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - - /*--- Array initialization ---*/ - Psi = NULL; - ForceProj_Vector = NULL; - ObjFuncSource = NULL; - IntBoundary_Jump = NULL; - HB_Source = NULL; - GradReconAllocated = false; - - /*--- Allocate residual structures ---*/ - Res_TruncError = new su2double [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Res_TruncError[iVar] = 0.0; + if (config->GetReconstructionGradientRequired()) { + Gradient_Reconstruction.resize(nPoint,nVar,nDim,0.0); + } else { + Gradient_Reconstruction = Gradient; } - - /*--- Only for residual smoothing (multigrid) ---*/ - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) - nMGSmooth += config->GetMG_CorrecSmooth(iMesh); - - if (nMGSmooth > 0) { - Residual_Sum = new su2double [nVar]; - Residual_Old = new su2double [nVar]; + + if (config->GetLeastSquaresRequired()) { + Rmatrix.resize(nPoint,nDim,nDim,0.0); } /*--- Allocate undivided laplacian (centered) and limiter (upwind)---*/ if (config->GetKind_ConvNumScheme_AdjFlow() == SPACE_CENTERED) - Undivided_Laplacian = new su2double [nVar]; + Undivided_Laplacian.resize(nPoint,nVar); /*--- Always allocate the slope limiter, and the auxiliar variables (check the logic - JST with 2nd order Turb model - ) ---*/ - Limiter = new su2double [nVar]; - Solution_Max = new su2double [nVar]; - Solution_Min = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Limiter[iVar] = 0.0; - Solution_Max[iVar] = 0.0; - Solution_Min[iVar] = 0.0; - } + Limiter.resize(nPoint,nVar) = su2double(0.0); + Solution_Max.resize(nPoint,nVar) = su2double(0.0); + Solution_Min.resize(nPoint,nVar) = su2double(0.0); /*--- Solution initialization ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = val_solution[iVar]; - Solution_Old[iVar] = val_solution[iVar]; - } + su2double val_solution[5] = {psirho, phi[0], phi[1], psie, psie}; + if(nDim==3) val_solution[3] = phi[2]; - /*--- Allocate and initializate solution for dual time strategy ---*/ - if (dual_time) { - Solution_time_n = new su2double [nVar]; - Solution_time_n1 = new su2double [nVar]; + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution(iPoint,iVar) = val_solution[iVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Solution_time_n[iVar] = val_solution[iVar]; - Solution_time_n1[iVar] = val_solution[iVar]; - } - } + Solution_Old = Solution; - if (config->GetReconstructionGradientRequired()) { - GradReconAllocated = true; - Gradient_Reconstruction = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Gradient_Reconstruction[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; - } - } else { - Gradient_Reconstruction = Gradient; + /*--- Allocate and initializate solution for dual time strategy ---*/ + if (dual_time) { + Solution_time_n = Solution; + Solution_time_n1 = Solution; } /*--- Allocate auxiliar vector for sensitivity computation ---*/ - Grad_AuxVar = new su2double [nDim]; + AuxVar.resize(nPoint); + Grad_AuxVar.resize(nPoint,nDim); /*--- Allocate and initializate projection vector for wall boundary condition ---*/ - ForceProj_Vector = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - ForceProj_Vector[iDim] = 0.0; + ForceProj_Vector.resize(nPoint,nDim) = su2double(0.0); /*--- Allocate and initializate interior boundary jump vector for near field boundary condition ---*/ - IntBoundary_Jump = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - IntBoundary_Jump[iVar] = 0.0; + IntBoundary_Jump.resize(nPoint,nVar) = su2double(0.0); /*--- Allocate space for the harmonic balance source terms ---*/ - if (config->GetTime_Marching() == HARMONIC_BALANCE) { - HB_Source = new su2double[nVar]; - for (iVar = 0; iVar < nVar; iVar++) - HB_Source[iVar] = 0.0; - } - + if (config->GetTime_Marching() == HARMONIC_BALANCE) + HB_Source.resize(nPoint,nVar) = su2double(0.0); + if (config->GetMultizone_Problem()) Set_BGSSolution_k(); -} - -CAdjEulerVariable::~CAdjEulerVariable(void) { - if (Psi != NULL) delete [] Psi; - if (ForceProj_Vector != NULL) delete [] ForceProj_Vector; - if (ObjFuncSource != NULL) delete [] ObjFuncSource; - if (IntBoundary_Jump != NULL) delete [] IntBoundary_Jump; - if (HB_Source != NULL) delete [] HB_Source; - - if (GradReconAllocated) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - if (Gradient_Reconstruction!=NULL) delete [] Gradient_Reconstruction[iVar]; - delete [] Gradient_Reconstruction; - } + Sensor.resize(nPoint); } -bool CAdjEulerVariable::SetPrimVar(su2double SharpEdge_Distance, bool check, CConfig *config) { - unsigned short iVar; - bool check_dens = false, RightVol = true; +bool CAdjEulerVariable::SetPrimVar(unsigned long iPoint, su2double SharpEdge_Distance, bool check, CConfig *config) { + + bool RightVol = true; su2double adj_limit = config->GetAdjointLimit(); - check_dens = (fabs(Solution[0]) > adj_limit); + bool check_dens = (fabs(Solution(iPoint,0)) > adj_limit); /*--- Check that the adjoint solution is bounded ---*/ @@ -285,13 +128,12 @@ bool CAdjEulerVariable::SetPrimVar(su2double SharpEdge_Distance, bool check, CCo /*--- Copy the old solution ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = Solution_Old[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution(iPoint,iVar) = Solution_Old(iPoint,iVar); RightVol = false; } return RightVol; - } diff --git a/SU2_CFD/src/variables/CAdjNSVariable.cpp b/SU2_CFD/src/variables/CAdjNSVariable.cpp index b83accf92a18..55334cd1fd3b 100644 --- a/SU2_CFD/src/variables/CAdjNSVariable.cpp +++ b/SU2_CFD/src/variables/CAdjNSVariable.cpp @@ -38,15 +38,5 @@ #include "../../include/variables/CAdjNSVariable.hpp" -CAdjNSVariable::CAdjNSVariable(void) : CAdjEulerVariable() { } - -CAdjNSVariable::CAdjNSVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CAdjEulerVariable(val_solution, val_nDim, val_nvar, config) { -} - -CAdjNSVariable::CAdjNSVariable(su2double val_psirho, su2double *val_phi, su2double val_psie, - unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : - CAdjEulerVariable(val_psirho, val_phi, val_psie, val_nDim, val_nvar, config) { -} - -CAdjNSVariable::~CAdjNSVariable(void) { } +CAdjNSVariable::CAdjNSVariable(su2double psirho, const su2double *phi, su2double psie, unsigned long npoint, unsigned long ndim, unsigned long nvar, + CConfig *config) : CAdjEulerVariable(psirho, phi, psie, npoint, ndim, nvar, config) { } diff --git a/SU2_CFD/src/variables/CAdjTurbVariable.cpp b/SU2_CFD/src/variables/CAdjTurbVariable.cpp index eb7a671f35dc..d96117c6be64 100644 --- a/SU2_CFD/src/variables/CAdjTurbVariable.cpp +++ b/SU2_CFD/src/variables/CAdjTurbVariable.cpp @@ -37,51 +37,30 @@ #include "../../include/variables/CAdjTurbVariable.hpp" -CAdjTurbVariable::CAdjTurbVariable(void) : CVariable() { - /*--- Array initialization ---*/ +CAdjTurbVariable::CAdjTurbVariable(su2double psinu_inf, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) + : CVariable(npoint, ndim, nvar, config) { - dmuT_dUTvar = NULL; - dRTstar_dUTvar = NULL; - dFT_dUTvar = NULL; - EddyViscSens = NULL; + /*--- Initialization of variables ---*/ -} + Solution = psinu_inf; + Solution_Old = psinu_inf; -CAdjTurbVariable::CAdjTurbVariable(su2double val_psinu_inf, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CVariable(val_nDim, val_nvar, config) { - unsigned short iVar; + Residual_Old.resize(nPoint,nVar); - /*--- Array initialization ---*/ + /*--- Gradient related fields. ---*/ - dmuT_dUTvar = NULL; - dRTstar_dUTvar = NULL; - dFT_dUTvar = NULL; - EddyViscSens = NULL; + Gradient.resize(nPoint,nVar,nDim,0.0); - /*--- Initialization of variables ---*/ - - for (unsigned short iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = val_psinu_inf; - Solution_Old[iVar] = val_psinu_inf; + if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) { + Rmatrix.resize(nPoint,nDim,nDim,0.0); } - Residual_Old = new su2double [nVar]; - /*--- Always allocate the slope limiter, and the auxiliar variables (check the logic - JST with 2nd order Turb model - ) ---*/ - Limiter = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Limiter[iVar] = 0.0; - + Limiter.resize(nPoint,nVar) = su2double(0.0); + if (config->GetMultizone_Problem()) Set_BGSSolution_k(); } - -CAdjTurbVariable::~CAdjTurbVariable(void) { - - if (dmuT_dUTvar != NULL) delete [] dmuT_dUTvar; - if (EddyViscSens != NULL) delete [] EddyViscSens; - -} diff --git a/SU2_CFD/src/variables/CBaselineVariable.cpp b/SU2_CFD/src/variables/CBaselineVariable.cpp index 31aaf5c47eaf..3f41c7b01ef4 100644 --- a/SU2_CFD/src/variables/CBaselineVariable.cpp +++ b/SU2_CFD/src/variables/CBaselineVariable.cpp @@ -37,14 +37,8 @@ #include "../../include/variables/CBaselineVariable.hpp" -CBaselineVariable::CBaselineVariable(void) : CVariable() { } -CBaselineVariable::CBaselineVariable(su2double *val_solution, unsigned short val_nvar, CConfig *config) : CVariable(val_nvar, config) { - - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = val_solution[iVar]; +CBaselineVariable::CBaselineVariable(unsigned long npoint, unsigned long nvar, CConfig *config) + : CVariable(npoint,nvar,config) { } - -CBaselineVariable::~CBaselineVariable(void) { } - diff --git a/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp index 8a7d62fedfe9..5082cf94b1c5 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp @@ -37,30 +37,24 @@ #include "../../include/variables/CDiscAdjFEABoundVariable.hpp" -CDiscAdjFEABoundVariable::CDiscAdjFEABoundVariable() : CDiscAdjFEAVariable(){ - - FlowTraction_Sens = NULL; - SourceTerm_DispAdjoint = NULL; +CDiscAdjFEABoundVariable::CDiscAdjFEABoundVariable(const su2double *disp, const su2double *vel, + const su2double *accel, unsigned long npoint, unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config) : + CDiscAdjFEAVariable(disp, vel, accel, npoint, ndim, nvar, unsteady, config) { + VertexMap.Reset(nPoint); } -CDiscAdjFEABoundVariable::CDiscAdjFEABoundVariable(su2double* val_solution, unsigned short val_ndim, - unsigned short val_nvar, CConfig *config) : CDiscAdjFEAVariable(val_solution, val_ndim, val_nvar, config){ +void CDiscAdjFEABoundVariable::AllocateBoundaryVariables(CConfig *config) { + if (VertexMap.GetIsValid()) return; // nothing to do - unsigned short iDim; - FlowTraction_Sens = new su2double[nDim]; - SourceTerm_DispAdjoint = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++){ - FlowTraction_Sens[iDim] = val_solution[iDim]; - SourceTerm_DispAdjoint[iDim] = 0.0; - } + /*--- Count number of vertices and build map ---*/ -} + unsigned long nBoundPt = VertexMap.Build(); -CDiscAdjFEABoundVariable::~CDiscAdjFEABoundVariable(){ + /*--- Allocate ---*/ - if (FlowTraction_Sens != NULL) delete [] FlowTraction_Sens; - if (SourceTerm_DispAdjoint != NULL) delete [] SourceTerm_DispAdjoint; + FlowTraction_Sens.resize(nBoundPt,nDim) = su2double(0.0); + SourceTerm_DispAdjoint.resize(nBoundPt,nDim) = su2double(0.0); } diff --git a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp index bc10bc8fa15a..94b5b3c1d608 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp @@ -37,208 +37,62 @@ #include "../../include/variables/CDiscAdjFEAVariable.hpp" -CDiscAdjFEAVariable::CDiscAdjFEAVariable() : CVariable(){ - Sensitivity = NULL; - Solution_Direct = NULL; - - Dynamic_Derivative = NULL; - Dynamic_Derivative_n = NULL; - Dynamic_Derivative_Vel = NULL; - Dynamic_Derivative_Vel_n = NULL; - Dynamic_Derivative_Accel = NULL; - Dynamic_Derivative_Accel_n = NULL; - - Solution_Direct_Vel = NULL; - Solution_Direct_Accel = NULL; - - Solution_Vel = NULL; - Solution_Accel = NULL; - - Solution_Old_Vel = NULL; - Solution_Old_Accel = NULL; - - Solution_Vel_time_n = NULL; - Solution_Accel_time_n = NULL; - - Cross_Term_Derivative = NULL; - Geometry_CrossTerm_Derivative = NULL; - - Solution_BGS = NULL; - -} - -CDiscAdjFEAVariable::CDiscAdjFEAVariable(su2double* val_solution, unsigned short val_ndim, unsigned short val_nvar, - CConfig *config) : CVariable(val_ndim, val_nvar, config){ +CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double *vel, const su2double *accel, unsigned long npoint, + unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config) : CVariable(npoint, ndim, nvar, config) { bool fsi = config->GetFSI_Simulation(); - Dynamic_Derivative = NULL; - Dynamic_Derivative_n = NULL; - Dynamic_Derivative_Vel = NULL; - Dynamic_Derivative_Vel_n = NULL; - Dynamic_Derivative_Accel = NULL; - Dynamic_Derivative_Accel_n = NULL; - - Solution_Direct_Vel = NULL; - Solution_Direct_Accel = NULL; - - Solution_Vel = NULL; - Solution_Accel = NULL; - - Solution_Old_Vel = NULL; - Solution_Old_Accel = NULL; + Solution_Direct.resize(nPoint,nVar); - Solution_Vel_time_n = NULL; - Solution_Accel_time_n = NULL; + Sensitivity.resize(nPoint,nDim) = su2double(0.0); - Solution_Direct = new su2double[nVar]; + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution(iPoint,iVar) = disp[iVar]; - Sensitivity = new su2double[nDim]; - - unsigned short iVar,iDim; - - for (iDim = 0; iDim < nDim; iDim++){ - Sensitivity[iDim] = 0.0; - } - - for (iVar = 0; iVar < nVar; iVar++){ - Solution[iVar] = val_solution[iVar]; - } - - Solution_BGS = NULL; - Cross_Term_Derivative = NULL; - Geometry_CrossTerm_Derivative = NULL; - if (fsi){ - Cross_Term_Derivative = new su2double[nDim]; - Geometry_CrossTerm_Derivative = new su2double[nDim]; - Solution_BGS = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - Geometry_CrossTerm_Derivative [iDim] = 0.0; - Cross_Term_Derivative[iDim] = 0.0; - Solution_BGS[iDim] = 0.0; - } + if (fsi) { + Cross_Term_Derivative.resize(nPoint,nDim) = su2double(0.0); + Geometry_CrossTerm_Derivative.resize(nPoint,nDim) = su2double(0.0); + + Solution_BGS.resize(nPoint,nDim) = su2double(0.0); } if (config->GetMultizone_Problem()) Set_BGSSolution_k(); - -} - -CDiscAdjFEAVariable::CDiscAdjFEAVariable(su2double* val_solution, su2double* val_solution_accel, su2double* val_solution_vel, - unsigned short val_ndim, unsigned short val_nvar, CConfig *config) : - CVariable(val_ndim, val_nvar, config){ - - bool fsi = config->GetFSI_Simulation(); - - Dynamic_Derivative = new su2double[nVar]; - Dynamic_Derivative_n = new su2double[nVar]; - Dynamic_Derivative_Vel = new su2double[nVar]; - Dynamic_Derivative_Vel_n = new su2double[nVar]; - Dynamic_Derivative_Accel = new su2double[nVar]; - Dynamic_Derivative_Accel_n = new su2double[nVar]; - Solution_Direct_Vel = new su2double[nVar]; - Solution_Direct_Accel = new su2double[nVar]; + /*--- Nothing else to allocate ---*/ + if (!unsteady) return; - Solution_Vel = new su2double[nVar]; - Solution_Accel = new su2double[nVar]; - Solution_Old_Vel = new su2double[nVar]; - Solution_Old_Accel = new su2double[nVar]; + Dynamic_Derivative.resize(nPoint,nVar) = su2double(0.0); + Dynamic_Derivative_n.resize(nPoint,nVar) = su2double(0.0); + Dynamic_Derivative_Vel.resize(nPoint,nVar) = su2double(0.0); + Dynamic_Derivative_Vel_n.resize(nPoint,nVar) = su2double(0.0); + Dynamic_Derivative_Accel.resize(nPoint,nVar) = su2double(0.0); + Dynamic_Derivative_Accel_n.resize(nPoint,nVar) = su2double(0.0); - Solution_Vel_time_n = new su2double[nVar]; - Solution_Accel_time_n = new su2double[nVar]; + Solution_Direct_Vel.resize(nPoint,nVar) = su2double(0.0); + Solution_Direct_Accel.resize(nPoint,nVar) = su2double(0.0); - Solution_Direct = new su2double[nVar]; + Solution_Vel.resize(nPoint,nVar); + Solution_Accel.resize(nPoint,nVar); - Sensitivity = new su2double[nDim]; + Solution_Old_Vel.resize(nPoint,nVar) = su2double(0.0); + Solution_Old_Accel.resize(nPoint,nVar) = su2double(0.0); - unsigned short iVar,iDim; + Solution_Vel_time_n.resize(nPoint,nVar) = su2double(0.0); + Solution_Accel_time_n.resize(nPoint,nVar) = su2double(0.0); - for (iDim = 0; iDim < nDim; iDim++){ - Sensitivity[iDim] = 0.0; - } - - for (iVar = 0; iVar < nVar; iVar++){ - Solution[iVar] = val_solution[iVar]; - } - - for (iVar = 0; iVar < nVar; iVar++){ - Solution_Accel[iVar] = val_solution_accel[iVar]; - } - - for (iVar = 0; iVar < nVar; iVar++){ - Solution_Vel[iVar] = val_solution_vel[iVar]; - } - - /*--- Initialize the rest to 0 ---*/ - - for (iVar = 0; iVar < nVar; iVar++){ - Dynamic_Derivative[iVar] = 0.0; - Dynamic_Derivative_n[iVar] = 0.0; - Dynamic_Derivative_Vel[iVar] = 0.0; - Dynamic_Derivative_Vel_n[iVar] = 0.0; - Dynamic_Derivative_Accel[iVar] = 0.0; - Dynamic_Derivative_Accel_n[iVar] = 0.0; - - Solution_Direct_Vel[iVar] = 0.0; - Solution_Direct_Accel[iVar] = 0.0; - - Solution_Vel_time_n[iVar] = 0.0; - Solution_Accel_time_n[iVar] = 0.0; - - Solution_Old_Vel[iVar] = 0.0; - Solution_Old_Accel[iVar] = 0.0; - - } - - Solution_BGS = NULL; - Solution_BGS_k = NULL; - Cross_Term_Derivative = NULL; - Geometry_CrossTerm_Derivative = NULL; - if (fsi){ - Cross_Term_Derivative = new su2double[nDim]; - Geometry_CrossTerm_Derivative = new su2double[nDim]; - Solution_BGS_k = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - Geometry_CrossTerm_Derivative [iDim] = 0.0; - Cross_Term_Derivative[iDim] = 0.0; - Solution_BGS[iDim] = 0.0; - Solution_BGS_k[iDim] = 0.0; + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) { + Solution_Vel(iPoint,iVar) = vel[iVar]; + Solution_Accel(iPoint,iVar) = accel[iVar]; } } } +void CDiscAdjFEAVariable::Set_OldSolution_Vel() { Solution_Old_Vel = Solution_Vel; } -CDiscAdjFEAVariable::~CDiscAdjFEAVariable(){ - - if (Sensitivity != NULL) delete [] Sensitivity; - if (Solution_Direct != NULL) delete [] Solution_Direct; - - if (Dynamic_Derivative != NULL) delete [] Dynamic_Derivative; - if (Dynamic_Derivative_n != NULL) delete [] Dynamic_Derivative_n; - if (Dynamic_Derivative_Vel != NULL) delete [] Dynamic_Derivative_Vel; - if (Dynamic_Derivative_Vel_n != NULL) delete [] Dynamic_Derivative_Vel_n; - if (Dynamic_Derivative_Accel != NULL) delete [] Dynamic_Derivative_Accel; - if (Dynamic_Derivative_Accel_n != NULL) delete [] Dynamic_Derivative_Accel_n; - - if (Solution_Direct_Vel != NULL) delete [] Solution_Direct_Vel; - if (Solution_Direct_Accel != NULL) delete [] Solution_Direct_Accel; - - if (Solution_Vel != NULL) delete [] Solution_Vel; - if (Solution_Accel != NULL) delete [] Solution_Accel; - - if (Solution_Vel_time_n != NULL) delete [] Solution_Vel_time_n; - if (Solution_Accel_time_n != NULL) delete [] Solution_Accel_time_n; - - if (Solution_Old_Vel != NULL) delete [] Solution_Old_Vel; - if (Solution_Old_Accel != NULL) delete [] Solution_Old_Accel; - - if (Cross_Term_Derivative != NULL) delete [] Cross_Term_Derivative; - if (Geometry_CrossTerm_Derivative != NULL) delete [] Geometry_CrossTerm_Derivative; - - if (Solution_BGS != NULL) delete [] Solution_BGS; - -} +void CDiscAdjFEAVariable::Set_OldSolution_Accel() { Solution_Old_Accel = Solution_Accel; } diff --git a/SU2_CFD/src/variables/CDiscAdjMeshBoundVariable.cpp b/SU2_CFD/src/variables/CDiscAdjMeshBoundVariable.cpp index 08bcf8a07880..8a7544fbfa8c 100644 --- a/SU2_CFD/src/variables/CDiscAdjMeshBoundVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjMeshBoundVariable.cpp @@ -35,37 +35,40 @@ * License along with SU2. If not, see . */ - #include "../../include/variables/CDiscAdjMeshBoundVariable.hpp" -CDiscAdjMeshBoundVariable::CDiscAdjMeshBoundVariable(su2double *val_coor, unsigned short val_nDim, CConfig *config) : CDiscAdjMeshVariable(val_coor, val_nDim, config) { - unsigned short iDim; +CDiscAdjMeshBoundVariable::CDiscAdjMeshBoundVariable(unsigned long npoint, unsigned long ndim, CConfig *config) : + CVariable(npoint, ndim, config) { + + nDim = ndim; + + VertexMap.Reset(nPoint); +} + +void CDiscAdjMeshBoundVariable::AllocateBoundaryVariables(CConfig *config) { + + if (VertexMap.GetIsValid()) return; // nothing to do + + /*--- Count number of vertices and build map ---*/ + + unsigned long nBoundPt = VertexMap.Build(); + + /*--- Allocate ---*/ bool fsi = false; /*--- Initialize Boundary Displacement container to 0.0 ---*/ - Bound_Disp_Sens = new su2double [nDim]; - Bound_Disp_Direct = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++){ - Bound_Disp_Sens[iDim] = 0.0; - Bound_Disp_Direct[iDim] = 0.0; - } - /*--- Container for the BGS solution at the previous iteration ---*/ - Solution_BGS_k = NULL; - if (fsi){ - Solution_BGS_k = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - Solution_BGS_k[iDim] = 0.0; - } - } + Bound_Disp_Sens.resize(nBoundPt,nDim) = su2double(0.0); + Bound_Disp_Direct.resize(nBoundPt,nDim) = su2double(0.0); -} + /*--- Container for the BGS solution at the previous iteration ---*/ -CDiscAdjMeshBoundVariable::~CDiscAdjMeshBoundVariable(void) { + if (fsi) Solution_BGS_k.resize(nBoundPt,nDim) = su2double(0.0); - if (Bound_Disp_Sens != NULL) delete [] Bound_Disp_Sens; - if (Bound_Disp_Direct != NULL) delete [] Bound_Disp_Direct; +} +void CDiscAdjMeshBoundVariable::Set_BGSSolution_k() { + Solution_BGS_k = Bound_Disp_Sens; } diff --git a/SU2_CFD/src/variables/CDiscAdjMeshVariable.cpp b/SU2_CFD/src/variables/CDiscAdjMeshVariable.cpp deleted file mode 100644 index 1e351dbb4448..000000000000 --- a/SU2_CFD/src/variables/CDiscAdjMeshVariable.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/*! - * \file CDiscAdjMeshVariable.cpp - * \brief Main subroutines for the discrete adjoint mesh variable structure. - * \author Ruben Sanchez - * \version 6.2.0 "Falcon" - * - * The current SU2 release has been coordinated by the - * SU2 International Developers Society - * with selected contributions from the open-source community. - * - * The main research teams contributing to the current release are: - * - Prof. Juan J. Alonso's group at Stanford University. - * - Prof. Piero Colonna's group at Delft University of Technology. - * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. - * - Prof. Alberto Guardone's group at Polytechnic University of Milan. - * - Prof. Rafael Palacios' group at Imperial College London. - * - Prof. Vincent Terrapon's group at the University of Liege. - * - Prof. Edwin van der Weide's group at the University of Twente. - * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. - * - * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, - * Tim Albring, and the SU2 contributors. - * - * 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 . - */ - - -#include "../../include/variables/CDiscAdjMeshVariable.hpp" - -CDiscAdjMeshVariable::CDiscAdjMeshVariable(su2double *val_coor, unsigned short val_nDim, CConfig *config) : CVariable(val_nDim, config) { - - /*--- Store the dimensionality of the problem ---*/ - nDim = val_nDim; - -} - -CDiscAdjMeshVariable::~CDiscAdjMeshVariable(void) { - -} diff --git a/SU2_CFD/src/variables/CDiscAdjVariable.cpp b/SU2_CFD/src/variables/CDiscAdjVariable.cpp index c84c43b8ad4d..c8ef81878871 100644 --- a/SU2_CFD/src/variables/CDiscAdjVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjVariable.cpp @@ -37,129 +37,49 @@ #include "../../include/variables/CDiscAdjVariable.hpp" -CDiscAdjVariable::CDiscAdjVariable() : CVariable() { - /*--- Initialize arrays to NULL ---*/ +CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) + : CVariable(npoint, ndim, nvar, config) { - Solution_Direct = NULL; - Sensitivity = NULL; - - DualTime_Derivative = NULL; - DualTime_Derivative_n = NULL; - - Geometry_Direct = NULL; - Solution_Geometry = NULL; - Solution_Geometry_Old = NULL; - Cross_Term_Derivative = NULL; - - Solution_BGS = NULL; - Solution_BGS_k = NULL; - Solution_Geometry_BGS_k = NULL; - - Geometry_CrossTerm_Derivative = NULL; - Geometry_CrossTerm_Derivative_Flow = NULL; - -} - -CDiscAdjVariable::CDiscAdjVariable(su2double* val_solution, unsigned short val_ndim, unsigned short val_nvar, - CConfig *config) : CVariable(val_ndim, val_nvar, config) { - - bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) - || (config->GetTime_Marching() == DT_STEPPING_2ND); + bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND); bool fsi = config->GetFSI_Simulation(); - /*--- Initialize arrays to NULL ---*/ - - Solution_Direct = NULL; - Sensitivity = NULL; - - DualTime_Derivative = NULL; - DualTime_Derivative_n = NULL; - - Geometry_Direct = NULL; - Solution_Geometry = NULL; - Solution_Geometry_Old = NULL; - Cross_Term_Derivative = NULL; - - Solution_BGS = NULL; - Solution_Geometry_BGS_k = NULL; - - Geometry_CrossTerm_Derivative = NULL; - Geometry_CrossTerm_Derivative_Flow = NULL; - if (dual_time) { - DualTime_Derivative = new su2double[nVar]; - DualTime_Derivative_n = new su2double[nVar]; + DualTime_Derivative.resize(nPoint,nVar) = su2double(0.0); + DualTime_Derivative_n.resize(nPoint,nVar) = su2double(0.0); + + Solution_time_n.resize(nPoint,nVar) = su2double(0.0); + Solution_time_n1.resize(nPoint,nVar) = su2double(0.0); } - Solution_Direct = new su2double[nVar]; + Solution_Direct.resize(nPoint,nVar); + Sensitivity.resize(nPoint,nDim) = su2double(0.0); - Sensitivity = new su2double[nDim]; + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for (unsigned long iVar = 0; iVar < nVar; ++iVar) + Solution(iPoint,iVar) = sol[iVar]; - unsigned short iVar,iDim; + External = Solution; + External_Old.resize(nPoint,nVar) = su2double(0.0); - for (iDim = 0; iDim < nDim; iDim++) { - Sensitivity[iDim] = 0.0; - } + if (fsi) { + Geometry_Direct.resize(nPoint,nDim) = su2double(0.0); + Solution_Geometry.resize(nPoint,nDim) = su2double(1e-16); + Solution_Geometry_Old.resize(nPoint,nDim) = su2double(0.0); + Cross_Term_Derivative.resize(nPoint,nVar) = su2double(0.0); + Geometry_CrossTerm_Derivative.resize(nPoint,nDim) = su2double(0.0); + Geometry_CrossTerm_Derivative_Flow.resize(nPoint,nDim) = su2double(0.0); - for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = val_solution[iVar]; + Solution_BGS.resize(nPoint,nVar) = su2double(0.0); + Solution_Geometry_BGS_k.resize(nPoint,nDim) = su2double(0.0); } - - if (dual_time) { - for (iVar = 0; iVar < nVar; iVar++) { - Solution_time_n[iVar] = 0.0; - Solution_time_n1[iVar] = 0.0; - DualTime_Derivative[iVar] = 0.0; - DualTime_Derivative_n[iVar] = 0.0; - } - } - - if (fsi){ - Solution_Geometry = new su2double[nDim]; - Geometry_Direct = new su2double[nDim]; - Solution_Geometry_Old = new su2double[nDim]; - Geometry_CrossTerm_Derivative = new su2double[nDim]; - Geometry_CrossTerm_Derivative_Flow = new su2double[nDim]; - Cross_Term_Derivative = new su2double[nVar]; - Solution_BGS = new su2double[nVar]; - Solution_Geometry_BGS_k = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - Geometry_Direct[iDim] = 0.0; - Solution_Geometry[iDim] = 1e-16; - Solution_Geometry_Old[iDim] = 0.0; - Solution_Geometry_BGS_k[iDim] = 0.0; - Geometry_CrossTerm_Derivative[iDim] = 0.0; - Geometry_CrossTerm_Derivative_Flow[iDim] = 0.0; - } - for (iVar = 0; iVar < nVar; iVar++) { - Cross_Term_Derivative[iVar] = 0.0; - Solution_BGS[iVar] = 0.0; - } - } - - if (config->GetMultizone_Problem()) + if (config->GetMultizone_Problem()) { + Solution_BGS.resize(nPoint,nVar) = su2double(0.0); Set_BGSSolution_k(); - + } } -CDiscAdjVariable::~CDiscAdjVariable() { - - if (Geometry_Direct != NULL) delete [] Geometry_Direct; - if (Solution_Geometry != NULL) delete [] Solution_Geometry; - if (Solution_Geometry_Old != NULL) delete [] Solution_Geometry_Old; - if (Cross_Term_Derivative != NULL) delete [] Cross_Term_Derivative; - if (Geometry_CrossTerm_Derivative != NULL) delete [] Geometry_CrossTerm_Derivative; - if (Geometry_CrossTerm_Derivative_Flow != NULL) delete [] Geometry_CrossTerm_Derivative_Flow; - if (Solution_BGS != NULL) delete [] Solution_BGS; - if (Solution_Geometry_BGS_k != NULL) delete [] Solution_Geometry_BGS_k; - - if (Solution_Direct != NULL) delete [] Solution_Direct; - if (Sensitivity != NULL) delete [] Sensitivity; - - if (DualTime_Derivative != NULL) delete [] DualTime_Derivative; - if (DualTime_Derivative_n != NULL) delete [] DualTime_Derivative_n; - -} +void CDiscAdjVariable::Set_OldSolution_Geometry() { Solution_Geometry_Old = Solution_Geometry; } diff --git a/SU2_CFD/src/variables/CEulerVariable.cpp b/SU2_CFD/src/variables/CEulerVariable.cpp index d9c587807a0d..7d6390c35192 100644 --- a/SU2_CFD/src/variables/CEulerVariable.cpp +++ b/SU2_CFD/src/variables/CEulerVariable.cpp @@ -37,457 +37,136 @@ #include "../../include/variables/CEulerVariable.hpp" -CEulerVariable::CEulerVariable(void) : CVariable() { - /*--- Array initialization ---*/ +CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2double energy, unsigned long npoint, + unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { - HB_Source = NULL; - Primitive = NULL; - Secondary = NULL; - - Gradient_Primitive = NULL; - Gradient_Reconstruction = NULL; - GradReconAllocated = false; - Gradient_Secondary = NULL; - - Limiter_Primitive = NULL; - Limiter_Secondary = NULL; - - WindGust = NULL; - WindGustDer = NULL; - - nPrimVar = 0; - nPrimVarGrad = 0; - - nSecondaryVar = 0; - nSecondaryVarGrad = 0; - - Solution_New = NULL; - -} - -CEulerVariable::CEulerVariable(su2double val_density, su2double *val_velocity, su2double val_energy, unsigned short val_nDim, - unsigned short val_nvar, CConfig *config) : CVariable(val_nDim, val_nvar, config) { - unsigned short iVar, iDim, iMesh, nMGSmooth = 0; - - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - bool viscous = config->GetViscous(); - bool windgust = config->GetWind_Gust(); + bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND); + bool viscous = config->GetViscous(); + bool windgust = config->GetWind_Gust(); bool classical_rk4 = (config->GetKind_TimeIntScheme_Flow() == CLASSICAL_RK4_EXPLICIT); - /*--- Array initialization ---*/ - - HB_Source = NULL; - Primitive = NULL; - Secondary = NULL; - - Gradient_Primitive = NULL; - Gradient_Reconstruction = NULL; - GradReconAllocated = false; - Gradient_Secondary = NULL; - - Limiter_Primitive = NULL; - Limiter_Secondary = NULL; - - WindGust = NULL; - WindGustDer = NULL; - - nPrimVar = 0; - nPrimVarGrad = 0; - - nSecondaryVar = 0; - nSecondaryVarGrad = 0; - - Solution_New = NULL; - /*--- Allocate and initialize the primitive variables and gradients ---*/ - nPrimVar = nDim+9; nPrimVarGrad = nDim+4; - if (viscous) { nSecondaryVar = 8; nSecondaryVarGrad = 2; } - else { nSecondaryVar = 2; nSecondaryVarGrad = 2; } + nPrimVar = nDim+9; + nPrimVarGrad = nDim+4; + nSecondaryVar = viscous? 8 : 2; + nSecondaryVarGrad = 2; /*--- Allocate residual structures ---*/ - Res_TruncError = new su2double [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Res_TruncError[iVar] = 0.0; - } + Res_TruncError.resize(nPoint,nVar) = su2double(0.0); /*--- Only for residual smoothing (multigrid) ---*/ - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) - nMGSmooth += config->GetMG_CorrecSmooth(iMesh); - - if (nMGSmooth > 0) { - Residual_Sum = new su2double [nVar]; - Residual_Old = new su2double [nVar]; - } - - /*--- Allocate undivided laplacian (centered) and limiter (upwind)---*/ - - if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) { - Undivided_Laplacian = new su2double [nVar]; - } - - /*--- Always allocate the slope limiter, - and the auxiliar variables (check the logic - JST with 2nd order Turb model - ) ---*/ - - Limiter_Primitive = new su2double [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Limiter_Primitive[iVar] = 0.0; - - Limiter_Secondary = new su2double [nSecondaryVarGrad]; - for (iVar = 0; iVar < nSecondaryVarGrad; iVar++) - Limiter_Secondary[iVar] = 0.0; - - Limiter = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Limiter[iVar] = 0.0; - - Solution_Max = new su2double [nPrimVarGrad]; - Solution_Min = new su2double [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Solution_Max[iVar] = 0.0; - Solution_Min[iVar] = 0.0; - } - - /*--- Solution and old solution initialization ---*/ - - Solution[0] = val_density; - Solution_Old[0] = val_density; - for (iDim = 0; iDim < nDim; iDim++) { - Solution[iDim+1] = val_density*val_velocity[iDim]; - Solution_Old[iDim+1] = val_density*val_velocity[iDim]; - } - Solution[nVar-1] = val_density*val_energy; - Solution_Old[nVar-1] = val_density*val_energy; - - /*--- New solution initialization for Classical RK4 ---*/ - - if (classical_rk4) { - Solution_New = new su2double[nVar]; - Solution_New[0] = val_density; - for (iDim = 0; iDim < nDim; iDim++) { - Solution_New[iDim+1] = val_density*val_velocity[iDim]; - } - Solution_New[nVar-1] = val_density*val_energy; - } - - /*--- Allocate and initialize solution for dual time strategy ---*/ - - if (dual_time) { - Solution_time_n[0] = val_density; - Solution_time_n1[0] = val_density; - for (iDim = 0; iDim < nDim; iDim++) { - Solution_time_n[iDim+1] = val_density*val_velocity[iDim]; - Solution_time_n1[iDim+1] = val_density*val_velocity[iDim]; + for (unsigned long iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + if (config->GetMG_CorrecSmooth(iMesh) > 0) { + Residual_Sum.resize(nPoint,nVar); + Residual_Old.resize(nPoint,nVar); + break; } - Solution_time_n[nVar-1] = val_density*val_energy; - Solution_time_n1[nVar-1] = val_density*val_energy; - } - - - /*--- Allocate space for the harmonic balance source terms ---*/ - - if (config->GetTime_Marching() == HARMONIC_BALANCE) { - HB_Source = new su2double[nVar]; - for (iVar = 0; iVar < nVar; iVar++) HB_Source[iVar] = 0.0; - } - - /*--- Allocate vector for wind gust and wind gust derivative field ---*/ - - if (windgust) { - WindGust = new su2double [nDim]; - WindGustDer = new su2double [nDim+1]; - } - - /*--- Incompressible flow, primitive variables nDim+3, (P, vx, vy, vz, rho, beta) ---*/ - - Primitive = new su2double [nPrimVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) Primitive[iVar] = 0.0; - - Secondary = new su2double [nSecondaryVar]; - for (iVar = 0; iVar < nSecondaryVar; iVar++) Secondary[iVar] = 0.0; - - /*--- Compressible flow, gradients primitive variables nDim+4, (T, vx, vy, vz, P, rho, h) - We need P, and rho for running the adjoint problem ---*/ - - Gradient_Primitive = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Primitive[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Primitive[iVar][iDim] = 0.0; - } - - if (config->GetReconstructionGradientRequired()) { - GradReconAllocated = true; - Gradient_Reconstruction = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Reconstruction[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; - } - } else { - Gradient_Reconstruction = Gradient_Primitive; - } - - Gradient_Secondary = new su2double* [nSecondaryVarGrad]; - for (iVar = 0; iVar < nSecondaryVarGrad; iVar++) { - Gradient_Secondary[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Secondary[iVar][iDim] = 0.0; - } - - if (config->GetMultizone_Problem()) - Set_BGSSolution_k(); -} - -CEulerVariable::CEulerVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : CVariable(val_nDim, val_nvar, config) { - unsigned short iVar, iDim, iMesh, nMGSmooth = 0; - - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - bool viscous = config->GetViscous(); - bool windgust = config->GetWind_Gust(); - bool classical_rk4 = (config->GetKind_TimeIntScheme_Flow() == CLASSICAL_RK4_EXPLICIT); - - /*--- Array initialization ---*/ - - HB_Source = NULL; - Primitive = NULL; - Secondary = NULL; - - Gradient_Primitive = NULL; - Gradient_Reconstruction = NULL; - GradReconAllocated = false; - Gradient_Secondary = NULL; - - Limiter_Primitive = NULL; - Limiter_Secondary = NULL; - - WindGust = NULL; - WindGustDer = NULL; - - nPrimVar = 0; - nPrimVarGrad = 0; - - nSecondaryVar = 0; - nSecondaryVarGrad = 0; - - Solution_New = NULL; - - /*--- Allocate and initialize the primitive variables and gradients ---*/ - - nPrimVar = nDim+9; nPrimVarGrad = nDim+4; - if (viscous) { nSecondaryVar = 8; nSecondaryVarGrad = 2; } - else { nSecondaryVar = 2; nSecondaryVarGrad = 2; } - - - /*--- Allocate residual structures ---*/ - - Res_TruncError = new su2double [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Res_TruncError[iVar] = 0.0; - } - - /*--- Only for residual smoothing (multigrid) ---*/ - - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) - nMGSmooth += config->GetMG_CorrecSmooth(iMesh); - - if (nMGSmooth > 0) { - Residual_Sum = new su2double [nVar]; - Residual_Old = new su2double [nVar]; } /*--- Allocate undivided laplacian (centered) and limiter (upwind)---*/ if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) - Undivided_Laplacian = new su2double [nVar]; + Undivided_Laplacian.resize(nPoint,nVar); /*--- Always allocate the slope limiter, and the auxiliar variables (check the logic - JST with 2nd order Turb model - ) ---*/ - Limiter_Primitive = new su2double [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Limiter_Primitive[iVar] = 0.0; + Limiter_Primitive.resize(nPoint,nPrimVarGrad) = su2double(0.0); + Limiter.resize(nPoint,nVar) = su2double(0.0); - Limiter_Secondary = new su2double [nSecondaryVarGrad]; - for (iVar = 0; iVar < nSecondaryVarGrad; iVar++) - Limiter_Secondary[iVar] = 0.0; + Solution_Max.resize(nPoint,nPrimVarGrad) = su2double(0.0); + Solution_Min.resize(nPoint,nPrimVarGrad) = su2double(0.0); - Limiter = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Limiter[iVar] = 0.0; + /*--- Solution initialization ---*/ - Solution_Max = new su2double [nPrimVarGrad]; - Solution_Min = new su2double [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Solution_Max[iVar] = 0.0; - Solution_Min[iVar] = 0.0; - } + su2double val_solution[5] = {su2double(1.0), velocity[0], velocity[1], energy, energy}; + if(nDim==3) val_solution[3] = velocity[2]; - /*--- Solution initialization ---*/ + for(unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for (unsigned long iVar = 0; iVar < nVar; ++iVar) + Solution(iPoint,iVar) = density*val_solution[iVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = val_solution[iVar]; - Solution_Old[iVar] = val_solution[iVar]; - } + Solution_Old = Solution; /*--- New solution initialization for Classical RK4 ---*/ - if (classical_rk4) { - Solution_New = new su2double[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Solution_New[iVar] = val_solution[iVar]; - } - } + if (classical_rk4) Solution_New = Solution; /*--- Allocate and initializate solution for dual time strategy ---*/ if (dual_time) { - Solution_time_n = new su2double [nVar]; - Solution_time_n1 = new su2double [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Solution_time_n[iVar] = val_solution[iVar]; - Solution_time_n1[iVar] = val_solution[iVar]; - } + Solution_time_n = Solution; + Solution_time_n1 = Solution; } /*--- Allocate space for the harmonic balance source terms ---*/ - if (config->GetTime_Marching() == HARMONIC_BALANCE) { - HB_Source = new su2double[nVar]; - for (iVar = 0; iVar < nVar; iVar++) HB_Source[iVar] = 0.0; - } + if (config->GetTime_Marching() == HARMONIC_BALANCE) + HB_Source.resize(nPoint,nVar) = su2double(0.0); /*--- Allocate vector for wind gust and wind gust derivative field ---*/ if (windgust) { - WindGust = new su2double [nDim]; - WindGustDer = new su2double [nDim+1]; + WindGust.resize(nPoint,nDim); + WindGustDer.resize(nPoint,nDim+1); } /*--- Compressible flow, primitive variables nDim+5, (T, vx, vy, vz, P, rho, h, c) ---*/ - Primitive = new su2double [nPrimVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) Primitive[iVar] = 0.0; - - Secondary = new su2double [nSecondaryVar]; - for (iVar = 0; iVar < nSecondaryVar; iVar++) Secondary[iVar] = 0.0; - + Primitive.resize(nPoint,nPrimVar) = su2double(0.0); + Secondary.resize(nPoint,nSecondaryVar) = su2double(0.0); /*--- Compressible flow, gradients primitive variables nDim+4, (T, vx, vy, vz, P, rho, h) We need P, and rho for running the adjoint problem ---*/ - Gradient_Primitive = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Primitive[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Primitive[iVar][iDim] = 0.0; - } + Gradient_Primitive.resize(nPoint,nPrimVarGrad,nDim,0.0); if (config->GetReconstructionGradientRequired()) { - GradReconAllocated = true; - Gradient_Reconstruction = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Reconstruction[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; - } + Gradient_Reconstruction.resize(nPoint,nPrimVarGrad,nDim,0.0); } else { Gradient_Reconstruction = Gradient_Primitive; } - Gradient_Secondary = new su2double* [nSecondaryVarGrad]; - for (iVar = 0; iVar < nSecondaryVarGrad; iVar++) { - Gradient_Secondary[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Secondary[iVar][iDim] = 0.0; + if (config->GetLeastSquaresRequired()) { + Rmatrix.resize(nPoint,nDim,nDim,0.0); } - + if (config->GetMultizone_Problem()) Set_BGSSolution_k(); -} - -CEulerVariable::~CEulerVariable(void) { - unsigned short iVar; - - if (HB_Source != NULL) delete [] HB_Source; - if (Primitive != NULL) delete [] Primitive; - if (Secondary != NULL) delete [] Secondary; - if (Limiter_Primitive != NULL) delete [] Limiter_Primitive; - if (Limiter_Secondary != NULL) delete [] Limiter_Secondary; - if (WindGust != NULL) delete [] WindGust; - if (WindGustDer != NULL) delete [] WindGustDer; - - if (Gradient_Primitive != NULL) { - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - if (Gradient_Primitive[iVar] != NULL) delete [] Gradient_Primitive[iVar]; - delete [] Gradient_Primitive; - } - if (GradReconAllocated) { - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - if (Gradient_Reconstruction[iVar] != NULL) delete [] Gradient_Reconstruction[iVar]; - delete [] Gradient_Reconstruction; - } - if (Gradient_Secondary != NULL) { - for (iVar = 0; iVar < nSecondaryVarGrad; iVar++) - if (Gradient_Secondary[iVar] != NULL) delete [] Gradient_Secondary[iVar]; - delete [] Gradient_Secondary; - } - - if (Solution_New != NULL) delete [] Solution_New; -} - -void CEulerVariable::SetGradient_PrimitiveZero(unsigned short val_primvar) { - unsigned short iVar, iDim; - - for (iVar = 0; iVar < val_primvar; iVar++) - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Primitive[iVar][iDim] = 0.0; -} -void CEulerVariable::SetGradient_SecondaryZero(unsigned short val_secondaryvar) { - unsigned short iVar, iDim; + Velocity2.resize(nPoint) = su2double(0.0); + Max_Lambda_Inv.resize(nPoint) = su2double(0.0); + Delta_Time.resize(nPoint) = su2double(0.0); + Lambda.resize(nPoint) = su2double(0.0); + Sensor.resize(nPoint) = su2double(0.0); - for (iVar = 0; iVar < val_secondaryvar; iVar++) - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Secondary[iVar][iDim] = 0.0; } -su2double CEulerVariable::GetProjVel(su2double *val_vector) { - su2double ProjVel; - unsigned short iDim; - - ProjVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVel += Primitive[iDim+1]*val_vector[iDim]; - - return ProjVel; +void CEulerVariable::SetGradient_PrimitiveZero() { + Gradient_Primitive.storage.setConstant(0.0); } -bool CEulerVariable::SetPrimVar(CFluidModel *FluidModel) { - unsigned short iVar; - bool check_dens = false, check_press = false, check_sos = false, check_temp = false, RightVol = true; +bool CEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { + bool RightVol = true; - SetVelocity(); // Computes velocity and velocity^2 - su2double density = GetDensity(); - su2double staticEnergy = GetEnergy()-0.5*Velocity2; + SetVelocity(iPoint); // Computes velocity and velocity^2 + su2double density = GetDensity(iPoint); + su2double staticEnergy = GetEnergy(iPoint)-0.5*Velocity2(iPoint); /*--- Check will be moved inside fluid model plus error description strings ---*/ FluidModel->SetTDState_rhoe(density, staticEnergy); - check_dens = SetDensity(); - check_press = SetPressure(FluidModel->GetPressure()); - check_sos = SetSoundSpeed(FluidModel->GetSoundSpeed2()); - check_temp = SetTemperature(FluidModel->GetTemperature()); + bool check_dens = SetDensity(iPoint); + bool check_press = SetPressure(iPoint, FluidModel->GetPressure()); + bool check_sos = SetSoundSpeed(iPoint, FluidModel->GetSoundSpeed2()); + bool check_temp = SetTemperature(iPoint, FluidModel->GetTemperature()); /*--- Check that the solution has a physical meaning ---*/ @@ -495,40 +174,38 @@ bool CEulerVariable::SetPrimVar(CFluidModel *FluidModel) { /*--- Copy the old solution ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = Solution_Old[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution(iPoint, iVar) = Solution_Old(iPoint, iVar); /*--- Recompute the primitive variables ---*/ - SetVelocity(); // Computes velocity and velocity^2 - su2double density = GetDensity(); - su2double staticEnergy = GetEnergy()-0.5*Velocity2; + SetVelocity(iPoint); // Computes velocity and velocity^2 + su2double density = GetDensity(iPoint); + su2double staticEnergy = GetEnergy(iPoint)-0.5*Velocity2(iPoint); /* check will be moved inside fluid model plus error description strings*/ FluidModel->SetTDState_rhoe(density, staticEnergy); - SetDensity(); - SetPressure(FluidModel->GetPressure()); - SetSoundSpeed(FluidModel->GetSoundSpeed2()); - SetTemperature(FluidModel->GetTemperature()); + SetDensity(iPoint); + SetPressure(iPoint, FluidModel->GetPressure()); + SetSoundSpeed(iPoint, FluidModel->GetSoundSpeed2()); + SetTemperature(iPoint, FluidModel->GetTemperature()); RightVol = false; } - /*--- Set enthalpy ---*/ - - SetEnthalpy(); // Requires pressure computation. + SetEnthalpy(iPoint); // Requires pressure computation. return RightVol; - } -void CEulerVariable::SetSecondaryVar(CFluidModel *FluidModel) { +void CEulerVariable::SetSecondaryVar(unsigned long iPoint, CFluidModel *FluidModel) { /*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/ - SetdPdrho_e(FluidModel->GetdPdrho_e()); - SetdPde_rho(FluidModel->GetdPde_rho()); + SetdPdrho_e(iPoint, FluidModel->GetdPdrho_e()); + SetdPde_rho(iPoint, FluidModel->GetdPde_rho()); } +void CEulerVariable::SetSolution_New() { Solution_New = Solution; } diff --git a/SU2_CFD/src/variables/CFEABoundVariable.cpp b/SU2_CFD/src/variables/CFEABoundVariable.cpp index db7e26be2c36..07b4cfcb043d 100644 --- a/SU2_CFD/src/variables/CFEABoundVariable.cpp +++ b/SU2_CFD/src/variables/CFEABoundVariable.cpp @@ -38,37 +38,48 @@ #include "../../include/variables/CFEABoundVariable.hpp" -CFEABoundVariable::CFEABoundVariable(void) : CFEAVariable() { - - Residual_Ext_Surf = NULL; // Residual component due to external surface forces - Residual_Ext_Surf_n = NULL; // Residual component due to external surface forces at time n (for gen-alpha methods) +CFEABoundVariable::CFEABoundVariable(const su2double *val_fea, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) + : CFEAVariable(val_fea, npoint, ndim, nvar, config) { + VertexMap.Reset(nPoint); } -CFEABoundVariable::CFEABoundVariable(su2double *val_fea, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CFEAVariable(val_fea, val_nDim, val_nvar, config) { +void CFEABoundVariable::AllocateBoundaryVariables(CConfig *config) { - unsigned short iVar; - bool gen_alpha = (config->GetKind_TimeIntScheme_FEA() == GENERALIZED_ALPHA); + if (VertexMap.GetIsValid()) return; // nothing to do + + /*--- Count number of vertices and build map ---*/ + + unsigned long nBoundPt = VertexMap.Build(); + + /*--- Allocate ---*/ - Residual_Ext_Surf = NULL; - Residual_Ext_Surf_n = NULL; + bool gen_alpha = (config->GetKind_TimeIntScheme_FEA() == GENERALIZED_ALPHA); + fsi_analysis = config->GetFSI_Simulation(); /*--- Surface residual ---*/ - Residual_Ext_Surf = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) Residual_Ext_Surf[iVar] = 0.0; + Residual_Ext_Surf.resize(nBoundPt,nVar) = su2double(0.0); + + /*--- Flow traction ---*/ + if (fsi_analysis) FlowTraction.resize(nBoundPt,nVar) = su2double(0.0); /*--- Generalized alpha integration method requires storing the old residuals ---*/ if (gen_alpha) { - Residual_Ext_Surf_n = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) Residual_Ext_Surf_n[iVar] = 0.0; - } + Residual_Ext_Surf_n.resize(nBoundPt,nVar) = su2double(0.0); + if (fsi_analysis) FlowTraction_n.resize(nBoundPt,nVar) = su2double(0.0); + } } -CFEABoundVariable::~CFEABoundVariable(void) { +void CFEABoundVariable::Set_FlowTraction_n() { FlowTraction_n = FlowTraction; } + +void CFEABoundVariable::Set_SurfaceLoad_Res_n() { Residual_Ext_Surf_n = Residual_Ext_Surf; } - if (Residual_Ext_Surf != NULL) delete [] Residual_Ext_Surf; - if (Residual_Ext_Surf_n != NULL) delete [] Residual_Ext_Surf_n; +void CFEABoundVariable::Clear_FlowTraction() { FlowTraction.setConstant(0.0); } +void CFEABoundVariable::RegisterFlowTraction() { + if (!fsi_analysis) return; + for (unsigned long iVertex = 0; iVertex < FlowTraction.rows(); iVertex++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterInput(FlowTraction(iVertex,iVar)); } diff --git a/SU2_CFD/src/variables/CFEAFSIBoundVariable.cpp b/SU2_CFD/src/variables/CFEAFSIBoundVariable.cpp deleted file mode 100644 index 6f689807bbf4..000000000000 --- a/SU2_CFD/src/variables/CFEAFSIBoundVariable.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/*! - * \file CFEABoundVariable.cpp - * \brief Definition of the variables for FEM elastic structural problems. - * \author R. Sanchez - * \version 6.2.0 "Falcon" - * - * The current SU2 release has been coordinated by the - * SU2 International Developers Society - * with selected contributions from the open-source community. - * - * The main research teams contributing to the current release are: - * - Prof. Juan J. Alonso's group at Stanford University. - * - Prof. Piero Colonna's group at Delft University of Technology. - * - Prof. Nicolas R. Gauger's group at Kaiserslautern University of Technology. - * - Prof. Alberto Guardone's group at Polytechnic University of Milan. - * - Prof. Rafael Palacios' group at Imperial College London. - * - Prof. Vincent Terrapon's group at the University of Liege. - * - Prof. Edwin van der Weide's group at the University of Twente. - * - Lab. of New Concepts in Aeronautics at Tech. Institute of Aeronautics. - * - * Copyright 2012-2019, Francisco D. Palacios, Thomas D. Economon, - * Tim Albring, and the SU2 contributors. - * - * 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 . - */ - -#include "../../include/variables/CFEAFSIBoundVariable.hpp" - -CFEAFSIBoundVariable::CFEAFSIBoundVariable(void) : CFEABoundVariable() { - - FlowTraction = NULL; // Nodal traction due to the fluid (fsi) - FlowTraction_n = NULL; // Nodal traction due to the fluid (fsi) at time n (for gen-alpha methods) - -} - -CFEAFSIBoundVariable::CFEAFSIBoundVariable(su2double *val_fea, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CFEABoundVariable(val_fea, val_nDim, val_nvar, config) { - - unsigned short iVar; - bool gen_alpha = (config->GetKind_TimeIntScheme_FEA() == GENERALIZED_ALPHA); - - /*--- Flow traction ---*/ - FlowTraction = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - FlowTraction[iVar] = 0.0; - } - - /*--- Generalized alpha integration method requires storing the old residuals ---*/ - FlowTraction_n = NULL; - if (gen_alpha) { - FlowTraction_n = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - FlowTraction_n[iVar] = 0.0; - } - } - -} - -CFEAFSIBoundVariable::~CFEAFSIBoundVariable(void) { - - if (FlowTraction != NULL) delete [] FlowTraction; - if (FlowTraction_n != NULL) delete [] FlowTraction_n; - -} diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index a953cc5c5917..51615062942f 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -37,133 +37,111 @@ #include "../../include/variables/CFEAVariable.hpp" -CFEAVariable::CFEAVariable(void) : CVariable() { - VonMises_Stress = 0.0; +CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) + : CVariable(npoint, ndim, nvar, config) { - Stress = NULL; // Nodal stress (for output purposes) - Residual_Ext_Body = NULL; // Residual component due to body forces + bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); + bool body_forces = config->GetDeadLoad(); + bool incremental_load = config->GetIncrementalLoad(); + bool prestretch_fem = config->GetPrestretch(); // Structure is prestretched + bool discrete_adjoint = config->GetDiscrete_Adjoint(); + bool refgeom = config->GetRefGeom(); // Reference geometry needs to be stored + bool dynamic_analysis = config->GetTime_Domain(); + bool fsi_analysis = config->GetFSI_Simulation(); - Solution_Vel = NULL; // Velocity at the node at time t+dt - Solution_Vel_time_n = NULL; // Velocity at the node at time t + VonMises_Stress.resize(nPoint) = su2double(0.0); - Solution_Accel = NULL; // Acceleration at the node at time t+dt - Solution_Accel_time_n = NULL; // Acceleration at the node at time t - - Solution_Pred = NULL; // Predictor of the solution at the current subiteration - Solution_Pred_Old = NULL; // Predictor of the solution at the previous subiteration - - Prestretch = NULL; // Prestretch geometry - Reference_Geometry = NULL; // Reference geometry for optimization purposes -} - -CFEAVariable::CFEAVariable(su2double *val_fea, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CVariable(val_nDim, val_nvar, config) { - - unsigned short iVar; - bool nonlinear_analysis = (config->GetGeometricConditions() == LARGE_DEFORMATIONS); // Nonlinear analysis. - bool body_forces = config->GetDeadLoad(); // Body forces (dead loads). - bool incremental_load = config->GetIncrementalLoad(); - bool prestretch_fem = config->GetPrestretch(); // Structure is prestretched - - bool discrete_adjoint = config->GetDiscrete_Adjoint(); - - bool refgeom = config->GetRefGeom(); // Reference geometry needs to be stored - - bool dynamic_analysis = (config->GetTime_Domain()); - bool fsi_analysis = (config->GetnMarker_Fluid_Load() > 0); - - VonMises_Stress = 0.0; - - Stress = NULL; // Nodal stress (for output purposes) - Residual_Ext_Body = NULL; // Residual component due to body forces - - Solution_Vel = NULL; // Velocity at the node at time t+dt - Solution_Vel_time_n = NULL; // Velocity at the node at time t - - Solution_Accel = NULL; // Acceleration at the node at time t+dt - Solution_Accel_time_n = NULL; // Acceleration at the node at time t - - Solution_Pred = NULL; // Predictor of the solution at the current subiteration - Solution_Pred_Old = NULL; // Predictor of the solution at the previous subiteration - - Prestretch = NULL; // Prestretch geometry - Reference_Geometry = NULL; // Reference geometry for optimization purposes - - if (nDim == 2) Stress = new su2double [3]; - else if (nDim == 3) Stress = new su2double [6]; + if (nDim==2) Stress.resize(nPoint,3); + else Stress.resize(nPoint,6); /*--- Initialization of variables ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = val_fea[iVar]; - } + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution(iPoint,iVar) = val_fea[iVar]; if (dynamic_analysis) { - Solution_Vel = new su2double [nVar]; - Solution_Vel_time_n = new su2double [nVar]; - Solution_Accel = new su2double [nVar]; - Solution_Accel_time_n = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Solution_Vel[iVar] = val_fea[iVar+nVar]; - Solution_Vel_time_n[iVar] = val_fea[iVar+nVar]; - Solution_Accel[iVar] = val_fea[iVar+2*nVar]; - Solution_Accel_time_n[iVar] = val_fea[iVar+2*nVar]; + Solution_Vel.resize(nPoint,nVar); + Solution_Accel.resize(nPoint,nVar); + + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) { + Solution_Vel(iPoint,iVar) = val_fea[iVar+nVar]; + Solution_Accel(iPoint,iVar) = val_fea[iVar+2*nVar]; + } } + Solution_Vel_time_n = Solution_Vel; + Solution_Accel_time_n = Solution_Accel; } + if (fsi_analysis) { - Solution_Pred = new su2double [nVar]; - Solution_Pred_Old = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Solution_Pred[iVar] = val_fea[iVar]; - Solution_Pred_Old[iVar] = val_fea[iVar]; - } + Solution_Pred = Solution; + Solution_Pred_Old = Solution; } - /*--- This variable is not "ours", careful not to leak memory ---*/ - if (Solution_Old == NULL) - { - /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ - if (incremental_load && nonlinear_analysis) { - Solution_Old = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) Solution_Old[iVar] = 0.0; - } - /*--- If we are running a discrete adjoint iteration, we need this vector for cross-dependencies ---*/ - else if (discrete_adjoint && fsi_analysis) { - Solution_Old = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) Solution_Old[iVar] = val_fea[iVar]; - } - } + /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ + + if (incremental_load && nonlinear_analysis) Solution_Old.resize(nPoint,nVar) = su2double(0.0); + + /*--- If we are running a discrete adjoint iteration, we need this vector for cross-dependencies ---*/ + + else if (discrete_adjoint && fsi_analysis) Solution_Old = Solution; /*--- Body residual ---*/ - if (body_forces) { - Residual_Ext_Body = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) Residual_Ext_Body[iVar] = 0.0; - } + if (body_forces) Residual_Ext_Body.resize(nPoint,nVar) = su2double(0.0); - if (refgeom) Reference_Geometry = new su2double [nVar]; + if (refgeom) Reference_Geometry.resize(nPoint,nVar); - if (prestretch_fem) Prestretch = new su2double [nVar]; + if (prestretch_fem) Prestretch.resize(nPoint,nVar); if (config->GetMultizone_Problem()) Set_BGSSolution_k(); } -CFEAVariable::~CFEAVariable(void) { - - if (Stress != NULL) delete [] Stress; - if (Residual_Ext_Body != NULL) delete [] Residual_Ext_Body; +void CFEAVariable::SetSolution_Vel_time_n() { Solution_Vel_time_n = Solution_Vel; } - if (Solution_Vel != NULL) delete [] Solution_Vel; - if (Solution_Vel_time_n != NULL) delete [] Solution_Vel_time_n; +void CFEAVariable::SetSolution_Accel_time_n() { Solution_Accel_time_n = Solution_Accel; } - if (Solution_Accel != NULL) delete [] Solution_Accel; - if (Solution_Accel_time_n != NULL) delete [] Solution_Accel_time_n; +void CFEAVariable::Register_femSolution_time_n() { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterInput(Solution_time_n(iPoint,iVar)); +} - if (Solution_Pred != NULL) delete [] Solution_Pred; - if (Solution_Pred_Old != NULL) delete [] Solution_Pred_Old; +void CFEAVariable::RegisterSolution_Vel(bool input) { + if (input) { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterInput(Solution_Vel(iPoint,iVar)); + } + else { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterOutput(Solution_Vel(iPoint,iVar)); + } +} - if (Reference_Geometry != NULL) delete [] Reference_Geometry; - if (Prestretch != NULL) delete [] Prestretch; +void CFEAVariable::RegisterSolution_Vel_time_n() { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterInput(Solution_Vel_time_n(iPoint,iVar)); +} +void CFEAVariable::RegisterSolution_Accel(bool input) { + if (input) { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterInput(Solution_Accel(iPoint,iVar)); + } + else { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterOutput(Solution_Accel(iPoint,iVar)); + } } +void CFEAVariable::RegisterSolution_Accel_time_n() { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterInput(Solution_Accel_time_n(iPoint,iVar)); +} diff --git a/SU2_CFD/src/variables/CHeatFVMVariable.cpp b/SU2_CFD/src/variables/CHeatFVMVariable.cpp index 18c5ce29285a..da62931a891c 100644 --- a/SU2_CFD/src/variables/CHeatFVMVariable.cpp +++ b/SU2_CFD/src/variables/CHeatFVMVariable.cpp @@ -37,74 +37,59 @@ #include "../../include/variables/CHeatFVMVariable.hpp" -CHeatFVMVariable::CHeatFVMVariable(void) : CVariable() { - /*--- Array initialization ---*/ - Solution_Direct = NULL; - Solution_BGS_k = NULL; - GradReconAllocated = false; -} - -CHeatFVMVariable::CHeatFVMVariable(su2double val_Heat, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CVariable(val_nDim, val_nvar, config) { +CHeatFVMVariable::CHeatFVMVariable(su2double heat, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) +: CVariable(npoint, ndim, nvar, config) { - unsigned short iDim, iVar, iMesh, nMGSmooth = 0; bool low_fidelity = false; bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND)); - /*--- Array initialization ---*/ - Solution_Direct = NULL; - GradReconAllocated = false; - /*--- Initialization of heat variable ---*/ - Solution[0] = val_Heat; Solution_Old[0] = val_Heat; + + Solution = heat; + Solution_Old = heat; /*--- Allocate residual structures ---*/ - Res_TruncError = new su2double [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Res_TruncError[iVar] = 0.0; - } + Res_TruncError.resize(nPoint,nVar) = su2double(0.0); /*--- Only for residual smoothing (multigrid) ---*/ - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) - nMGSmooth += config->GetMG_CorrecSmooth(iMesh); - - if ((nMGSmooth > 0) || low_fidelity) { - Residual_Sum = new su2double [nVar]; - Residual_Old = new su2double [nVar]; + for (unsigned long iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + if ((config->GetMG_CorrecSmooth(iMesh) > 0) || low_fidelity) { + Residual_Sum.resize(nPoint,nVar); + Residual_Old.resize(nPoint,nVar); + break; + } } /*--- Allocate and initialize solution for dual time strategy ---*/ if (dual_time) { - Solution_time_n[0] = val_Heat; - Solution_time_n1[0] = val_Heat; - } - - if (config->GetKind_ConvNumScheme_Heat() == SPACE_CENTERED) { - Undivided_Laplacian = new su2double [nVar]; + Solution_time_n = heat; + Solution_time_n1 = heat; } + /*--- Gradient related fields ---*/ + Gradient.resize(nPoint,nVar,nDim,0.0); + if (config->GetReconstructionGradientRequired()) { - GradReconAllocated = true; - Gradient_Reconstruction = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Gradient_Reconstruction[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; - } + Gradient_Reconstruction.resize(nPoint,nVar,nDim,0.0); } else { Gradient_Reconstruction = Gradient; } + + if (config->GetLeastSquaresRequired()) { + Rmatrix.resize(nPoint,nDim,nDim,0.0); + } + + if (config->GetKind_ConvNumScheme_Heat() == SPACE_CENTERED) + Undivided_Laplacian.resize(nPoint,nVar); + + Max_Lambda_Inv.resize(nPoint); + Max_Lambda_Visc.resize(nPoint); + Delta_Time.resize(nPoint); if (config->GetMultizone_Problem()) Set_BGSSolution_k(); - -} - -CHeatFVMVariable::~CHeatFVMVariable(void) { - if (Solution_Direct != NULL) delete [] Solution_Direct; } diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index a627ca5c8234..4f07905fd4d0 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -37,339 +37,123 @@ #include "../../include/variables/CIncEulerVariable.hpp" -CIncEulerVariable::CIncEulerVariable(void) : CVariable() { - /*--- Array initialization ---*/ +CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, + unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { - Primitive = NULL; - Gradient_Primitive = NULL; - Gradient_Reconstruction = NULL; - GradReconAllocated = false; - Limiter_Primitive = NULL; - Grad_AuxVar = NULL; - - nPrimVar = 0; - nPrimVarGrad = 0; - - nSecondaryVar = 0; - nSecondaryVarGrad = 0; -} - -CIncEulerVariable::CIncEulerVariable(su2double val_pressure, su2double *val_velocity, su2double val_temperature, - unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : - CVariable(val_nDim, val_nvar, config) { - - unsigned short iVar, iDim, iMesh, nMGSmooth = 0; - - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); + bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || + (config->GetTime_Marching() == DT_STEPPING_2ND); bool viscous = config->GetViscous(); bool axisymmetric = config->GetAxisymmetric(); - /*--- Array initialization ---*/ - - Primitive = NULL; - Gradient_Primitive = NULL; - Gradient_Reconstruction = NULL; - GradReconAllocated = false; - Limiter_Primitive = NULL; - - Grad_AuxVar = NULL; - - nPrimVar = 0; - nPrimVarGrad = 0; - - nSecondaryVar = 0; - nSecondaryVarGrad = 0; - /*--- Allocate and initialize the primitive variables and gradients ---*/ nPrimVar = nDim+9; nPrimVarGrad = nDim+4; /*--- Allocate residual structures ---*/ - Res_TruncError = new su2double [nVar]; - - for (iVar = 0; iVar < nVar; iVar++) { - Res_TruncError[iVar] = 0.0; - } + Res_TruncError.resize(nPoint,nVar) = su2double(0.0); /*--- Only for residual smoothing (multigrid) ---*/ - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) - nMGSmooth += config->GetMG_CorrecSmooth(iMesh); - - if (nMGSmooth > 0) { - Residual_Sum = new su2double [nVar]; - Residual_Old = new su2double [nVar]; - } - - /*--- Allocate undivided laplacian (centered) and limiter (upwind)---*/ - - if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) { - Undivided_Laplacian = new su2double [nVar]; - } - - /*--- Always allocate the slope limiter, - and the auxiliar variables (check the logic - JST with 2nd order Turb model - ) ---*/ - - Limiter_Primitive = new su2double [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Limiter_Primitive[iVar] = 0.0; - - Limiter = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Limiter[iVar] = 0.0; - - Solution_Max = new su2double [nPrimVarGrad]; - Solution_Min = new su2double [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Solution_Max[iVar] = 0.0; - Solution_Min[iVar] = 0.0; - } - - /*--- Solution and old solution initialization ---*/ - - Solution[0] = val_pressure; - Solution_Old[0] = val_pressure; - for (iDim = 0; iDim < nDim; iDim++) { - Solution[iDim+1] = val_velocity[iDim]; - Solution_Old[iDim+1] = val_velocity[iDim]; - } - Solution[nDim+1] = val_temperature; - Solution_Old[nDim+1] = val_temperature; - - /*--- Allocate and initialize solution for dual time strategy ---*/ - - if (dual_time) { - Solution_time_n[0] = val_pressure; - Solution_time_n1[0] = val_pressure; - for (iDim = 0; iDim < nDim; iDim++) { - Solution_time_n[iDim+1] = val_velocity[iDim]; - Solution_time_n1[iDim+1] = val_velocity[iDim]; + for (unsigned long iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { + if (config->GetMG_CorrecSmooth(iMesh) > 0) { + Residual_Sum.resize(nPoint,nVar); + Residual_Old.resize(nPoint,nVar); + break; } - Solution[nDim+1] = val_temperature; - Solution_Old[nDim+1] = val_temperature; - } - - /*--- Incompressible flow, primitive variables nDim+9, (P, vx, vy, vz, T, rho, beta, lamMu, EddyMu, Kt_eff, Cp, Cv) ---*/ - - Primitive = new su2double [nPrimVar]; - for (iVar = 0; iVar < nPrimVar; iVar++) Primitive[iVar] = 0.0; - - /*--- Incompressible flow, gradients primitive variables nDim+4, (P, vx, vy, vz, T, rho, beta) - * We need P, and rho for running the adjoint problem ---*/ - - Gradient_Primitive = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Primitive[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Primitive[iVar][iDim] = 0.0; - } - - if (config->GetReconstructionGradientRequired()) { - GradReconAllocated = true; - Gradient_Reconstruction = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Reconstruction[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; - } - } else { - Gradient_Reconstruction = Gradient_Primitive; - } - - /*--- If axisymmetric and viscous, we need an auxiliary gradient. ---*/ - - if (axisymmetric && viscous) - Grad_AuxVar = new su2double[nDim]; - -} - -CIncEulerVariable::CIncEulerVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CVariable(val_nDim, val_nvar, config) { - - unsigned short iVar, iDim, iMesh, nMGSmooth = 0; - - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - bool viscous = config->GetViscous(); - bool axisymmetric = config->GetAxisymmetric(); - - /*--- Array initialization ---*/ - - Primitive = NULL; - Gradient_Primitive = NULL; - Gradient_Reconstruction = NULL; - GradReconAllocated = false; - Limiter_Primitive = NULL; - - Grad_AuxVar = NULL; - - nPrimVar = 0; - nPrimVarGrad = 0; - - nSecondaryVar = 0; - nSecondaryVarGrad = 0; - - /*--- Allocate and initialize the primitive variables and gradients ---*/ - - nPrimVar = nDim+9; nPrimVarGrad = nDim+4; - - /*--- Allocate residual structures ---*/ - - Res_TruncError = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Res_TruncError[iVar] = 0.0; - } - - /*--- Only for residual smoothing (multigrid) ---*/ - - for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) - nMGSmooth += config->GetMG_CorrecSmooth(iMesh); - - if (nMGSmooth > 0) { - Residual_Sum = new su2double [nVar]; - Residual_Old = new su2double [nVar]; } /*--- Allocate undivided laplacian (centered) and limiter (upwind)---*/ if (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED) - Undivided_Laplacian = new su2double [nVar]; + Undivided_Laplacian.resize(nPoint,nVar); /*--- Always allocate the slope limiter, and the auxiliar variables (check the logic - JST with 2nd order Turb model - ) ---*/ - Limiter_Primitive = new su2double [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Limiter_Primitive[iVar] = 0.0; + Limiter_Primitive.resize(nPoint,nPrimVarGrad) = su2double(0.0); - Limiter = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Limiter[iVar] = 0.0; + Limiter.resize(nPoint,nVar) = su2double(0.0); - Solution_Max = new su2double [nPrimVarGrad]; - Solution_Min = new su2double [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Solution_Max[iVar] = 0.0; - Solution_Min[iVar] = 0.0; - } + Solution_Max.resize(nPoint,nPrimVarGrad) = su2double(0.0); + Solution_Min.resize(nPoint,nPrimVarGrad) = su2double(0.0); /*--- Solution initialization ---*/ - for (iVar = 0; iVar < nVar; iVar++) { - Solution[iVar] = val_solution[iVar]; - Solution_Old[iVar] = val_solution[iVar]; - } + su2double val_solution[5] = {pressure, velocity[0], velocity[1], temperature, temperature}; + if(nDim==3) val_solution[3] = velocity[2]; + + for(unsigned long iPoint=0; iPointGetReconstructionGradientRequired()) { - GradReconAllocated = true; - Gradient_Reconstruction = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) { - Gradient_Reconstruction[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; - } + Gradient_Reconstruction.resize(nPoint,nPrimVarGrad,nDim,0.0); } else { Gradient_Reconstruction = Gradient_Primitive; } + if (config->GetLeastSquaresRequired()) { + Rmatrix.resize(nPoint,nDim,nDim,0.0); + } + /*--- If axisymmetric and viscous, we need an auxiliary gradient. ---*/ - - if (axisymmetric && viscous) - Grad_AuxVar = new su2double[nDim]; + + if (axisymmetric && viscous) Grad_AuxVar.resize(nPoint,nDim); if (config->GetMultizone_Problem()) Set_BGSSolution_k(); - -} -CIncEulerVariable::~CIncEulerVariable(void) { - unsigned short iVar; - - if (Primitive != NULL) delete [] Primitive; - if (Limiter_Primitive != NULL) delete [] Limiter_Primitive; - - if (Gradient_Primitive != NULL) { - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - if (Gradient_Primitive!=NULL) delete [] Gradient_Primitive[iVar]; - delete [] Gradient_Primitive; - } - - if (GradReconAllocated) { - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - if (Gradient_Reconstruction!=NULL) delete [] Gradient_Reconstruction[iVar]; - delete [] Gradient_Reconstruction; - } + Density_Old.resize(nPoint) = su2double(0.0); + Velocity2.resize(nPoint) = su2double(0.0); + Max_Lambda_Inv.resize(nPoint) = su2double(0.0); + Delta_Time.resize(nPoint) = su2double(0.0); + Lambda.resize(nPoint) = su2double(0.0); + Sensor.resize(nPoint) = su2double(0.0); } -void CIncEulerVariable::SetGradient_PrimitiveZero(unsigned short val_primvar) { - unsigned short iVar, iDim; - - for (iVar = 0; iVar < val_primvar; iVar++) - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Primitive[iVar][iDim] = 0.0; -} - - -su2double CIncEulerVariable::GetProjVel(su2double *val_vector) { - su2double ProjVel; - unsigned short iDim; - - ProjVel = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - ProjVel += Primitive[iDim+1]*val_vector[iDim]; - - return ProjVel; +void CIncEulerVariable::SetGradient_PrimitiveZero() { + Gradient_Primitive.storage.setConstant(0.0); } -bool CIncEulerVariable::SetPrimVar(CFluidModel *FluidModel) { +bool CIncEulerVariable::SetPrimVar(unsigned long iPoint, CFluidModel *FluidModel) { - unsigned short iVar; + unsigned long iVar; bool check_dens = false, check_temp = false, physical = true; /*--- Store the density from the previous iteration. ---*/ - Density_Old = GetDensity(); + Density_Old(iPoint) = GetDensity(iPoint); /*--- Set the value of the pressure ---*/ - SetPressure(); + SetPressure(iPoint); /*--- Set the value of the temperature directly ---*/ - su2double Temperature = Solution[nDim+1]; - check_temp = SetTemperature(Temperature); + su2double Temperature = Solution(iPoint,nDim+1); + check_temp = SetTemperature(iPoint,Temperature); /*--- Use the fluid model to compute the new value of density. Note that the thermodynamic pressure is constant and decoupled @@ -381,7 +165,7 @@ bool CIncEulerVariable::SetPrimVar(CFluidModel *FluidModel) { /*--- Set the value of the density ---*/ - check_dens = SetDensity(FluidModel->GetDensity()); + check_dens = SetDensity(iPoint, FluidModel->GetDensity()); /*--- Non-physical solution found. Revert to old values. ---*/ @@ -390,14 +174,14 @@ bool CIncEulerVariable::SetPrimVar(CFluidModel *FluidModel) { /*--- Copy the old solution ---*/ for (iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = Solution_Old[iVar]; + Solution(iPoint, iVar) = Solution_Old(iPoint, iVar); /*--- Recompute the primitive variables ---*/ - Temperature = Solution[nDim+1]; - SetTemperature(Temperature); + Temperature = Solution(iPoint, nDim+1); + SetTemperature(iPoint, Temperature); FluidModel->SetTDState_T(Temperature); - SetDensity(FluidModel->GetDensity()); + SetDensity(iPoint, FluidModel->GetDensity()); /*--- Flag this point as non-physical. ---*/ @@ -407,12 +191,12 @@ bool CIncEulerVariable::SetPrimVar(CFluidModel *FluidModel) { /*--- Set the value of the velocity and velocity^2 (requires density) ---*/ - SetVelocity(); + SetVelocity(iPoint); /*--- Set specific heats (only necessary for consistency with preconditioning). ---*/ - SetSpecificHeatCp(FluidModel->GetCp()); - SetSpecificHeatCv(FluidModel->GetCv()); + SetSpecificHeatCp(iPoint, FluidModel->GetCp()); + SetSpecificHeatCv(iPoint, FluidModel->GetCv()); return physical; diff --git a/SU2_CFD/src/variables/CIncNSVariable.cpp b/SU2_CFD/src/variables/CIncNSVariable.cpp index 9f7be562914b..501a67559f92 100644 --- a/SU2_CFD/src/variables/CIncNSVariable.cpp +++ b/SU2_CFD/src/variables/CIncNSVariable.cpp @@ -38,96 +38,85 @@ #include "../../include/variables/CIncNSVariable.hpp" -CIncNSVariable::CIncNSVariable(void) : CIncEulerVariable() { } - -CIncNSVariable::CIncNSVariable(su2double val_pressure, su2double *val_velocity, su2double val_temperature, - unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : - CIncEulerVariable(val_pressure, val_velocity, val_temperature, val_nDim, val_nvar, config) { - DES_LengthScale = 0.0; +CIncNSVariable::CIncNSVariable(su2double pressure, const su2double *velocity, su2double temperature, + unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) : + CIncEulerVariable(pressure, velocity, temperature, npoint, ndim, nvar, config) { + Vorticity.resize(nPoint,3); + StrainMag.resize(nPoint); + DES_LengthScale.resize(nPoint) = su2double(0.0); + Max_Lambda_Visc.resize(nPoint); } -CIncNSVariable::CIncNSVariable(su2double *val_solution, unsigned short val_nDim, unsigned short val_nvar, - CConfig *config) : CIncEulerVariable(val_solution, val_nDim, val_nvar, config) { - DES_LengthScale = 0.0; -} +bool CIncNSVariable::SetVorticity_StrainMag() { -CIncNSVariable::~CIncNSVariable(void) { } + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { -bool CIncNSVariable::SetVorticity(void) { + /*--- Vorticity ---*/ - Vorticity[0] = 0.0; Vorticity[1] = 0.0; + Vorticity(iPoint,0) = 0.0; Vorticity(iPoint,1) = 0.0; - Vorticity[2] = Gradient_Primitive[2][0]-Gradient_Primitive[1][1]; + Vorticity(iPoint,2) = Gradient_Primitive(iPoint,2,0)-Gradient_Primitive(iPoint,1,1); - if (nDim == 3) { - Vorticity[0] = Gradient_Primitive[3][1]-Gradient_Primitive[2][2]; - Vorticity[1] = -(Gradient_Primitive[3][0]-Gradient_Primitive[1][2]); - } + if (nDim == 3) { + Vorticity(iPoint,0) = Gradient_Primitive(iPoint,3,1)-Gradient_Primitive(iPoint,2,2); + Vorticity(iPoint,1) = -(Gradient_Primitive(iPoint,3,0)-Gradient_Primitive(iPoint,1,2)); + } - return false; + /*--- Strain Magnitude ---*/ -} + AD::StartPreacc(); + AD::SetPreaccIn(Gradient_Primitive[iPoint], nDim+1, nDim); -bool CIncNSVariable::SetStrainMag(void) { + su2double Div = 0.0; + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Div += Gradient_Primitive(iPoint,iDim+1,iDim); - su2double Div; - unsigned short iDim; + StrainMag(iPoint) = 0.0; - AD::StartPreacc(); - AD::SetPreaccIn(Gradient_Primitive, nDim+1, nDim); + /*--- Add diagonal part ---*/ - Div = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Div += Gradient_Primitive[iDim+1][iDim]; - } + for (unsigned long iDim = 0; iDim < nDim; iDim++) { + StrainMag(iPoint) += pow(Gradient_Primitive(iPoint,iDim+1,iDim) - 1.0/3.0*Div, 2.0); + } + if (nDim == 2) { + StrainMag(iPoint) += pow(1.0/3.0*Div, 2.0); + } - StrainMag = 0.0; + /*--- Add off diagonals ---*/ - /*--- Add diagonal part ---*/ + StrainMag(iPoint) += 2.0*pow(0.5*(Gradient_Primitive(iPoint,1,1) + Gradient_Primitive(iPoint,2,0)), 2); - for (iDim = 0; iDim < nDim; iDim++) { - StrainMag += pow(Gradient_Primitive[iDim+1][iDim] - 1.0/3.0*Div, 2.0); - } - if (nDim == 2) { - StrainMag += pow(1.0/3.0*Div, 2.0); - } - - /*--- Add off diagonals ---*/ + if (nDim == 3) { + StrainMag(iPoint) += 2.0*pow(0.5*(Gradient_Primitive(iPoint,1,2) + Gradient_Primitive(iPoint,3,0)), 2); + StrainMag(iPoint) += 2.0*pow(0.5*(Gradient_Primitive(iPoint,2,2) + Gradient_Primitive(iPoint,3,1)), 2); + } - StrainMag += 2.0*pow(0.5*(Gradient_Primitive[1][1] + Gradient_Primitive[2][0]), 2.0); + StrainMag(iPoint) = sqrt(2.0*StrainMag(iPoint)); - if (nDim == 3) { - StrainMag += 2.0*pow(0.5*(Gradient_Primitive[1][2] + Gradient_Primitive[3][0]), 2.0); - StrainMag += 2.0*pow(0.5*(Gradient_Primitive[2][2] + Gradient_Primitive[3][1]), 2.0); + AD::SetPreaccOut(StrainMag(iPoint)); + AD::EndPreacc(); } - - StrainMag = sqrt(2.0*StrainMag); - - AD::SetPreaccOut(StrainMag); - AD::EndPreacc(); - return false; - } -bool CIncNSVariable::SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel) { +bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel) { unsigned short iVar; bool check_dens = false, check_temp = false, physical = true; /*--- Store the density from the previous iteration. ---*/ - Density_Old = GetDensity(); + Density_Old(iPoint) = GetDensity(iPoint); /*--- Set the value of the pressure ---*/ - SetPressure(); + SetPressure(iPoint); /*--- Set the value of the temperature directly ---*/ - su2double Temperature = Solution[nDim+1]; - check_temp = SetTemperature(Temperature); + su2double Temperature = Solution(iPoint,nDim+1); + check_temp = SetTemperature(iPoint,Temperature); /*--- Use the fluid model to compute the new value of density. Note that the thermodynamic pressure is constant and decoupled @@ -139,7 +128,7 @@ bool CIncNSVariable::SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidMo /*--- Set the value of the density ---*/ - check_dens = SetDensity(FluidModel->GetDensity()); + check_dens = SetDensity(iPoint, FluidModel->GetDensity()); /*--- Non-physical solution found. Revert to old values. ---*/ @@ -148,14 +137,14 @@ bool CIncNSVariable::SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidMo /*--- Copy the old solution ---*/ for (iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = Solution_Old[iVar]; + Solution(iPoint,iVar) = Solution_Old(iPoint,iVar); /*--- Recompute the primitive variables ---*/ - Temperature = Solution[nDim+1]; - SetTemperature(Temperature); + Temperature = Solution(iPoint,nDim+1); + SetTemperature(iPoint, Temperature); FluidModel->SetTDState_T(Temperature); - SetDensity(FluidModel->GetDensity()); + SetDensity(iPoint, FluidModel->GetDensity()); /*--- Flag this point as non-physical. ---*/ @@ -165,25 +154,25 @@ bool CIncNSVariable::SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidMo /*--- Set the value of the velocity and velocity^2 (requires density) ---*/ - SetVelocity(); + SetVelocity(iPoint); /*--- Set laminar viscosity ---*/ - SetLaminarViscosity(FluidModel->GetLaminarViscosity()); + SetLaminarViscosity(iPoint, FluidModel->GetLaminarViscosity()); /*--- Set eddy viscosity locally and in the fluid model. ---*/ - SetEddyViscosity(eddy_visc); + SetEddyViscosity(iPoint, eddy_visc); FluidModel->SetEddyViscosity(eddy_visc); /*--- Set thermal conductivity (effective value if RANS). ---*/ - SetThermalConductivity(FluidModel->GetThermalConductivity()); + SetThermalConductivity(iPoint, FluidModel->GetThermalConductivity()); /*--- Set specific heats ---*/ - SetSpecificHeatCp(FluidModel->GetCp()); - SetSpecificHeatCv(FluidModel->GetCv()); + SetSpecificHeatCp(iPoint, FluidModel->GetCp()); + SetSpecificHeatCv(iPoint, FluidModel->GetCv()); return physical; diff --git a/SU2_CFD/src/variables/CMeshBoundVariable.cpp b/SU2_CFD/src/variables/CMeshBoundVariable.cpp index f3d4adc2eaba..d31f0475a60c 100644 --- a/SU2_CFD/src/variables/CMeshBoundVariable.cpp +++ b/SU2_CFD/src/variables/CMeshBoundVariable.cpp @@ -37,20 +37,34 @@ #include "../../include/variables/CMeshBoundVariable.hpp" -CMeshBoundVariable::CMeshBoundVariable(su2double *val_coor, unsigned short val_nDim, CConfig *config) : CMeshVariable(val_coor, val_nDim, config) { +CMeshBoundVariable::CMeshBoundVariable(unsigned long npoint, unsigned long ndim, CConfig *config) : + CMeshVariable(npoint, ndim, config) { - unsigned short iDim; + VertexMap.Reset(nPoint); +} - /*--- Initialize Boundary Displacement container to 0.0 ---*/ - Boundary_Displacement = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++){ - Boundary_Displacement[iDim] = 0.0; - } +void CMeshBoundVariable::AllocateBoundaryVariables(CConfig *config) { -} + if (VertexMap.GetIsValid()) return; // nothing to do + + /*--- Count number of vertices and build map ---*/ -CMeshBoundVariable::~CMeshBoundVariable(void) { + unsigned long nBoundPt = VertexMap.Build(); - if (Boundary_Displacement != NULL) delete [] Boundary_Displacement; + /*--- Allocate ---*/ + Boundary_Displacement.resize(nBoundPt,nDim) = su2double(0.0); +} + +void CMeshBoundVariable::Register_BoundDisp(bool input) { + if (input) { + for (unsigned long iVertex = 0; iVertex < Boundary_Displacement.rows(); iVertex++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterInput(Boundary_Displacement(iVertex,iVar)); + } + else { + for (unsigned long iVertex = 0; iVertex < Boundary_Displacement.rows(); iVertex++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterOutput(Boundary_Displacement(iVertex,iVar)); + } } diff --git a/SU2_CFD/src/variables/CMeshElement.cpp b/SU2_CFD/src/variables/CMeshElement.cpp index 2004473ab684..2e9654d65475 100644 --- a/SU2_CFD/src/variables/CMeshElement.cpp +++ b/SU2_CFD/src/variables/CMeshElement.cpp @@ -45,7 +45,3 @@ CMeshElement::CMeshElement(void){ WallDistance = 0.0; /*!< \brief Store the reference distance to the nearest wall of the element. */ } - -CMeshElement::~CMeshElement(void){ - -} diff --git a/SU2_CFD/src/variables/CMeshVariable.cpp b/SU2_CFD/src/variables/CMeshVariable.cpp index f5581ea2a0e4..e6c13d9c09d8 100644 --- a/SU2_CFD/src/variables/CMeshVariable.cpp +++ b/SU2_CFD/src/variables/CMeshVariable.cpp @@ -37,54 +37,35 @@ #include "../../include/variables/CMeshVariable.hpp" -CMeshVariable::CMeshVariable(const su2double *val_coor, unsigned short val_nDim, CConfig *config) : CVariable(val_nDim, config) { - - unsigned short iDim; - - /*--- Initialize pointers to NULL ---*/ - Mesh_Coord = nullptr; - - Solution_Old = nullptr; - - Solution_time_n = nullptr; - Solution_time_n1 = nullptr; +CMeshVariable::CMeshVariable(unsigned long npoint, unsigned long ndim, CConfig *config) : + CVariable(npoint, ndim, config) { /*--- Booleans that determine the kind of problems ---*/ bool time_domain = config->GetTime_Domain(); - bool multizone = config->GetMultizone_Problem(); /*--- Store the dimensionality of the problem ---*/ - nDim = val_nDim; + nDim = ndim; /*--- Initalize the variables that will always be there in a problem with moving mesh ---*/ - Mesh_Coord = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++){ - Mesh_Coord[iDim] = val_coor[iDim]; - } - - /*--- Initialize the variables necessary when the problem is multizone ---*/ - if (multizone){ - Solution_Old = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim++){ - Solution_Old[iDim] = 0.0; - } - } + Mesh_Coord.resize(nPoint,nDim) = su2double(0.0); + WallDistance.resize(nPoint) = su2double(1e-9); /*--- Initialize the variables necessary when the problem is time domain ---*/ - if (time_domain){ - Solution_time_n = new su2double [nDim]; - Solution_time_n1 = new su2double [nDim]; - - for (iDim = 0; iDim < nDim; iDim++){ - Solution_time_n[iDim] = 0.0; - Solution_time_n1[iDim] = 0.0; - } + if (time_domain) { + Solution_time_n.resize(nPoint,nDim) = su2double(0.0); + Solution_time_n1.resize(nPoint,nDim) = su2double(0.0); } - } -CMeshVariable::~CMeshVariable(void) { - - if (Mesh_Coord != nullptr) delete [] Mesh_Coord; - +void CMeshVariable::Register_MeshCoord(bool input) { + if (input) { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iDim = 0; iDim < nDim; iDim++) + AD::RegisterInput(Mesh_Coord(iPoint,iDim)); + } + else { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iDim = 0; iDim < nDim; iDim++) + AD::RegisterOutput(Mesh_Coord(iPoint,iDim)); + } } diff --git a/SU2_CFD/src/variables/CNSVariable.cpp b/SU2_CFD/src/variables/CNSVariable.cpp index ebb28eb3b39c..635eff013ae0 100644 --- a/SU2_CFD/src/variables/CNSVariable.cpp +++ b/SU2_CFD/src/variables/CNSVariable.cpp @@ -38,102 +38,75 @@ #include "../../include/variables/CNSVariable.hpp" -CNSVariable::CNSVariable(void) : CEulerVariable() { } - -CNSVariable::CNSVariable(su2double val_density, su2double *val_velocity, su2double val_energy, - unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : - CEulerVariable(val_density, val_velocity, val_energy, val_nDim, val_nvar, config) { - - Temperature_Ref = config->GetTemperature_Ref(); - Viscosity_Ref = config->GetViscosity_Ref(); - Viscosity_Inf = config->GetViscosity_FreeStreamND(); - Prandtl_Lam = config->GetPrandtl_Lam(); - Prandtl_Turb = config->GetPrandtl_Turb(); - - inv_TimeScale = config->GetModVel_FreeStream() / config->GetRefLength(); - Roe_Dissipation = 0.0; - Vortex_Tilting = 0.0; - Tau_Wall = -1.0; - -} - -CNSVariable::CNSVariable(su2double *val_solution, unsigned short val_nDim, - unsigned short val_nvar, CConfig *config) : - CEulerVariable(val_solution, val_nDim, val_nvar, config) { - - Temperature_Ref = config->GetTemperature_Ref(); - Viscosity_Ref = config->GetViscosity_Ref(); - Viscosity_Inf = config->GetViscosity_FreeStreamND(); - Prandtl_Lam = config->GetPrandtl_Lam(); - Prandtl_Turb = config->GetPrandtl_Turb(); - - inv_TimeScale = config->GetModVel_FreeStream() / config->GetRefLength(); - Roe_Dissipation = 0.0; - Vortex_Tilting = 0.0; - Tau_Wall = -1.0; - +CNSVariable::CNSVariable(su2double density, const su2double *velocity, su2double energy, + unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) : + CEulerVariable(density,velocity,energy,npoint,ndim,nvar,config) { + + inv_TimeScale = config->GetModVel_FreeStream() / config->GetRefLength(); + + Vorticity.resize(nPoint,3) = su2double(0.0); + StrainMag.resize(nPoint) = su2double(0.0); + Tau_Wall.resize(nPoint) = su2double(-1.0); + DES_LengthScale.resize(nPoint) = su2double(0.0); + Roe_Dissipation.resize(nPoint) = su2double(0.0); + Vortex_Tilting.resize(nPoint) = su2double(0.0); + Max_Lambda_Visc.resize(nPoint) = su2double(0.0); } -CNSVariable::~CNSVariable(void) { } +bool CNSVariable::SetVorticity_StrainMag() { -bool CNSVariable::SetVorticity(void) { + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - Vorticity[0] = 0.0; Vorticity[1] = 0.0; + /*--- Vorticity ---*/ - Vorticity[2] = Gradient_Primitive[2][0]-Gradient_Primitive[1][1]; + Vorticity(iPoint,0) = 0.0; Vorticity(iPoint,1) = 0.0; - if (nDim == 3) { - Vorticity[0] = Gradient_Primitive[3][1]-Gradient_Primitive[2][2]; - Vorticity[1] = -(Gradient_Primitive[3][0]-Gradient_Primitive[1][2]); - } + Vorticity(iPoint,2) = Gradient_Primitive(iPoint,2,0)-Gradient_Primitive(iPoint,1,1); - return false; + if (nDim == 3) { + Vorticity(iPoint,0) = Gradient_Primitive(iPoint,3,1)-Gradient_Primitive(iPoint,2,2); + Vorticity(iPoint,1) = -(Gradient_Primitive(iPoint,3,0)-Gradient_Primitive(iPoint,1,2)); + } -} + /*--- Strain Magnitude ---*/ -bool CNSVariable::SetStrainMag(void) { + AD::StartPreacc(); + AD::SetPreaccIn(Gradient_Primitive[iPoint], nDim+1, nDim); - su2double Div; - unsigned short iDim; + su2double Div = 0.0; + for (unsigned long iDim = 0; iDim < nDim; iDim++) + Div += Gradient_Primitive(iPoint,iDim+1,iDim); - AD::StartPreacc(); - AD::SetPreaccIn(Gradient_Primitive, nDim+1, nDim); + StrainMag(iPoint) = 0.0; - Div = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - Div += Gradient_Primitive[iDim+1][iDim]; - } + /*--- Add diagonal part ---*/ - StrainMag = 0.0; + for (unsigned long iDim = 0; iDim < nDim; iDim++) { + StrainMag(iPoint) += pow(Gradient_Primitive(iPoint,iDim+1,iDim) - 1.0/3.0*Div, 2.0); + } + if (nDim == 2) { + StrainMag(iPoint) += pow(1.0/3.0*Div, 2.0); + } - /*--- Add diagonal part ---*/ + /*--- Add off diagonals ---*/ - for (iDim = 0; iDim < nDim; iDim++) { - StrainMag += pow(Gradient_Primitive[iDim+1][iDim] - 1.0/3.0*Div, 2.0); - } - if (nDim == 2) { - StrainMag += pow(1.0/3.0*Div, 2.0); - } + StrainMag(iPoint) += 2.0*pow(0.5*(Gradient_Primitive(iPoint,1,1) + Gradient_Primitive(iPoint,2,0)), 2); - /*--- Add off diagonals ---*/ + if (nDim == 3) { + StrainMag(iPoint) += 2.0*pow(0.5*(Gradient_Primitive(iPoint,1,2) + Gradient_Primitive(iPoint,3,0)), 2); + StrainMag(iPoint) += 2.0*pow(0.5*(Gradient_Primitive(iPoint,2,2) + Gradient_Primitive(iPoint,3,1)), 2); + } - StrainMag += 2.0*pow(0.5*(Gradient_Primitive[1][1] + Gradient_Primitive[2][0]), 2.0); + StrainMag(iPoint) = sqrt(2.0*StrainMag(iPoint)); - if (nDim == 3) { - StrainMag += 2.0*pow(0.5*(Gradient_Primitive[1][2] + Gradient_Primitive[3][0]), 2.0); - StrainMag += 2.0*pow(0.5*(Gradient_Primitive[2][2] + Gradient_Primitive[3][1]), 2.0); + AD::SetPreaccOut(StrainMag(iPoint)); + AD::EndPreacc(); } - - StrainMag = sqrt(2.0*StrainMag); - - AD::SetPreaccOut(StrainMag); - AD::EndPreacc(); - return false; - } -void CNSVariable::SetRoe_Dissipation_NTS(su2double val_delta, +void CNSVariable::SetRoe_Dissipation_NTS(unsigned long iPoint, + su2double val_delta, su2double val_const_DES){ static const su2double cnu = pow(0.09, 1.5), @@ -142,20 +115,20 @@ void CNSVariable::SetRoe_Dissipation_NTS(su2double val_delta, ch3 = 2.0, sigma_max = 1.0; - unsigned short iDim; - su2double Omega, Omega_2 = 0, Baux, Gaux, Lturb, Kaux, Aaux; + unsigned long iDim; + su2double Omega, Omega_2 = 0.0, Baux, Gaux, Lturb, Kaux, Aaux; AD::StartPreacc(); - AD::SetPreaccIn(Vorticity, 3); - AD::SetPreaccIn(StrainMag); + AD::SetPreaccIn(Vorticity[iPoint], 3); + AD::SetPreaccIn(StrainMag(iPoint)); AD::SetPreaccIn(val_delta); AD::SetPreaccIn(val_const_DES); /*--- Density ---*/ - AD::SetPreaccIn(Solution[0]); + AD::SetPreaccIn(Solution(iPoint,0)); /*--- Laminar viscosity --- */ - AD::SetPreaccIn(Primitive[nDim+5]); + AD::SetPreaccIn(Primitive(iPoint,nDim+5)); /*--- Eddy viscosity ---*/ - AD::SetPreaccIn(Primitive[nDim+6]); + AD::SetPreaccIn(Primitive(iPoint,nDim+6)); /*--- Central/upwind blending based on: * Zhixiang Xiao, Jian Liu, Jingbo Huang, and Song Fu. "Numerical @@ -165,86 +138,77 @@ void CNSVariable::SetRoe_Dissipation_NTS(su2double val_delta, * ---*/ for (iDim = 0; iDim < 3; iDim++){ - Omega_2 += Vorticity[iDim]*Vorticity[iDim]; + Omega_2 += pow(Vorticity(iPoint,iDim),2); } Omega = sqrt(Omega_2); - Baux = (ch3 * Omega * max(StrainMag, Omega)) / - max((pow(StrainMag,2)+Omega_2)*0.5, 1E-20); + Baux = (ch3 * Omega * max(StrainMag(iPoint), Omega)) / + max((pow(StrainMag(iPoint),2)+Omega_2)*0.5, 1E-20); Gaux = tanh(pow(Baux,4.0)); - Kaux = max(sqrt((Omega_2 + pow(StrainMag, 2))*0.5), 0.1 * inv_TimeScale); + Kaux = max(sqrt((Omega_2 + pow(StrainMag(iPoint), 2))*0.5), 0.1 * inv_TimeScale); - const su2double nu = GetLaminarViscosity()/GetDensity(); - const su2double nu_t = GetEddyViscosity()/GetDensity(); + const su2double nu = GetLaminarViscosity(iPoint)/GetDensity(iPoint); + const su2double nu_t = GetEddyViscosity(iPoint)/GetDensity(iPoint); Lturb = sqrt((nu + nu_t)/(cnu*Kaux)); Aaux = ch2*max((val_const_DES*val_delta/Lturb)/Gaux - 0.5, 0.0); - Roe_Dissipation = sigma_max * tanh(pow(Aaux, ch1)); + Roe_Dissipation(iPoint) = sigma_max * tanh(pow(Aaux, ch1)); - AD::SetPreaccOut(Roe_Dissipation); + AD::SetPreaccOut(Roe_Dissipation(iPoint)); AD::EndPreacc(); } -void CNSVariable::SetRoe_Dissipation_FD(su2double val_wall_dist){ +void CNSVariable::SetRoe_Dissipation_FD(unsigned long iPoint, su2double val_wall_dist){ /*--- Constants for Roe Dissipation ---*/ - static const su2double k2 = pow(0.41,2.0); - - su2double uijuij = 0; - unsigned short iDim, jDim; + const passivedouble k2 = pow(0.41,2.0); AD::StartPreacc(); - AD::SetPreaccIn(Gradient_Primitive, nVar, nDim); + AD::SetPreaccIn(Gradient_Primitive[iPoint], nVar, nDim); AD::SetPreaccIn(val_wall_dist); /*--- Eddy viscosity ---*/ - AD::SetPreaccIn(Primitive[nDim+5]); + AD::SetPreaccIn(Primitive(iPoint,nDim+5)); /*--- Laminar viscosity --- */ - AD::SetPreaccIn(Primitive[nDim+6]); + AD::SetPreaccIn(Primitive(iPoint,nDim+6)); - for(iDim=0;iDimSetTDState_rhoe(density, staticEnergy); - check_dens = SetDensity(); - check_press = SetPressure(FluidModel->GetPressure()); - check_sos = SetSoundSpeed(FluidModel->GetSoundSpeed2()); - check_temp = SetTemperature(FluidModel->GetTemperature()); + bool check_dens = SetDensity(iPoint); + bool check_press = SetPressure(iPoint, FluidModel->GetPressure()); + bool check_sos = SetSoundSpeed(iPoint, FluidModel->GetSoundSpeed2()); + bool check_temp = SetTemperature(iPoint, FluidModel->GetTemperature()); /*--- Check that the solution has a physical meaning ---*/ @@ -252,23 +216,23 @@ bool CNSVariable::SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidModel /*--- Copy the old solution ---*/ - for (iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = Solution_Old[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution(iPoint,iVar) = Solution_Old(iPoint,iVar); /*--- Recompute the primitive variables ---*/ - SetVelocity(); // Computes velocity and velocity^2 - density = GetDensity(); - staticEnergy = GetEnergy()-0.5*Velocity2 - turb_ke; + SetVelocity(iPoint); // Computes velocity and velocity^2 + density = GetDensity(iPoint); + staticEnergy = GetEnergy(iPoint)-0.5*Velocity2(iPoint) - turb_ke; /*--- Check will be moved inside fluid model plus error description strings ---*/ FluidModel->SetTDState_rhoe(density, staticEnergy); - SetDensity(); - SetPressure(FluidModel->GetPressure()); - SetSoundSpeed(FluidModel->GetSoundSpeed2()); - SetTemperature(FluidModel->GetTemperature()); + SetDensity(iPoint); + SetPressure(iPoint, FluidModel->GetPressure()); + SetSoundSpeed(iPoint, FluidModel->GetSoundSpeed2()); + SetTemperature(iPoint, FluidModel->GetTemperature()); RightVol = false; @@ -276,45 +240,44 @@ bool CNSVariable::SetPrimVar(su2double eddy_visc, su2double turb_ke, CFluidModel /*--- Set enthalpy ---*/ - SetEnthalpy(); // Requires pressure computation. + SetEnthalpy(iPoint); // Requires pressure computation. /*--- Set laminar viscosity ---*/ - SetLaminarViscosity(FluidModel->GetLaminarViscosity()); + SetLaminarViscosity(iPoint, FluidModel->GetLaminarViscosity()); /*--- Set eddy viscosity ---*/ - SetEddyViscosity(eddy_visc); + SetEddyViscosity(iPoint, eddy_visc); /*--- Set thermal conductivity ---*/ - SetThermalConductivity(FluidModel->GetThermalConductivity()); + SetThermalConductivity(iPoint, FluidModel->GetThermalConductivity()); /*--- Set specific heat ---*/ - SetSpecificHeatCp(FluidModel->GetCp()); + SetSpecificHeatCp(iPoint, FluidModel->GetCp()); return RightVol; - } -void CNSVariable::SetSecondaryVar(CFluidModel *FluidModel) { +void CNSVariable::SetSecondaryVar(unsigned long iPoint, CFluidModel *FluidModel) { /*--- Compute secondary thermodynamic properties (partial derivatives...) ---*/ - SetdPdrho_e( FluidModel->GetdPdrho_e() ); - SetdPde_rho( FluidModel->GetdPde_rho() ); + SetdPdrho_e( iPoint, FluidModel->GetdPdrho_e() ); + SetdPde_rho( iPoint, FluidModel->GetdPde_rho() ); - SetdTdrho_e( FluidModel->GetdTdrho_e() ); - SetdTde_rho( FluidModel->GetdTde_rho() ); + SetdTdrho_e( iPoint, FluidModel->GetdTdrho_e() ); + SetdTde_rho( iPoint, FluidModel->GetdTde_rho() ); /*--- Compute secondary thermo-physical properties (partial derivatives...) ---*/ - Setdmudrho_T( FluidModel->Getdmudrho_T() ); - SetdmudT_rho( FluidModel->GetdmudT_rho() ); + Setdmudrho_T( iPoint, FluidModel->Getdmudrho_T() ); + SetdmudT_rho( iPoint, FluidModel->GetdmudT_rho() ); - Setdktdrho_T( FluidModel->Getdktdrho_T() ); - SetdktdT_rho( FluidModel->GetdktdT_rho() ); + Setdktdrho_T( iPoint, FluidModel->Getdktdrho_T() ); + SetdktdT_rho( iPoint, FluidModel->GetdktdT_rho() ); } diff --git a/SU2_CFD/src/variables/CTransLMVariable.cpp b/SU2_CFD/src/variables/CTransLMVariable.cpp index e2ed54b47016..03a7d19ace45 100644 --- a/SU2_CFD/src/variables/CTransLMVariable.cpp +++ b/SU2_CFD/src/variables/CTransLMVariable.cpp @@ -37,17 +37,18 @@ #include "../../include/variables/CTransLMVariable.hpp" -CTransLMVariable::CTransLMVariable(void) : CTurbVariable() {} -CTransLMVariable::CTransLMVariable(su2double val_nu_tilde, su2double val_intermittency, su2double val_REth, - unsigned short val_nDim, unsigned short val_nvar, CConfig *config) : - CTurbVariable(val_nDim, val_nvar, config) { - // Initialization of variables - Solution[0] = val_intermittency; Solution_Old[0] = val_intermittency; - Solution[1] = val_REth; Solution_Old[1] = val_REth; +CTransLMVariable::CTransLMVariable(su2double intermittency, su2double REth, unsigned long npoint, unsigned long ndim, + unsigned long nvar, CConfig *config) : CTurbVariable(npoint, ndim, nvar, config) { + + for(unsigned long iPoint=0; iPointGetMultizone_Problem()) Set_BGSSolution_k(); -} -CTransLMVariable::~CTransLMVariable(void) { } + gamma_sep.resize(nPoint); +} diff --git a/SU2_CFD/src/variables/CTurbSAVariable.cpp b/SU2_CFD/src/variables/CTurbSAVariable.cpp index cb8a897c1fc8..7b519f7a543b 100644 --- a/SU2_CFD/src/variables/CTurbSAVariable.cpp +++ b/SU2_CFD/src/variables/CTurbSAVariable.cpp @@ -38,31 +38,29 @@ #include "../../include/variables/CTurbSAVariable.hpp" -CTurbSAVariable::CTurbSAVariable(void) : CTurbVariable() { } +CTurbSAVariable::CTurbSAVariable(su2double val_nu_tilde, su2double val_muT, unsigned long npoint, unsigned long ndim, unsigned long nvar, + CConfig *config) : CTurbVariable(npoint, ndim, nvar, config) { -CTurbSAVariable::CTurbSAVariable(su2double val_nu_tilde, su2double val_muT, unsigned short val_nDim, - unsigned short val_nvar, CConfig *config) : CTurbVariable(val_nDim, val_nvar, config) { + Solution_Old = Solution = val_nu_tilde; + muT.resize(nPoint) = val_muT; + + /*--- Allocate and initialize solution for the dual time strategy ---*/ bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND)); - /*--- Initialization of S-A variables ---*/ - Solution[0] = val_nu_tilde; Solution_Old[0] = val_nu_tilde; - - /*--- Initialization of the eddy viscosity ---*/ - muT = val_muT; - - /*--- Allocate and initialize solution for the dual time strategy ---*/ if (dual_time) { - Solution_time_n[0] = val_nu_tilde; - Solution_time_n1[0] = val_nu_tilde; + Solution_time_n = Solution; + Solution_time_n1 = Solution; } - DES_LengthScale = 0.0; - + gamma_BC.resize(nPoint); + DES_LengthScale.resize(nPoint) = su2double(0.0); + Vortex_Tilting.resize(nPoint); } -void CTurbSAVariable::SetVortex_Tilting(su2double **PrimGrad_Flow, su2double* Vorticity, su2double LaminarViscosity){ +void CTurbSAVariable::SetVortex_Tilting(unsigned long iPoint, su2double **PrimGrad_Flow, + su2double* Vorticity, su2double LaminarViscosity) { su2double Strain[3][3] = {{0,0,0}, {0,0,0}, {0,0,0}}, Omega, StrainDotVort[3], numVecVort[3]; su2double numerator, trace0, trace1, denominator; @@ -71,7 +69,7 @@ void CTurbSAVariable::SetVortex_Tilting(su2double **PrimGrad_Flow, su2double* Vo AD::SetPreaccIn(PrimGrad_Flow, nDim+1, nDim); AD::SetPreaccIn(Vorticity, 3); /*--- Eddy viscosity ---*/ - AD::SetPreaccIn(muT); + AD::SetPreaccIn(muT(iPoint)); /*--- Laminar viscosity --- */ AD::SetPreaccIn(LaminarViscosity); @@ -102,10 +100,8 @@ void CTurbSAVariable::SetVortex_Tilting(su2double **PrimGrad_Flow, su2double* Vo trace1 = pow(Strain[0][0] + Strain[1][1] + Strain[2][2],2.0); denominator = pow(Omega, 2.0) * sqrt(trace0-trace1); - Vortex_Tilting = (numerator/denominator) * max(1.0,0.2*LaminarViscosity/muT); + Vortex_Tilting(iPoint) = (numerator/denominator) * max(1.0,0.2*LaminarViscosity/muT(iPoint)); - AD::SetPreaccOut(Vortex_Tilting); + AD::SetPreaccOut(Vortex_Tilting(iPoint)); AD::EndPreacc(); } - -CTurbSAVariable::~CTurbSAVariable(void) {} diff --git a/SU2_CFD/src/variables/CTurbSSTVariable.cpp b/SU2_CFD/src/variables/CTurbSSTVariable.cpp index 3e8c11b9f4b5..a381c3546085 100644 --- a/SU2_CFD/src/variables/CTurbSSTVariable.cpp +++ b/SU2_CFD/src/variables/CTurbSSTVariable.cpp @@ -38,74 +38,59 @@ #include "../../include/variables/CTurbSSTVariable.hpp" -CTurbSSTVariable::CTurbSSTVariable(void) : CTurbVariable() { } +CTurbSSTVariable::CTurbSSTVariable(su2double kine, su2double omega, su2double mut, unsigned long npoint, unsigned long ndim, unsigned long nvar, const su2double* constants, CConfig *config) + : CTurbVariable(npoint, ndim, nvar, config) { -CTurbSSTVariable::CTurbSSTVariable(su2double val_kine, su2double val_omega, su2double val_muT, - unsigned short val_nDim, unsigned short val_nvar, su2double *constants, - CConfig *config) : CTurbVariable(val_nDim, val_nvar, config) { - - bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || - (config->GetTime_Marching() == DT_STEPPING_2ND)); - - /*--- Initialization of variables ---*/ - - Solution[0] = val_kine; Solution_Old[0] = val_kine; - Solution[1] = val_omega; Solution_Old[1] = val_omega; + for(unsigned long iPoint=0; iPointGetTime_Marching() == HARMONIC_BALANCE) { - HB_Source = new su2double[nVar]; - for (iVar = 0; iVar < nVar; iVar++) - HB_Source[iVar] = 0.0; + HB_Source.resize(nPoint,nVar) = su2double(0.0); } - /*--- Always allocate the slope limiter, - and the auxiliar variables (check the logic - JST with 2nd order Turb model - ) ---*/ + /*--- Gradient related fields ---*/ - Limiter = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) - Limiter[iVar] = 0.0; - - Solution_Max = new su2double [nVar]; - Solution_Min = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Solution_Max[iVar] = 0.0; - Solution_Min[iVar] = 0.0; - } + Gradient.resize(nPoint,nVar,nDim,0.0); if (config->GetReconstructionGradientRequired()) { - GradReconAllocated = true; - Gradient_Reconstruction = new su2double*[nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Gradient_Reconstruction[iVar] = new su2double[nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Gradient_Reconstruction[iVar][iDim] = 0.0; - } + Gradient_Reconstruction.resize(nPoint,nVar,nDim,0.0); } else { Gradient_Reconstruction = Gradient; } -} - -CTurbVariable::~CTurbVariable(void) { - if (HB_Source != NULL) delete [] HB_Source; - - if (GradReconAllocated) { - for (unsigned short iVar = 0; iVar < nVar; iVar++) - if (Gradient_Reconstruction!=NULL) delete [] Gradient_Reconstruction[iVar]; - delete [] Gradient_Reconstruction; + if (config->GetLeastSquaresRequired()) { + Rmatrix.resize(nPoint,nDim,nDim,0.0); } - + + /*--- Always allocate the slope limiter, and the auxiliar + variables (check the logic - JST with 2nd order Turb model) ---*/ + + Limiter.resize(nPoint,nVar) = su2double(0.0); + Solution_Max.resize(nPoint,nVar) = su2double(0.0); + Solution_Min.resize(nPoint,nVar) = su2double(0.0); + + Delta_Time.resize(nPoint); + } diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index f6dcb9ae4f3e..fbbf768e6a5f 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -37,188 +37,130 @@ #include "../../include/variables/CVariable.hpp" -unsigned short CVariable::nDim = 0; - -CVariable::CVariable(void) { - - /*--- Array initialization ---*/ - Solution = NULL; - Solution_Old = NULL; - Solution_time_n = NULL; - Solution_time_n1 = NULL; - Gradient = NULL; - Limiter = NULL; - Solution_Max = NULL; - Solution_Min = NULL; - Grad_AuxVar = NULL; - Undivided_Laplacian = NULL; - Res_TruncError = NULL; - Residual_Old = NULL; - Residual_Sum = NULL; - Solution_Adj_Old = NULL; - Solution_BGS_k = NULL; - /* Under-relaxation parameter. */ - UnderRelaxation = 1.0; - - /* Non-physical point (first-order) initialization. */ - Non_Physical = false; - Non_Physical_Counter = 0; - -} - -CVariable::CVariable(unsigned short val_nvar, CConfig *config) { - - /*--- Array initialization ---*/ - Solution = NULL; - Solution_Old = NULL; - Solution_time_n = NULL; - Solution_time_n1 = NULL; - Gradient = NULL; - Rmatrix = NULL; - Limiter = NULL; - Solution_Max = NULL; - Solution_Min = NULL; - Grad_AuxVar = NULL; - Undivided_Laplacian = NULL; - Res_TruncError = NULL; - Residual_Old = NULL; - Residual_Sum = NULL; - Solution_Adj_Old = NULL; - Solution_BGS_k = NULL; +CVariable::CVariable(unsigned long npoint, unsigned long nvar, CConfig *config) { /*--- Initialize the number of solution variables. This version of the constructor will be used primarily for converting the restart files into solution files (SU2_SOL). ---*/ - nVar = val_nvar; + nPoint = npoint; + nVar = nvar; - /*--- Allocate the solution array - here it is also possible - to allocate some extra flow variables that do not participate - in the simulation ---*/ - Solution = new su2double [nVar]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = 0.0; + /*--- Allocate the solution array. ---*/ + Solution.resize(nPoint,nVar) = su2double(0.0); - /* Under-relaxation parameter. */ - UnderRelaxation = 1.0; - - /* Non-physical point (first-order) initialization. */ - Non_Physical = false; - Non_Physical_Counter = 0; - - if (config->GetMultizone_Problem()){ - Solution_BGS_k = new su2double[nVar](); - } + if (config->GetMultizone_Problem()) + Solution_BGS_k.resize(nPoint,nVar) = su2double(0.0); } -CVariable::CVariable(unsigned short val_nDim, unsigned short val_nvar, CConfig *config) { - - unsigned short iVar, iDim, jDim; - - /*--- Array initialization ---*/ - Solution = NULL; - Solution_Old = NULL; - Solution_time_n = NULL; - Solution_time_n1 = NULL; - Gradient = NULL; - Rmatrix = NULL; - Limiter = NULL; - Solution_Max = NULL; - Solution_Min = NULL; - Grad_AuxVar = NULL; - Undivided_Laplacian = NULL; - Res_TruncError = NULL; - Residual_Old = NULL; - Residual_Sum = NULL; - Solution_Adj_Old = NULL; - Solution_BGS_k = NULL; +CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) { /*--- Initializate the number of dimension and number of variables ---*/ - nDim = val_nDim; - nVar = val_nvar; + nPoint = npoint; + nDim = ndim; + nVar = nvar; - /*--- Allocate solution, solution old, residual and gradient - which is common for all the problems, here it is also possible - to allocate some extra flow variables that do not participate - in the simulation ---*/ - Solution = new su2double [nVar]; + /*--- Allocate fields common to all problems. Do not allocate fields + that are specific to one solver, i.e. not common, in this class. ---*/ + Solution.resize(nPoint,nVar) = su2double(0.0); - for (iVar = 0; iVar < nVar; iVar++) - Solution[iVar] = 0.0; - - Solution_Old = new su2double [nVar]; - - Gradient = new su2double* [nVar]; - for (iVar = 0; iVar < nVar; iVar++) { - Gradient[iVar] = new su2double [nDim]; - for (iDim = 0; iDim < nDim; iDim ++) - Gradient[iVar][iDim] = 0.0; - } + Solution_Old.resize(nPoint,nVar) = su2double(0.0); if (config->GetTime_Marching() != NO) { - Solution_time_n = new su2double [nVar]; - Solution_time_n1 = new su2double [nVar]; + Solution_time_n.resize(nPoint,nVar); + Solution_time_n1.resize(nPoint,nVar); } else if (config->GetTime_Domain()) { - Solution_time_n = new su2double [nVar]; - for (iVar = 0; iVar < nVar; iVar++) Solution_time_n[iVar] = 0.0; + Solution_time_n.resize(nPoint,nVar) = su2double(0.0); } - if (config->GetFSI_Simulation() && config->GetDiscrete_Adjoint()){ - Solution_Adj_Old = new su2double [nVar]; + if (config->GetFSI_Simulation() && config->GetDiscrete_Adjoint()) { + Solution_Adj_Old.resize(nPoint,nVar); } - - Rmatrix = new su2double*[nDim]; - for (iDim = 0; iDim < nDim; iDim++) { - Rmatrix[iDim] = new su2double[nDim]; - for (jDim = 0; jDim < nDim; jDim++) - Rmatrix[iDim][jDim] = 0.0; - } - + /* Under-relaxation parameter. */ - UnderRelaxation = 1.0; + UnderRelaxation.resize(nPoint) = 1.0; /* Non-physical point (first-order) initialization. */ - Non_Physical = false; - Non_Physical_Counter = 0; - - if (config->GetMultizone_Problem()){ - Solution_BGS_k = new su2double[nVar](); + Non_Physical.resize(nPoint) = false; + Non_Physical_Counter.resize(nPoint) = 0; + + if(config->GetMultizone_Problem() && config->GetAD_Mode()) { + Input_AdjIndices.resize(nPoint,nVar) = -1; + Output_AdjIndices.resize(nPoint,nVar) = -1; } - - Delta_Time = 0.0; - + + if (config->GetMultizone_Problem()) + Solution_BGS_k.resize(nPoint,nVar) = su2double(0.0); } -CVariable::~CVariable(void) { - unsigned short iVar, iDim; - - if (Solution != NULL) delete [] Solution; - if (Solution_Old != NULL) delete [] Solution_Old; - if (Solution_time_n != NULL) delete [] Solution_time_n; - if (Solution_time_n1 != NULL) delete [] Solution_time_n1; - if (Limiter != NULL) delete [] Limiter; - if (Solution_Max != NULL) delete [] Solution_Max; - if (Solution_Min != NULL) delete [] Solution_Min; - if (Grad_AuxVar != NULL) delete [] Grad_AuxVar; - if (Undivided_Laplacian != NULL) delete [] Undivided_Laplacian; - if (Res_TruncError != NULL) delete [] Res_TruncError; - if (Residual_Old != NULL) delete [] Residual_Old; - if (Residual_Sum != NULL) delete [] Residual_Sum; - if (Solution_Adj_Old != NULL) delete [] Solution_Adj_Old; - if (Solution_BGS_k != NULL) delete [] Solution_BGS_k; - - if (Gradient != NULL) { - for (iVar = 0; iVar < nVar; iVar++) - delete [] Gradient[iVar]; - delete [] Gradient; +void CVariable::Set_OldSolution() { Solution_Old = Solution; } + +void CVariable::Set_Solution() { Solution = Solution_Old; } + +void CVariable::Set_Solution_time_n() { Solution_time_n = Solution; } + +void CVariable::Set_Solution_time_n1() { Solution_time_n1 = Solution_time_n; } + +void CVariable::Set_BGSSolution_k() { Solution_BGS_k = Solution; } + +void CVariable::SetResidualSumZero() { Residual_Sum.setConstant(0.0); } + +void CVariable::SetAuxVarGradientZero() { Grad_AuxVar.setConstant(0.0); } + +void CVariable::SetGradientZero() { Gradient.storage.setConstant(0.0); } + +void CVariable::SetRmatrixZero() { Rmatrix.storage.setConstant(0.0); } + +void CVariable::SetUnd_LaplZero() { Undivided_Laplacian.setConstant(0.0); } + +void CVariable::SetExternalZero() { External.setConstant(0.0); } + +void CVariable::Set_OldExternal() { External_Old = External; } + +void CVariable::RegisterSolution(bool input) { + if (input) { + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for(unsigned long iVar=0; iVar& indices = input? Input_AdjIndices : Output_AdjIndices; + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for(unsigned long iVar=0; iVar < nVar; ++iVar) + AD::SetAdjIndex(indices(iPoint,iVar), Solution(iPoint,iVar)); } diff --git a/SU2_DEF/src/SU2_DEF.cpp b/SU2_DEF/src/SU2_DEF.cpp index ad035c7f17e7..a29ad2b050ae 100644 --- a/SU2_DEF/src/SU2_DEF.cpp +++ b/SU2_DEF/src/SU2_DEF.cpp @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) { } /*--- Initialize the configuration of the driver ---*/ - driver_config = new CConfig(config_file_name, SU2_DEF, nZone, false); + driver_config = new CConfig(config_file_name, SU2_DEF, false); /*--- Initialize a char to store the zone filename ---*/ char zone_file_name[MAX_STRING_SIZE]; diff --git a/SU2_DOT/src/SU2_DOT.cpp b/SU2_DOT/src/SU2_DOT.cpp index 0bfca1658ddf..e104d1bd6ab0 100644 --- a/SU2_DOT/src/SU2_DOT.cpp +++ b/SU2_DOT/src/SU2_DOT.cpp @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) { } /*--- Initialize the configuration of the driver ---*/ - driver_config = new CConfig(config_file_name, SU2_DOT, nZone, false); + driver_config = new CConfig(config_file_name, SU2_DOT, false); /*--- Initialize a char to store the zone filename ---*/ char zone_file_name[MAX_STRING_SIZE]; @@ -937,10 +937,10 @@ void SetSensitivity_Files(CGeometry ***geometry, CConfig **config, unsigned shor for (iPoint = 0; iPoint < nPoint; iPoint++) { for (iDim = 0; iDim < nDim; iDim++) { - solver->node[iPoint]->SetSolution(iDim, geometry[iZone][INST_0]->node[iPoint]->GetCoord(iDim)); + solver->GetNodes()->SetSolution(iPoint, iDim, geometry[iZone][INST_0]->node[iPoint]->GetCoord(iDim)); } for (iVar = 0; iVar < nDim; iVar++) { - solver->node[iPoint]->SetSolution(iVar+nDim, geometry[iZone][INST_0]->GetSensitivity(iPoint, iVar)); + solver->GetNodes()->SetSolution(iPoint, iVar+nDim, geometry[iZone][INST_0]->GetSensitivity(iPoint, iVar)); } } @@ -980,7 +980,7 @@ void SetSensitivity_Files(CGeometry ***geometry, CConfig **config, unsigned shor Sens = Prod/Area; - solver->node[iPoint]->SetSolution(2*nDim, Sens); + solver->GetNodes()->SetSolution(iPoint, 2*nDim, Sens); } } diff --git a/SU2_GEO/src/SU2_GEO.cpp b/SU2_GEO/src/SU2_GEO.cpp index 9059ed22de1a..75a5b24eb478 100644 --- a/SU2_GEO/src/SU2_GEO.cpp +++ b/SU2_GEO/src/SU2_GEO.cpp @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { constructor, the input configuration file is parsed and all options are read and stored. ---*/ - config_container[iZone] = new CConfig(config_file_name, SU2_GEO, nZone, true); + config_container[iZone] = new CConfig(config_file_name, SU2_GEO, true); config_container[iZone]->SetMPICommunicator(MPICommunicator); /*--- Definition of the geometry class to store the primal grid in the partitioning process. ---*/ diff --git a/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj b/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj index 974fa93b558f..7c898369da79 100644 --- a/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj +++ b/SU2_IDE/Xcode/SU2_CFD.xcodeproj/project.pbxproj @@ -86,6 +86,7 @@ E9225F761FCBC36D002F3682 /* solver_adjoint_elasticity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9225F741FCBC36D002F3682 /* solver_adjoint_elasticity.cpp */; }; E941BB8E1B71D0D0005C6C06 /* solver_adjoint_discrete.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E941BB8D1B71D0D0005C6C06 /* solver_adjoint_discrete.cpp */; }; E941BB941B71D124005C6C06 /* mpi_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E941BB911B71D124005C6C06 /* mpi_structure.cpp */; }; + E96008AA235557AA0002EADD /* signal_processing_toolbox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E96008A9235557A90002EADD /* signal_processing_toolbox.cpp */; }; E96FAF102189FE9C0046BF5D /* blas_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E96FAF0F2189FE9C0046BF5D /* blas_structure.cpp */; }; E96FAF142189FECA0046BF5D /* graph_coloring_structure.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E96FAF112189FECA0046BF5D /* graph_coloring_structure.cpp */; }; E96FAF152189FECA0046BF5D /* fem_gauss_jacobi_quadrature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E96FAF122189FECA0046BF5D /* fem_gauss_jacobi_quadrature.cpp */; }; @@ -145,8 +146,6 @@ E9D6EE682317B80600618E36 /* CDiscAdjMeshSolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE662317B80600618E36 /* CDiscAdjMeshSolver.cpp */; }; E9D6EE6A2317B86300618E36 /* CFEAMeshElasticity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE692317B86300618E36 /* CFEAMeshElasticity.cpp */; }; E9D6EE722317B88F00618E36 /* CDiscAdjMeshBoundVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE6B2317B88F00618E36 /* CDiscAdjMeshBoundVariable.cpp */; }; - E9D6EE732317B88F00618E36 /* CFEAFSIBoundVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE6C2317B88F00618E36 /* CFEAFSIBoundVariable.cpp */; }; - E9D6EE742317B88F00618E36 /* CDiscAdjMeshVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE6D2317B88F00618E36 /* CDiscAdjMeshVariable.cpp */; }; E9D6EE752317B88F00618E36 /* CDiscAdjFEABoundVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE6E2317B88F00618E36 /* CDiscAdjFEABoundVariable.cpp */; }; E9D6EE762317B88F00618E36 /* CMeshElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE6F2317B88F00618E36 /* CMeshElement.cpp */; }; E9D6EE772317B88F00618E36 /* CMeshBoundVariable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E9D6EE702317B88F00618E36 /* CMeshBoundVariable.cpp */; }; @@ -333,6 +332,10 @@ E941BBA31B71D1AB005C6C06 /* primitive_structure.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; lineEnding = 0; path = primitive_structure.inl; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; E941BBA51B71D1AB005C6C06 /* mpi_structure.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = mpi_structure.hpp; path = ../../Common/include/mpi_structure.hpp; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; E941BBA61B71D1AB005C6C06 /* mpi_structure.inl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; lineEnding = 0; name = mpi_structure.inl; path = ../../Common/include/mpi_structure.inl; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.cpp; }; + E96008A6235557790002EADD /* CVertexMap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CVertexMap.hpp; path = ../../Common/include/toolboxes/CVertexMap.hpp; sourceTree = ""; }; + E96008A7235557790002EADD /* signal_processing_toolbox.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = signal_processing_toolbox.hpp; path = ../../Common/include/toolboxes/signal_processing_toolbox.hpp; sourceTree = ""; }; + E96008A82355577A0002EADD /* C2DContainer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = C2DContainer.hpp; path = ../../Common/include/toolboxes/C2DContainer.hpp; sourceTree = ""; }; + E96008A9235557A90002EADD /* signal_processing_toolbox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = signal_processing_toolbox.cpp; path = ../../Common/src/toolboxes/signal_processing_toolbox.cpp; sourceTree = ""; }; E96FAF0F2189FE9C0046BF5D /* blas_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = blas_structure.cpp; path = ../../Common/src/blas_structure.cpp; sourceTree = ""; }; E96FAF112189FECA0046BF5D /* graph_coloring_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = graph_coloring_structure.cpp; path = ../../Common/src/graph_coloring_structure.cpp; sourceTree = ""; }; E96FAF122189FECA0046BF5D /* fem_gauss_jacobi_quadrature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fem_gauss_jacobi_quadrature.cpp; path = ../../Common/src/fem_gauss_jacobi_quadrature.cpp; sourceTree = ""; }; @@ -458,8 +461,6 @@ E9D6EE662317B80600618E36 /* CDiscAdjMeshSolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjMeshSolver.cpp; path = ../../SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp; sourceTree = ""; }; E9D6EE692317B86300618E36 /* CFEAMeshElasticity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFEAMeshElasticity.cpp; path = ../../SU2_CFD/src/numerics/CFEAMeshElasticity.cpp; sourceTree = ""; }; E9D6EE6B2317B88F00618E36 /* CDiscAdjMeshBoundVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjMeshBoundVariable.cpp; path = ../../SU2_CFD/src/variables/CDiscAdjMeshBoundVariable.cpp; sourceTree = ""; }; - E9D6EE6C2317B88F00618E36 /* CFEAFSIBoundVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFEAFSIBoundVariable.cpp; path = ../../SU2_CFD/src/variables/CFEAFSIBoundVariable.cpp; sourceTree = ""; }; - E9D6EE6D2317B88F00618E36 /* CDiscAdjMeshVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjMeshVariable.cpp; path = ../../SU2_CFD/src/variables/CDiscAdjMeshVariable.cpp; sourceTree = ""; }; E9D6EE6E2317B88F00618E36 /* CDiscAdjFEABoundVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CDiscAdjFEABoundVariable.cpp; path = ../../SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp; sourceTree = ""; }; E9D6EE6F2317B88F00618E36 /* CMeshElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMeshElement.cpp; path = ../../SU2_CFD/src/variables/CMeshElement.cpp; sourceTree = ""; }; E9D6EE702317B88F00618E36 /* CMeshBoundVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CMeshBoundVariable.cpp; path = ../../SU2_CFD/src/variables/CMeshBoundVariable.cpp; sourceTree = ""; }; @@ -468,11 +469,9 @@ E9D6EE7A2317B8B000618E36 /* CDiscAdjMeshSolver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjMeshSolver.hpp; path = ../../SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp; sourceTree = ""; }; E9D6EE7B2317B8B000618E36 /* CMeshSolver.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMeshSolver.hpp; path = ../../SU2_CFD/include/solvers/CMeshSolver.hpp; sourceTree = ""; }; E9D6EE7C2317B8CC00618E36 /* CMeshElement.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMeshElement.hpp; path = ../../SU2_CFD/include/variables/CMeshElement.hpp; sourceTree = ""; }; - E9D6EE7D2317B8CC00618E36 /* CDiscAdjMeshVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjMeshVariable.hpp; path = ../../SU2_CFD/include/variables/CDiscAdjMeshVariable.hpp; sourceTree = ""; }; E9D6EE7E2317B8CC00618E36 /* CDiscAdjFEABoundVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjFEABoundVariable.hpp; path = ../../SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp; sourceTree = ""; }; E9D6EE7F2317B8CC00618E36 /* CMeshVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMeshVariable.hpp; path = ../../SU2_CFD/include/variables/CMeshVariable.hpp; sourceTree = ""; }; E9D6EE802317B8CC00618E36 /* CDiscAdjMeshBoundVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CDiscAdjMeshBoundVariable.hpp; path = ../../SU2_CFD/include/variables/CDiscAdjMeshBoundVariable.hpp; sourceTree = ""; }; - E9D6EE812317B8CC00618E36 /* CFEAFSIBoundVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CFEAFSIBoundVariable.hpp; path = ../../SU2_CFD/include/variables/CFEAFSIBoundVariable.hpp; sourceTree = ""; }; E9D6EE822317B8CC00618E36 /* CMeshBoundVariable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CMeshBoundVariable.hpp; path = ../../SU2_CFD/include/variables/CMeshBoundVariable.hpp; sourceTree = ""; }; E9D85B4B1C3F1B9E0077122F /* ad_structure.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; name = ad_structure.cpp; path = ../../Common/src/ad_structure.cpp; sourceTree = ""; }; E9D85B4D1C3F1BE00077122F /* ad_structure.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = ad_structure.hpp; path = ../../Common/include/ad_structure.hpp; sourceTree = ""; }; @@ -658,6 +657,7 @@ E9D85B4D1C3F1BE00077122F /* ad_structure.hpp */, E9FDF6EC1D2DD0860066E49C /* adt_structure.hpp */, E96FAF1A2189FF620046BF5D /* blas_structure.hpp */, + E96008A82355577A0002EADD /* C2DContainer.hpp */, E984B694234576EB00AEDA72 /* CAdjElasticityOutput.hpp */, E984B68A234576E900AEDA72 /* CAdjFlowIncOutput.hpp */, E984B68B234576EA00AEDA72 /* CAdjFlowOutput.hpp */, @@ -673,14 +673,12 @@ E97429E72323596C006DA2D3 /* CDiscAdjFlowTractionInterface.hpp */, E9D6EE802317B8CC00618E36 /* CDiscAdjMeshBoundVariable.hpp */, E9D6EE7A2317B8B000618E36 /* CDiscAdjMeshSolver.hpp */, - E9D6EE7D2317B8CC00618E36 /* CDiscAdjMeshVariable.hpp */, EB14FF9C22F790720045FB27 /* CDiscAdjSinglezoneDriver.hpp */, E97429E92323596D006DA2D3 /* CDisplacementsInterface.hpp */, E97429EA2323596D006DA2D3 /* CDisplacementsInterfaceLegacy.hpp */, EB14FF9D22F790720045FB27 /* CDriver.hpp */, E9D6EE5B23165FE400618E36 /* CDummyDriver.hpp */, E984B687234576E900AEDA72 /* CElasticityOutput.hpp */, - E9D6EE812317B8CC00618E36 /* CFEAFSIBoundVariable.hpp */, E9D6EE792317B8A100618E36 /* CFEAMeshElasticity.hpp */, E984B696234576FE00AEDA72 /* CFEMDataSorter.hpp */, E984B6A32345770000AEDA72 /* CFileWriter.hpp */, @@ -734,6 +732,7 @@ E9C2835922A701B5007B4E59 /* CTGVSolution.hpp */, E9C2835422A701B5007B4E59 /* CUserDefinedSolution.hpp */, E9C2835522A701B5007B4E59 /* CVerificationSolution.hpp */, + E96008A6235557790002EADD /* CVertexMap.hpp */, E941BB951B71D1AB005C6C06 /* datatype_structure.hpp */, E941BB971B71D1AB005C6C06 /* datatypes */, 05E6DBB417EB627400FA1F7E /* definition_structure.hpp */, @@ -759,6 +758,7 @@ 05E6DACD17EB608000FA1F7E /* primal_grid_structure.hpp */, 400CEC2F21FA81B60019B790 /* printing_toolbox.hpp */, 355D2C9E2172BDE100C10535 /* sgs_model.hpp */, + E96008A7235557790002EADD /* signal_processing_toolbox.hpp */, 05E6DBB917EB627400FA1F7E /* solver_structure.hpp */, 05E6DBBA17EB627400FA1F7E /* SU2_CFD.hpp */, E90B501422DFE0CB000ED392 /* task_definition.hpp */, @@ -863,6 +863,7 @@ 052D51AB17A22E24003BE8B2 /* Output */, 400CEC2D21FA81A10019B790 /* printing_toolbox.cpp */, 05F8F2662008A1AA000FEA01 /* Python */, + E96008A9235557A90002EADD /* signal_processing_toolbox.cpp */, 052D517F17A21FAC003BE8B2 /* Solver */, 05E6DBEC17EB62A100FA1F7E /* SU2_CFD.cpp */, 05F108A21978D2E500F2F288 /* TransportModel */, @@ -910,11 +911,9 @@ E9D6EE6E2317B88F00618E36 /* CDiscAdjFEABoundVariable.cpp */, E90B4FEB22DFDFE2000ED392 /* CDiscAdjFEAVariable.cpp */, E9D6EE6B2317B88F00618E36 /* CDiscAdjMeshBoundVariable.cpp */, - E9D6EE6D2317B88F00618E36 /* CDiscAdjMeshVariable.cpp */, E90B4FEA22DFDFE2000ED392 /* CDiscAdjVariable.cpp */, E90B4FEF22DFDFE3000ED392 /* CEulerVariable.cpp */, E90B4FF622DFDFE4000ED392 /* CFEABoundVariable.cpp */, - E9D6EE6C2317B88F00618E36 /* CFEAFSIBoundVariable.cpp */, E90B4FF422DFDFE4000ED392 /* CFEAVariable.cpp */, E90B4FEE22DFDFE3000ED392 /* CHeatFVMVariable.cpp */, E90B4FE722DFDFE2000ED392 /* CIncEulerVariable.cpp */, @@ -1125,7 +1124,6 @@ E9D6EE782317B88F00618E36 /* CMeshVariable.cpp in Sources */, E9E51ADD22FAB11800773E0C /* CCGNSMeshReaderFVM.cpp in Sources */, E9E674372302A92C009B6A25 /* CRectangularMeshReaderFVM.cpp in Sources */, - E9D6EE742317B88F00618E36 /* CDiscAdjMeshVariable.cpp in Sources */, EB14FF9822F790500045FB27 /* CSinglezoneDriver.cpp in Sources */, E9F512C81CB2FD6B004D5089 /* numerics_direct_elasticity_linear.cpp in Sources */, E984B6692345765C00AEDA72 /* output_structure_legacy.cpp in Sources */, @@ -1135,6 +1133,7 @@ 05E6DC0417EB62A100FA1F7E /* integration_time.cpp in Sources */, E9D6EE572316522800618E36 /* (null) in Sources */, 05F1089B1978D2AE00F2F288 /* fluid_model_ppr.cpp in Sources */, + E96008AA235557AA0002EADD /* signal_processing_toolbox.cpp in Sources */, E984B66A2345765C00AEDA72 /* CBaselineOutput.cpp in Sources */, E97429D423235901006DA2D3 /* CMixingPlaneInterface.cpp in Sources */, E984B6842345767900AEDA72 /* CSurfaceFEMDataSorter.cpp in Sources */, @@ -1244,7 +1243,6 @@ E984B65C2345765C00AEDA72 /* CMeshOutput.cpp in Sources */, E90B4FFB22DFDFE4000ED392 /* CAdjNSVariable.cpp in Sources */, E90B500F22DFE043000ED392 /* CSysVector.cpp in Sources */, - E9D6EE732317B88F00618E36 /* CFEAFSIBoundVariable.cpp in Sources */, E90B4FDA22DFDF94000ED392 /* CNSUnitQuadSolution.cpp in Sources */, E9C830802061E60E004417A9 /* fem_integration_rules.cpp in Sources */, E90B501222DFE043000ED392 /* CSysSolve.cpp in Sources */, @@ -1259,7 +1257,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_CXX_LIBRARY = "compiler-default"; CLANG_ENABLE_MODULES = YES; CLANG_WARN_BOOL_CONVERSION = YES; @@ -1274,6 +1272,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 6.2.0; + GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 3; @@ -1315,7 +1314,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_CXX_LIBRARY = "compiler-default"; CLANG_ENABLE_MODULES = YES; CLANG_WARN_BOOL_CONVERSION = YES; @@ -1330,6 +1329,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CURRENT_PROJECT_VERSION = 6.2.0; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_C_LANGUAGE_STANDARD = gnu99; GCC_MODEL_TUNING = G5; GCC_OPTIMIZATION_LEVEL = 3; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = NO; diff --git a/SU2_MSH/src/SU2_MSH.cpp b/SU2_MSH/src/SU2_MSH.cpp index eb57a65c6ee2..390f84e6459b 100644 --- a/SU2_MSH/src/SU2_MSH.cpp +++ b/SU2_MSH/src/SU2_MSH.cpp @@ -101,7 +101,7 @@ int main(int argc, char *argv[]) { constructor, the input configuration file is parsed and all options are read and stored. ---*/ - config_container[iZone] = new CConfig(config_file_name, SU2_MSH, nZone, true); + config_container[iZone] = new CConfig(config_file_name, SU2_MSH, true); config_container[iZone]->SetMPICommunicator(MPICommunicator); /*--- Definition of the geometry class to store the primal grid in the partitioning process. ---*/ diff --git a/SU2_PY/pySU2/Makefile.am b/SU2_PY/pySU2/Makefile.am index 8da1e827ebec..e65a43251d20 100644 --- a/SU2_PY/pySU2/Makefile.am +++ b/SU2_PY/pySU2/Makefile.am @@ -84,12 +84,12 @@ all: real: ${SWIG_SO_REAL} if BUILD_NORMAL - EXTRA_CC_FLAGS = -fPIC -O3 + EXTRA_CC_FLAGS = -fPIC -O3 -std=c++11 endif if BUILD_REVERSE - EXTRA_CC_FLAGS = -fPIC -O3 -std=c++0x -DCODI_REVERSE_TYPE -I$(top_srcdir)/externals/codi/include -I$(top_srcdir)/externals/medi/include -# EXTRA_CC_FLAGS = -fPIC -g3 -std=c++0x -DCODI_REVERSE_TYPE -I$(top_srcdir)/externals/codi/include -I$(top_srcdir)/externals/medi/include + EXTRA_CC_FLAGS = -fPIC -O3 -std=c++11 -DCODI_REVERSE_TYPE -I$(top_srcdir)/externals/codi/include -I$(top_srcdir)/externals/medi/include +# EXTRA_CC_FLAGS = -fPIC -g3 -std=c++11 -DCODI_REVERSE_TYPE -I$(top_srcdir)/externals/codi/include -I$(top_srcdir)/externals/medi/include endif #SU2_BASE lib diff --git a/SU2_SOL/src/SU2_SOL.cpp b/SU2_SOL/src/SU2_SOL.cpp index 5ceeb85940cf..6c90b37f54df 100644 --- a/SU2_SOL/src/SU2_SOL.cpp +++ b/SU2_SOL/src/SU2_SOL.cpp @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) { } /*--- Initialize the configuration of the driver ---*/ - driver_config = new CConfig(config_file_name, SU2_SOL, nZone, false); + driver_config = new CConfig(config_file_name, SU2_SOL, false); /*--- Initialize a char to store the zone filename ---*/ char zone_file_name[MAX_STRING_SIZE]; diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/cht_2d_3cylinders.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/cht_2d_3cylinders.cfg new file mode 100644 index 000000000000..51f91e815391 --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/cht_2d_3cylinders.cfg @@ -0,0 +1,79 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: 2D cylinder array with CHT couplings % +% Author: O. Burghardt, T. Economon % +% Institution: Chair for Scientific Computing, TU Kaiserslautern % +% Date: August 8, 2019 % +% File Version 6.0.1 "Falcon" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= MULTIPHYSICS +% +% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT, DISCRETE_ADJOINT) +MATH_PROBLEM= DISCRETE_ADJOINT +% +% +CONFIG_LIST = (flow_cylinder.cfg, solid_cylinder1.cfg, solid_cylinder2.cfg, solid_cylinder3.cfg) +% +% +MARKER_ZONE_INTERFACE= (cylinder_outer1, cylinder_inner1, cylinder_outer2, cylinder_inner2, cylinder_outer3, cylinder_inner3) +% +% +MARKER_CHT_INTERFACE= (cylinder_outer1, cylinder_inner1, cylinder_outer2, cylinder_inner2, cylinder_outer3, cylinder_inner3) +% +% +TIME_DOMAIN = NO +% +% Number of total iterations +OUTER_ITER = 11 +% +% Mesh input file +MESH_FILENAME= mesh_cht_3cyl.su2 +% +% Mesh input file format (SU2, CGNS, NETCDF_ASCII) +MESH_FORMAT= SU2 + +% These are just default parameters so that we can run SU2_DOT_AD, they have no physical meaning for this test case. + +% ----------------------- DESIGN VARIABLE PARAMETERS --------------------------% +% +% Kind of deformation (NO_DEFORMATION, TRANSLATION, ROTATION, SCALE, +% FFD_SETTING, FFD_NACELLE +% FFD_CONTROL_POINT, FFD_CAMBER, FFD_THICKNESS, FFD_TWIST +% FFD_CONTROL_POINT_2D, FFD_CAMBER_2D, FFD_THICKNESS_2D, FFD_TWIST_2D, +% HICKS_HENNE, SURFACE_BUMP) +DV_KIND= HICKS_HENNE +% +% Marker of the surface in which we are going apply the shape deformation +DV_MARKER= ( cylinder_outer1, cylinder_inner1, cylinder_outer2, cylinder_inner2, cylinder_outer3, cylinder_inner3 ) +% +% Parameters of the shape deformation +% - NO_DEFORMATION ( 1.0 ) +% - TRANSLATION ( x_Disp, y_Disp, z_Disp ), as a unit vector +% - ROTATION ( x_Orig, y_Orig, z_Orig, x_End, y_End, z_End ) +% - SCALE ( 1.0 ) +% - ANGLE_OF_ATTACK ( 1.0 ) +% - FFD_SETTING ( 1.0 ) +% - FFD_CONTROL_POINT ( FFD_BoxTag, i_Ind, j_Ind, k_Ind, x_Disp, y_Disp, z_Disp ) +% - FFD_NACELLE ( FFD_BoxTag, rho_Ind, theta_Ind, phi_Ind, rho_Disp, phi_Disp ) +% - FFD_GULL ( FFD_BoxTag, j_Ind ) +% - FFD_ANGLE_OF_ATTACK ( FFD_BoxTag, 1.0 ) +% - FFD_CAMBER ( FFD_BoxTag, i_Ind, j_Ind ) +% - FFD_THICKNESS ( FFD_BoxTag, i_Ind, j_Ind ) +% - FFD_TWIST ( FFD_BoxTag, j_Ind, x_Orig, y_Orig, z_Orig, x_End, y_End, z_End ) +% - FFD_CONTROL_POINT_2D ( FFD_BoxTag, i_Ind, j_Ind, x_Disp, y_Disp ) +% - FFD_CAMBER_2D ( FFD_BoxTag, i_Ind ) +% - FFD_THICKNESS_2D ( FFD_BoxTag, i_Ind ) +% - FFD_TWIST_2D ( FFD_BoxTag, x_Orig, y_Orig ) +% - HICKS_HENNE ( Lower Surface (0)/Upper Surface (1)/Only one Surface (2), x_Loc ) +% - SURFACE_BUMP ( x_Start, x_End, x_Loc ) +DV_PARAM= (0.0, 0.5) +% +% Value of the shape deformation +DV_VALUE= 0.1 diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/flow_cylinder.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/flow_cylinder.cfg new file mode 100644 index 000000000000..651ab1abfe8d --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/flow_cylinder.cfg @@ -0,0 +1,258 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Steady incompressible laminar flow around heated cylinders % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= INC_NAVIER_STOKES +% +% If Navier-Stokes, kind of turbulent model (NONE, SA) +KIND_TURB_MODEL= NONE +% +% Restart solution (NO, YES) +RESTART_SOL= NO +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) +% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. +OBJECTIVE_FUNCTION= TOTAL_HEATFLUX +% +% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. +OBJECTIVE_WEIGHT = 1.0 +% +% Read binary restart files (YES, NO) +READ_BINARY_RESTART = YES +% +% Data written to history file +HISTORY_OUTPUT=(ITER, RMS_RES, HEAT ) + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% Farfield boundary marker(s) (NONE = no marker) +MARKER_FAR= ( farfield ) +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= (cylinder_outer1, cylinder_outer2, cylinder_outer3) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= (cylinder_outer1, cylinder_outer2, cylinder_outer3) + +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +% Density model within the incompressible flow solver. +% Options are CONSTANT (default), BOUSSINESQ, or VARIABLE. If VARIABLE, +% an appropriate fluid model must be selected. +INC_DENSITY_MODEL= VARIABLE +% +% Solve the energy equation in the incompressible flow solver +INC_ENERGY_EQUATION = YES +% +% Initial density for incompressible flows (1.2886 kg/m^3 by default) +INC_DENSITY_INIT= 0.000210322 +% +% Initial velocity for incompressible flows (1.0,0,0 m/s by default) +INC_VELOCITY_INIT= ( 3.40297, 0.0, 0.0 ) +% +% Initial temperature for incompressible flows that include the +% energy equation (288.15 K by default). Value is ignored if +% INC_ENERGY_EQUATION is false. +INC_TEMPERATURE_INIT= 288.15 +% +% Non-dimensionalization scheme for incompressible flows. Options are +% INITIAL_VALUES (default), REFERENCE_VALUES, or DIMENSIONAL. +% INC_*_REF values are ignored unless REFERENCE_VALUES is chosen. +INC_NONDIM= DIMENSIONAL + +% ---- IDEAL GAS, POLYTROPIC, VAN DER WAALS AND PENG ROBINSON CONSTANTS -------% +% +% Fluid model (STANDARD_AIR, IDEAL_GAS, VW_GAS, PR_GAS, +% CONSTANT_DENSITY, INC_IDEAL_GAS) +FLUID_MODEL= INC_IDEAL_GAS +% +% Specific heat at constant pressure, Cp (1004.703 J/kg*K (air)). +% Incompressible fluids with energy eqn. only (CONSTANT_DENSITY, INC_IDEAL_GAS). +SPECIFIC_HEAT_CP= 1004.703 +% +% Molecular weight for an incompressible ideal gas (28.96 g/mol (air) default) +% Incompressible fluids with energy eqn. only (CONSTANT_DENSITY, INC_IDEAL_GAS). +MOLECULAR_WEIGHT= 28.96 + +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +% Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY). +VISCOSITY_MODEL= CONSTANT_VISCOSITY +% +% Molecular Viscosity that would be constant (1.716E-5 by default) +MU_CONSTANT= 1.7893e-05 +% +% Sutherland Viscosity Ref (1.716E-5 default value for AIR SI) +MU_REF= 1.716E-5 +% +% Sutherland Temperature Ref (273.15 K default value for AIR SI) +MU_T_REF= 273.15 +% +% Sutherland constant (110.4 default value for AIR SI) +SUTHERLAND_CONSTANT= 110.4 + +% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% +% +% Conductivity model (CONSTANT_CONDUCTIVITY, CONSTANT_PRANDTL). +CONDUCTIVITY_MODEL= CONSTANT_PRANDTL +% +% Molecular Thermal Conductivity that would be constant (0.0257 by default) +KT_CONSTANT= 0.0257 +% +% Laminar Prandtl number (0.72 (air), only for CONSTANT_PRANDTL) +PRANDTL_LAM= 0.72 +% +% Turbulent Prandtl number (0.9 (air), only for CONSTANT_PRANDTL) +PRANDTL_TURB= 0.90 + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 10.0, 10000.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linael solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-15 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 5 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +% Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, HLLC, +% TURKEL_PREC, MSW) +CONV_NUM_METHOD_FLOW= FDS +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_FLOW= YES +% +% Slope limiter (NONE, VENKATAKRISHNAN, VENKATAKRISHNAN_WANG, +% BARTH_JESPERSEN, VAN_ALBADA_EDGE) +SLOPE_LIMITER_FLOW= NONE +% +% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -19 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 100 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Restart adjoint input file +SOLUTION_ADJ_FILENAME= solution_adj.dat +% +% Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, +% FIELDVIEW, FIELDVIEW_BINARY) +TABULAR_FORMAT= TECPLOT +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history +% +% Output file with the forces breakdown +BREAKDOWN_FILENAME= forces_breakdown.dat +% +% Output file restart flow +RESTART_FILENAME= restart_flow.dat +% +% Output file restart adjoint +RESTART_ADJ_FILENAME= restart_adj.dat +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file adjoint (w/o extension) variables +VOLUME_ADJ_FILENAME= adjoint +% +% Output Objective function +VALUE_OBJFUNC_FILENAME= of_eval.dat +% +% Output objective function gradient (using continuous adjoint) +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Output file surface adjoint coefficient (w/o extension) +SURFACE_ADJ_FILENAME= surface_adjoint +% +% Writing solution file frequency +WRT_SOL_FREQ= 250 +% +% Writing convergence history frequency +WRT_CON_FREQ= 1 + +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_ITER= 200 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% Visualize the deformation (NO, YES) +VISUALIZE_VOLUME_DEF= YES diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder1.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder1.cfg new file mode 100644 index 000000000000..61e97b996331 --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder1.cfg @@ -0,0 +1,186 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Steady incompressible laminar flow around heated cylinders % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= HEAT_EQUATION_FVM +% +% Restart solution (NO, YES) +RESTART_SOL= NO +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) +% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. +OBJECTIVE_FUNCTION= TOTAL_HEATFLUX +% +% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. +OBJECTIVE_WEIGHT = 1.0 +% +% Read binary restart files (YES, NO) +READ_BINARY_RESTART = YES + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_ISOTHERMAL= ( core1, 350.0 ) +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= (cylinder_inner1 ) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( NONE ) + +% ---------------- (SOLIDS) CONDUCTION CONDITION DEFINITION -------------------% +% +% We should keep the dimensionalization of the coupled flow solver +INC_NONDIM= DIMENSIONAL +% +% Temperature initialization value +SOLID_TEMPERATURE_INIT= 350.0 +% +% Nettis case: hollow cylinder (air w/ 4x the conductivity) +% +% Solid density (kg/m^3) +SOLID_DENSITY= 0.000210322 +% +% Solid specific heat (J/kg*K) +SPECIFIC_HEAT_CP_SOLID = 1004.703 +% +% Solid thermal conductivity (W/m*K) +THERMAL_CONDUCTIVITY_SOLID= 0.1028 + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 10.0, 10000.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linael solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-15 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 5 + +% -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% +% +TIME_DISCRE_HEAT= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -19 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 100 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Restart adjoint input file +SOLUTION_ADJ_FILENAME= solution_adj.dat +% +% Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, +% FIELDVIEW, FIELDVIEW_BINARY) +TABULAR_FORMAT= TECPLOT +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history +% +% Output file with the forces breakdown +BREAKDOWN_FILENAME= forces_breakdown.dat +% +% Output file restart flow +RESTART_FILENAME= restart_flow.dat +% +% Output file restart adjoint +RESTART_ADJ_FILENAME= restart_adj.dat +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file adjoint (w/o extension) variables +VOLUME_ADJ_FILENAME= adjoint +% +% Output Objective function +VALUE_OBJFUNC_FILENAME= of_eval.dat +% +% Output objective function gradient (using continuous adjoint) +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Output file surface adjoint coefficient (w/o extension) +SURFACE_ADJ_FILENAME= surface_adjoint +% +% Writing solution file frequency +WRT_SOL_FREQ= 250 +% +% Writing convergence history frequency +WRT_CON_FREQ= 1 + +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_ITER= 200 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% Visualize the deformation (NO, YES) +VISUALIZE_VOLUME_DEF= YES diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder2.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder2.cfg new file mode 100644 index 000000000000..1282a952a7dc --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder2.cfg @@ -0,0 +1,196 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Steady incompressible laminar flow around heated cylinders % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= HEAT_EQUATION_FVM +% +% Restart solution (NO, YES) +RESTART_SOL= NO +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) +% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. +OBJECTIVE_FUNCTION= TOTAL_HEATFLUX +% +% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. +OBJECTIVE_WEIGHT = 1.0 +% +% Read binary restart files (YES, NO) +READ_BINARY_RESTART = YES + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_ISOTHERMAL= ( core2, 350.0 ) +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= (cylinder_inner2) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( NONE ) + +% ---------------- (SOLIDS) CONDUCTION CONDITION DEFINITION -------------------% +% +% We should keep the dimensionalization of the coupled flow solver +INC_NONDIM= DIMENSIONAL +% +% Temperature initialization value +SOLID_TEMPERATURE_INIT= 350.0 +% +% Nettis case: hollow cylinder (air w/ 4x the conductivity) +% +% Solid density (kg/m^3) +SOLID_DENSITY= 0.000210322 +% +% Solid specific heat (J/kg*K) +SPECIFIC_HEAT_CP_SOLID = 1004.703 +% +% Solid thermal conductivity (W/m*K) +THERMAL_CONDUCTIVITY_SOLID= 0.1028 + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 10.0, 10000.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linael solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-15 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 5 + +% -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% +% +% Time discretization (EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_HEAT= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -19 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 100 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Restart adjoint input file +SOLUTION_ADJ_FILENAME= solution_adj.dat +% +% Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, +% FIELDVIEW, FIELDVIEW_BINARY) +TABULAR_FORMAT= TECPLOT +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history +% +% Output file with the forces breakdown +BREAKDOWN_FILENAME= forces_breakdown.dat +% +% Output file restart flow +RESTART_FILENAME= restart_flow.dat +% +% Output file restart adjoint +RESTART_ADJ_FILENAME= restart_adj.dat +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file adjoint (w/o extension) variables +VOLUME_ADJ_FILENAME= adjoint +% +% Output Objective function +VALUE_OBJFUNC_FILENAME= of_eval.dat +% +% Output objective function gradient (using continuous adjoint) +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Output file surface adjoint coefficient (w/o extension) +SURFACE_ADJ_FILENAME= surface_adjoint +% +% Writing solution file frequency +WRT_SOL_FREQ= 250 +% +% Writing convergence history frequency +WRT_CON_FREQ= 1 + +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_ITER= 200 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% Visualize the deformation (NO, YES) +VISUALIZE_VOLUME_DEF= YES diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder3.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder3.cfg new file mode 100644 index 000000000000..89c0c5e7a9cc --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder3.cfg @@ -0,0 +1,196 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Steady incompressible laminar flow around heated cylinders % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= HEAT_EQUATION_FVM +% +% Restart solution (NO, YES) +RESTART_SOL= NO +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) +% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. +OBJECTIVE_FUNCTION= TOTAL_HEATFLUX +% +% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. +OBJECTIVE_WEIGHT = 1.0 +% +% Read binary restart files (YES, NO) +READ_BINARY_RESTART = YES + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_ISOTHERMAL= ( core3, 350.0 ) +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= ( cylinder_inner3 ) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( NONE ) + +% ---------------- (SOLIDS) CONDUCTION CONDITION DEFINITION -------------------% +% +% We should keep the dimensionalization of the coupled flow solver +INC_NONDIM= DIMENSIONAL +% +% Temperature initialization value +SOLID_TEMPERATURE_INIT= 350.0 +% +% Nettis case: hollow cylinder (air w/ 4x the conductivity) +% +% Solid density (kg/m^3) +SOLID_DENSITY= 0.000210322 +% +% Solid specific heat (J/kg*K) +SPECIFIC_HEAT_CP_SOLID = 1004.703 +% +% Solid thermal conductivity (W/m*K) +THERMAL_CONDUCTIVITY_SOLID= 0.1028 + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 10.0, 10000.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linael solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-15 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 5 + +% -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% +% +% Time discretization (EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_HEAT= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -19 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 100 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Restart adjoint input file +SOLUTION_ADJ_FILENAME= solution_adj.dat +% +% Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, +% FIELDVIEW, FIELDVIEW_BINARY) +TABULAR_FORMAT= TECPLOT +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history +% +% Output file with the forces breakdown +BREAKDOWN_FILENAME= forces_breakdown.dat +% +% Output file restart flow +RESTART_FILENAME= restart_flow.dat +% +% Output file restart adjoint +RESTART_ADJ_FILENAME= restart_adj.dat +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file adjoint (w/o extension) variables +VOLUME_ADJ_FILENAME= adjoint +% +% Output Objective function +VALUE_OBJFUNC_FILENAME= of_eval.dat +% +% Output objective function gradient (using continuous adjoint) +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Output file surface adjoint coefficient (w/o extension) +SURFACE_ADJ_FILENAME= surface_adjoint +% +% Writing solution file frequency +WRT_SOL_FREQ= 250 +% +% Writing convergence history frequency +WRT_CON_FREQ= 1 + +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_ITER= 200 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% Visualize the deformation (NO, YES) +VISUALIZE_VOLUME_DEF= YES diff --git a/TestCases/coupled_cht/incomp_2d/cht_2d_3cylinders.cfg b/TestCases/coupled_cht/incomp_2d/cht_2d_3cylinders.cfg new file mode 100644 index 000000000000..88f0428519c2 --- /dev/null +++ b/TestCases/coupled_cht/incomp_2d/cht_2d_3cylinders.cfg @@ -0,0 +1,79 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: 2D cylinder array with CHT couplings % +% Author: O. Burghardt, T. Economon % +% Institution: Chair for Scientific Computing, TU Kaiserslautern % +% Date: August 8, 2019 % +% File Version 6.0.1 "Falcon" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= MULTIPHYSICS +% +% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT, DISCRETE_ADJOINT) +MATH_PROBLEM= DIRECT +% +% +CONFIG_LIST = (flow_cylinder.cfg, solid_cylinder1.cfg, solid_cylinder2.cfg, solid_cylinder3.cfg) +% +% +MARKER_ZONE_INTERFACE= (cylinder_outer1, cylinder_inner1, cylinder_outer2, cylinder_inner2, cylinder_outer3, cylinder_inner3) +% +% +MARKER_CHT_INTERFACE= (cylinder_outer1, cylinder_inner1, cylinder_outer2, cylinder_inner2, cylinder_outer3, cylinder_inner3) +% +% +TIME_DOMAIN = NO +% +% Number of total iterations +OUTER_ITER = 11 +% +% Mesh input file +MESH_FILENAME= mesh_cht_3cyl.su2 +% +% Mesh input file format (SU2, CGNS, NETCDF_ASCII) +MESH_FORMAT= SU2 + +% These are just default parameters so that we can run SU2_DOT_AD, they have no physical meaning for this test case. + +% ----------------------- DESIGN VARIABLE PARAMETERS --------------------------% +% +% Kind of deformation (NO_DEFORMATION, TRANSLATION, ROTATION, SCALE, +% FFD_SETTING, FFD_NACELLE +% FFD_CONTROL_POINT, FFD_CAMBER, FFD_THICKNESS, FFD_TWIST +% FFD_CONTROL_POINT_2D, FFD_CAMBER_2D, FFD_THICKNESS_2D, FFD_TWIST_2D, +% HICKS_HENNE, SURFACE_BUMP) +DV_KIND= HICKS_HENNE +% +% Marker of the surface in which we are going apply the shape deformation +DV_MARKER= ( cylinder_outer1, cylinder_inner1, cylinder_outer2, cylinder_inner2, cylinder_outer3, cylinder_inner3 ) +% +% Parameters of the shape deformation +% - NO_DEFORMATION ( 1.0 ) +% - TRANSLATION ( x_Disp, y_Disp, z_Disp ), as a unit vector +% - ROTATION ( x_Orig, y_Orig, z_Orig, x_End, y_End, z_End ) +% - SCALE ( 1.0 ) +% - ANGLE_OF_ATTACK ( 1.0 ) +% - FFD_SETTING ( 1.0 ) +% - FFD_CONTROL_POINT ( FFD_BoxTag, i_Ind, j_Ind, k_Ind, x_Disp, y_Disp, z_Disp ) +% - FFD_NACELLE ( FFD_BoxTag, rho_Ind, theta_Ind, phi_Ind, rho_Disp, phi_Disp ) +% - FFD_GULL ( FFD_BoxTag, j_Ind ) +% - FFD_ANGLE_OF_ATTACK ( FFD_BoxTag, 1.0 ) +% - FFD_CAMBER ( FFD_BoxTag, i_Ind, j_Ind ) +% - FFD_THICKNESS ( FFD_BoxTag, i_Ind, j_Ind ) +% - FFD_TWIST ( FFD_BoxTag, j_Ind, x_Orig, y_Orig, z_Orig, x_End, y_End, z_End ) +% - FFD_CONTROL_POINT_2D ( FFD_BoxTag, i_Ind, j_Ind, x_Disp, y_Disp ) +% - FFD_CAMBER_2D ( FFD_BoxTag, i_Ind ) +% - FFD_THICKNESS_2D ( FFD_BoxTag, i_Ind ) +% - FFD_TWIST_2D ( FFD_BoxTag, x_Orig, y_Orig ) +% - HICKS_HENNE ( Lower Surface (0)/Upper Surface (1)/Only one Surface (2), x_Loc ) +% - SURFACE_BUMP ( x_Start, x_End, x_Loc ) +DV_PARAM= (0.0, 0.5) +% +% Value of the shape deformation +DV_VALUE= 0.1 diff --git a/TestCases/coupled_cht/incomp_2d/flow_cylinder.cfg b/TestCases/coupled_cht/incomp_2d/flow_cylinder.cfg new file mode 100644 index 000000000000..651ab1abfe8d --- /dev/null +++ b/TestCases/coupled_cht/incomp_2d/flow_cylinder.cfg @@ -0,0 +1,258 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Steady incompressible laminar flow around heated cylinders % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= INC_NAVIER_STOKES +% +% If Navier-Stokes, kind of turbulent model (NONE, SA) +KIND_TURB_MODEL= NONE +% +% Restart solution (NO, YES) +RESTART_SOL= NO +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) +% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. +OBJECTIVE_FUNCTION= TOTAL_HEATFLUX +% +% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. +OBJECTIVE_WEIGHT = 1.0 +% +% Read binary restart files (YES, NO) +READ_BINARY_RESTART = YES +% +% Data written to history file +HISTORY_OUTPUT=(ITER, RMS_RES, HEAT ) + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% Farfield boundary marker(s) (NONE = no marker) +MARKER_FAR= ( farfield ) +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= (cylinder_outer1, cylinder_outer2, cylinder_outer3) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= (cylinder_outer1, cylinder_outer2, cylinder_outer3) + +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +% Density model within the incompressible flow solver. +% Options are CONSTANT (default), BOUSSINESQ, or VARIABLE. If VARIABLE, +% an appropriate fluid model must be selected. +INC_DENSITY_MODEL= VARIABLE +% +% Solve the energy equation in the incompressible flow solver +INC_ENERGY_EQUATION = YES +% +% Initial density for incompressible flows (1.2886 kg/m^3 by default) +INC_DENSITY_INIT= 0.000210322 +% +% Initial velocity for incompressible flows (1.0,0,0 m/s by default) +INC_VELOCITY_INIT= ( 3.40297, 0.0, 0.0 ) +% +% Initial temperature for incompressible flows that include the +% energy equation (288.15 K by default). Value is ignored if +% INC_ENERGY_EQUATION is false. +INC_TEMPERATURE_INIT= 288.15 +% +% Non-dimensionalization scheme for incompressible flows. Options are +% INITIAL_VALUES (default), REFERENCE_VALUES, or DIMENSIONAL. +% INC_*_REF values are ignored unless REFERENCE_VALUES is chosen. +INC_NONDIM= DIMENSIONAL + +% ---- IDEAL GAS, POLYTROPIC, VAN DER WAALS AND PENG ROBINSON CONSTANTS -------% +% +% Fluid model (STANDARD_AIR, IDEAL_GAS, VW_GAS, PR_GAS, +% CONSTANT_DENSITY, INC_IDEAL_GAS) +FLUID_MODEL= INC_IDEAL_GAS +% +% Specific heat at constant pressure, Cp (1004.703 J/kg*K (air)). +% Incompressible fluids with energy eqn. only (CONSTANT_DENSITY, INC_IDEAL_GAS). +SPECIFIC_HEAT_CP= 1004.703 +% +% Molecular weight for an incompressible ideal gas (28.96 g/mol (air) default) +% Incompressible fluids with energy eqn. only (CONSTANT_DENSITY, INC_IDEAL_GAS). +MOLECULAR_WEIGHT= 28.96 + +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +% Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY). +VISCOSITY_MODEL= CONSTANT_VISCOSITY +% +% Molecular Viscosity that would be constant (1.716E-5 by default) +MU_CONSTANT= 1.7893e-05 +% +% Sutherland Viscosity Ref (1.716E-5 default value for AIR SI) +MU_REF= 1.716E-5 +% +% Sutherland Temperature Ref (273.15 K default value for AIR SI) +MU_T_REF= 273.15 +% +% Sutherland constant (110.4 default value for AIR SI) +SUTHERLAND_CONSTANT= 110.4 + +% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% +% +% Conductivity model (CONSTANT_CONDUCTIVITY, CONSTANT_PRANDTL). +CONDUCTIVITY_MODEL= CONSTANT_PRANDTL +% +% Molecular Thermal Conductivity that would be constant (0.0257 by default) +KT_CONSTANT= 0.0257 +% +% Laminar Prandtl number (0.72 (air), only for CONSTANT_PRANDTL) +PRANDTL_LAM= 0.72 +% +% Turbulent Prandtl number (0.9 (air), only for CONSTANT_PRANDTL) +PRANDTL_TURB= 0.90 + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 10.0, 10000.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linael solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-15 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 5 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +% Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, HLLC, +% TURKEL_PREC, MSW) +CONV_NUM_METHOD_FLOW= FDS +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_FLOW= YES +% +% Slope limiter (NONE, VENKATAKRISHNAN, VENKATAKRISHNAN_WANG, +% BARTH_JESPERSEN, VAN_ALBADA_EDGE) +SLOPE_LIMITER_FLOW= NONE +% +% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_FLOW= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -19 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 100 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Restart adjoint input file +SOLUTION_ADJ_FILENAME= solution_adj.dat +% +% Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, +% FIELDVIEW, FIELDVIEW_BINARY) +TABULAR_FORMAT= TECPLOT +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history +% +% Output file with the forces breakdown +BREAKDOWN_FILENAME= forces_breakdown.dat +% +% Output file restart flow +RESTART_FILENAME= restart_flow.dat +% +% Output file restart adjoint +RESTART_ADJ_FILENAME= restart_adj.dat +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file adjoint (w/o extension) variables +VOLUME_ADJ_FILENAME= adjoint +% +% Output Objective function +VALUE_OBJFUNC_FILENAME= of_eval.dat +% +% Output objective function gradient (using continuous adjoint) +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Output file surface adjoint coefficient (w/o extension) +SURFACE_ADJ_FILENAME= surface_adjoint +% +% Writing solution file frequency +WRT_SOL_FREQ= 250 +% +% Writing convergence history frequency +WRT_CON_FREQ= 1 + +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_ITER= 200 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% Visualize the deformation (NO, YES) +VISUALIZE_VOLUME_DEF= YES diff --git a/TestCases/coupled_cht/incomp_2d/solid_cylinder1.cfg b/TestCases/coupled_cht/incomp_2d/solid_cylinder1.cfg new file mode 100644 index 000000000000..61e97b996331 --- /dev/null +++ b/TestCases/coupled_cht/incomp_2d/solid_cylinder1.cfg @@ -0,0 +1,186 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Steady incompressible laminar flow around heated cylinders % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= HEAT_EQUATION_FVM +% +% Restart solution (NO, YES) +RESTART_SOL= NO +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) +% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. +OBJECTIVE_FUNCTION= TOTAL_HEATFLUX +% +% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. +OBJECTIVE_WEIGHT = 1.0 +% +% Read binary restart files (YES, NO) +READ_BINARY_RESTART = YES + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_ISOTHERMAL= ( core1, 350.0 ) +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= (cylinder_inner1 ) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( NONE ) + +% ---------------- (SOLIDS) CONDUCTION CONDITION DEFINITION -------------------% +% +% We should keep the dimensionalization of the coupled flow solver +INC_NONDIM= DIMENSIONAL +% +% Temperature initialization value +SOLID_TEMPERATURE_INIT= 350.0 +% +% Nettis case: hollow cylinder (air w/ 4x the conductivity) +% +% Solid density (kg/m^3) +SOLID_DENSITY= 0.000210322 +% +% Solid specific heat (J/kg*K) +SPECIFIC_HEAT_CP_SOLID = 1004.703 +% +% Solid thermal conductivity (W/m*K) +THERMAL_CONDUCTIVITY_SOLID= 0.1028 + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 10.0, 10000.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linael solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-15 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 5 + +% -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% +% +TIME_DISCRE_HEAT= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -19 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 100 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Restart adjoint input file +SOLUTION_ADJ_FILENAME= solution_adj.dat +% +% Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, +% FIELDVIEW, FIELDVIEW_BINARY) +TABULAR_FORMAT= TECPLOT +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history +% +% Output file with the forces breakdown +BREAKDOWN_FILENAME= forces_breakdown.dat +% +% Output file restart flow +RESTART_FILENAME= restart_flow.dat +% +% Output file restart adjoint +RESTART_ADJ_FILENAME= restart_adj.dat +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file adjoint (w/o extension) variables +VOLUME_ADJ_FILENAME= adjoint +% +% Output Objective function +VALUE_OBJFUNC_FILENAME= of_eval.dat +% +% Output objective function gradient (using continuous adjoint) +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Output file surface adjoint coefficient (w/o extension) +SURFACE_ADJ_FILENAME= surface_adjoint +% +% Writing solution file frequency +WRT_SOL_FREQ= 250 +% +% Writing convergence history frequency +WRT_CON_FREQ= 1 + +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_ITER= 200 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% Visualize the deformation (NO, YES) +VISUALIZE_VOLUME_DEF= YES diff --git a/TestCases/coupled_cht/incomp_2d/solid_cylinder2.cfg b/TestCases/coupled_cht/incomp_2d/solid_cylinder2.cfg new file mode 100644 index 000000000000..1282a952a7dc --- /dev/null +++ b/TestCases/coupled_cht/incomp_2d/solid_cylinder2.cfg @@ -0,0 +1,196 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Steady incompressible laminar flow around heated cylinders % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= HEAT_EQUATION_FVM +% +% Restart solution (NO, YES) +RESTART_SOL= NO +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) +% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. +OBJECTIVE_FUNCTION= TOTAL_HEATFLUX +% +% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. +OBJECTIVE_WEIGHT = 1.0 +% +% Read binary restart files (YES, NO) +READ_BINARY_RESTART = YES + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_ISOTHERMAL= ( core2, 350.0 ) +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= (cylinder_inner2) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( NONE ) + +% ---------------- (SOLIDS) CONDUCTION CONDITION DEFINITION -------------------% +% +% We should keep the dimensionalization of the coupled flow solver +INC_NONDIM= DIMENSIONAL +% +% Temperature initialization value +SOLID_TEMPERATURE_INIT= 350.0 +% +% Nettis case: hollow cylinder (air w/ 4x the conductivity) +% +% Solid density (kg/m^3) +SOLID_DENSITY= 0.000210322 +% +% Solid specific heat (J/kg*K) +SPECIFIC_HEAT_CP_SOLID = 1004.703 +% +% Solid thermal conductivity (W/m*K) +THERMAL_CONDUCTIVITY_SOLID= 0.1028 + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 10.0, 10000.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linael solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-15 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 5 + +% -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% +% +% Time discretization (EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_HEAT= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -19 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 100 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Restart adjoint input file +SOLUTION_ADJ_FILENAME= solution_adj.dat +% +% Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, +% FIELDVIEW, FIELDVIEW_BINARY) +TABULAR_FORMAT= TECPLOT +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history +% +% Output file with the forces breakdown +BREAKDOWN_FILENAME= forces_breakdown.dat +% +% Output file restart flow +RESTART_FILENAME= restart_flow.dat +% +% Output file restart adjoint +RESTART_ADJ_FILENAME= restart_adj.dat +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file adjoint (w/o extension) variables +VOLUME_ADJ_FILENAME= adjoint +% +% Output Objective function +VALUE_OBJFUNC_FILENAME= of_eval.dat +% +% Output objective function gradient (using continuous adjoint) +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Output file surface adjoint coefficient (w/o extension) +SURFACE_ADJ_FILENAME= surface_adjoint +% +% Writing solution file frequency +WRT_SOL_FREQ= 250 +% +% Writing convergence history frequency +WRT_CON_FREQ= 1 + +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_ITER= 200 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% Visualize the deformation (NO, YES) +VISUALIZE_VOLUME_DEF= YES diff --git a/TestCases/coupled_cht/incomp_2d/solid_cylinder3.cfg b/TestCases/coupled_cht/incomp_2d/solid_cylinder3.cfg new file mode 100644 index 000000000000..89c0c5e7a9cc --- /dev/null +++ b/TestCases/coupled_cht/incomp_2d/solid_cylinder3.cfg @@ -0,0 +1,196 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Steady incompressible laminar flow around heated cylinders % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= HEAT_EQUATION_FVM +% +% Restart solution (NO, YES) +RESTART_SOL= NO +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) +% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. +OBJECTIVE_FUNCTION= TOTAL_HEATFLUX +% +% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. +OBJECTIVE_WEIGHT = 1.0 +% +% Read binary restart files (YES, NO) +READ_BINARY_RESTART = YES + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_ISOTHERMAL= ( core3, 350.0 ) +% +% Marker(s) of the surface to be plotted or designed +MARKER_PLOTTING= ( cylinder_inner3 ) +% +% Marker(s) of the surface where the functional (Cd, Cl, etc.) will be evaluated +MARKER_MONITORING= ( NONE ) + +% ---------------- (SOLIDS) CONDUCTION CONDITION DEFINITION -------------------% +% +% We should keep the dimensionalization of the coupled flow solver +INC_NONDIM= DIMENSIONAL +% +% Temperature initialization value +SOLID_TEMPERATURE_INIT= 350.0 +% +% Nettis case: hollow cylinder (air w/ 4x the conductivity) +% +% Solid density (kg/m^3) +SOLID_DENSITY= 0.000210322 +% +% Solid specific heat (J/kg*K) +SPECIFIC_HEAT_CP_SOLID = 1004.703 +% +% Solid thermal conductivity (W/m*K) +THERMAL_CONDUCTIVITY_SOLID= 0.1028 + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% Courant-Friedrichs-Lewy condition of the finest grid +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 1.5, 0.5, 10.0, 10000.0 ) +% +% Runge-Kutta alpha coefficients +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) +% +% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, +% MOMENT_Y, MOMENT_Z, EFFICIENCY, +% EQUIVALENT_AREA, NEARFIELD_PRESSURE, +% FORCE_X, FORCE_Y, FORCE_Z, THRUST, +% TORQUE, TOTAL_HEATFLUX, +% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, +% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, +% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linael solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 1E-15 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 5 + +% -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% +% +% Time discretization (EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_HEAT= EULER_IMPLICIT + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -19 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 +% +% Number of elements to apply the criteria +CONV_CAUCHY_ELEMS= 100 +% +% Epsilon to control the series convergence +CONV_CAUCHY_EPS= 1E-6 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Restart adjoint input file +SOLUTION_ADJ_FILENAME= solution_adj.dat +% +% Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, +% FIELDVIEW, FIELDVIEW_BINARY) +TABULAR_FORMAT= TECPLOT +% +% Output file convergence history (w/o extension) +CONV_FILENAME= history +% +% Output file with the forces breakdown +BREAKDOWN_FILENAME= forces_breakdown.dat +% +% Output file restart flow +RESTART_FILENAME= restart_flow.dat +% +% Output file restart adjoint +RESTART_ADJ_FILENAME= restart_adj.dat +% +% Output file flow (w/o extension) variables +VOLUME_FILENAME= flow +% +% Output file adjoint (w/o extension) variables +VOLUME_ADJ_FILENAME= adjoint +% +% Output Objective function +VALUE_OBJFUNC_FILENAME= of_eval.dat +% +% Output objective function gradient (using continuous adjoint) +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Output file surface flow coefficient (w/o extension) +SURFACE_FILENAME= surface_flow +% +% Output file surface adjoint coefficient (w/o extension) +SURFACE_ADJ_FILENAME= surface_adjoint +% +% Writing solution file frequency +WRT_SOL_FREQ= 250 +% +% Writing convergence history frequency +WRT_CON_FREQ= 1 + +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +% Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) +DEFORM_LINEAR_SOLVER= FGMRES +% +% Number of smoothing iterations for mesh deformation +DEFORM_LINEAR_ITER= 200 +% +% Number of nonlinear deformation iterations (surface deformation increments) +DEFORM_NONLINEAR_ITER= 1 +% +% Print the residuals during mesh deformation to the console (YES, NO) +DEFORM_CONSOLE_OUTPUT= YES +% +% Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, +% WALL_DISTANCE, CONSTANT_STIFFNESS) +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +% +% Visualize the deformation (NO, YES) +VISUALIZE_VOLUME_DEF= YES diff --git a/TestCases/coupled_cht/incompressible/config.cfg b/TestCases/coupled_cht/incompressible/config.cfg deleted file mode 100644 index 0aa8e2473331..000000000000 --- a/TestCases/coupled_cht/incompressible/config.cfg +++ /dev/null @@ -1,25 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% SU2 configuration file % -% Case description: 2D Cylinder test case for CHT coupling % -% Author: Ole Burghardt % -% Institution: Chair for Scientific Computing, TU Kaiserslautern % -% Date: March 12th, 2018 % -% File Version 6.0.1 "Falcon" % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SOLVER= MULTIPHYSICS - -CONFIG_LIST = (configFlow.cfg, configSolid.cfg) - -MARKER_ZONE_INTERFACE= (PIN, PINSD) - -MESH_FILENAME= coupled_cht_cylinder2d.su2 - -TIME_DOMAIN = NO - -OUTER_ITER = 11 - -% Only required by the python scripts -MATH_PROBLEM = DIRECT -WRT_SOL_FREQ = 100 diff --git a/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg b/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg index 110917c6ae2b..00ba0cae1050 100755 --- a/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg +++ b/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg @@ -40,7 +40,7 @@ MATERIAL_DENSITY= 2700.0 % Boundary conditions -------------------------------------------------- % % fluid MARKER_FAR= ( farfield ) -MARKER_EULER= ( leading_edge, 0.0, pressure_side, 0.0, suction_side, 0.0) +MARKER_EULER= ( leading_edge, pressure_side, suction_side) % interface % this needs to appear before the normal load marker MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) diff --git a/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg b/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg index 2a3746d8f612..7608733a0ab1 100644 --- a/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg +++ b/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg @@ -312,7 +312,7 @@ WRT_SOL_FREQ= 250 WRT_CON_FREQ= 1 % % Screen output -SCREEN_OUTPUT= (INNER_ITER, RMS_ADJ_PRESSURE, RMS_ADJ_HEAT, SENS_PRESS, SENS_AOA) +SCREEN_OUTPUT= (INNER_ITER, RMS_ADJ_PRESSURE, RMS_ADJ_TEMPERATURE, SENS_PRESS, SENS_AOA) % ----------------------- DESIGN VARIABLE PARAMETERS --------------------------% % % Kind of deformation (NO_DEFORMATION, TRANSLATION, ROTATION, SCALE, diff --git a/TestCases/fea_fsi/Airfoil_RBF/config.cfg b/TestCases/fea_fsi/Airfoil_RBF/config.cfg index cf944219af6c..437ca3394f55 100755 --- a/TestCases/fea_fsi/Airfoil_RBF/config.cfg +++ b/TestCases/fea_fsi/Airfoil_RBF/config.cfg @@ -1,25 +1,25 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % % SU2 configuration file % % Case description: 2D airfoil FSI with radial basis function interp. % % Institution: Imperial College London % % Date: 2015.08.12 % -% File Version 3.9 "eagle" % -% % +% File Version 6.2 "Falcon" % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -SOLVER= MULTIPHYSICS +SOLVER = MULTIPHYSICS CONFIG_LIST = (configFlow.cfg, configFEA.cfg) MULTIZONE_SOLVER = BLOCK_GAUSS_SEIDEL -MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) +MARKER_ZONE_INTERFACE = (pressure_side,pressure_side_s, suction_side,suction_side_s) -MESH_FILENAME= mesh.su2 +MESH_FILENAME = mesh.su2 TIME_DOMAIN = NO -OUTER_ITER = 1 +OUTER_ITER = 50 +% enable this option to see convergence output for individual zones +WRT_ZONE_CONV = NO diff --git a/TestCases/fea_fsi/Airfoil_RBF/configFEA.cfg b/TestCases/fea_fsi/Airfoil_RBF/configFEA.cfg index 44ea9d2eaac6..fa18417b62ee 100644 --- a/TestCases/fea_fsi/Airfoil_RBF/configFEA.cfg +++ b/TestCases/fea_fsi/Airfoil_RBF/configFEA.cfg @@ -6,16 +6,12 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Interface options ---------------------------------------------------- % - +% See "configFlow.cfg" for explanation of these options. KIND_INTERPOLATION = RADIAL_BASIS_FUNCTION -CONSERVATIVE_INTERPOLATION = NO +CONSERVATIVE_INTERPOLATION = YES KIND_RADIAL_BASIS_FUNCTION = WENDLAND_C2 RADIAL_BASIS_FUNCTION_PARAMETER = 0.015 RADIAL_BASIS_FUNCTION_POLYNOMIAL_TERM = YES - -INNER_ITER = 30 -WRT_BINARY_RESTART=NO -READ_BINARY_RESTART=NO % % Physics -------------------------------------------------------------- % SOLVER= ELASTICITY @@ -29,20 +25,10 @@ MATERIAL_DENSITY= 2700.0 % % Boundary conditions -------------------------------------------------- % MARKER_PRESSURE= ( pressure_side_s,0.0, suction_side_s,0.0 ) -MARKER_FLUID_LOAD = (pressure_side_s, suction_side_s, clamped) -MARKER_CLAMPED = ( clamped ) -% -% Common numerics settings --------------------------------------------- % -REF_DIMENSIONALIZATION= DIMENSIONAL -NUM_METHOD_GRAD= GREEN_GAUSS -CFL_NUMBER= 10.0 +MARKER_FLUID_LOAD= ( pressure_side_s, suction_side_s, clamped ) +MARKER_CLAMPED= ( clamped ) % -% Flow numerics -------------------------------------------------------- % -CONV_NUM_METHOD_FLOW= JST -JST_SENSOR_COEFF= ( 0.5, 0.02 ) -TIME_DISCRE_FLOW= EULER_IMPLICIT -% -% Solid numerics ------------------------------------------------------- % +% Numerics ------------------------------------------------------------- % GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS FORMULATION_ELASTICITY_2D= PLANE_STRESS % @@ -53,31 +39,31 @@ LINEAR_SOLVER_ERROR= 1E-6 LINEAR_SOLVER_ITER= 1000 LINEAR_SOLVER_RESTART_FREQUENCY= 100 % -% Convergence criteria ------------------------------------------------- % -OUTER_ITER= 1 -% interaction -FSI_ITER= 1 -% if running from scratch this helps a bunch +% Fluid-structure interaction ------------------------------------------ % +% when running from scratch RAMP_LOADING helps (don't do it with restart) %RAMP_LOADING= YES %RAMP_FSI_ITER= 5 BGS_RELAXATION= FIXED_PARAMETER STAT_RELAX_PARAMETER= 0.7 -% solid -NONLINEAR_FEM_INT_ITER= 30 +% +% Convergence criteria ------------------------------------------------- % +INNER_ITER= 30 +CONV_FIELD= RMS_UTOL, RMS_ETOL +CONV_STARTITER= 0 +CONV_RESIDUAL_MINVAL= -5 % % In\Out --------------------------------------------------------------- % MESH_FILENAME= meshFEA.su2 MESH_FORMAT= SU2 -MULTIZONE_MESH = NO -% +MULTIZONE_MESH= NO +% inputs RESTART_SOL= YES SOLUTION_FILENAME= solution_solid.dat -WRT_SOL_FREQ= 999999 +% outputs +WRT_SOL_FREQ= 9999 RESTART_FILENAME= restart_solid.dat -% -TABULAR_FORMAT= CSV VOLUME_FILENAME= solid -% -WRT_CON_FREQ= 10 +% history and screen +SCREEN_WRT_FREQ_INNER= 10 CONV_FILENAME= history diff --git a/TestCases/fea_fsi/Airfoil_RBF/configFlow.cfg b/TestCases/fea_fsi/Airfoil_RBF/configFlow.cfg index e255e2118c55..c4865ad0e1cf 100644 --- a/TestCases/fea_fsi/Airfoil_RBF/configFlow.cfg +++ b/TestCases/fea_fsi/Airfoil_RBF/configFlow.cfg @@ -6,23 +6,35 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Interface options ---------------------------------------------------- % - +% This is one of the ways of interpolating between non-matching meshes, +% its attractiveness comes from removing the need to map nodes between +% sides, the downside is that dense matrix algebra is involved, so w.r.t. +% the number of interface nodes the approach is quadratic in memory and +% cubic in computation. To manage this the interface needs to be split in +% patches (by the user, this example has 2 patches), compiling with BLAS +% and LAPACK is recommended. KIND_INTERPOLATION = RADIAL_BASIS_FUNCTION -CONSERVATIVE_INTERPOLATION = NO +% Conserve virtual work by using the transpose of the displacement +% interpolation matrix when transferring fluid loads, this is usually the +% best option, if the range of cell sizes on the interface is large (2-3 +% orders) and you have issues, break up the interface or use "NO" for +% consistent interpolation. +CONSERVATIVE_INTERPOLATION = YES +% Wendland provides good results and produces a nice diagonally dominant +% interpolation kernel, other options: +% INV_MULTI_QUADRIC; GAUSSIAN; THIN_PLATE_SPLINE; MULTI_QUADRIC KIND_RADIAL_BASIS_FUNCTION = WENDLAND_C2 +% The radius in meters, 2 times the largest cell size on the interface is +% a good compromise between accuracy and condition number of the kernel. RADIAL_BASIS_FUNCTION_PARAMETER = 0.015 +% Recommended as it recovers rigid body motion, only requires a few more +% matrix products... feel free to explore though! RADIAL_BASIS_FUNCTION_POLYNOMIAL_TERM = YES - -WRT_BINARY_RESTART=NO -READ_BINARY_RESTART=NO % % Physics -------------------------------------------------------------- % SOLVER= EULER MATH_PROBLEM= DIRECT KIND_TURB_MODEL= NONE - -MULTIZONE_MESH = NO -INNER_ITER= 60 % % Compressible free-stream conditions ---------------------------------- % MACH_NUMBER= 0.7 @@ -39,14 +51,8 @@ GAMMA_VALUE= 1.4 GAS_CONSTANT= 287.87 % % Boundary conditions -------------------------------------------------- % -% fluid MARKER_FAR= ( farfield ) -MARKER_EULER= ( leading_edge, 0.0, pressure_side, 0.0, suction_side, 0.0) -% solid -MARKER_CLAMPED = ( clamped ) -% -SURFACE_MOVEMENT= FLUID_STRUCTURE_STATIC -MARKER_MOVING= ( leading_edge, pressure_side, suction_side ) +MARKER_EULER= ( leading_edge, pressure_side, suction_side ) % % Post processing and monitoring --------------------------------------- % REF_ORIGIN_MOMENT_X= -0.125 @@ -58,22 +64,15 @@ MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) % -% Common numerics settings --------------------------------------------- % -REF_DIMENSIONALIZATION= DIMENSIONAL -NUM_METHOD_GRAD= GREEN_GAUSS -CFL_NUMBER= 10.0 -% % Flow numerics -------------------------------------------------------- % CONV_NUM_METHOD_FLOW= JST JST_SENSOR_COEFF= ( 0.5, 0.02 ) TIME_DISCRE_FLOW= EULER_IMPLICIT +REF_DIMENSIONALIZATION= DIMENSIONAL +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER= 10.0 % -% Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= BCGSTAB -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-2 -LINEAR_SOLVER_ITER= 100 -% Multigrid +% Multigrid ------------------------------------------------------------ % MGLEVEL= 1 MGCYCLE= V_CYCLE MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) @@ -82,41 +81,43 @@ MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) MG_DAMP_RESTRICTION= 0.75 MG_DAMP_PROLONGATION= 0.75 % +% Grid deformation ----------------------------------------------------- % +SURFACE_MOVEMENT= FLUID_STRUCTURE_STATIC +MARKER_MOVING= ( leading_edge, pressure_side, suction_side ) +DEFORM_NONLINEAR_ITER= 1 +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +DEFORM_CONSOLE_OUTPUT= NO +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= BCGSTAB +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-2 +LINEAR_SOLVER_ITER= 100 +% DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT DEFORM_LINEAR_SOLVER_PREC= ILU DEFORM_LINEAR_SOLVER_ERROR= 1e-6 DEFORM_LINEAR_SOLVER_ITER= 1000 % % Convergence criteria ------------------------------------------------- % -OUTER_ITER= 1 -% interaction -FSI_ITER= 1 -% if running from scratch this helps a bunch -%RAMP_LOADING= YES -%RAMP_FSI_ITER= 5 -BGS_RELAXATION= FIXED_PARAMETER -STAT_RELAX_PARAMETER= 0.7 -% fluid +INNER_ITER= 60 CONV_CRITERIA= RESIDUAL CONV_STARTITER= 0 CONV_RESIDUAL_MINVAL= -9 -% grid deformation -DEFORM_NONLINEAR_ITER= 1 -DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME % % In\Out --------------------------------------------------------------- % MESH_FILENAME= meshFlow.su2 MESH_FORMAT= SU2 -% +MULTIZONE_MESH= NO +% inputs RESTART_SOL= YES SOLUTION_FILENAME= solution_fluid.dat -WRT_SOL_FREQ= 999999 +% outputs +WRT_SOL_FREQ= 9999 RESTART_FILENAME= restart_fluid.dat -% -TABULAR_FORMAT= CSV VOLUME_FILENAME= fluid SURFACE_FILENAME= surface_fluid -% -WRT_CON_FREQ= 10 +% history and screen +SCREEN_WRT_FREQ_INNER= 10 CONV_FILENAME= history diff --git a/TestCases/fea_fsi/Airfoil_RBF/settings.cfg b/TestCases/fea_fsi/Airfoil_RBF/settings.cfg deleted file mode 100644 index 6a8b9e76ec6b..000000000000 --- a/TestCases/fea_fsi/Airfoil_RBF/settings.cfg +++ /dev/null @@ -1,171 +0,0 @@ -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% SU2 configuration file % -% Case description: 2D airfoil FSI with radial basis function interp. % -% Institution: Imperial College London % -% File Version 6.2.0 "Falcon" % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Interface options ---------------------------------------------------- % - -% This is one of the ways of interpolating between non-matching meshes, -% its attractiveness comes from removing the need to map nodes between -% sides, the downside is that dense matrix algebra is involved, so w.r.t. -% the number of interface nodes the approach is quadratic in memory and -% cubic in computation. To manage this the interface needs to be split in -% patches (by the user, this example has 2 patches), compiling with BLAS -% and LAPACK is also recommended and the way to get some parallelism (if -% the particular library supports it), to do so you need to set the env -% var CPPFLAGS=-DHAVE_LAPACK plus LDFLAGS and LIBS appropriately: -% Ref. LAPACK: LDFLAGS=-L/libdirpath LIBS=-llapack -lrefblas -lgfortran -% OpenBLAS: LDFLAGS=-L/libdirpath LIBS=-lopenblas -lgfortran -% Others are similar, check the docs of your library of choice. -KIND_INTERPOLATION = RADIAL_BASIS_FUNCTION -% Conserve virtual work by using the transpose of the displacement -% interpolation matrix when transferring fluid loads, this is usually the -% best option, if the range of cell sizes on the interface is large (2-3 -% orders) and you have issues, break up the interface or use "NO" for -% consistent interpolation. -CONSERVATIVE_INTERPOLATION = YES -% Wendland provides good results and produces a nice diagonally dominant -% interpolation kernel, other options: -% INV_MULTI_QUADRIC; GAUSSIAN; THIN_PLATE_SPLINE; MULTI_QUADRIC -KIND_RADIAL_BASIS_FUNCTION = WENDLAND_C2 -% The radius in meters, 2 times the largest cell size on the interface is -% a good compromise between accuracy and condition number of the kernel. -RADIAL_BASIS_FUNCTION_PARAMETER = 0.015 -% Recommended as it recovers rigid body motion, only requires a few more -% matrix products... feel free to explore though! -RADIAL_BASIS_FUNCTION_POLYNOMIAL_TERM = YES -% -% Physics -------------------------------------------------------------- % -SOLVER= FLUID_STRUCTURE_INTERACTION -MATH_PROBLEM= DIRECT -% -FSI_FLUID_PROBLEM= EULER -KIND_TURB_MODEL= NONE -FSI_STRUCTURAL_PROBLEM= ELASTICITY -% -% Compressible free-stream conditions ---------------------------------- % -MACH_NUMBER= 0.7 -AOA= 2.5 -INIT_OPTION= TD_CONDITIONS -FREESTREAM_OPTION= TEMPERATURE_FS -FREESTREAM_PRESSURE= 101325.0 -FREESTREAM_TEMPERATURE= 273.15 -REYNOLDS_LENGTH= 0.5 -% -% Fluid properties ----------------------------------------------------- % -FLUID_MODEL= IDEAL_GAS -GAMMA_VALUE= 1.4 -GAS_CONSTANT= 287.87 -% -% Solid properties ----------------------------------------------------- % -MATERIAL_MODEL= NEO_HOOKEAN -ELASTICITY_MODULUS= 7E8 -POISSON_RATIO= 0.35 -MATERIAL_DENSITY= 2700.0 -% -% Boundary conditions -------------------------------------------------- % -% fluid -MARKER_FAR= ( farfield ) -MARKER_EULER= ( leading_edge, 0.0, pressure_side, 0.0, suction_side, 0.0) -% interface -% this needs to appear before the last dummy load marker -MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) -% solid -MARKER_CLAMPED = ( clamped ) -% this needs to be here to make SU2 happy -MARKER_PRESSURE= ( pressure_side_s,0.0, suction_side_s,0.0 ) -% -SURFACE_MOVEMENT= FLUID_STRUCTURE_STATIC -MARKER_MOVING= ( leading_edge, pressure_side, suction_side ) -% -% Post processing and monitoring --------------------------------------- % -REF_ORIGIN_MOMENT_X= -0.125 -REF_ORIGIN_MOMENT_Y= 0.00 -REF_ORIGIN_MOMENT_Z= 0.00 -REF_LENGTH= 0.5 -REF_AREA= 0.5 -MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) -MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) -MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) -% -% Common numerics settings --------------------------------------------- % -REF_DIMENSIONALIZATION= DIMENSIONAL -NUM_METHOD_GRAD= GREEN_GAUSS -CFL_NUMBER= 10.0 -% -% Flow numerics -------------------------------------------------------- % -CONV_NUM_METHOD_FLOW= JST -JST_SENSOR_COEFF= ( 0.5, 0.02 ) -TIME_DISCRE_FLOW= EULER_IMPLICIT -% -% Solid numerics ------------------------------------------------------- % -GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS -FORMULATION_ELASTICITY_2D= PLANE_STRESS -% -% Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= BCGSTAB -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-2 -LINEAR_SOLVER_ITER= 100 -% Multigrid -MGLEVEL= 1 -MGCYCLE= V_CYCLE -MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) -MG_POST_SMOOTH= ( 0, 0, 0, 0 ) -MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) -MG_DAMP_RESTRICTION= 0.75 -MG_DAMP_PROLONGATION= 0.75 -% -FSI_LINEAR_SOLVER_STRUC= RESTARTED_FGMRES -FSI_LINEAR_SOLVER_PREC_STRUC= ILU -FSI_LINEAR_SOLVER_ERROR_STRUC= 1E-6 -FSI_LINEAR_SOLVER_ITER_STRUC= 1000 -LINEAR_SOLVER_RESTART_FREQUENCY= 100 -% -DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT -DEFORM_LINEAR_SOLVER_PREC= ILU -DEFORM_LINEAR_SOLVER_ERROR= 1e-6 -DEFORM_LINEAR_SOLVER_ITER= 1000 -% -% Convergence criteria ------------------------------------------------- % -EXT_ITER= 1 -% interaction -FSI_ITER= 1 -% if running from scratch this helps a bunch -%RAMP_LOADING= YES -%RAMP_FSI_ITER= 5 -BGS_RELAXATION= FIXED_PARAMETER -STAT_RELAX_PARAMETER= 0.7 -CONV_RESIDUAL_MINVAL_FSI= -8 -% fluid -UNST_INT_ITER= 60 -CONV_CRITERIA= RESIDUAL -CONV_STARTITER= 0 -CONV_RESIDUAL_MINVAL= -9 -% solid -NONLINEAR_FEM_INT_ITER= 30 -% grid deformation -DEFORM_NONLINEAR_ITER= 1 -DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME -% -% In\Out --------------------------------------------------------------- % -MESH_FILENAME= mesh.su2 -MESH_FORMAT= SU2 -% -RESTART_SOL= YES -SOLUTION_FILENAME= solution_fluid.dat -SOLUTION_STRUCTURE_FILENAME= solution_solid.dat -WRT_SOL_FREQ= 999999 -RESTART_FILENAME= restart_fluid.dat -RESTART_STRUCTURE_FILENAME= restart_solid.dat -% -TABULAR_FORMAT= CSV -VOLUME_FILENAME= fluid -SURFACE_FILENAME= surface_fluid -VOLUME_STRUCTURE_FILENAME= solid -% -WRT_CON_FREQ= 10 -CONV_FILENAME= history - diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 520867292dd0..f0477b8a9577 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1111,11 +1111,11 @@ def main(): # CHT incompressible cht_incompressible = TestCase('cht_incompressible') - cht_incompressible.cfg_dir = "coupled_cht/incompressible" - cht_incompressible.cfg_file = "config.cfg" + cht_incompressible.cfg_dir = "coupled_cht/incomp_2d" + cht_incompressible.cfg_file = "cht_2d_3cylinders.cfg" cht_incompressible.test_iter = 10 - cht_incompressible.test_vals = [10.000000, -2.607260, -2.708775] #last 4 columns - cht_incompressible.su2_exec = "mpirun -n 2 SU2_CFD" + cht_incompressible.test_vals = [-2.132187, -0.579649, -0.579649, -0.579649] #last 4 columns + cht_incompressible.su2_exec = "SU2_CFD" cht_incompressible.timeout = 1600 cht_incompressible.multizone = True cht_incompressible.tol = 0.00001 diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index c7debc389a0c..bd1995839977 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -254,7 +254,7 @@ def main(): discadj_heat.cfg_dir = "disc_adj_heat" discadj_heat.cfg_file = "disc_adj_heat.cfg" discadj_heat.test_iter = 10 - discadj_heat.test_vals = [3.183906, 0.923840, -223.200000, -2059.800000] #last 4 columns + discadj_heat.test_vals = [-2.281765, 0.706785, -0.743990, -6.866000] #last 4 columns discadj_heat.su2_exec = "parallel_computation.py -f" discadj_heat.timeout = 1600 discadj_heat.tol = 0.00001 @@ -275,6 +275,21 @@ def main(): # discadj_fsi.tol = 0.00001 # test_list.append(discadj_fsi) + ################################### + ### Coupled CHT Adjoint ### + ################################### + + # Coupled discrete adjoint for heatflux in heated cylinder array + discadj_cht = TestCase('discadj_cht') + discadj_cht.cfg_dir = "coupled_cht/disc_adj_incomp_2d" + discadj_cht.cfg_file = "cht_2d_3cylinders.cfg" + discadj_cht.test_iter = 10 + discadj_cht.test_vals = [-2.403180, -3.097866, -3.097837, -3.095571] #last 4 columns + discadj_cht.su2_exec = "parallel_computation.py -f" + discadj_cht.timeout = 1600 + discadj_cht.tol = 0.00001 + test_list.append(discadj_cht) + ###################################### ### RUN TESTS ### ###################################### diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index c2bb796f75ff..19e15e8c9ce4 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1193,8 +1193,8 @@ def main(): airfoilRBF = TestCase('airfoil_fsi_rbf') airfoilRBF.cfg_dir = "fea_fsi/Airfoil_RBF" airfoilRBF.cfg_file = "config.cfg" - airfoilRBF.test_iter = 0 - airfoilRBF.test_vals = [0.000000, 1.440246, -2.236518] #last 4 columns + airfoilRBF.test_iter = 1 + airfoilRBF.test_vals = [1.0, -2.979045, -4.882900] airfoilRBF.su2_exec = "SU2_CFD" airfoilRBF.timeout = 1600 airfoilRBF.multizone = True @@ -1207,10 +1207,10 @@ def main(): # CHT incompressible cht_incompressible = TestCase('cht_incompressible') - cht_incompressible.cfg_dir = "coupled_cht/incompressible" - cht_incompressible.cfg_file = "config.cfg" + cht_incompressible.cfg_dir = "coupled_cht/incomp_2d" + cht_incompressible.cfg_file = "cht_2d_3cylinders.cfg" cht_incompressible.test_iter = 10 - cht_incompressible.test_vals = [10.000000, -2.601006, -3.342894] #last 4 columns + cht_incompressible.test_vals = [-2.132187, -0.579649, -0.579649, -0.579649] #last 4 columns cht_incompressible.su2_exec = "SU2_CFD" cht_incompressible.timeout = 1600 cht_incompressible.multizone = True diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index bbe94ac14f5d..d0a9be91b4ff 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -239,7 +239,7 @@ def main(): discadj_heat.cfg_dir = "disc_adj_heat" discadj_heat.cfg_file = "disc_adj_heat.cfg" discadj_heat.test_iter = 10 - discadj_heat.test_vals = [3.139355, 1.144919, -1040.600000, -2464.900000] #last 4 columns + discadj_heat.test_vals = [-2.271573, 0.671194, -3.172000, -8.231600] #last 4 columns discadj_heat.su2_exec = "SU2_CFD_AD" discadj_heat.timeout = 1600 discadj_heat.tol = 0.00001 @@ -258,7 +258,22 @@ def main(): # discadj_fsi.su2_exec = "SU2_CFD_AD" # discadj_fsi.timeout = 1600 # discadj_fsi.tol = 0.00001 -# test_list.append(discadj_fsi) +# test_list.append(discadj_fsi) + + ################################### + ### Coupled CHT Adjoint ### + ################################### + + # Coupled discrete adjoint for heatflux in heated cylinder array + discadj_cht = TestCase('discadj_cht') + discadj_cht.cfg_dir = "coupled_cht/disc_adj_incomp_2d" + discadj_cht.cfg_file = "cht_2d_3cylinders.cfg" + discadj_cht.test_iter = 10 + discadj_cht.test_vals = [-2.403785, -3.097865, -3.097836, -3.097833] #last 4 columns + discadj_cht.su2_exec = "parallel_computation.py -f" + discadj_cht.timeout = 1600 + discadj_cht.tol = 0.00001 + test_list.append(discadj_cht) ###################################### ### RUN TESTS ### diff --git a/meson.build b/meson.build index 94d7310b108e..80eb2436a6c1 100644 --- a/meson.build +++ b/meson.build @@ -16,7 +16,8 @@ default_warning_flags = ['-Wno-unused-parameter', '-Wno-empty-body', '-Wno-format-security', '-Wno-deprecated-declarations', - '-Wno-non-virtual-dtor'] + '-Wno-non-virtual-dtor', + '-Wno-inconsistent-missing-override'] # external dependencies mpi_dep = [dependency('mpi', language:'c', required : get_option('with-mpi')), @@ -35,6 +36,11 @@ if get_option('enable-cgns') su2_cpp_args += '-DHAVE_CGNS' endif +# Check for non-debug build +if get_option('buildtype')!='debug' + su2_cpp_args += '-DNDEBUG' +endif + # check if MPI dependencies are found and add them if mpi_dep[0].found() and mpi_dep[1].found() From 953dfe77cddb514d1d923f5c19a4ac3a0888d8f1 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 16 Oct 2019 09:24:15 -0700 Subject: [PATCH 16/57] Fixed memory allocation. --- SU2_CFD/src/variables/CVariable.cpp | 1 + externals/meson | 2 +- externals/ninja | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index fbbf768e6a5f..9b35363c9a1e 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -81,6 +81,7 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva /* Under-relaxation parameter. */ UnderRelaxation.resize(nPoint) = 1.0; + LocalCFL.resize(nPoint) = 0.0; /* Non-physical point (first-order) initialization. */ Non_Physical.resize(nPoint) = false; diff --git a/externals/meson b/externals/meson index c904d3eefe2a..e9bd7d49bdc8 160000 --- a/externals/meson +++ b/externals/meson @@ -1 +1 @@ -Subproject commit c904d3eefe2a01ca60027e2a5192e1f1c7ca5d9d +Subproject commit e9bd7d49bdc8c630cca3bf4cc02c437841b6aaf6 diff --git a/externals/ninja b/externals/ninja index e0bc2e5fd903..20b30dac6698 160000 --- a/externals/ninja +++ b/externals/ninja @@ -1 +1 @@ -Subproject commit e0bc2e5fd9036a31d507881e1383adde3672aaef +Subproject commit 20b30dac6698d119e7797b34d6ed2c4ed8f48417 From 1dd60a780dbe374f441817c6ff68f53f3791ec4b Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 17 Oct 2019 10:52:33 -0700 Subject: [PATCH 17/57] Removed old relaxation factors. --- Common/include/config_structure.hpp | 14 -------------- Common/include/config_structure.inl | 4 ---- Common/src/config_structure.cpp | 5 ----- config_template.cfg | 6 ------ 4 files changed, 29 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index c0aa01a7aea6..d7a08f77640f 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -561,8 +561,6 @@ class CConfig { unsigned short Linear_Solver_ILU_n; /*!< \brief ILU fill=in level. */ su2double SemiSpan; /*!< \brief Wing Semi span. */ su2double Roe_Kappa; /*!< \brief Relaxation of the Roe scheme. */ - su2double Relaxation_Factor_Flow; /*!< \brief Relaxation coefficient of the linear solver mean flow. */ - su2double Relaxation_Factor_Turb; /*!< \brief Relaxation coefficient of the linear solver turbulence. */ su2double Relaxation_Factor_AdjFlow; /*!< \brief Relaxation coefficient of the linear solver adjoint mean flow. */ su2double Relaxation_Factor_CHT; /*!< \brief Relaxation coefficient for the update of conjugate heat variables. */ su2double AdjTurb_Linear_Error; /*!< \brief Min error of the turbulent adjoint linear solver for the implicit formulation. */ @@ -4083,23 +4081,11 @@ class CConfig { */ su2double GetLinear_Solver_Smoother_Relaxation(void) const; - /*! - * \brief Get the relaxation coefficient of the linear solver for the implicit formulation. - * \return relaxation coefficient of the linear solver for the implicit formulation. - */ - su2double GetRelaxation_Factor_Flow(void); - /*! * \brief Get the relaxation coefficient of the linear solver for the implicit formulation. * \return relaxation coefficient of the linear solver for the implicit formulation. */ su2double GetRelaxation_Factor_AdjFlow(void); - - /*! - * \brief Get the relaxation coefficient of the linear solver for the implicit formulation. - * \return relaxation coefficient of the linear solver for the implicit formulation. - */ - su2double GetRelaxation_Factor_Turb(void); /*! * \brief Get the relaxation coefficient of the CHT coupling. diff --git a/Common/include/config_structure.inl b/Common/include/config_structure.inl index 18aab50d13f9..8617a972a0b5 100644 --- a/Common/include/config_structure.inl +++ b/Common/include/config_structure.inl @@ -1020,12 +1020,8 @@ inline unsigned long CConfig::GetLinear_Solver_Restart_Frequency(void) { return inline su2double CConfig::GetLinear_Solver_Smoother_Relaxation(void) const { return Linear_Solver_Smoother_Relaxation; } -inline su2double CConfig::GetRelaxation_Factor_Flow(void) { return Relaxation_Factor_Flow; } - inline su2double CConfig::GetRelaxation_Factor_AdjFlow(void) { return Relaxation_Factor_AdjFlow; } -inline su2double CConfig::GetRelaxation_Factor_Turb(void) { return Relaxation_Factor_Turb; } - inline su2double CConfig::GetRelaxation_Factor_CHT(void) { return Relaxation_Factor_CHT; } inline su2double CConfig::GetRoe_Kappa(void) { return Roe_Kappa; } diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index 4fe885fb709f..b1009a95d0ac 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -1457,10 +1457,6 @@ void CConfig::SetConfig_Options() { /* DESCRIPTION: Relaxation factor for iterative linear smoothers (SMOOTHER_ILU/JACOBI/LU-SGS/LINELET) */ addDoubleOption("LINEAR_SOLVER_SMOOTHER_RELAXATION", Linear_Solver_Smoother_Relaxation, 1.0); /* DESCRIPTION: Relaxation of the flow equations solver for the implicit formulation */ - addDoubleOption("RELAXATION_FACTOR_FLOW", Relaxation_Factor_Flow, 1.0); - /* DESCRIPTION: Relaxation of the turb equations solver for the implicit formulation */ - addDoubleOption("RELAXATION_FACTOR_TURB", Relaxation_Factor_Turb, 1.0); - /* DESCRIPTION: Relaxation of the adjoint flow equations solver for the implicit formulation */ addDoubleOption("RELAXATION_FACTOR_ADJFLOW", Relaxation_Factor_AdjFlow, 1.0); /* DESCRIPTION: Relaxation of the CHT coupling */ addDoubleOption("RELAXATION_FACTOR_CHT", Relaxation_Factor_CHT, 1.0); @@ -3920,7 +3916,6 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ /*--- Setting relaxation factor and CFL for the adjoint runs ---*/ if (ContinuousAdjoint) { - Relaxation_Factor_Flow = Relaxation_Factor_AdjFlow; CFL[0] = CFL[0] * CFLRedCoeff_AdjFlow; CFL_AdaptParam[2] *= CFLRedCoeff_AdjFlow; CFL_AdaptParam[3] *= CFLRedCoeff_AdjFlow; diff --git a/config_template.cfg b/config_template.cfg index 03de90fa9d77..b4f939eb07ac 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -935,9 +935,6 @@ CENTRAL_JACOBIAN_FIX_FACTOR= 1.0 % % Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) TIME_DISCRE_FLOW= EULER_IMPLICIT -% -% Relaxation coefficient -RELAXATION_FACTOR_FLOW= 0.95 % ------------------- FEM FLOW NUMERICAL METHOD DEFINITION --------------------% % @@ -994,9 +991,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT % % Reduction factor of the CFL coefficient in the turbulence problem CFL_REDUCTION_TURB= 1.0 -% -% Relaxation coefficient -RELAXATION_FACTOR_TURB= 0.95 % --------------------- HEAT NUMERICAL METHOD DEFINITION ----------------------% % From cacb0e9bc11c0c533abd54fb866dbd5eee2b340d Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 17 Oct 2019 12:10:33 -0700 Subject: [PATCH 18/57] Adjusting allocation of the reconstruction gradient memory. --- SU2_CFD/include/variables/CAdjEulerVariable.hpp | 5 +++-- SU2_CFD/include/variables/CEulerVariable.hpp | 3 ++- SU2_CFD/include/variables/CHeatFVMVariable.hpp | 5 +++-- SU2_CFD/include/variables/CIncEulerVariable.hpp | 3 ++- SU2_CFD/include/variables/CTurbVariable.hpp | 5 +++-- SU2_CFD/src/variables/CAdjEulerVariable.cpp | 5 +++-- SU2_CFD/src/variables/CEulerVariable.cpp | 5 +++-- SU2_CFD/src/variables/CHeatFVMVariable.cpp | 5 +++-- SU2_CFD/src/variables/CIncEulerVariable.cpp | 5 +++-- SU2_CFD/src/variables/CTurbVariable.cpp | 5 +++-- 10 files changed, 28 insertions(+), 18 deletions(-) diff --git a/SU2_CFD/include/variables/CAdjEulerVariable.hpp b/SU2_CFD/include/variables/CAdjEulerVariable.hpp index d407a187d628..90b05a267512 100644 --- a/SU2_CFD/include/variables/CAdjEulerVariable.hpp +++ b/SU2_CFD/include/variables/CAdjEulerVariable.hpp @@ -53,8 +53,9 @@ class CAdjEulerVariable : public CVariable { MatrixType IntBoundary_Jump; /*!< \brief Interior boundary jump vector. */ MatrixType HB_Source; /*!< \brief Harmonic balance source term. */ - VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ - + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index b3091128eb5d..73f14e32887e 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -55,7 +55,8 @@ class CEulerVariable : public CVariable { /*--- Primitive variable definition ---*/ MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term (T, vx, vy, vz, P, rho). */ + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ /*--- Secondary variable definition ---*/ diff --git a/SU2_CFD/include/variables/CHeatFVMVariable.hpp b/SU2_CFD/include/variables/CHeatFVMVariable.hpp index 306b6178659c..c7c76b871dcb 100644 --- a/SU2_CFD/include/variables/CHeatFVMVariable.hpp +++ b/SU2_CFD/include/variables/CHeatFVMVariable.hpp @@ -49,8 +49,9 @@ class CHeatFVMVariable final : public CVariable { protected: MatrixType Solution_Direct; /*!< \brief Direct solution container for use in the adjoint Heat solver. */ - VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ - + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 902b6031fac5..6ea6f902777f 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -50,7 +50,8 @@ class CIncEulerVariable : public CVariable { VectorType Velocity2; /*!< \brief Square of the velocity vector. */ MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ VectorType Density_Old; /*!< \brief Old density for variable density turbulent flows (SST). */ diff --git a/SU2_CFD/include/variables/CTurbVariable.hpp b/SU2_CFD/include/variables/CTurbVariable.hpp index ae2528af61e4..7740ac76d8af 100644 --- a/SU2_CFD/include/variables/CTurbVariable.hpp +++ b/SU2_CFD/include/variables/CTurbVariable.hpp @@ -50,8 +50,9 @@ class CTurbVariable : public CVariable { VectorType muT; /*!< \brief Eddy viscosity. */ MatrixType HB_Source; /*!< \brief Harmonic Balance source term. */ - VectorOfMatrix Gradient_Reconstruction; /*!< \brief Gradient of the variables for MUSCL reconstruction for the convective term */ - + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/src/variables/CAdjEulerVariable.cpp b/SU2_CFD/src/variables/CAdjEulerVariable.cpp index f44e7668d730..901b44bbebab 100644 --- a/SU2_CFD/src/variables/CAdjEulerVariable.cpp +++ b/SU2_CFD/src/variables/CAdjEulerVariable.cpp @@ -38,7 +38,7 @@ #include "../../include/variables/CAdjEulerVariable.hpp" CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2double psie, unsigned long npoint, unsigned long ndim, - unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { + unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(Gradient) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -58,7 +58,8 @@ CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2 Gradient.resize(nPoint,nVar,nDim,0.0); if (config->GetReconstructionGradientRequired()) { - Gradient_Reconstruction.resize(nPoint,nVar,nDim,0.0); + Gradient_Aux.resize(nPoint,nVar,nDim,0.0); + Gradient_Reconstruction = Gradient_Aux; } else { Gradient_Reconstruction = Gradient; } diff --git a/SU2_CFD/src/variables/CEulerVariable.cpp b/SU2_CFD/src/variables/CEulerVariable.cpp index 7d6390c35192..5cb284119a68 100644 --- a/SU2_CFD/src/variables/CEulerVariable.cpp +++ b/SU2_CFD/src/variables/CEulerVariable.cpp @@ -39,7 +39,7 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2double energy, unsigned long npoint, - unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { + unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(Gradient_Primitive) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -127,7 +127,8 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2 Gradient_Primitive.resize(nPoint,nPrimVarGrad,nDim,0.0); if (config->GetReconstructionGradientRequired()) { - Gradient_Reconstruction.resize(nPoint,nPrimVarGrad,nDim,0.0); + Gradient_Aux.resize(nPoint,nPrimVarGrad,nDim,0.0); + Gradient_Reconstruction = Gradient_Aux; } else { Gradient_Reconstruction = Gradient_Primitive; } diff --git a/SU2_CFD/src/variables/CHeatFVMVariable.cpp b/SU2_CFD/src/variables/CHeatFVMVariable.cpp index a1a60c087ad0..2ecd7fed9985 100644 --- a/SU2_CFD/src/variables/CHeatFVMVariable.cpp +++ b/SU2_CFD/src/variables/CHeatFVMVariable.cpp @@ -39,7 +39,7 @@ CHeatFVMVariable::CHeatFVMVariable(su2double heat, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) -: CVariable(npoint, ndim, nvar, config) { +: CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(Gradient) { bool low_fidelity = false; bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || @@ -74,7 +74,8 @@ CHeatFVMVariable::CHeatFVMVariable(su2double heat, unsigned long npoint, unsigne Gradient.resize(nPoint,nVar,nDim,0.0); if (config->GetReconstructionGradientRequired()) { - Gradient_Reconstruction.resize(nPoint,nVar,nDim,0.0); + Gradient_Aux.resize(nPoint,nVar,nDim,0.0); + Gradient_Reconstruction = Gradient_Aux; } else { Gradient_Reconstruction = Gradient; } diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index acd9bc4a16df..226aa2dc7ead 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -39,7 +39,7 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, - unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { + unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) , Gradient_Reconstruction(Gradient_Primitive) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -107,7 +107,8 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci Gradient_Primitive.resize(nPoint,nPrimVarGrad,nDim,0.0); if (config->GetReconstructionGradientRequired()) { - Gradient_Reconstruction.resize(nPoint,nPrimVarGrad,nDim,0.0); + Gradient_Aux.resize(nPoint,nPrimVarGrad,nDim,0.0); + Gradient_Reconstruction = Gradient_Aux; } else { Gradient_Reconstruction = Gradient_Primitive; } diff --git a/SU2_CFD/src/variables/CTurbVariable.cpp b/SU2_CFD/src/variables/CTurbVariable.cpp index b288a3f670d7..9f6915a443b8 100644 --- a/SU2_CFD/src/variables/CTurbVariable.cpp +++ b/SU2_CFD/src/variables/CTurbVariable.cpp @@ -39,7 +39,7 @@ CTurbVariable::CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) -: CVariable(npoint, ndim, nvar, config) { +: CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(Gradient) { /*--- Allocate space for the harmonic balance source terms ---*/ @@ -52,7 +52,8 @@ CTurbVariable::CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned Gradient.resize(nPoint,nVar,nDim,0.0); if (config->GetReconstructionGradientRequired()) { - Gradient_Reconstruction.resize(nPoint,nVar,nDim,0.0); + Gradient_Aux.resize(nPoint,nVar,nDim,0.0); + Gradient_Reconstruction = Gradient_Aux; } else { Gradient_Reconstruction = Gradient; } From 9ef49a96170ee533f5a722524efcb1b7af56672e Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 18 Oct 2019 12:47:17 -0700 Subject: [PATCH 19/57] Adjustment to local CFL and underrelaxation allocations. Important change to viscous stress tensor for SST. Increased Jacobian fix factor default. --- Common/include/config_structure.hpp | 10 +++++----- Common/src/config_structure.cpp | 2 +- SU2_CFD/include/variables/CAdjEulerVariable.hpp | 4 ++-- SU2_CFD/include/variables/CEulerVariable.hpp | 2 +- SU2_CFD/include/variables/CHeatFVMVariable.hpp | 4 ++-- SU2_CFD/include/variables/CIncEulerVariable.hpp | 2 +- SU2_CFD/include/variables/CTurbVariable.hpp | 4 ++-- SU2_CFD/include/variables/CVariable.hpp | 4 ++-- SU2_CFD/src/drivers/CDriver.cpp | 5 +++-- SU2_CFD/src/numerics_direct_mean.cpp | 3 +-- SU2_CFD/src/variables/CAdjEulerVariable.cpp | 6 +++++- SU2_CFD/src/variables/CEulerVariable.cpp | 10 +++++++++- SU2_CFD/src/variables/CHeatFVMVariable.cpp | 2 +- SU2_CFD/src/variables/CIncEulerVariable.cpp | 10 +++++++++- SU2_CFD/src/variables/CTurbVariable.cpp | 6 +++++- SU2_CFD/src/variables/CVariable.cpp | 8 -------- config_template.cfg | 2 +- 17 files changed, 50 insertions(+), 34 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index d7a08f77640f..ddb1be6f8d90 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -111,7 +111,7 @@ class CConfig { su2double FFD_Tol; /*!< \brief Tolerance in the point inversion problem. */ su2double Opt_RelaxFactor; /*!< \brief Scale factor for the line search. */ su2double Opt_LineSearch_Bound; /*!< \brief Bounds for the line search. */ - su2double StartTime; + su2double StartTime; /*!< \brief Start time for performance tracking of each phase of the code: preprocessing, compute, and output. */ bool ContinuousAdjoint, /*!< \brief Flag to know if the code is solving an adjoint problem. */ Viscous, /*!< \brief Flag to know if the code is solving a viscous problem. */ EquivArea, /*!< \brief Flag to know if the code is going to compute and plot the equivalent area. */ @@ -9198,14 +9198,14 @@ class CConfig { unsigned short GetnConv_Field(); /*! - * \brief Set_StartTime - * \param starttime + * \brief Set the start time to track a phase of the code (preprocessing, compute, output). + * \param[in] Value of the start time to track a phase of the code. */ void Set_StartTime(su2double starttime); /*! - * \brief Get_StartTime - * \return + * \brief Get the start time to track a phase of the code (preprocessing, compute, output). + * \return Value of the start time to track a phase of the code. */ su2double Get_StartTime(); diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index b1009a95d0ac..16aae71c4900 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -1569,7 +1569,7 @@ void CConfig::SetConfig_Options() { /*!\brief USE_ACCURATE_FLUX_JACOBIANS \n DESCRIPTION: Use numerically computed Jacobians for AUSM+up(2) and SLAU(2) \ingroup Config*/ addBoolOption("USE_ACCURATE_FLUX_JACOBIANS", Use_Accurate_Jacobians, false); /*!\brief CENTRAL_JACOBIAN_FIX_FACTOR \n DESCRIPTION: Improve the numerical properties (diagonal dominance) of the global Jacobian matrix, 3 to 4 is "optimum" (central schemes) \ingroup Config*/ - addDoubleOption("CENTRAL_JACOBIAN_FIX_FACTOR", Cent_Jac_Fix_Factor, 1.0); + addDoubleOption("CENTRAL_JACOBIAN_FIX_FACTOR", Cent_Jac_Fix_Factor, 4.0); /*!\brief CONV_NUM_METHOD_ADJFLOW * \n DESCRIPTION: Convective numerical method for the adjoint solver. diff --git a/SU2_CFD/include/variables/CAdjEulerVariable.hpp b/SU2_CFD/include/variables/CAdjEulerVariable.hpp index 90b05a267512..34ad8ae6239c 100644 --- a/SU2_CFD/include/variables/CAdjEulerVariable.hpp +++ b/SU2_CFD/include/variables/CAdjEulerVariable.hpp @@ -53,8 +53,8 @@ class CAdjEulerVariable : public CVariable { MatrixType IntBoundary_Jump; /*!< \brief Interior boundary jump vector. */ MatrixType HB_Source; /*!< \brief Harmonic balance source term. */ - VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ - VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + VectorOfMatrix& Gradient_Reconstruction = Gradient; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ public: /*! diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 73f14e32887e..119811810f0b 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -55,7 +55,7 @@ class CEulerVariable : public CVariable { /*--- Primitive variable definition ---*/ MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction = Gradient_Primitive; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ diff --git a/SU2_CFD/include/variables/CHeatFVMVariable.hpp b/SU2_CFD/include/variables/CHeatFVMVariable.hpp index c7c76b871dcb..86e83fb8981c 100644 --- a/SU2_CFD/include/variables/CHeatFVMVariable.hpp +++ b/SU2_CFD/include/variables/CHeatFVMVariable.hpp @@ -49,8 +49,8 @@ class CHeatFVMVariable final : public CVariable { protected: MatrixType Solution_Direct; /*!< \brief Direct solution container for use in the adjoint Heat solver. */ - VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ - VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + VectorOfMatrix& Gradient_Reconstruction = Gradient; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ public: /*! diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 6ea6f902777f..cf4c7bd5d45b 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -50,7 +50,7 @@ class CIncEulerVariable : public CVariable { VectorType Velocity2; /*!< \brief Square of the velocity vector. */ MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction = Gradient_Primitive; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ VectorType Density_Old; /*!< \brief Old density for variable density turbulent flows (SST). */ diff --git a/SU2_CFD/include/variables/CTurbVariable.hpp b/SU2_CFD/include/variables/CTurbVariable.hpp index 7740ac76d8af..3b5db9eed803 100644 --- a/SU2_CFD/include/variables/CTurbVariable.hpp +++ b/SU2_CFD/include/variables/CTurbVariable.hpp @@ -50,8 +50,8 @@ class CTurbVariable : public CVariable { VectorType muT; /*!< \brief Eddy viscosity. */ MatrixType HB_Source; /*!< \brief Harmonic Balance source term. */ - VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ - VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + VectorOfMatrix& Gradient_Reconstruction = Gradient; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ public: /*! diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 5db48fd77754..53dd3715b4e2 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -580,7 +580,7 @@ class CVariable { * \brief Get the value of the under-relaxation parameter for the current control volume (CV). * \return Value of the under-relaxation parameter for this CV. */ - inline su2double GetUnderRelaxation(unsigned long iPoint) { return UnderRelaxation(iPoint); } + inline su2double GetUnderRelaxation(unsigned long iPoint) const { return UnderRelaxation(iPoint); } /*! * \brief Set the value of the local CFL number for the current control volume (CV). @@ -592,7 +592,7 @@ class CVariable { * \brief Get the value of the local CFL number for the current control volume (CV). * \return Value of the local CFL number for this CV. */ - inline su2double GetLocalCFL(unsigned long iPoint) { return LocalCFL(iPoint); } + inline su2double GetLocalCFL(unsigned long iPoint) const { return LocalCFL(iPoint); } /*! * \brief Set auxiliar variables, we are looking for the gradient of that variable. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index cf453b04fb29..079df8a84f2e 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -520,12 +520,13 @@ void CDriver::Postprocessing() { cout.precision(6); cout << endl << endl <<"-------------------------- Performance Summary --------------------------" << endl; cout << "Simulation totals:" << endl; + cout << setw(25) << "Wall-clock time (hrs):" << setw(12) << (TotalTime)/(60.0*60.0) << " | "; + cout << setw(20) << "Core-hrs:" << setw(12) << (su2double)size*(TotalTime)/(60.0*60.0) << endl; cout << setw(25) << "Cores:" << setw(12) << size << " | "; cout << setw(20) << "DOFs/point:" << setw(12) << (su2double)DOFsPerPoint << endl; cout << setw(25) << "Points/core:" << setw(12) << 1.0e6*MpointsDomain/(su2double)size << " | "; cout << setw(20) << "Ghost points/core:" << setw(12) << 1.0e6*(Mpoints-MpointsDomain)/(su2double)size << endl; - cout << setw(25) << "Wall-clock time (hrs):" << setw(12) << (TotalTime)/(60.0*60.0) << " | "; - cout << setw(20) << "Core-hrs:" << setw(12) << (su2double)size*(TotalTime)/(60.0*60.0) << endl; + cout << setw(25) << "Ghost/Owned Point Ratio:" << setw(12) << (Mpoints-MpointsDomain)/MpointsDomain << " | " << endl; cout << endl; cout << "Preprocessing phase:" << endl; cout << setw(25) << "Preproc. Time (s):" << setw(12)<< UsedTimePreproc << " | "; diff --git a/SU2_CFD/src/numerics_direct_mean.cpp b/SU2_CFD/src/numerics_direct_mean.cpp index a76e150de33a..906b6f5560aa 100644 --- a/SU2_CFD/src/numerics_direct_mean.cpp +++ b/SU2_CFD/src/numerics_direct_mean.cpp @@ -4136,8 +4136,7 @@ void CAvgGrad_Base::SetStressTensor(const su2double *val_primvar, for (iDim = 0 ; iDim < nDim; iDim++) for (jDim = 0 ; jDim < nDim; jDim++) tau[iDim][jDim] = total_viscosity*( val_gradprimvar[jDim+1][iDim] + val_gradprimvar[iDim+1][jDim] ) - - TWO3*total_viscosity*div_vel*delta[iDim][jDim] - - TWO3*Density*val_turb_ke*delta[iDim][jDim]; + - TWO3*total_viscosity*div_vel*delta[iDim][jDim]; } } diff --git a/SU2_CFD/src/variables/CAdjEulerVariable.cpp b/SU2_CFD/src/variables/CAdjEulerVariable.cpp index 901b44bbebab..891e223d065d 100644 --- a/SU2_CFD/src/variables/CAdjEulerVariable.cpp +++ b/SU2_CFD/src/variables/CAdjEulerVariable.cpp @@ -38,7 +38,7 @@ #include "../../include/variables/CAdjEulerVariable.hpp" CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2double psie, unsigned long npoint, unsigned long ndim, - unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(Gradient) { + unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -113,6 +113,10 @@ CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2 Sensor.resize(nPoint); + /* Non-physical point (first-order) initialization. */ + Non_Physical.resize(nPoint) = false; + Non_Physical_Counter.resize(nPoint) = 0; + } bool CAdjEulerVariable::SetPrimVar(unsigned long iPoint, su2double SharpEdge_Distance, bool check, CConfig *config) { diff --git a/SU2_CFD/src/variables/CEulerVariable.cpp b/SU2_CFD/src/variables/CEulerVariable.cpp index 5cb284119a68..b895d3250fbf 100644 --- a/SU2_CFD/src/variables/CEulerVariable.cpp +++ b/SU2_CFD/src/variables/CEulerVariable.cpp @@ -39,7 +39,7 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2double energy, unsigned long npoint, - unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(Gradient_Primitive) { + unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -146,6 +146,14 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2 Lambda.resize(nPoint) = su2double(0.0); Sensor.resize(nPoint) = su2double(0.0); + /* Under-relaxation parameter. */ + UnderRelaxation.resize(nPoint) = su2double(1.0); + LocalCFL.resize(nPoint) = su2double(0.0); + + /* Non-physical point (first-order) initialization. */ + Non_Physical.resize(nPoint) = false; + Non_Physical_Counter.resize(nPoint) = 0; + } void CEulerVariable::SetGradient_PrimitiveZero() { diff --git a/SU2_CFD/src/variables/CHeatFVMVariable.cpp b/SU2_CFD/src/variables/CHeatFVMVariable.cpp index 2ecd7fed9985..4f5089e8e4f2 100644 --- a/SU2_CFD/src/variables/CHeatFVMVariable.cpp +++ b/SU2_CFD/src/variables/CHeatFVMVariable.cpp @@ -39,7 +39,7 @@ CHeatFVMVariable::CHeatFVMVariable(su2double heat, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) -: CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(Gradient) { +: CVariable(npoint, ndim, nvar, config) { bool low_fidelity = false; bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 226aa2dc7ead..0ffad68222ad 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -39,7 +39,7 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, - unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) , Gradient_Reconstruction(Gradient_Primitive) { + unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -131,6 +131,14 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci Lambda.resize(nPoint) = su2double(0.0); Sensor.resize(nPoint) = su2double(0.0); + /* Under-relaxation parameter. */ + UnderRelaxation.resize(nPoint) = su2double(1.0); + LocalCFL.resize(nPoint) = su2double(0.0); + + /* Non-physical point (first-order) initialization. */ + Non_Physical.resize(nPoint) = false; + Non_Physical_Counter.resize(nPoint) = 0; + } void CIncEulerVariable::SetGradient_PrimitiveZero() { diff --git a/SU2_CFD/src/variables/CTurbVariable.cpp b/SU2_CFD/src/variables/CTurbVariable.cpp index 9f6915a443b8..bf9215286d3f 100644 --- a/SU2_CFD/src/variables/CTurbVariable.cpp +++ b/SU2_CFD/src/variables/CTurbVariable.cpp @@ -39,7 +39,7 @@ CTurbVariable::CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) -: CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(Gradient) { +: CVariable(npoint, ndim, nvar, config) { /*--- Allocate space for the harmonic balance source terms ---*/ @@ -71,4 +71,8 @@ CTurbVariable::CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned Delta_Time.resize(nPoint) = su2double(0.0); + /* Under-relaxation parameter. */ + UnderRelaxation.resize(nPoint) = su2double(1.0); + LocalCFL.resize(nPoint) = su2double(0.0); + } diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 9b35363c9a1e..f10f83e6030d 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -78,14 +78,6 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva if (config->GetFSI_Simulation() && config->GetDiscrete_Adjoint()) { Solution_Adj_Old.resize(nPoint,nVar); } - - /* Under-relaxation parameter. */ - UnderRelaxation.resize(nPoint) = 1.0; - LocalCFL.resize(nPoint) = 0.0; - - /* Non-physical point (first-order) initialization. */ - Non_Physical.resize(nPoint) = false; - Non_Physical_Counter.resize(nPoint) = 0; if(config->GetMultizone_Problem() && config->GetAD_Mode()) { Input_AdjIndices.resize(nPoint,nVar) = -1; diff --git a/config_template.cfg b/config_template.cfg index b4f939eb07ac..6177197d63d7 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -931,7 +931,7 @@ ENTROPY_FIX_COEFF= 0.0 % % Higher values than 1 (3 to 4) make the global Jacobian of central schemes (compressible flow % only) more diagonal dominant (but mathematically incorrect) so that higher CFL can be used. -CENTRAL_JACOBIAN_FIX_FACTOR= 1.0 +CENTRAL_JACOBIAN_FIX_FACTOR= 4.0 % % Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) TIME_DISCRE_FLOW= EULER_IMPLICIT From 04dd6b2bdb44753f1b66749611ad7b871e1b337b Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 21 Oct 2019 22:55:40 -0700 Subject: [PATCH 20/57] Updating initializers for reconstruction gradient. --- .../include/variables/CAdjEulerVariable.hpp | 2 +- SU2_CFD/include/variables/CEulerVariable.hpp | 2 +- .../include/variables/CHeatFVMVariable.hpp | 2 +- .../include/variables/CIncEulerVariable.hpp | 2 +- SU2_CFD/include/variables/CTurbVariable.hpp | 2 +- SU2_CFD/src/solver_direct_elasticity.cpp | 2 +- SU2_CFD/src/solver_direct_heat.cpp | 9 ++++-- SU2_CFD/src/solver_direct_mean.cpp | 32 +++++++++++-------- 8 files changed, 30 insertions(+), 23 deletions(-) diff --git a/SU2_CFD/include/variables/CAdjEulerVariable.hpp b/SU2_CFD/include/variables/CAdjEulerVariable.hpp index 34ad8ae6239c..de49ec2d66b3 100644 --- a/SU2_CFD/include/variables/CAdjEulerVariable.hpp +++ b/SU2_CFD/include/variables/CAdjEulerVariable.hpp @@ -53,7 +53,7 @@ class CAdjEulerVariable : public CVariable { MatrixType IntBoundary_Jump; /*!< \brief Interior boundary jump vector. */ MatrixType HB_Source; /*!< \brief Harmonic balance source term. */ - VectorOfMatrix& Gradient_Reconstruction = Gradient; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ public: diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 119811810f0b..0600ce4035a3 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -55,7 +55,7 @@ class CEulerVariable : public CVariable { /*--- Primitive variable definition ---*/ MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - VectorOfMatrix& Gradient_Reconstruction = Gradient_Primitive; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ diff --git a/SU2_CFD/include/variables/CHeatFVMVariable.hpp b/SU2_CFD/include/variables/CHeatFVMVariable.hpp index 86e83fb8981c..33d911c8820d 100644 --- a/SU2_CFD/include/variables/CHeatFVMVariable.hpp +++ b/SU2_CFD/include/variables/CHeatFVMVariable.hpp @@ -49,7 +49,7 @@ class CHeatFVMVariable final : public CVariable { protected: MatrixType Solution_Direct; /*!< \brief Direct solution container for use in the adjoint Heat solver. */ - VectorOfMatrix& Gradient_Reconstruction = Gradient; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ public: diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index cf4c7bd5d45b..841d21975e6f 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -50,7 +50,7 @@ class CIncEulerVariable : public CVariable { VectorType Velocity2; /*!< \brief Square of the velocity vector. */ MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - VectorOfMatrix& Gradient_Reconstruction = Gradient_Primitive; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ VectorType Density_Old; /*!< \brief Old density for variable density turbulent flows (SST). */ diff --git a/SU2_CFD/include/variables/CTurbVariable.hpp b/SU2_CFD/include/variables/CTurbVariable.hpp index 3b5db9eed803..5796d18078ee 100644 --- a/SU2_CFD/include/variables/CTurbVariable.hpp +++ b/SU2_CFD/include/variables/CTurbVariable.hpp @@ -50,7 +50,7 @@ class CTurbVariable : public CVariable { VectorType muT; /*!< \brief Eddy viscosity. */ MatrixType HB_Source; /*!< \brief Harmonic Balance source term. */ - VectorOfMatrix& Gradient_Reconstruction = Gradient; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ public: diff --git a/SU2_CFD/src/solver_direct_elasticity.cpp b/SU2_CFD/src/solver_direct_elasticity.cpp index c51f66082091..e554bd30936e 100644 --- a/SU2_CFD/src/solver_direct_elasticity.cpp +++ b/SU2_CFD/src/solver_direct_elasticity.cpp @@ -3615,7 +3615,7 @@ void CFEASolver::Solve_System(CGeometry *geometry, CConfig *config) { /*--- Store the value of the residual. ---*/ - SetIterLinSolver(System.GetResidual()); + SetResLinSolver(System.GetResidual()); } diff --git a/SU2_CFD/src/solver_direct_heat.cpp b/SU2_CFD/src/solver_direct_heat.cpp index 192b08013390..8a9bbd73bae3 100644 --- a/SU2_CFD/src/solver_direct_heat.cpp +++ b/SU2_CFD/src/solver_direct_heat.cpp @@ -307,9 +307,12 @@ void CHeatSolverFVM::Preprocessing(CGeometry *geometry, CSolver **solver_contain Jacobian.SetValZero(); if (config->GetReconstructionGradientRequired()) { - if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config, true); - if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config, true); - if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == GREEN_GAUSS) + SetSolution_Gradient_GG(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); + if (config->GetKind_Gradient_Method_Recon() == WEIGHTED_LEAST_SQUARES) + SetSolution_Gradient_LS(geometry, config, true); } if (config->GetKind_Gradient_Method() == GREEN_GAUSS) SetSolution_Gradient_GG(geometry, config); if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) SetSolution_Gradient_LS(geometry, config); diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 187cd140ae4e..65ece8ccc02e 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -487,13 +487,15 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, unsigned short gradients by least squares, S matrix := inv(R)*traspose(inv(R)), c vector := transpose(WA)*(Wb) ---*/ - Smatrix = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Smatrix[iDim] = new su2double [nDim]; - - Cvector = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Cvector[iVar] = new su2double [nDim]; + if (config->GetLeastSquaresRequired()) { + Smatrix = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Smatrix[iDim] = new su2double [nDim]; + + Cvector = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) + Cvector[iVar] = new su2double [nDim]; + } /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ @@ -14329,13 +14331,15 @@ CNSSolver::CNSSolver(CGeometry *geometry, CConfig *config, unsigned short iMesh) gradients by least squares, S matrix := inv(R)*traspose(inv(R)), c vector := transpose(WA)*(Wb) ---*/ - Smatrix = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Smatrix[iDim] = new su2double [nDim]; - - Cvector = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Cvector[iVar] = new su2double [nDim]; + if (config->GetLeastSquaresRequired()) { + Smatrix = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Smatrix[iDim] = new su2double [nDim]; + + Cvector = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) + Cvector[iVar] = new su2double [nDim]; + } /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ From 8df1d8410625b1299a5a53cbeaed4d6631054aa7 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Tue, 22 Oct 2019 18:53:49 +0100 Subject: [PATCH 21/57] fix reconstruction gradient reference mechanism --- SU2_CFD/include/variables/CAdjEulerVariable.hpp | 6 +++--- SU2_CFD/include/variables/CEulerVariable.hpp | 2 +- SU2_CFD/include/variables/CHeatFVMVariable.hpp | 6 +++--- SU2_CFD/include/variables/CIncEulerVariable.hpp | 2 +- SU2_CFD/include/variables/CTurbVariable.hpp | 8 ++++---- SU2_CFD/src/variables/CAdjEulerVariable.cpp | 6 ++---- SU2_CFD/src/variables/CEulerVariable.cpp | 6 ++---- SU2_CFD/src/variables/CHeatFVMVariable.cpp | 5 +---- SU2_CFD/src/variables/CIncEulerVariable.cpp | 6 ++---- SU2_CFD/src/variables/CTurbVariable.cpp | 5 +---- 10 files changed, 20 insertions(+), 32 deletions(-) diff --git a/SU2_CFD/include/variables/CAdjEulerVariable.hpp b/SU2_CFD/include/variables/CAdjEulerVariable.hpp index de49ec2d66b3..77c507449ff6 100644 --- a/SU2_CFD/include/variables/CAdjEulerVariable.hpp +++ b/SU2_CFD/include/variables/CAdjEulerVariable.hpp @@ -53,9 +53,9 @@ class CAdjEulerVariable : public CVariable { MatrixType IntBoundary_Jump; /*!< \brief Interior boundary jump vector. */ MatrixType HB_Source; /*!< \brief Harmonic balance source term. */ - VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ - VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ - + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 0600ce4035a3..73f14e32887e 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -55,7 +55,7 @@ class CEulerVariable : public CVariable { /*--- Primitive variable definition ---*/ MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ diff --git a/SU2_CFD/include/variables/CHeatFVMVariable.hpp b/SU2_CFD/include/variables/CHeatFVMVariable.hpp index 33d911c8820d..f1a0a02b0616 100644 --- a/SU2_CFD/include/variables/CHeatFVMVariable.hpp +++ b/SU2_CFD/include/variables/CHeatFVMVariable.hpp @@ -49,9 +49,9 @@ class CHeatFVMVariable final : public CVariable { protected: MatrixType Solution_Direct; /*!< \brief Direct solution container for use in the adjoint Heat solver. */ - VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ - VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ - + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 841d21975e6f..6ea6f902777f 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -50,7 +50,7 @@ class CIncEulerVariable : public CVariable { VectorType Velocity2; /*!< \brief Square of the velocity vector. */ MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ - VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ VectorType Density_Old; /*!< \brief Old density for variable density turbulent flows (SST). */ diff --git a/SU2_CFD/include/variables/CTurbVariable.hpp b/SU2_CFD/include/variables/CTurbVariable.hpp index 5796d18078ee..9fcc4e6c2666 100644 --- a/SU2_CFD/include/variables/CTurbVariable.hpp +++ b/SU2_CFD/include/variables/CTurbVariable.hpp @@ -49,10 +49,10 @@ class CTurbVariable : public CVariable { protected: VectorType muT; /*!< \brief Eddy viscosity. */ MatrixType HB_Source; /*!< \brief Harmonic Balance source term. */ - - VectorOfMatrix& Gradient_Reconstruction = Gradient_Aux; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ - VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ - + + VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ + VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/src/variables/CAdjEulerVariable.cpp b/SU2_CFD/src/variables/CAdjEulerVariable.cpp index 891e223d065d..95204ae0a076 100644 --- a/SU2_CFD/src/variables/CAdjEulerVariable.cpp +++ b/SU2_CFD/src/variables/CAdjEulerVariable.cpp @@ -38,7 +38,8 @@ #include "../../include/variables/CAdjEulerVariable.hpp" CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2double psie, unsigned long npoint, unsigned long ndim, - unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { + unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), + Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient} { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -59,9 +60,6 @@ CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2 if (config->GetReconstructionGradientRequired()) { Gradient_Aux.resize(nPoint,nVar,nDim,0.0); - Gradient_Reconstruction = Gradient_Aux; - } else { - Gradient_Reconstruction = Gradient; } if (config->GetLeastSquaresRequired()) { diff --git a/SU2_CFD/src/variables/CEulerVariable.cpp b/SU2_CFD/src/variables/CEulerVariable.cpp index b895d3250fbf..73a01d51c49e 100644 --- a/SU2_CFD/src/variables/CEulerVariable.cpp +++ b/SU2_CFD/src/variables/CEulerVariable.cpp @@ -39,7 +39,8 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2double energy, unsigned long npoint, - unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { + unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), + Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient_Primitive} { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -128,9 +129,6 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2 if (config->GetReconstructionGradientRequired()) { Gradient_Aux.resize(nPoint,nPrimVarGrad,nDim,0.0); - Gradient_Reconstruction = Gradient_Aux; - } else { - Gradient_Reconstruction = Gradient_Primitive; } if (config->GetLeastSquaresRequired()) { diff --git a/SU2_CFD/src/variables/CHeatFVMVariable.cpp b/SU2_CFD/src/variables/CHeatFVMVariable.cpp index 4f5089e8e4f2..1b62f1d12d15 100644 --- a/SU2_CFD/src/variables/CHeatFVMVariable.cpp +++ b/SU2_CFD/src/variables/CHeatFVMVariable.cpp @@ -39,7 +39,7 @@ CHeatFVMVariable::CHeatFVMVariable(su2double heat, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) -: CVariable(npoint, ndim, nvar, config) { + : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient} { bool low_fidelity = false; bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || @@ -75,9 +75,6 @@ CHeatFVMVariable::CHeatFVMVariable(su2double heat, unsigned long npoint, unsigne if (config->GetReconstructionGradientRequired()) { Gradient_Aux.resize(nPoint,nVar,nDim,0.0); - Gradient_Reconstruction = Gradient_Aux; - } else { - Gradient_Reconstruction = Gradient; } if (config->GetLeastSquaresRequired()) { diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 0ffad68222ad..7f12cedd0edc 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -39,7 +39,8 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, - unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { + unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), + Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient_Primitive} { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); @@ -108,9 +109,6 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci if (config->GetReconstructionGradientRequired()) { Gradient_Aux.resize(nPoint,nPrimVarGrad,nDim,0.0); - Gradient_Reconstruction = Gradient_Aux; - } else { - Gradient_Reconstruction = Gradient_Primitive; } if (config->GetLeastSquaresRequired()) { diff --git a/SU2_CFD/src/variables/CTurbVariable.cpp b/SU2_CFD/src/variables/CTurbVariable.cpp index bf9215286d3f..fa6d3a901778 100644 --- a/SU2_CFD/src/variables/CTurbVariable.cpp +++ b/SU2_CFD/src/variables/CTurbVariable.cpp @@ -39,7 +39,7 @@ CTurbVariable::CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) -: CVariable(npoint, ndim, nvar, config) { + : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient} { /*--- Allocate space for the harmonic balance source terms ---*/ @@ -53,9 +53,6 @@ CTurbVariable::CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned if (config->GetReconstructionGradientRequired()) { Gradient_Aux.resize(nPoint,nVar,nDim,0.0); - Gradient_Reconstruction = Gradient_Aux; - } else { - Gradient_Reconstruction = Gradient; } if (config->GetLeastSquaresRequired()) { From f156d75477d745f24c443fc42c4b544741abb6c0 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 24 Oct 2019 14:17:45 -0700 Subject: [PATCH 22/57] Fix for SST eddy viscosity expression. Adjusting SST clipping. --- SU2_CFD/src/solver_direct_turbulent.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index efc79f4d618d..fe30fbee230c 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -3410,11 +3410,11 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh lowerlimit = new su2double[nVar]; upperlimit = new su2double[nVar]; - lowerlimit[0] = 1.0e-10; - upperlimit[0] = 1.0e10; + lowerlimit[0] = 0.0; + upperlimit[0] = 1.0e30; - lowerlimit[1] = 1.0e-4; - upperlimit[1] = 1.0e15; + lowerlimit[1] = 0.0; + upperlimit[1] = 1.0e30; /*--- Far-field flow state quantities and initialization. ---*/ su2double rhoInf, *VelInf, muLamInf, Intensity, viscRatio, muT_Inf; @@ -3576,7 +3576,7 @@ void CTurbSSTSolver::Preprocessing(CGeometry *geometry, CSolver **solver_contain } void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { - su2double rho = 0.0, mu = 0.0, dist, omega, kine, strMag, F2, muT, zeta; + su2double rho = 0.0, mu = 0.0, dist, omega, kine, F2, muT, zeta; su2double a1 = constants[7]; unsigned long iPoint; @@ -3598,8 +3598,11 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai dist = geometry->node[iPoint]->GetWall_Distance(); - strMag = solver_container[FLOW_SOL]->GetNodes()->GetStrainMag(iPoint); - + su2double *Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); + su2double Omega = sqrt(Vorticity[0]*Vorticity[0] + + Vorticity[1]*Vorticity[1] + + Vorticity[2]*Vorticity[2]); + nodes->SetBlendingFunc(iPoint,mu, dist, rho); F2 = nodes->GetF2blending(iPoint); @@ -3608,8 +3611,8 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai kine = nodes->GetSolution(iPoint,0); omega = nodes->GetSolution(iPoint,1); - zeta = min(1.0/omega, a1/(strMag*F2)); - muT = min(max(rho*kine*zeta,0.0),1.0); + zeta = min(1.0/omega, a1/(Omega*F2)); + muT = max(rho*kine*zeta,0.0); nodes->SetmuT(iPoint,muT); } From 6624e0d4f546f1bf2078bb152cc015a20d0ebe0e Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 24 Oct 2019 15:05:04 -0700 Subject: [PATCH 23/57] Small change to limits. --- SU2_CFD/src/solver_direct_turbulent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index fe30fbee230c..3d0198307511 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -3413,8 +3413,8 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh lowerlimit[0] = 0.0; upperlimit[0] = 1.0e30; - lowerlimit[1] = 0.0; - upperlimit[1] = 1.0e30; + lowerlimit[1] = 1.0e-4; + upperlimit[1] = 1.0e15; /*--- Far-field flow state quantities and initialization. ---*/ su2double rhoInf, *VelInf, muLamInf, Intensity, viscRatio, muT_Inf; From 2b1356dfe11d873e50594353d05a2d956182476d Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 24 Oct 2019 20:37:59 -0700 Subject: [PATCH 24/57] Meson fix for SU2_DOT_AD build. --- SU2_DOT/src/meson.build | 1 + config_template.cfg | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/SU2_DOT/src/meson.build b/SU2_DOT/src/meson.build index ebb972f448bf..f476c01ee859 100644 --- a/SU2_DOT/src/meson.build +++ b/SU2_DOT/src/meson.build @@ -34,6 +34,7 @@ endif if get_option('enable-autodiff') su2_dot_src_ad = ['SU2_DOT.cpp'] su2_cfd_obj_ad = su2_cfd_ad.extract_objects(['solver_structure.cpp', + 'CMarkerProfileReaderFVM.cpp', 'output/COutput.cpp', 'output/output_structure_legacy.cpp', 'output/CBaselineOutput.cpp', diff --git a/config_template.cfg b/config_template.cfg index 6177197d63d7..eec0f22f4f28 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -765,7 +765,7 @@ CFL_ADAPT= NO % % Parameters of the adaptive CFL number (factor down, factor up, CFL min value, % CFL max value ) -CFL_ADAPT_PARAM= ( 1.5, 0.5, 1.25, 50.0 ) +CFL_ADAPT_PARAM= ( 0.1, 2.0, 10.0, 1e10 ) % % Maximum Delta Time in local time stepping simulations MAX_DELTA_TIME= 1E6 From 00d1852cdef26ccdb6416c96cab5843cb8d2a3a0 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 25 Oct 2019 12:44:58 -0700 Subject: [PATCH 25/57] Removing old options from regression cfgs. --- TestCases/coupled_cht/incompressible/configFlow.cfg | 2 -- .../coupled_cht/incompressible/coupled_cht_incompressible.cfg | 2 -- TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg | 1 - TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg | 1 - TestCases/disc_adj_heat/disc_adj_heat.cfg | 2 -- .../transonic_stator_2D/transonic_stator.cfg | 2 -- .../flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg | 2 -- .../flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg | 2 -- TestCases/rans/propeller/propeller.cfg | 2 -- TestCases/sliding_interface/channel_2D/channel_2D_NN.cfg | 1 - TestCases/sliding_interface/channel_2D/channel_2D_WA.cfg | 1 - TestCases/sliding_interface/channel_3D/channel_3D_NN.cfg | 1 - TestCases/sliding_interface/channel_3D/channel_3D_WA.cfg | 1 - TestCases/sliding_interface/pipe/pipe_NN.cfg | 1 - TestCases/sliding_interface/pipe/pipe_WA.cfg | 1 - .../sliding_interface/rotating_cylinders/rot_cylinders_NN.cfg | 1 - .../sliding_interface/rotating_cylinders/rot_cylinders_WA.cfg | 1 - TestCases/sliding_interface/single_stage/single_stage_NN.cfg | 2 -- TestCases/sliding_interface/single_stage/single_stage_WA.cfg | 2 -- .../supersonic_vortex_shedding/sup_vor_shed_NN.cfg | 1 - .../supersonic_vortex_shedding/sup_vor_shed_WA.cfg | 1 - TestCases/sliding_interface/uniform_flow/uniform_NN.cfg | 1 - TestCases/sliding_interface/uniform_flow/uniform_WA.cfg | 1 - TestCases/turbomachinery/APU_turbocharger/Jones.cfg | 2 -- TestCases/turbomachinery/APU_turbocharger/Jones_rst.cfg | 2 -- TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg | 2 -- .../turbomachinery/centrifugal_blade/centrifugal_blade.cfg | 2 -- .../turbomachinery/centrifugal_stage/centrifugal_stage.cfg | 2 -- .../turbomachinery/transonic_stator_2D/transonic_stator.cfg | 2 -- .../turbomachinery/transonic_stator_2D/transonic_stator_rst.cfg | 2 -- 30 files changed, 46 deletions(-) diff --git a/TestCases/coupled_cht/incompressible/configFlow.cfg b/TestCases/coupled_cht/incompressible/configFlow.cfg index 220c3e4fca19..e050394e3d32 100644 --- a/TestCases/coupled_cht/incompressible/configFlow.cfg +++ b/TestCases/coupled_cht/incompressible/configFlow.cfg @@ -94,7 +94,6 @@ CONV_NUM_METHOD_FLOW= JST MUSCL_FLOW= YES JST_SENSOR_COEFF= ( 0.5, 0.05 ) TIME_DISCRE_FLOW= EULER_IMPLICIT -RELAXATION_FACTOR_FLOW= 1.0 % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% @@ -102,7 +101,6 @@ CONV_NUM_METHOD_TURB= SCALAR_UPWIND MUSCL_TURB= NO TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 1.0 -RELAXATION_FACTOR_TURB= 1.0 % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/coupled_cht/incompressible/coupled_cht_incompressible.cfg b/TestCases/coupled_cht/incompressible/coupled_cht_incompressible.cfg index e525f42d3e60..4011936d1efe 100644 --- a/TestCases/coupled_cht/incompressible/coupled_cht_incompressible.cfg +++ b/TestCases/coupled_cht/incompressible/coupled_cht_incompressible.cfg @@ -124,7 +124,6 @@ JST_SENSOR_COEFF= ( 0.5, 0.05 ) TIME_DISCRE_FLOW= EULER_IMPLICIT -RELAXATION_FACTOR_FLOW= 1.0 % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% @@ -136,7 +135,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 1.0 -RELAXATION_FACTOR_TURB= 1.0 % -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% diff --git a/TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg b/TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg index a3fda84557ca..19ecbd6297d6 100644 --- a/TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg +++ b/TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg @@ -340,7 +340,6 @@ ENTROPY_FIX_COEFF= 0.0 TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 0.95 % ---------------- ADJOINT-FLOW NUMERICAL METHOD DEFINITION -------------------% diff --git a/TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg b/TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg index 05a1a67ecb19..09c25f03699c 100644 --- a/TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg +++ b/TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg @@ -225,7 +225,6 @@ CONV_NUM_METHOD_FLOW= JST TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 0.95 % ---------------- ADJOINT-FLOW NUMERICAL METHOD DEFINITION -------------------% % diff --git a/TestCases/disc_adj_heat/disc_adj_heat.cfg b/TestCases/disc_adj_heat/disc_adj_heat.cfg index cd7b0275ef93..c2f622588870 100644 --- a/TestCases/disc_adj_heat/disc_adj_heat.cfg +++ b/TestCases/disc_adj_heat/disc_adj_heat.cfg @@ -116,7 +116,6 @@ JST_SENSOR_COEFF= ( 0.5, 0.05 ) TIME_DISCRE_FLOW= EULER_IMPLICIT -RELAXATION_FACTOR_FLOW= 1.0 % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% @@ -128,7 +127,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 1.0 -RELAXATION_FACTOR_TURB= 1.0 % -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% diff --git a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg index 13abd08a28d7..d35eda8ddacb 100644 --- a/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg +++ b/TestCases/disc_adj_turbomachinery/transonic_stator_2D/transonic_stator.cfg @@ -259,7 +259,6 @@ JST_SENSOR_COEFF= ( 0.5, 0.02 ) TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% @@ -281,7 +280,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.1 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 1.0 % % % ----------------------- DESIGN VARIABLE PARAMETERS --------------------------% diff --git a/TestCases/py_wrapper/flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg b/TestCases/py_wrapper/flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg index 0d6b815b4e12..be628c9e6629 100644 --- a/TestCases/py_wrapper/flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg +++ b/TestCases/py_wrapper/flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg @@ -398,7 +398,6 @@ CONV_NUM_METHOD_FLOW= JST TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 0.95 % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % @@ -412,7 +411,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 1.0 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 0.95 % ------------------------ GRID DEFORMATION PARAMETERS ------------------------% % diff --git a/TestCases/py_wrapper/flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg b/TestCases/py_wrapper/flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg index c31d0d9144b1..24b383204e9c 100644 --- a/TestCases/py_wrapper/flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg +++ b/TestCases/py_wrapper/flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg @@ -378,7 +378,6 @@ CONV_NUM_METHOD_FLOW= JST TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 0.95 % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % @@ -392,7 +391,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 1.0 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 0.95 % ------------------------ GRID DEFORMATION PARAMETERS ------------------------% % diff --git a/TestCases/rans/propeller/propeller.cfg b/TestCases/rans/propeller/propeller.cfg index aecb8e74d91c..746bd07c96f4 100644 --- a/TestCases/rans/propeller/propeller.cfg +++ b/TestCases/rans/propeller/propeller.cfg @@ -182,7 +182,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 0.9 % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % @@ -200,7 +199,6 @@ SLOPE_LIMITER_TURB= VENKATAKRISHNAN TIME_DISCRE_TURB= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 0.9 % --------------------------- CONVERGENCE PARAMETERS --------------------------% % diff --git a/TestCases/sliding_interface/channel_2D/channel_2D_NN.cfg b/TestCases/sliding_interface/channel_2D/channel_2D_NN.cfg index 0c11516ed457..9e79e979cd6c 100644 --- a/TestCases/sliding_interface/channel_2D/channel_2D_NN.cfg +++ b/TestCases/sliding_interface/channel_2D/channel_2D_NN.cfg @@ -175,7 +175,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/channel_2D/channel_2D_WA.cfg b/TestCases/sliding_interface/channel_2D/channel_2D_WA.cfg index 16930aa9718e..eebace601a1c 100644 --- a/TestCases/sliding_interface/channel_2D/channel_2D_WA.cfg +++ b/TestCases/sliding_interface/channel_2D/channel_2D_WA.cfg @@ -174,7 +174,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/channel_3D/channel_3D_NN.cfg b/TestCases/sliding_interface/channel_3D/channel_3D_NN.cfg index bde13568ebb9..64c16fb1d48b 100644 --- a/TestCases/sliding_interface/channel_3D/channel_3D_NN.cfg +++ b/TestCases/sliding_interface/channel_3D/channel_3D_NN.cfg @@ -176,7 +176,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/channel_3D/channel_3D_WA.cfg b/TestCases/sliding_interface/channel_3D/channel_3D_WA.cfg index 85f5d747e11d..0bf0094fb7e1 100644 --- a/TestCases/sliding_interface/channel_3D/channel_3D_WA.cfg +++ b/TestCases/sliding_interface/channel_3D/channel_3D_WA.cfg @@ -174,7 +174,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/pipe/pipe_NN.cfg b/TestCases/sliding_interface/pipe/pipe_NN.cfg index f4e5a9dc1a3b..030545723345 100644 --- a/TestCases/sliding_interface/pipe/pipe_NN.cfg +++ b/TestCases/sliding_interface/pipe/pipe_NN.cfg @@ -181,7 +181,6 @@ SLOPE_LIMITER_FLOW= NONE TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/pipe/pipe_WA.cfg b/TestCases/sliding_interface/pipe/pipe_WA.cfg index 276de07977c5..d3426972777f 100644 --- a/TestCases/sliding_interface/pipe/pipe_WA.cfg +++ b/TestCases/sliding_interface/pipe/pipe_WA.cfg @@ -180,7 +180,6 @@ SLOPE_LIMITER_FLOW= NONE TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/rotating_cylinders/rot_cylinders_NN.cfg b/TestCases/sliding_interface/rotating_cylinders/rot_cylinders_NN.cfg index 0c2a4dda36a8..f0905c16e3f9 100644 --- a/TestCases/sliding_interface/rotating_cylinders/rot_cylinders_NN.cfg +++ b/TestCases/sliding_interface/rotating_cylinders/rot_cylinders_NN.cfg @@ -179,7 +179,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/rotating_cylinders/rot_cylinders_WA.cfg b/TestCases/sliding_interface/rotating_cylinders/rot_cylinders_WA.cfg index 9911c580bb90..9803529ee86e 100644 --- a/TestCases/sliding_interface/rotating_cylinders/rot_cylinders_WA.cfg +++ b/TestCases/sliding_interface/rotating_cylinders/rot_cylinders_WA.cfg @@ -182,7 +182,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/single_stage/single_stage_NN.cfg b/TestCases/sliding_interface/single_stage/single_stage_NN.cfg index 14a23937bf7d..e8bc15224ebd 100644 --- a/TestCases/sliding_interface/single_stage/single_stage_NN.cfg +++ b/TestCases/sliding_interface/single_stage/single_stage_NN.cfg @@ -197,7 +197,6 @@ SLOPE_LIMITER_FLOW= NONE TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % @@ -221,7 +220,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.01 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 1.0 % % % diff --git a/TestCases/sliding_interface/single_stage/single_stage_WA.cfg b/TestCases/sliding_interface/single_stage/single_stage_WA.cfg index e231aa261af1..69d11c02dfdf 100644 --- a/TestCases/sliding_interface/single_stage/single_stage_WA.cfg +++ b/TestCases/sliding_interface/single_stage/single_stage_WA.cfg @@ -195,7 +195,6 @@ SLOPE_LIMITER_FLOW= NONE TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % @@ -219,7 +218,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.01 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 1.0 % % % diff --git a/TestCases/sliding_interface/supersonic_vortex_shedding/sup_vor_shed_NN.cfg b/TestCases/sliding_interface/supersonic_vortex_shedding/sup_vor_shed_NN.cfg index 296594694862..cefa2217b64b 100644 --- a/TestCases/sliding_interface/supersonic_vortex_shedding/sup_vor_shed_NN.cfg +++ b/TestCases/sliding_interface/supersonic_vortex_shedding/sup_vor_shed_NN.cfg @@ -182,7 +182,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/supersonic_vortex_shedding/sup_vor_shed_WA.cfg b/TestCases/sliding_interface/supersonic_vortex_shedding/sup_vor_shed_WA.cfg index 8ee81a64d3c7..0d3c1a121c32 100644 --- a/TestCases/sliding_interface/supersonic_vortex_shedding/sup_vor_shed_WA.cfg +++ b/TestCases/sliding_interface/supersonic_vortex_shedding/sup_vor_shed_WA.cfg @@ -182,7 +182,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/sliding_interface/uniform_flow/uniform_NN.cfg b/TestCases/sliding_interface/uniform_flow/uniform_NN.cfg index b32195abce41..9e7cef652fa6 100644 --- a/TestCases/sliding_interface/uniform_flow/uniform_NN.cfg +++ b/TestCases/sliding_interface/uniform_flow/uniform_NN.cfg @@ -178,7 +178,6 @@ SLOPE_LIMITER_FLOW= NONE TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % diff --git a/TestCases/sliding_interface/uniform_flow/uniform_WA.cfg b/TestCases/sliding_interface/uniform_flow/uniform_WA.cfg index 961758c2d7ab..9c1ed17b5f31 100644 --- a/TestCases/sliding_interface/uniform_flow/uniform_WA.cfg +++ b/TestCases/sliding_interface/uniform_flow/uniform_WA.cfg @@ -178,7 +178,6 @@ SLOPE_LIMITER_FLOW= NONE TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % diff --git a/TestCases/turbomachinery/APU_turbocharger/Jones.cfg b/TestCases/turbomachinery/APU_turbocharger/Jones.cfg index 1362b58f30f2..505c5c95c7a8 100755 --- a/TestCases/turbomachinery/APU_turbocharger/Jones.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/Jones.cfg @@ -246,7 +246,6 @@ JST_SENSOR_COEFF= ( 0.5, 0.02 ) TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 0.95 % ENTROPY_FIX_COEFF= 0.001 % @@ -270,7 +269,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.5 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 0.95 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/turbomachinery/APU_turbocharger/Jones_rst.cfg b/TestCases/turbomachinery/APU_turbocharger/Jones_rst.cfg index f16bd867d18b..16d17b0e0b93 100755 --- a/TestCases/turbomachinery/APU_turbocharger/Jones_rst.cfg +++ b/TestCases/turbomachinery/APU_turbocharger/Jones_rst.cfg @@ -251,7 +251,6 @@ JST_SENSOR_COEFF= ( 0.5, 0.02 ) TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 0.95 % ENTROPY_FIX_COEFF= 0.001 % @@ -275,7 +274,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.5 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 0.95 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg index a868f32f19e6..dc86b6875204 100755 --- a/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg +++ b/TestCases/turbomachinery/axial_stage_2D/Axial_stage2D.cfg @@ -242,7 +242,6 @@ JST_SENSOR_COEFF= ( 0.5, 0.02 ) TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% @@ -264,7 +263,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.5 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 0.95 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg b/TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg index 74d9c8dfc22f..ce87e1e5f692 100755 --- a/TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg +++ b/TestCases/turbomachinery/centrifugal_blade/centrifugal_blade.cfg @@ -275,7 +275,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % @@ -299,7 +298,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.01 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 1.0 % % % diff --git a/TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg b/TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg index 757be80790e9..e650e733a9f1 100755 --- a/TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg +++ b/TestCases/turbomachinery/centrifugal_stage/centrifugal_stage.cfg @@ -283,7 +283,6 @@ SLOPE_LIMITER_FLOW= VENKATAKRISHNAN TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % @@ -307,7 +306,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.01 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 1.0 % % % diff --git a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator.cfg b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator.cfg index 73a7326e7bbd..dc3a5cbd334b 100644 --- a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator.cfg +++ b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator.cfg @@ -250,7 +250,6 @@ JST_SENSOR_COEFF= ( 0.5, 0.02 ) TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% @@ -272,7 +271,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.1 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% diff --git a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_rst.cfg b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_rst.cfg index 329a81058e2e..d8d209589124 100644 --- a/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_rst.cfg +++ b/TestCases/turbomachinery/transonic_stator_2D/transonic_stator_rst.cfg @@ -255,7 +255,6 @@ JST_SENSOR_COEFF= ( 0.5, 0.02 ) TIME_DISCRE_FLOW= EULER_IMPLICIT % % Relaxation coefficient -RELAXATION_FACTOR_FLOW= 1.0 % % % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% @@ -277,7 +276,6 @@ TIME_DISCRE_TURB= EULER_IMPLICIT CFL_REDUCTION_TURB= 0.1 % % Relaxation coefficient -RELAXATION_FACTOR_TURB= 1.0 % % % --------------------------- CONVERGENCE PARAMETERS --------------------------% From 74f907f41dafb32233edd2d6fb5dfac2359612b3 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 31 Oct 2019 09:03:16 -0700 Subject: [PATCH 26/57] Adding gitflow comment to readme. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 80a0a3ebad70..34518b397476 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ Thanks for building, and happy optimizing! SU2 DEVELOPERS ---------------------------------------------------------- +We follow the popular "GitFlow" branching model for scalable development. In the SU2 repository, the master branch represents the latest stable major or minor release (7.0, 6.2.0, etc.), it should only be modified during version releases. Work that is staged for release is put into the develop branch via Pull Requests on GitHub from various "feature" branches where folks do their day-to-day work on the code. At release time, the work that has been merged into the develop branch is pushed to the master branch and tagged as a release. + SU2 is being developed by individuals and organized teams all around the world. The current SU2 release has been coordinated by the SU2 International Developers Society with selected contributions from the open-source community. From cf57e62e4d92886d3b3da1dc3c25ade9a8ab1ad9 Mon Sep 17 00:00:00 2001 From: pcarruscag Date: Fri, 1 Nov 2019 18:58:39 +0000 Subject: [PATCH 27/57] replace curly braces with parentheses for old compiler compatibility --- SU2_CFD/src/variables/CAdjEulerVariable.cpp | 2 +- SU2_CFD/src/variables/CEulerVariable.cpp | 2 +- SU2_CFD/src/variables/CHeatFVMVariable.cpp | 2 +- SU2_CFD/src/variables/CIncEulerVariable.cpp | 2 +- SU2_CFD/src/variables/CTurbVariable.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/variables/CAdjEulerVariable.cpp b/SU2_CFD/src/variables/CAdjEulerVariable.cpp index 95204ae0a076..e83031a2b2d3 100644 --- a/SU2_CFD/src/variables/CAdjEulerVariable.cpp +++ b/SU2_CFD/src/variables/CAdjEulerVariable.cpp @@ -39,7 +39,7 @@ CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2double psie, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), - Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient} { + Gradient_Reconstruction(config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); diff --git a/SU2_CFD/src/variables/CEulerVariable.cpp b/SU2_CFD/src/variables/CEulerVariable.cpp index 73a01d51c49e..59e25056ba9f 100644 --- a/SU2_CFD/src/variables/CEulerVariable.cpp +++ b/SU2_CFD/src/variables/CEulerVariable.cpp @@ -40,7 +40,7 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2double energy, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), - Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient_Primitive} { + Gradient_Reconstruction(config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient_Primitive) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); diff --git a/SU2_CFD/src/variables/CHeatFVMVariable.cpp b/SU2_CFD/src/variables/CHeatFVMVariable.cpp index 1b62f1d12d15..39239ddaa76b 100644 --- a/SU2_CFD/src/variables/CHeatFVMVariable.cpp +++ b/SU2_CFD/src/variables/CHeatFVMVariable.cpp @@ -39,7 +39,7 @@ CHeatFVMVariable::CHeatFVMVariable(su2double heat, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) - : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient} { + : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient) { bool low_fidelity = false; bool dual_time = ((config->GetTime_Marching() == DT_STEPPING_1ST) || diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 7f12cedd0edc..04b9f6277ac7 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -40,7 +40,7 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config), - Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient_Primitive} { + Gradient_Reconstruction(config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient_Primitive) { bool dual_time = (config->GetTime_Marching() == DT_STEPPING_1ST) || (config->GetTime_Marching() == DT_STEPPING_2ND); diff --git a/SU2_CFD/src/variables/CTurbVariable.cpp b/SU2_CFD/src/variables/CTurbVariable.cpp index fa6d3a901778..523b6c26766c 100644 --- a/SU2_CFD/src/variables/CTurbVariable.cpp +++ b/SU2_CFD/src/variables/CTurbVariable.cpp @@ -39,7 +39,7 @@ CTurbVariable::CTurbVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) - : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction{config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient} { + : CVariable(npoint, ndim, nvar, config), Gradient_Reconstruction(config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient) { /*--- Allocate space for the harmonic balance source terms ---*/ From b5d51af8ba98c8ef5a116b2cf03c58b7f48425ee Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 1 Nov 2019 15:07:41 -0400 Subject: [PATCH 28/57] Addressing small text clean up. --- Common/include/config_structure.hpp | 13 +++++++------ SU2_CFD/include/solver_structure.hpp | 2 +- SU2_CFD/include/variables/CAdjEulerVariable.hpp | 2 +- SU2_CFD/include/variables/CEulerVariable.hpp | 2 +- SU2_CFD/include/variables/CHeatFVMVariable.hpp | 2 +- SU2_CFD/include/variables/CIncEulerVariable.hpp | 8 ++++---- SU2_CFD/include/variables/CVariable.hpp | 14 ++++++++++++-- SU2_CFD/src/solver_direct_heat.cpp | 2 +- SU2_CFD/src/solver_direct_mean_inc.cpp | 4 ++-- SU2_CFD/src/solver_structure.cpp | 2 +- SU2_CFD/src/variables/CAdjEulerVariable.cpp | 4 ++-- SU2_CFD/src/variables/CIncEulerVariable.cpp | 2 +- 12 files changed, 34 insertions(+), 23 deletions(-) diff --git a/Common/include/config_structure.hpp b/Common/include/config_structure.hpp index b68c67df093f..80c25d2a8b86 100644 --- a/Common/include/config_structure.hpp +++ b/Common/include/config_structure.hpp @@ -1620,20 +1620,21 @@ class CConfig { su2double GetGamma(void); /*! - * \brief Get the values of the CFL adapation. - * \return Value of CFL adapation + * \brief Get the values of the CFL adaption parameters. + * \return Value of CFL adaption parameter */ su2double GetCFL_AdaptParam(unsigned short val_index); /*! - * \brief Get the values of the CFL adapation. - * \return Value of CFL adapation + * \brief Set the values of the CFL adaption parameters. + * \param[in] val_index - Index of the particular CFL adaption parameter + * \param[in] val_cfl_param - Value of the CFL adaption parameter */ inline void SetCFL_AdaptParam(unsigned short val_index, su2double val_cfl_param) { CFL_AdaptParam[val_index] = val_cfl_param; } /*! - * \brief Get the values of the CFL adapation. - * \return Value of CFL adapation + * \brief Get the value of the CFL adaption flag. + * \return TRUE if CFL adaption is active; otherwise FALSE. */ bool GetCFL_Adapt(void); diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 54e6f0fa43ef..9a3ce89c2a73 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -282,7 +282,7 @@ class CSolver { /*! * \brief Set the final linear solver residual. - * \param[in] val_relinsolver - Value of final linear solver residual. + * \param[in] val_reslinsolver - Value of final linear solver residual. */ void SetResLinSolver(su2double val_reslinsolver); diff --git a/SU2_CFD/include/variables/CAdjEulerVariable.hpp b/SU2_CFD/include/variables/CAdjEulerVariable.hpp index 77c507449ff6..d9aab8fefa78 100644 --- a/SU2_CFD/include/variables/CAdjEulerVariable.hpp +++ b/SU2_CFD/include/variables/CAdjEulerVariable.hpp @@ -164,7 +164,7 @@ class CAdjEulerVariable : public CVariable { * \param[in] iPoint - Index of the current node. * \param[in] iVar - Index of the variable. * \param[in] iDim - Index of the dimension. - * \param[in] iDim - Index of the dimension. + * \param[in] value - Value of the reconstruction gradient component. */ inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { Gradient_Reconstruction(iPoint,iVar,iDim) = value; diff --git a/SU2_CFD/include/variables/CEulerVariable.hpp b/SU2_CFD/include/variables/CEulerVariable.hpp index 73f14e32887e..cbfad5ec8aa4 100644 --- a/SU2_CFD/include/variables/CEulerVariable.hpp +++ b/SU2_CFD/include/variables/CEulerVariable.hpp @@ -193,7 +193,7 @@ class CEulerVariable : public CVariable { * \param[in] iPoint - Index of the current node. * \param[in] iVar - Index of the variable. * \param[in] iDim - Index of the dimension. - * \param[in] iDim - Index of the dimension. + * \param[in] value - Value of the reconstruction gradient component. */ inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { Gradient_Reconstruction(iPoint,iVar,iDim) = value; diff --git a/SU2_CFD/include/variables/CHeatFVMVariable.hpp b/SU2_CFD/include/variables/CHeatFVMVariable.hpp index f1a0a02b0616..86da3b86afac 100644 --- a/SU2_CFD/include/variables/CHeatFVMVariable.hpp +++ b/SU2_CFD/include/variables/CHeatFVMVariable.hpp @@ -84,7 +84,7 @@ class CHeatFVMVariable final : public CVariable { * \param[in] iPoint - Index of the current node. * \param[in] iVar - Index of the variable. * \param[in] iDim - Index of the dimension. - * \param[in] iDim - Index of the dimension. + * \param[in] value - Value of the reconstruction gradient component. */ inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { Gradient_Reconstruction(iPoint,iVar,iDim) = value; diff --git a/SU2_CFD/include/variables/CIncEulerVariable.hpp b/SU2_CFD/include/variables/CIncEulerVariable.hpp index 6ea6f902777f..6a689ade69be 100644 --- a/SU2_CFD/include/variables/CIncEulerVariable.hpp +++ b/SU2_CFD/include/variables/CIncEulerVariable.hpp @@ -48,11 +48,11 @@ class CIncEulerVariable : public CVariable { protected: VectorType Velocity2; /*!< \brief Square of the velocity vector. */ - MatrixType Primitive; /*!< \brief Primitive variables (T, vx, vy, vz, P, rho, h, c) in compressible flows. */ - VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (T, vx, vy, vz, P, rho). */ + MatrixType Primitive; /*!< \brief Primitive variables (P, vx, vy, vz, T, rho, beta, lamMu, EddyMu, Kt_eff, Cp, Cv) in incompressible flows. */ + VectorOfMatrix Gradient_Primitive; /*!< \brief Gradient of the primitive variables (P, vx, vy, vz, T, rho, beta). */ VectorOfMatrix& Gradient_Reconstruction; /*!< \brief Reference to the gradient of the primitive variables for MUSCL reconstruction for the convective term */ VectorOfMatrix Gradient_Aux; /*!< \brief Auxiliary structure to store a second gradient for reconstruction, if required. */ - MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (T, vx, vy, vz, P, rho). */ + MatrixType Limiter_Primitive; /*!< \brief Limiter of the primitive variables (P, vx, vy, vz, T, rho, beta). */ VectorType Density_Old; /*!< \brief Old density for variable density turbulent flows (SST). */ public: @@ -173,7 +173,7 @@ class CIncEulerVariable : public CVariable { * \param[in] iPoint - Index of the current node. * \param[in] iVar - Index of the variable. * \param[in] iDim - Index of the dimension. - * \param[in] iDim - Index of the dimension. + * \param[in] value - Value of the reconstruction gradient component. */ inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { Gradient_Reconstruction(iPoint,iVar,iDim) = value; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index df791a59ebde..8de40be1c3b2 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -299,6 +299,7 @@ class CVariable { /*! * \brief Set the variable solution at time n. + * \param[in] iPoint - Point index. */ inline void Set_Solution_time_n(unsigned long iPoint, unsigned long iVar, su2double val_sol) { Solution_time_n(iPoint,iVar) = val_sol; @@ -306,6 +307,7 @@ class CVariable { /*! * \brief Set the variable solution at time n-1. + * \param[in] iPoint - Point index. */ inline void Set_Solution_time_n1(unsigned long iPoint, unsigned long iVar, su2double val_sol) { Solution_time_n1(iPoint,iVar) = val_sol; @@ -330,6 +332,7 @@ class CVariable { /*! * \brief Set to zero velocity components of the solution. + * \param[in] iPoint - Point index. */ inline void SetVelSolutionOldZero(unsigned long iPoint) { for (unsigned long iDim = 0; iDim < nDim; iDim++) Solution_Old(iPoint, iDim+1) = 0.0; @@ -418,8 +421,6 @@ class CVariable { /*! * \brief A virtual member. - * \param[in] val_var - Number of the variable. - * \param[in] val_solution - Value that we want to add to the solution. * \param[in] iPoint - Point index. * \param[in] iVar - Number of the variable. * \param[in] solution - Value that we want to add to the solution. @@ -479,12 +480,14 @@ class CVariable { /*! * \brief Get the solution of the problem. + * \param[in] iPoint - Point index. * \return Pointer to the solution vector. */ inline su2double *GetSolution(unsigned long iPoint) { return Solution[iPoint]; } /*! * \brief Get the old solution of the problem (Runge-Kutta method) + * \param[in] iPoint - Point index. * \return Pointer to the old solution vector. */ inline su2double *GetSolution_Old(unsigned long iPoint) { return Solution_Old[iPoint]; } @@ -505,12 +508,14 @@ class CVariable { /*! * \brief Get the solution at time n. + * \param[in] iPoint - Point index. * \return Pointer to the solution (at time n) vector. */ inline su2double *GetSolution_time_n(unsigned long iPoint) { return Solution_time_n[iPoint]; } /*! * \brief Get the solution at time n-1. + * \param[in] iPoint - Point index. * \return Pointer to the solution (at time n-1) vector. */ inline su2double *GetSolution_time_n1(unsigned long iPoint) { return Solution_time_n1[iPoint]; } @@ -572,24 +577,28 @@ class CVariable { /*! * \brief Set the value of the under-relaxation parameter for the current control volume (CV). + * \param[in] iPoint - Point index. * \param[in] val_under_relaxation - the input value of the under-relaxation parameter for this CV. */ inline void SetUnderRelaxation(unsigned long iPoint, su2double val_under_relaxation) { UnderRelaxation(iPoint) = val_under_relaxation; } /*! * \brief Get the value of the under-relaxation parameter for the current control volume (CV). + * \param[in] iPoint - Point index. * \return Value of the under-relaxation parameter for this CV. */ inline su2double GetUnderRelaxation(unsigned long iPoint) const { return UnderRelaxation(iPoint); } /*! * \brief Set the value of the local CFL number for the current control volume (CV). + * \param[in] iPoint - Point index. * \param[in] val_cfl - the input value of the local CFL number for this CV. */ inline void SetLocalCFL(unsigned long iPoint, su2double val_cfl) { LocalCFL(iPoint) = val_cfl; } /*! * \brief Get the value of the local CFL number for the current control volume (CV). + * \param[in] iPoint - Point index. * \return Value of the local CFL number for this CV. */ inline su2double GetLocalCFL(unsigned long iPoint) const { return LocalCFL(iPoint); } @@ -904,6 +913,7 @@ class CVariable { /*! * \brief Get the value of the derivatives of the wind gust + * \param[in] iPoint - Point index. * \return Value of the derivatives of the wind gust */ inline virtual su2double* GetWindGustDer(unsigned long iPoint) { return nullptr;} diff --git a/SU2_CFD/src/solver_direct_heat.cpp b/SU2_CFD/src/solver_direct_heat.cpp index 8a9bbd73bae3..ae759960d3a5 100644 --- a/SU2_CFD/src/solver_direct_heat.cpp +++ b/SU2_CFD/src/solver_direct_heat.cpp @@ -574,7 +574,7 @@ void CHeatSolverFVM::Centered_Residual(CGeometry *geometry, CSolver **solver_con void CHeatSolverFVM::Upwind_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config, unsigned short iMesh) { su2double *V_i, *V_j, Temp_i, Temp_i_Corrected, Temp_j, Temp_j_Corrected, **Gradient_i, **Gradient_j, Project_Grad_i, Project_Grad_j, - **Temp_i_Grad, **Temp_j_Grad, Project_Temp_i_Grad, Project_Temp_j_Grad; + **Temp_i_Grad, **Temp_j_Grad, Project_Temp_i_Grad, Project_Temp_j_Grad; unsigned short iDim, iVar; unsigned long iEdge, iPoint, jPoint; bool flow = ((config->GetKind_Solver() == INC_NAVIER_STOKES) diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index 1cc1481fe5a4..43350eed3cbf 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -1599,7 +1599,7 @@ unsigned long CIncEulerSolver::SetPrimitive_Variables(CSolver **solver_container physical = nodes->SetPrimVar(iPoint,FluidModel); /* Check for non-realizable states for reporting. */ - + if (!physical) nonPhysicalPoints++; /*--- Initialize the convective, source and viscous residual vector ---*/ @@ -7428,7 +7428,7 @@ unsigned long CIncNSSolver::SetPrimitive_Variables(CSolver **solver_container, C physical = static_cast(nodes)->SetPrimVar(iPoint,eddy_visc, turb_ke, FluidModel); /* Check for non-realizable states for reporting. */ - + if (!physical) nonPhysicalPoints++; /*--- Set the DES length scale ---*/ diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index f7508a3d830b..c05435caf1ba 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -4999,7 +4999,7 @@ void CSolver::LoadInletProfile(CGeometry **geometry, /*--- Read the profile data from an ASCII file. ---*/ CMarkerProfileReaderFVM profileReader(geometry[MESH_0], config, profile_filename, KIND_MARKER, nCol_InletFile); - + /*--- Load data from the restart into correct containers. ---*/ Marker_Counter = 0; diff --git a/SU2_CFD/src/variables/CAdjEulerVariable.cpp b/SU2_CFD/src/variables/CAdjEulerVariable.cpp index 95204ae0a076..72af97bf622d 100644 --- a/SU2_CFD/src/variables/CAdjEulerVariable.cpp +++ b/SU2_CFD/src/variables/CAdjEulerVariable.cpp @@ -55,7 +55,7 @@ CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2 break; } } - + Gradient.resize(nPoint,nVar,nDim,0.0); if (config->GetReconstructionGradientRequired()) { @@ -91,7 +91,7 @@ CAdjEulerVariable::CAdjEulerVariable(su2double psirho, const su2double *phi, su2 Solution_time_n = Solution; Solution_time_n1 = Solution; } - + /*--- Allocate auxiliar vector for sensitivity computation ---*/ AuxVar.resize(nPoint); Grad_AuxVar.resize(nPoint,nDim); diff --git a/SU2_CFD/src/variables/CIncEulerVariable.cpp b/SU2_CFD/src/variables/CIncEulerVariable.cpp index 7f12cedd0edc..b81228e19c9c 100644 --- a/SU2_CFD/src/variables/CIncEulerVariable.cpp +++ b/SU2_CFD/src/variables/CIncEulerVariable.cpp @@ -118,7 +118,7 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci /*--- If axisymmetric and viscous, we need an auxiliary gradient. ---*/ if (axisymmetric && viscous) Grad_AuxVar.resize(nPoint,nDim); - + if (config->GetMultizone_Problem()) Set_BGSSolution_k(); From 58f511af2bbf365c61b10d2f9e74c638a128b100 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 1 Nov 2019 15:40:12 -0400 Subject: [PATCH 29/57] Couple more small changes. --- SU2_CFD/include/variables/CTurbVariable.hpp | 2 +- SU2_CFD/src/variables/CHeatFVMVariable.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/variables/CTurbVariable.hpp b/SU2_CFD/include/variables/CTurbVariable.hpp index 9fcc4e6c2666..30316bca4825 100644 --- a/SU2_CFD/include/variables/CTurbVariable.hpp +++ b/SU2_CFD/include/variables/CTurbVariable.hpp @@ -98,7 +98,7 @@ class CTurbVariable : public CVariable { * \param[in] iPoint - Index of the current node. * \param[in] iVar - Index of the variable. * \param[in] iDim - Index of the dimension. - * \param[in] iDim - Index of the dimension. + * \param[in] value - Value of the reconstruction gradient component. */ inline void SetGradient_Reconstruction(unsigned long iPoint, unsigned long iVar, unsigned long iDim, su2double value) final { Gradient_Reconstruction(iPoint,iVar,iDim) = value; diff --git a/SU2_CFD/src/variables/CHeatFVMVariable.cpp b/SU2_CFD/src/variables/CHeatFVMVariable.cpp index 39239ddaa76b..03d6cb6153cb 100644 --- a/SU2_CFD/src/variables/CHeatFVMVariable.cpp +++ b/SU2_CFD/src/variables/CHeatFVMVariable.cpp @@ -80,7 +80,7 @@ CHeatFVMVariable::CHeatFVMVariable(su2double heat, unsigned long npoint, unsigne if (config->GetLeastSquaresRequired()) { Rmatrix.resize(nPoint,nDim,nDim,0.0); } - + if (config->GetKind_ConvNumScheme_Heat() == SPACE_CENTERED) Undivided_Laplacian.resize(nPoint,nVar); From 19a393201121daeed2df8bcabe001f58dd27ff24 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 4 Nov 2019 19:48:08 +0100 Subject: [PATCH 30/57] Added a routine to reset CFL adaption variables --- SU2_CFD/include/solver_structure.hpp | 5 +++++ SU2_CFD/src/integration_structure.cpp | 6 ++++++ SU2_CFD/src/solver_structure.cpp | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/SU2_CFD/include/solver_structure.hpp b/SU2_CFD/include/solver_structure.hpp index 9a3ce89c2a73..821949f34b6b 100644 --- a/SU2_CFD/include/solver_structure.hpp +++ b/SU2_CFD/include/solver_structure.hpp @@ -1422,6 +1422,11 @@ class CSolver { */ void AdaptCFLNumber(CGeometry **geometry, CSolver ***solver_container, CConfig *config); + /*! + * \brief Reset the local CFL adaption variables + */ + void ResetCFLAdapt(); + /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. diff --git a/SU2_CFD/src/integration_structure.cpp b/SU2_CFD/src/integration_structure.cpp index 606c6ca7143a..a0c91efd5433 100644 --- a/SU2_CFD/src/integration_structure.cpp +++ b/SU2_CFD/src/integration_structure.cpp @@ -447,8 +447,14 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon solver->GetNodes()->Set_Solution_time_n1(); solver->GetNodes()->Set_Solution_time_n(); + solver->ResetCFLAdapt(); for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + + /*--- Initialize the local CFL number ---*/ + + solver->GetNodes()->SetLocalCFL(iPoint, config->GetCFL(iMesh)); + geometry->node[iPoint]->SetVolume_nM1(); geometry->node[iPoint]->SetVolume_n(); diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index c05435caf1ba..8d9ead0e9fed 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -2256,6 +2256,16 @@ void CSolver::CompleteComms(CGeometry *geometry, } +void CSolver::ResetCFLAdapt(){ + NonLinRes_Series.clear(); + NonLinRes_Value = 0; + NonLinRes_Func = 0; + Old_Func = 0; + New_Func = 0; + NonLinRes_Counter = 0; +} + + void CSolver::AdaptCFLNumber(CGeometry **geometry, CSolver ***solver_container, CConfig *config) { From aa9a1c34f39a958177810d229eb0e2fafec54239 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 4 Nov 2019 11:35:18 -0800 Subject: [PATCH 31/57] Bug fix for profile reader. --- SU2_CFD/src/solver_direct_mean.cpp | 2 +- SU2_CFD/src/solver_structure.cpp | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 4d24540deb6e..2e4d98516362 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -12457,7 +12457,7 @@ void CEulerSolver::SetResidual_DualTime(CGeometry *geometry, CSolver **solver_co } - /*--- Loop over the boundary edges ---*/ + /*--- Loop over the boundary edges ---*/ for (iMarker = 0; iMarker < geometry->GetnMarker(); iMarker++) { if ((config->GetMarker_All_KindBC(iMarker) != INTERNAL_BOUNDARY) && diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index c05435caf1ba..50646b83a220 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -4980,11 +4980,10 @@ void CSolver::LoadInletProfile(CGeometry **geometry, /*--- Count the number of columns that we have for this flow case, excluding the coordinates. Here, we have 2 entries for the total conditions or mass flow, another nDim for the direction vector, and - finally entries for the number of turbulence variables. ---*/ + finally entries for the number of turbulence variables. This is only + necessary in case we are writing a template profile file. ---*/ unsigned short nCol_InletFile = 2 + nDim + nVar_Turb; - vector Inlet_Values(nCol_InletFile); - vector Inlet_Fine(nCol_InletFile); /*--- Multizone problems require the number of the zone to be appended. ---*/ @@ -5032,6 +5031,8 @@ void CSolver::LoadInletProfile(CGeometry **geometry, unsigned short nColumns = profileReader.GetNumberOfColumnsInProfile(jMarker); + vector Inlet_Values(nColumns); + /*--- Loop through the nodes on this marker. ---*/ for (iVertex = 0; iVertex < geometry[MESH_0]->nVertex[iMarker]; iVertex++) { @@ -5117,6 +5118,17 @@ void CSolver::LoadInletProfile(CGeometry **geometry, Marker_Tag = config->GetMarker_All_TagBound(iMarker); + /* Check the number of columns and allocate temp array. */ + + unsigned short nColumns; + for (jMarker = 0; jMarker < profileReader.GetNumberOfProfiles(); jMarker++) { + if (profileReader.GetTagForProfile(jMarker) == Marker_Tag) { + nColumns = profileReader.GetNumberOfColumnsInProfile(jMarker); + } + } + vector Inlet_Values(nColumns); + vector Inlet_Fine(nColumns); + /*--- Loop through the nodes on this marker. ---*/ for (iVertex = 0; iVertex < geometry[iMesh]->nVertex[iMarker]; iVertex++) { @@ -5131,7 +5143,7 @@ void CSolver::LoadInletProfile(CGeometry **geometry, /*--- Reset the values for the coarse point. ---*/ - for (iVar = 0; iVar < nCol_InletFile; iVar++) Inlet_Values[iVar] = 0.0; + for (iVar = 0; iVar < nColumns; iVar++) Inlet_Values[iVar] = 0.0; /*-- Loop through the children and extract the inlet values from those nodes that lie on the boundary as well as their @@ -5142,9 +5154,9 @@ void CSolver::LoadInletProfile(CGeometry **geometry, for (iChildren = 0; iChildren < geometry[iMesh]->node[iPoint]->GetnChildren_CV(); iChildren++) { Point_Fine = geometry[iMesh]->node[iPoint]->GetChildren_CV(iChildren); - for (iVar = 0; iVar < nCol_InletFile; iVar++) Inlet_Fine[iVar] = 0.0; + for (iVar = 0; iVar < nColumns; iVar++) Inlet_Fine[iVar] = 0.0; Area_Children = solver[iMesh-1][KIND_SOLVER]->GetInletAtVertex(Inlet_Fine.data(), Point_Fine, KIND_MARKER, Marker_Tag, geometry[iMesh-1], config); - for (iVar = 0; iVar < nCol_InletFile; iVar++) { + for (iVar = 0; iVar < nColumns; iVar++) { Inlet_Values[iVar] += Inlet_Fine[iVar]*Area_Children/Area_Parent; } } From f16e97ca2cca5dd40105d50d42d68669a853d46b Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 4 Nov 2019 13:46:22 -0800 Subject: [PATCH 32/57] Euler cases checked. Updated regression values. --- TestCases/parallel_regression.py | 8 ++++---- TestCases/serial_regression.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index d57391263820..8f855c10202d 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -68,7 +68,7 @@ def main(): naca0012.cfg_dir = "euler/naca0012" naca0012.cfg_file = "inv_NACA0012_Roe.cfg" naca0012.test_iter = 20 - naca0012.test_vals = [-4.052370, -3.563380, 0.336120, 0.021570] #last 4 columns + naca0012.test_vals = [-4.056135, -3.565160, 0.336703, 0.021541] #last 4 columns naca0012.su2_exec = "parallel_computation.py -f" naca0012.timeout = 1600 naca0012.tol = 0.00001 @@ -90,7 +90,7 @@ def main(): oneram6.cfg_dir = "euler/oneram6" oneram6.cfg_file = "inv_ONERAM6.cfg" oneram6.test_iter = 10 - oneram6.test_vals = [-7.079068, -6.542899, 0.282322, 0.011804] #last 4 columns + oneram6.test_vals = [-6.952066, -6.361272, 0.282282, 0.011747] #last 4 columns oneram6.su2_exec = "parallel_computation.py -f" oneram6.timeout = 3200 oneram6.tol = 0.00001 @@ -101,7 +101,7 @@ def main(): fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" fixedCL_naca0012.cfg_file = "inv_NACA0012.cfg" fixedCL_naca0012.test_iter = 10 - fixedCL_naca0012.test_vals = [-12.175228, -6.778440, 0.300000, 0.019470] #last 4 columns + fixedCL_naca0012.test_vals = [-12.137680, -6.705671, 0.300000, 0.019470] #last 4 columns fixedCL_naca0012.su2_exec = "parallel_computation.py -f" fixedCL_naca0012.timeout = 1600 fixedCL_naca0012.tol = 0.00001 @@ -124,7 +124,7 @@ def main(): bluntbody.cfg_dir = "euler/bluntbody" bluntbody.cfg_file = "blunt.cfg" bluntbody.test_iter = 20 - bluntbody.test_vals = [0.553700, 6.926057, -0.000000, 1.792561] #last 4 columns + bluntbody.test_vals = [0.540009, 6.916653, 0.000000, 1.868976] #last 4 columns bluntbody.su2_exec = "parallel_computation.py -f" bluntbody.timeout = 1600 bluntbody.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 69b18f5b6a43..249fd9f60a72 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -67,7 +67,7 @@ def main(): naca0012.cfg_dir = "euler/naca0012" naca0012.cfg_file = "inv_NACA0012_Roe.cfg" naca0012.test_iter = 20 - naca0012.test_vals = [-4.021036, -3.511771, 0.339316, 0.022257] #last 4 columns + naca0012.test_vals = [-4.024286, -3.515166, 0.339392, 0.022217] #last 4 columns naca0012.su2_exec = "SU2_CFD" naca0012.timeout = 1600 naca0012.new_output= True @@ -91,7 +91,7 @@ def main(): oneram6.cfg_dir = "euler/oneram6" oneram6.cfg_file = "inv_ONERAM6.cfg" oneram6.test_iter = 10 - oneram6.test_vals = [-7.077986, -6.539796, 0.282344, 0.011807] #last 4 columns + oneram6.test_vals = [-6.952991, -6.364311, 0.282263, 0.011762] #last 4 columns oneram6.su2_exec = "SU2_CFD" oneram6.timeout = 9600 oneram6.new_output = True @@ -103,7 +103,7 @@ def main(): fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" fixedCL_naca0012.cfg_file = "inv_NACA0012.cfg" fixedCL_naca0012.test_iter = 10 - fixedCL_naca0012.test_vals = [-12.181731, -6.784160, 0.300000, 0.019470] #last 4 columns + fixedCL_naca0012.test_vals = [-12.129591, -6.702940, 0.300000, 0.019470] #last 4 columns fixedCL_naca0012.su2_exec = "SU2_CFD" fixedCL_naca0012.new_output = True fixedCL_naca0012.timeout = 1600 @@ -117,7 +117,7 @@ def main(): polar_naca0012.polar = True polar_naca0012.new_output= True polar_naca0012.test_iter = 10 - polar_naca0012.test_vals = [-1.308958, 4.123692, 0.011587, 0.009698] #last 4 columns + polar_naca0012.test_vals = [-1.244014, 4.220468, 0.016275, 0.015988] #last 4 columns polar_naca0012.su2_exec = "compute_polar.py -n 1 -i 11" polar_naca0012.timeout = 1600 polar_naca0012.tol = 0.00001 @@ -129,7 +129,7 @@ def main(): bluntbody.cfg_file = "blunt.cfg" bluntbody.new_output = True bluntbody.test_iter = 20 - bluntbody.test_vals = [0.553700, 6.926057, -0.000000, 1.792561] #last 4 columns + bluntbody.test_vals = [0.540009, 6.916653, -0.000000, 1.868975] #last 4 columns bluntbody.su2_exec = "SU2_CFD" bluntbody.timeout = 1600 bluntbody.tol = 0.00001 From 01f13b896ee063e26daaee2cc882ba5eff9b3293 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 4 Nov 2019 15:35:16 -0800 Subject: [PATCH 33/57] RANS cases part I. Updated regression values. --- TestCases/cont_adj_euler/wedge/inv_wedge_ROE.cfg | 2 +- TestCases/parallel_regression.py | 8 ++++---- TestCases/serial_regression.py | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/TestCases/cont_adj_euler/wedge/inv_wedge_ROE.cfg b/TestCases/cont_adj_euler/wedge/inv_wedge_ROE.cfg index 23cbb3d1bfe3..ae62af171467 100644 --- a/TestCases/cont_adj_euler/wedge/inv_wedge_ROE.cfg +++ b/TestCases/cont_adj_euler/wedge/inv_wedge_ROE.cfg @@ -91,7 +91,7 @@ NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES CFL_NUMBER= 1.0 % % Adaptive CFL number (NO, YES) -CFL_ADAPT= YES +CFL_ADAPT= NO % % Parameters of the adaptive CFL number (factor down, factor up, CFL min value, % CFL max value ) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 8f855c10202d..9148333b36ff 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -198,7 +198,7 @@ def main(): rae2822_sa.cfg_dir = "rans/rae2822" rae2822_sa.cfg_file = "turb_SA_RAE2822.cfg" rae2822_sa.test_iter = 20 - rae2822_sa.test_vals = [-1.999739, -5.231505, 0.826880, 0.052973] #last 4 columns + rae2822_sa.test_vals = [-2.013881, -5.271311, 0.814981, 0.061858] #last 4 columns rae2822_sa.su2_exec = "parallel_computation.py -f" rae2822_sa.timeout = 1600 rae2822_sa.tol = 0.00001 @@ -209,7 +209,7 @@ def main(): rae2822_sst.cfg_dir = "rans/rae2822" rae2822_sst.cfg_file = "turb_SST_RAE2822.cfg" rae2822_sst.test_iter = 20 - rae2822_sst.test_vals = [-0.510806, 4.916635, 0.827705, 0.053331] #last 4 columns + rae2822_sst.test_vals = [-0.510623, 4.874845, 0.817046, 0.062059] #last 4 columns rae2822_sst.su2_exec = "parallel_computation.py -f" rae2822_sst.timeout = 1600 rae2822_sst.tol = 0.00001 @@ -220,7 +220,7 @@ def main(): rae2822_sst_sust.cfg_dir = "rans/rae2822" rae2822_sst_sust.cfg_file = "turb_SST_SUST_RAE2822.cfg" rae2822_sst_sust.test_iter = 20 - rae2822_sst_sust.test_vals = [-2.407053, 4.916635, 0.827705, 0.053331] #last 4 columns + rae2822_sst_sust.test_vals = [-2.427686, 4.874845, 0.817046, 0.062059] #last 4 columns rae2822_sst_sust.su2_exec = "parallel_computation.py -f" rae2822_sst_sust.timeout = 1600 rae2822_sst_sust.tol = 0.00001 @@ -242,7 +242,7 @@ def main(): turb_oneram6.cfg_dir = "rans/oneram6" turb_oneram6.cfg_file = "turb_ONERAM6.cfg" turb_oneram6.test_iter = 10 - turb_oneram6.test_vals = [-2.327430, -6.564331, 0.230257, 0.155839] #last 4 columns + turb_oneram6.test_vals = [-2.372511, -6.579340, 0.229864, 0.147639] #last 4 columns turb_oneram6.su2_exec = "parallel_computation.py -f" turb_oneram6.timeout = 3200 turb_oneram6.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 249fd9f60a72..df64264b033e 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -208,7 +208,7 @@ def main(): rae2822_sa.cfg_dir = "rans/rae2822" rae2822_sa.cfg_file = "turb_SA_RAE2822.cfg" rae2822_sa.test_iter = 20 - rae2822_sa.test_vals = [-2.000469, -5.228296, 0.820188, 0.052004] #last 4 columns + rae2822_sa.test_vals = [-2.021218, -5.268447, 0.807465, 0.060897] #last 4 columns rae2822_sa.su2_exec = "SU2_CFD" rae2822_sa.timeout = 1600 rae2822_sa.new_output = True @@ -220,7 +220,7 @@ def main(): rae2822_sst.cfg_dir = "rans/rae2822" rae2822_sst.cfg_file = "turb_SST_RAE2822.cfg" rae2822_sst.test_iter = 20 - rae2822_sst.test_vals = [-0.510826, 4.909241, 0.825023, 0.052675] #last 4 columns + rae2822_sst.test_vals = [-0.510641, 4.874876, 0.813353, 0.061455] #last 4 columns rae2822_sst.su2_exec = "SU2_CFD" rae2822_sst.new_output = True rae2822_sst.timeout = 1600 @@ -232,7 +232,7 @@ def main(): rae2822_sst_sust.cfg_dir = "rans/rae2822" rae2822_sst_sust.cfg_file = "turb_SST_SUST_RAE2822.cfg" rae2822_sst_sust.test_iter = 20 - rae2822_sst_sust.test_vals = [-2.401009, 4.909241, 0.825023, 0.052675] #last 4 columns + rae2822_sst_sust.test_vals = [-2.427577, 4.874876, 0.813353, 0.061455] #last 4 columns rae2822_sst_sust.su2_exec = "SU2_CFD" rae2822_sst_sust.timeout = 1600 rae2822_sst_sust.tol = 0.00001 @@ -255,7 +255,7 @@ def main(): turb_oneram6.cfg_dir = "rans/oneram6" turb_oneram6.cfg_file = "turb_ONERAM6.cfg" turb_oneram6.test_iter = 10 - turb_oneram6.test_vals = [-2.327431, -6.564331, 0.230257, 0.155839]#last 4 columns + turb_oneram6.test_vals = [-2.372511, -6.579339, 0.229864, 0.147639]#last 4 columns turb_oneram6.su2_exec = "SU2_CFD" turb_oneram6.new_output = True turb_oneram6.timeout = 3200 From 921ffd57213fa3830c6834cbd004a0e305529a48 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Tue, 5 Nov 2019 10:06:26 +0100 Subject: [PATCH 34/57] added reset of underrelaxation --- SU2_CFD/src/integration_structure.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SU2_CFD/src/integration_structure.cpp b/SU2_CFD/src/integration_structure.cpp index a0c91efd5433..853bbfa72821 100644 --- a/SU2_CFD/src/integration_structure.cpp +++ b/SU2_CFD/src/integration_structure.cpp @@ -451,6 +451,10 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + /*--- Initialize the underrelaxation ---*/ + + solver->GetNodes()->SetUnderRelaxation(iPoint, 1.0); + /*--- Initialize the local CFL number ---*/ solver->GetNodes()->SetLocalCFL(iPoint, config->GetCFL(iMesh)); From f900006e25376cf75fc89c5e70a603e3124028d4 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Tue, 5 Nov 2019 18:28:23 -0800 Subject: [PATCH 35/57] Adjustment for SA_NEG so under-relaxation does not cause stall. --- SU2_CFD/src/solver_direct_turbulent.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index 3d0198307511..69fa182b9ca8 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -474,13 +474,14 @@ void CTurbSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ void CTurbSolver::ComputeUnderRelaxationFactor(CSolver **solver_container, CConfig *config) { - /* Only apply the turbulent under-relaxation to the SA variants. */ + /* Only apply the turbulent under-relaxation to the SA variants. The + SA_NEG model is more robust due to allowing for negative nu_tilde, + so the under-relaxation is not applied to that variant. */ bool sa_model = ((config->GetKind_Turb_Model() == SA) || (config->GetKind_Turb_Model() == SA_E) || (config->GetKind_Turb_Model() == SA_COMP) || - (config->GetKind_Turb_Model() == SA_E_COMP) || - (config->GetKind_Turb_Model() == SA_NEG)); + (config->GetKind_Turb_Model() == SA_E_COMP)); /* Loop over the solution update given by relaxing the linear system for this nonlinear iteration. */ From 40eab170c8f2fc37c0fd719250c068dd1e98e8b9 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Tue, 5 Nov 2019 19:49:37 -0800 Subject: [PATCH 36/57] Bug fix for unweighted least squares with periodic BCs. --- Common/include/option_structure.hpp | 8 ++-- SU2_CFD/src/solver_direct_mean.cpp | 9 +++- SU2_CFD/src/solver_direct_mean_inc.cpp | 9 +++- SU2_CFD/src/solver_structure.cpp | 63 +++++++++++++++++++------- 4 files changed, 65 insertions(+), 24 deletions(-) diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index c08239363382..ca63700d85be 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -1991,13 +1991,15 @@ enum PERIODIC_QUANTITIES { PERIODIC_SENSOR = 6, /*!< \brief Dissipation sensor communication (periodic only). */ PERIODIC_SOL_GG = 7, /*!< \brief Solution gradient communication for Green-Gauss (periodic only). */ PERIODIC_PRIM_GG = 8, /*!< \brief Primitive gradient communication for Green-Gauss (periodic only). */ - PERIODIC_SOL_LS = 9, /*!< \brief Solution gradient communication for Least Squares (periodic only). */ - PERIODIC_PRIM_LS = 10, /*!< \brief Primitive gradient communication for Least Squares (periodic only). */ + PERIODIC_SOL_LS = 9, /*!< \brief Solution gradient communication for weighted Least Squares (periodic only). */ + PERIODIC_PRIM_LS = 10, /*!< \brief Primitive gradient communication for weighted Least Squares (periodic only). */ PERIODIC_LIM_SOL_1 = 11, /*!< \brief Solution limiter communication phase 1 of 2 (periodic only). */ PERIODIC_LIM_SOL_2 = 12, /*!< \brief Solution limiter communication phase 2 of 2 (periodic only). */ PERIODIC_LIM_PRIM_1 = 13, /*!< \brief Primitive limiter communication phase 1 of 2 (periodic only). */ PERIODIC_LIM_PRIM_2 = 14, /*!< \brief Primitive limiter communication phase 2 of 2 (periodic only). */ - PERIODIC_IMPLICIT = 15 /*!< \brief Implicit update communication to ensure consistency across periodic boundaries. */ + PERIODIC_IMPLICIT = 15, /*!< \brief Implicit update communication to ensure consistency across periodic boundaries. */ + PERIODIC_SOL_ULS = 16, /*!< \brief Solution gradient communication for unwieghted Least Squares (periodic only). */ + PERIODIC_PRIM_ULS = 17 /*!< \brief Primitive gradient communication for unweighted Least Squares (periodic only). */ }; /*! diff --git a/SU2_CFD/src/solver_direct_mean.cpp b/SU2_CFD/src/solver_direct_mean.cpp index 2e4d98516362..31a9ea91855e 100644 --- a/SU2_CFD/src/solver_direct_mean.cpp +++ b/SU2_CFD/src/solver_direct_mean.cpp @@ -5484,8 +5484,13 @@ void CEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *config /*--- Correct the gradient values across any periodic boundaries. ---*/ for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_LS); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_LS); + if (weighted) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_LS); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_LS); + } else { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_ULS); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_ULS); + } } /*--- Second loop over points of the grid to compute final gradient ---*/ diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index 43350eed3cbf..0152a4695539 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -3777,8 +3777,13 @@ void CIncEulerSolver::SetPrimitive_Gradient_LS(CGeometry *geometry, CConfig *con /*--- Correct the gradient values across any periodic boundaries. ---*/ for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_LS); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_LS); + if (weighted) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_LS); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_LS); + } else { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_ULS); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_PRIM_ULS); + } } /*--- Second loop over points of the grid to compute final gradient ---*/ diff --git a/SU2_CFD/src/solver_structure.cpp b/SU2_CFD/src/solver_structure.cpp index 927a08f5e90a..5b26e161ed36 100644 --- a/SU2_CFD/src/solver_structure.cpp +++ b/SU2_CFD/src/solver_structure.cpp @@ -280,7 +280,8 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, /*--- Local variables ---*/ bool boundary_i, boundary_j; - + bool weighted = true; + unsigned short iVar, jVar, iDim; unsigned short iNeighbor, nNeighbor = 0; unsigned short COUNT_PER_POINT = 0; @@ -351,11 +352,11 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, ICOUNT = nPrimVarGrad; JCOUNT = nDim; break; - case PERIODIC_SOL_LS: + case PERIODIC_SOL_LS: case PERIODIC_SOL_ULS: COUNT_PER_POINT = nDim*nDim + nVar*nDim; MPI_TYPE = COMM_TYPE_DOUBLE; break; - case PERIODIC_PRIM_LS: + case PERIODIC_PRIM_LS: case PERIODIC_PRIM_ULS: COUNT_PER_POINT = nDim*nDim + nPrimVarGrad*nDim; MPI_TYPE = COMM_TYPE_DOUBLE; break; @@ -868,7 +869,7 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, break; - case PERIODIC_SOL_LS: + case PERIODIC_SOL_LS: case PERIODIC_SOL_ULS: /*--- For L-S gradient calculations with rotational periodicity, we will need to rotate the x,y,z components. To make the process @@ -876,6 +877,13 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, neighbor points into their location on the donor marker before computing the terms that we need to communicate. ---*/ + /*--- Set a flag for unweighted or weighted least-squares. ---*/ + + weighted = true; + if (commType == PERIODIC_SOL_ULS) { + weighted = false; + } + /*--- Get coordinates for the current point. ---*/ Coord_i = geometry->node[iPoint]->GetCoord(); @@ -993,10 +1001,14 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, } } - weight = 0.0; - for (iDim = 0; iDim < nDim; iDim++) { - weight += ((rotCoord_j[iDim]-rotCoord_i[iDim])* - (rotCoord_j[iDim]-rotCoord_i[iDim])); + if (weighted) { + weight = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + weight += ((rotCoord_j[iDim]-rotCoord_i[iDim])* + (rotCoord_j[iDim]-rotCoord_i[iDim])); + } + } else { + weight = 1.0; } /*--- Sumations for entries of upper triangular matrix R ---*/ @@ -1066,7 +1078,7 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, break; - case PERIODIC_PRIM_LS: + case PERIODIC_PRIM_LS: case PERIODIC_PRIM_ULS: /*--- For L-S gradient calculations with rotational periodicity, we will need to rotate the x,y,z components. To make the process @@ -1074,6 +1086,13 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, neighbor points into their location on the donor marker before computing the terms that we need to communicate. ---*/ + /*--- Set a flag for unweighted or weighted least-squares. ---*/ + + weighted = true; + if (commType == PERIODIC_PRIM_ULS) { + weighted = false; + } + /*--- Get coordinates ---*/ Coord_i = geometry->node[iPoint]->GetCoord(); @@ -1191,10 +1210,15 @@ void CSolver::InitiatePeriodicComms(CGeometry *geometry, } } - weight = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - weight += ((rotCoord_j[iDim]-rotCoord_i[iDim])* - (rotCoord_j[iDim]-rotCoord_i[iDim])); + if (weighted) { + weight = 0.0; + for (iDim = 0; iDim < nDim; iDim++) { + weight += ((rotCoord_j[iDim]-rotCoord_i[iDim])* + (rotCoord_j[iDim]-rotCoord_i[iDim])); + } + } else { + weight = 1.0; + } /*--- Sumations for entries of upper triangular matrix R ---*/ @@ -1710,7 +1734,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, base_nodes->SetGradient_Primitive(iPoint, iVar, iDim, bufDRecv[buf_offset+iVar*nDim+iDim] + base_nodes->GetGradient_Primitive(iPoint, iVar, iDim)); break; - case PERIODIC_SOL_LS: + case PERIODIC_SOL_LS: case PERIODIC_SOL_ULS: /*--- For L-S, we build the upper triangular matrix and the r.h.s. vector by accumulating from all periodic partial @@ -1731,7 +1755,7 @@ void CSolver::CompletePeriodicComms(CGeometry *geometry, break; - case PERIODIC_PRIM_LS: + case PERIODIC_PRIM_LS: case PERIODIC_PRIM_ULS: /*--- For L-S, we build the upper triangular matrix and the r.h.s. vector by accumulating from all periodic partial @@ -3097,8 +3121,13 @@ void CSolver::SetSolution_Gradient_LS(CGeometry *geometry, CConfig *config, bool /*--- Correct the gradient values for any periodic boundaries. ---*/ for (unsigned short iPeriodic = 1; iPeriodic <= config->GetnMarker_Periodic()/2; iPeriodic++) { - InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_SOL_LS); - CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_SOL_LS); + if (weighted) { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_SOL_LS); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_SOL_LS); + } else { + InitiatePeriodicComms(geometry, config, iPeriodic, PERIODIC_SOL_ULS); + CompletePeriodicComms(geometry, config, iPeriodic, PERIODIC_SOL_ULS); + } } /*--- Second loop over points of the grid to compute final gradient ---*/ From f637a91d316290c29682938519d3f1df87440e4e Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 6 Nov 2019 13:55:09 -0800 Subject: [PATCH 37/57] RANS case regression updates part II. NACA 0012 with new restarts in test cases directory. --- .github/workflows/regression.yml | 2 +- TestCases/parallel_regression.py | 17 +++------------ TestCases/rans/naca0012/turb_NACA0012_sa.cfg | 21 ++++++------------- TestCases/rans/naca0012/turb_NACA0012_sst.cfg | 15 +++++++------ .../rans/naca0012/turb_NACA0012_sst_sust.cfg | 14 ++++++------- TestCases/serial_regression.py | 19 +++-------------- 6 files changed, 27 insertions(+), 61 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index c3b9dfda7358..e0ded591c93f 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -87,5 +87,5 @@ jobs: - name: Run Tests in Container uses: docker://su2code/test-su2:20191031 with: - args: -b ${{github.ref}} -t develop -c develop -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t develop -c feature_nlctrl -s ${{matrix.testscript}} diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 9148333b36ff..c38045a6791d 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -253,29 +253,18 @@ def main(): turb_naca0012_sa.cfg_dir = "rans/naca0012" turb_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" turb_naca0012_sa.test_iter = 10 - turb_naca0012_sa.test_vals = [-11.981164, -9.145363, 1.070528, 0.019417] #last 4 columns + turb_naca0012_sa.test_vals = [-12.081762, -16.111167, 1.064326, 0.019770] #last 4 columns turb_naca0012_sa.su2_exec = "parallel_computation.py -f" turb_naca0012_sa.timeout = 3200 turb_naca0012_sa.tol = 0.00001 test_list.append(turb_naca0012_sa) - - # NACA0012 (SA, FUN3D results for finest grid: CL=1.0983, CD=0.01242) with binary restart - turb_naca0012_sa_bin = TestCase('turb_naca0012_sa_bin') - turb_naca0012_sa_bin.cfg_dir = "rans/naca0012" - turb_naca0012_sa_bin.cfg_file = "turb_NACA0012_sa_binary.cfg" - turb_naca0012_sa_bin.test_iter = 10 - turb_naca0012_sa_bin.test_vals = [-11.981288, -9.145363, 1.070528, 0.019417] #last 4 columns - turb_naca0012_sa_bin.su2_exec = "parallel_computation.py -f" - turb_naca0012_sa_bin.timeout = 3200 - turb_naca0012_sa_bin.tol = 0.00001 - test_list.append(turb_naca0012_sa_bin) # NACA0012 (SST, FUN3D finest grid results: CL=1.0840, CD=0.01253) turb_naca0012_sst = TestCase('turb_naca0012_sst') turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-12.454442, -6.574917, 1.059622, 0.019138] #last 4 columns + turb_naca0012_sst.test_vals = [-15.805904, -6.248662, 1.049989, 0.019166] #last 4 columns turb_naca0012_sst.su2_exec = "parallel_computation.py -f" turb_naca0012_sst.timeout = 3200 turb_naca0012_sst.tol = 0.00001 @@ -286,7 +275,7 @@ def main(): turb_naca0012_sst_sust.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust.test_iter = 10 - turb_naca0012_sst_sust.test_vals = [-13.280836, -5.645158, 1.022304, 0.019539] #last 4 columns + turb_naca0012_sst_sust.test_vals = [-16.140320, -5.980468, 1.005228, 0.019014] #last 4 columns turb_naca0012_sst_sust.su2_exec = "parallel_computation.py -f" turb_naca0012_sst_sust.timeout = 3200 turb_naca0012_sst_sust.tol = 0.00001 diff --git a/TestCases/rans/naca0012/turb_NACA0012_sa.cfg b/TestCases/rans/naca0012/turb_NACA0012_sa.cfg index 9c53745856f6..b00a8d509366 100644 --- a/TestCases/rans/naca0012/turb_NACA0012_sa.cfg +++ b/TestCases/rans/naca0012/turb_NACA0012_sa.cfg @@ -18,7 +18,7 @@ SOLVER= RANS % % Specify turbulent model (NONE, SA, SA_NEG, SST) -KIND_TURB_MODEL= SA +KIND_TURB_MODEL= SA_NEG % % Mathematical problem (DIRECT, CONTINUOUS_ADJOINT) MATH_PROBLEM= DIRECT @@ -26,13 +26,6 @@ MATH_PROBLEM= DIRECT % Restart solution (NO, YES) RESTART_SOL= YES % -% Write binary restart files (YES, NO) -WRT_BINARY_RESTART= NO -% -% Read binary restart files (YES, NO) -READ_BINARY_RESTART= NO -% -% % New singlezone driver SINGLEZONE_DRIVER= YES @@ -88,9 +81,10 @@ MARKER_MONITORING= ( airfoil ) % % Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +NUM_METHOD_GRAD_RECON= LEAST_SQUARES % % Courant-Friedrichs-Lewy condition of the finest grid -CFL_NUMBER= 10.0 +CFL_NUMBER= 1000.0 % % Max Delta time MAX_DELTA_TIME= 1E10 @@ -119,13 +113,13 @@ LIMITER_ITER= 99999 LINEAR_SOLVER= FGMRES % % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) -LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_PREC= ILU % % Minimum error of the linear solver for implicit formulations LINEAR_SOLVER_ERROR= 1E-10 % % Max number of iterations of the linear solver for the implicit formulation -LINEAR_SOLVER_ITER= 5 +LINEAR_SOLVER_ITER= 20 % -------------------------- MULTIGRID PARAMETERS -----------------------------% % @@ -157,7 +151,7 @@ CONV_NUM_METHOD_FLOW= ROE MUSCL_FLOW= YES % % Slope limiter (VENKATAKRISHNAN, MINMOD) -SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +SLOPE_LIMITER_FLOW= NONE % % 2nd and 4th order artificial dissipation coefficients JST_SENSOR_COEFF= ( 0.5, 0.02 ) @@ -190,7 +184,6 @@ CFL_REDUCTION_TURB= 1.0 % CONV_CRITERIA= RESIDUAL % -% % Min value of the residual (log10 of the residual) CONV_RESIDUAL_MINVAL= -12 % @@ -202,7 +195,6 @@ CONV_CAUCHY_ELEMS= 100 % % Epsilon to control the series convergence CONV_CAUCHY_EPS= 1E-6 -% % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % @@ -256,4 +248,3 @@ WRT_CON_FREQ= 1 % % Screen output fields SCREEN_OUTPUT=(INNER_ITER, RMS_DENSITY, RMS_NU_TILDE, LIFT, DRAG) - diff --git a/TestCases/rans/naca0012/turb_NACA0012_sst.cfg b/TestCases/rans/naca0012/turb_NACA0012_sst.cfg index bfa4a67aa2ce..bf09e392fef2 100644 --- a/TestCases/rans/naca0012/turb_NACA0012_sst.cfg +++ b/TestCases/rans/naca0012/turb_NACA0012_sst.cfg @@ -32,7 +32,6 @@ WRT_BINARY_RESTART= NO % Read binary restart files (YES, NO) READ_BINARY_RESTART= NO % -% % New singlezone driver SINGLEZONE_DRIVER= YES @@ -88,9 +87,10 @@ MARKER_MONITORING= ( airfoil ) % % Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +NUM_METHOD_GRAD_RECON= LEAST_SQUARES % % Courant-Friedrichs-Lewy condition of the finest grid -CFL_NUMBER= 10.0 +CFL_NUMBER= 1000.0 % % Max Delta time MAX_DELTA_TIME= 1E10 @@ -119,13 +119,13 @@ LIMITER_ITER= 99999 LINEAR_SOLVER= FGMRES % % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) -LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_PREC= ILU % % Minimum error of the linear solver for implicit formulations LINEAR_SOLVER_ERROR= 1E-10 % % Max number of iterations of the linear solver for the implicit formulation -LINEAR_SOLVER_ITER= 2 +LINEAR_SOLVER_ITER= 20 % -------------------------- MULTIGRID PARAMETERS -----------------------------% % @@ -157,7 +157,7 @@ CONV_NUM_METHOD_FLOW= ROE MUSCL_FLOW= YES % % Slope limiter (VENKATAKRISHNAN, MINMOD) -SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +SLOPE_LIMITER_FLOW= NONE % % 2nd and 4th order artificial dissipation coefficients JST_SENSOR_COEFF= ( 0.5, 0.02 ) @@ -175,7 +175,7 @@ CONV_NUM_METHOD_TURB= SCALAR_UPWIND MUSCL_TURB= NO % % Slope limiter (VENKATAKRISHNAN, MINMOD) -SLOPE_LIMITER_TURB= VENKATAKRISHNAN +SLOPE_LIMITER_TURB= NONE % % Time discretization (EULER_IMPLICIT) TIME_DISCRE_TURB= EULER_IMPLICIT @@ -189,7 +189,6 @@ CFL_REDUCTION_TURB= 1.0 % CONV_CRITERIA= RESIDUAL % -% % Min value of the residual (log10 of the residual) CONV_RESIDUAL_MINVAL= -12 % @@ -255,4 +254,4 @@ WRT_CON_FREQ= 1 % % Screen output fields SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_TKE, RMS_DISSIPATION, LIFT, DRAG) - +OUTPUT_FILES= (RESTART_ASCII, PARAVIEW, SURFACE_PARAVIEW) diff --git a/TestCases/rans/naca0012/turb_NACA0012_sst_sust.cfg b/TestCases/rans/naca0012/turb_NACA0012_sst_sust.cfg index 11c5fc777071..768eb80fd690 100644 --- a/TestCases/rans/naca0012/turb_NACA0012_sst_sust.cfg +++ b/TestCases/rans/naca0012/turb_NACA0012_sst_sust.cfg @@ -91,9 +91,10 @@ MARKER_MONITORING= ( airfoil ) % % Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES +NUM_METHOD_GRAD_RECON= LEAST_SQUARES % % Courant-Friedrichs-Lewy condition of the finest grid -CFL_NUMBER= 10.0 +CFL_NUMBER= 1000.0 % % Max Delta time MAX_DELTA_TIME= 1E10 @@ -122,13 +123,13 @@ LIMITER_ITER= 99999 LINEAR_SOLVER= FGMRES % % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) -LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_PREC= ILU % % Minimum error of the linear solver for implicit formulations LINEAR_SOLVER_ERROR= 1E-10 % % Max number of iterations of the linear solver for the implicit formulation -LINEAR_SOLVER_ITER= 2 +LINEAR_SOLVER_ITER= 20 % -------------------------- MULTIGRID PARAMETERS -----------------------------% % @@ -160,7 +161,7 @@ CONV_NUM_METHOD_FLOW= ROE MUSCL_FLOW= YES % % Slope limiter (VENKATAKRISHNAN, MINMOD) -SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +SLOPE_LIMITER_FLOW= NONE % % 2nd and 4th order artificial dissipation coefficients JST_SENSOR_COEFF= ( 0.5, 0.02 ) @@ -178,7 +179,7 @@ CONV_NUM_METHOD_TURB= SCALAR_UPWIND MUSCL_TURB= NO % % Slope limiter (VENKATAKRISHNAN, MINMOD) -SLOPE_LIMITER_TURB= VENKATAKRISHNAN +SLOPE_LIMITER_TURB= NONE % % Time discretization (EULER_IMPLICIT) TIME_DISCRE_TURB= EULER_IMPLICIT @@ -192,7 +193,6 @@ CFL_REDUCTION_TURB= 1.0 % CONV_CRITERIA= RESIDUAL % -% % Min value of the residual (log10 of the residual) CONV_RESIDUAL_MINVAL= -12 % @@ -258,4 +258,4 @@ WRT_CON_FREQ= 1 % % Screen output fields SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_TKE, RMS_DISSIPATION, LIFT, DRAG) - +OUTPUT_FILES= (RESTART_ASCII, PARAVIEW, SURFACE_PARAVIEW) diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index df64264b033e..9f36c5e2710c 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -267,31 +267,19 @@ def main(): turb_naca0012_sa.cfg_dir = "rans/naca0012" turb_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" turb_naca0012_sa.test_iter = 10 - turb_naca0012_sa.test_vals = [-11.981166, -9.145363, 1.070528, 0.019417] #last 4 columns + turb_naca0012_sa.test_vals = [-12.081762, -16.111167, 1.064326, 0.019770] #last 4 columns turb_naca0012_sa.su2_exec = "SU2_CFD" turb_naca0012_sa.new_output = True turb_naca0012_sa.timeout = 3200 turb_naca0012_sa.tol = 0.00001 test_list.append(turb_naca0012_sa) - - # NACA0012 (SA, FUN3D results for finest grid: CL=1.0983, CD=0.01242) with binary restart - turb_naca0012_sa_bin = TestCase('turb_naca0012_sa_bin') - turb_naca0012_sa_bin.cfg_dir = "rans/naca0012" - turb_naca0012_sa_bin.cfg_file = "turb_NACA0012_sa_binary.cfg" - turb_naca0012_sa_bin.test_iter = 10 - turb_naca0012_sa_bin.test_vals = [-11.981289, -9.145363, 1.070528, 0.019417] #last 4 columns - turb_naca0012_sa_bin.su2_exec = "SU2_CFD" - turb_naca0012_sa_bin.new_output = True - turb_naca0012_sa_bin.timeout = 3200 - turb_naca0012_sa_bin.tol = 0.00001 - test_list.append(turb_naca0012_sa_bin) # NACA0012 (SST, FUN3D results for finest grid: CL=1.0840, CD=0.01253) turb_naca0012_sst = TestCase('turb_naca0012_sst') turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-12.454420, -6.572026, 1.059622, 0.019138] #last 4 columns + turb_naca0012_sst.test_vals = [-15.805904, -6.248662, 1.049989, 0.019166] #last 4 columns turb_naca0012_sst.su2_exec = "SU2_CFD" turb_naca0012_sst.new_output = True turb_naca0012_sst.timeout = 3200 @@ -303,13 +291,12 @@ def main(): turb_naca0012_sst_sust.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust.test_iter = 10 - turb_naca0012_sst_sust.test_vals = [-13.280975, -5.646508, 1.022304, 0.019539] #last 4 columns + turb_naca0012_sst_sust.test_vals = [-16.140320, -5.980468, 1.005228, 0.019014] #last 4 columns turb_naca0012_sst_sust.su2_exec = "SU2_CFD" turb_naca0012_sst_sust.timeout = 3200 turb_naca0012_sst_sust.tol = 0.00001 test_list.append(turb_naca0012_sst_sust) - # PROPELLER propeller = TestCase('propeller') propeller.cfg_dir = "rans/propeller" From 1ae4065c6caeba4935c3fc2e501225637128444b Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 6 Nov 2019 17:21:09 -0800 Subject: [PATCH 38/57] Updated regression values using new restarts. --- TestCases/parallel_regression.py | 10 +++++----- TestCases/serial_regression.py | 9 +++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index c38045a6791d..d3eceaf10d70 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -90,7 +90,7 @@ def main(): oneram6.cfg_dir = "euler/oneram6" oneram6.cfg_file = "inv_ONERAM6.cfg" oneram6.test_iter = 10 - oneram6.test_vals = [-6.952066, -6.361272, 0.282282, 0.011747] #last 4 columns + oneram6.test_vals = [-10.208444, -9.625586, 0.281704, 0.011821] #last 4 columns oneram6.su2_exec = "parallel_computation.py -f" oneram6.timeout = 3200 oneram6.tol = 0.00001 @@ -113,7 +113,7 @@ def main(): polar_naca0012.cfg_file = "inv_NACA0012.cfg" polar_naca0012.polar = True polar_naca0012.test_iter = 10 - polar_naca0012.test_vals = [-1.293870, 4.141024, -0.002288, 0.008868] #last 4 columns + polar_naca0012.test_vals = [-1.216242, 4.253547, 0.001423, 0.015977] #last 4 columns polar_naca0012.su2_exec = "compute_polar.py -i 11" polar_naca0012.timeout = 1600 polar_naca0012.tol = 0.00001 @@ -253,7 +253,7 @@ def main(): turb_naca0012_sa.cfg_dir = "rans/naca0012" turb_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" turb_naca0012_sa.test_iter = 10 - turb_naca0012_sa.test_vals = [-12.081762, -16.111167, 1.064326, 0.019770] #last 4 columns + turb_naca0012_sa.test_vals = [-12.078407, -16.147828, 1.064326, 0.019770] #last 4 columns turb_naca0012_sa.su2_exec = "parallel_computation.py -f" turb_naca0012_sa.timeout = 3200 turb_naca0012_sa.tol = 0.00001 @@ -264,7 +264,7 @@ def main(): turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-15.805904, -6.248662, 1.049989, 0.019166] #last 4 columns + turb_naca0012_sst.test_vals = [-15.804072, -6.250381, 1.049989, 0.019166] #last 4 columns turb_naca0012_sst.su2_exec = "parallel_computation.py -f" turb_naca0012_sst.timeout = 3200 turb_naca0012_sst.tol = 0.00001 @@ -275,7 +275,7 @@ def main(): turb_naca0012_sst_sust.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust.test_iter = 10 - turb_naca0012_sst_sust.test_vals = [-16.140320, -5.980468, 1.005228, 0.019014] #last 4 columns + turb_naca0012_sst_sust.test_vals = [-16.136012, -5.980662, 1.005228, 0.019014] #last 4 columns turb_naca0012_sst_sust.su2_exec = "parallel_computation.py -f" turb_naca0012_sst_sust.timeout = 3200 turb_naca0012_sst_sust.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 9f36c5e2710c..9c2c0bf87e0c 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -91,7 +91,7 @@ def main(): oneram6.cfg_dir = "euler/oneram6" oneram6.cfg_file = "inv_ONERAM6.cfg" oneram6.test_iter = 10 - oneram6.test_vals = [-6.952991, -6.364311, 0.282263, 0.011762] #last 4 columns + oneram6.test_vals = [-10.200724, -9.619291, 0.281704, 0.011821] #last 4 columns oneram6.su2_exec = "SU2_CFD" oneram6.timeout = 9600 oneram6.new_output = True @@ -267,7 +267,7 @@ def main(): turb_naca0012_sa.cfg_dir = "rans/naca0012" turb_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" turb_naca0012_sa.test_iter = 10 - turb_naca0012_sa.test_vals = [-12.081762, -16.111167, 1.064326, 0.019770] #last 4 columns + turb_naca0012_sa.test_vals = [-12.075873, -16.146770, 1.064326, 0.019770] #last 4 columns turb_naca0012_sa.su2_exec = "SU2_CFD" turb_naca0012_sa.new_output = True turb_naca0012_sa.timeout = 3200 @@ -279,7 +279,7 @@ def main(): turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-15.805904, -6.248662, 1.049989, 0.019166] #last 4 columns + turb_naca0012_sst.test_vals = [-15.807519, -6.250396, 1.049989, 0.019166] #last 4 columns turb_naca0012_sst.su2_exec = "SU2_CFD" turb_naca0012_sst.new_output = True turb_naca0012_sst.timeout = 3200 @@ -291,7 +291,7 @@ def main(): turb_naca0012_sst_sust.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust.test_iter = 10 - turb_naca0012_sst_sust.test_vals = [-16.140320, -5.980468, 1.005228, 0.019014] #last 4 columns + turb_naca0012_sst_sust.test_vals = [-16.136911, -5.980663, 1.005228, 0.019014] #last 4 columns turb_naca0012_sst_sust.su2_exec = "SU2_CFD" turb_naca0012_sst_sust.timeout = 3200 turb_naca0012_sst_sust.tol = 0.00001 @@ -308,6 +308,7 @@ def main(): propeller.timeout = 3200 propeller.tol = 0.00001 test_list.append(propeller) + ################################# ## Compressible RANS Restart ### ################################# From bd948400dabb3f29592b78d3df71d3eecf1e78b6 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Thu, 7 Nov 2019 09:53:46 +0100 Subject: [PATCH 39/57] Fix crash for adjoint in tecplot binary writer --- SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp index 4ae02eb1119d..6ad39be9ea44 100644 --- a/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp +++ b/SU2_CFD/src/output/filewriter/CTecplotBinaryFileWriter.cpp @@ -245,7 +245,7 @@ void CTecplotBinaryFileWriter::Write_Data(){ data_to_send[index++] =dataSorter->GetData(iVar,node_offset); } } - SU2_MPI::Alltoallv(&data_to_send[0], &num_values_to_send[0], &values_to_send_displacements[0], MPI_DOUBLE, + CBaseMPIWrapper::Alltoallv(&data_to_send[0], &num_values_to_send[0], &values_to_send_displacements[0], MPI_DOUBLE, &halo_var_data[0], &num_values_to_receive[0], &values_to_receive_displacements[0], MPI_DOUBLE, MPI_COMM_WORLD); } From 761dc2a5ecf25e5419a8c8ca04cbac53a813a7d6 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 7 Nov 2019 15:14:52 -0800 Subject: [PATCH 40/57] Reverting to old SST clipping. Seems to be important for UQ cases. --- SU2_CFD/src/solver_direct_turbulent.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/solver_direct_turbulent.cpp b/SU2_CFD/src/solver_direct_turbulent.cpp index 69fa182b9ca8..8c7bcda58a7d 100644 --- a/SU2_CFD/src/solver_direct_turbulent.cpp +++ b/SU2_CFD/src/solver_direct_turbulent.cpp @@ -3411,8 +3411,8 @@ CTurbSSTSolver::CTurbSSTSolver(CGeometry *geometry, CConfig *config, unsigned sh lowerlimit = new su2double[nVar]; upperlimit = new su2double[nVar]; - lowerlimit[0] = 0.0; - upperlimit[0] = 1.0e30; + lowerlimit[0] = 1.0e-10; + upperlimit[0] = 1.0e10; lowerlimit[1] = 1.0e-4; upperlimit[1] = 1.0e15; @@ -3600,9 +3600,9 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai dist = geometry->node[iPoint]->GetWall_Distance(); su2double *Vorticity = solver_container[FLOW_SOL]->GetNodes()->GetVorticity(iPoint); - su2double Omega = sqrt(Vorticity[0]*Vorticity[0] + - Vorticity[1]*Vorticity[1] + - Vorticity[2]*Vorticity[2]); + su2double VorticityMag = sqrt(Vorticity[0]*Vorticity[0] + + Vorticity[1]*Vorticity[1] + + Vorticity[2]*Vorticity[2]); nodes->SetBlendingFunc(iPoint,mu, dist, rho); @@ -3612,7 +3612,7 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai kine = nodes->GetSolution(iPoint,0); omega = nodes->GetSolution(iPoint,1); - zeta = min(1.0/omega, a1/(Omega*F2)); + zeta = min(1.0/omega, a1/(VorticityMag*F2)); muT = max(rho*kine*zeta,0.0); nodes->SetmuT(iPoint,muT); From e8968401c47953aa4b58f269ef0a0ded94526a9d Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Thu, 7 Nov 2019 15:26:22 -0800 Subject: [PATCH 41/57] Another old conflict fixed. --- TestCases/parallel_regression_AD.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index addd93c3fc57..2b92ccda0a58 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -284,11 +284,7 @@ def main(): discadj_cht.cfg_dir = "coupled_cht/disc_adj_incomp_2d" discadj_cht.cfg_file = "cht_2d_3cylinders.cfg" discadj_cht.test_iter = 10 -<<<<<<< HEAD - discadj_cht.test_vals = [-2.403180, -3.097866, -3.097837, -3.095571] #last 4 columns -======= discadj_cht.test_vals = [-2.403782, -3.097868, -3.097839, -3.097835] #last 4 columns ->>>>>>> various_fixes discadj_cht.su2_exec = "parallel_computation.py -f" discadj_cht.timeout = 1600 discadj_cht.tol = 0.00001 From f4ad569c3b9899d0d267a191365e1ba92e09107e Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 8 Nov 2019 10:02:54 -0800 Subject: [PATCH 42/57] Fixed initialization issue. More RANS regression updates. --- Common/src/config_structure.cpp | 1 + TestCases/parallel_regression.py | 10 +++++----- TestCases/rans/propeller/propeller.cfg | 2 +- TestCases/serial_regression.py | 10 +++++----- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Common/src/config_structure.cpp b/Common/src/config_structure.cpp index abab63526337..d4084cd6fe65 100644 --- a/Common/src/config_structure.cpp +++ b/Common/src/config_structure.cpp @@ -4581,6 +4581,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ /* Simpler boolean to control allocation of least-squares memory. */ + LeastSquaresRequired = false; if ((Kind_Gradient_Method_Recon == LEAST_SQUARES) || (Kind_Gradient_Method_Recon == WEIGHTED_LEAST_SQUARES) || (Kind_Gradient_Method == LEAST_SQUARES) || diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index d3eceaf10d70..fb61bae34743 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -264,7 +264,7 @@ def main(): turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-15.804072, -6.250381, 1.049989, 0.019166] #last 4 columns + turb_naca0012_sst.test_vals = [-15.274205, -6.250384, 1.049989, 0.019166] #last 4 columns turb_naca0012_sst.su2_exec = "parallel_computation.py -f" turb_naca0012_sst.timeout = 3200 turb_naca0012_sst.tol = 0.00001 @@ -275,7 +275,7 @@ def main(): turb_naca0012_sst_sust.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust.test_iter = 10 - turb_naca0012_sst_sust.test_vals = [-16.136012, -5.980662, 1.005228, 0.019014] #last 4 columns + turb_naca0012_sst_sust.test_vals = [-14.851291, -5.980663, 1.005228, 0.019014] #last 4 columns turb_naca0012_sst_sust.su2_exec = "parallel_computation.py -f" turb_naca0012_sst_sust.timeout = 3200 turb_naca0012_sst_sust.tol = 0.00001 @@ -286,7 +286,7 @@ def main(): propeller.cfg_dir = "rans/propeller" propeller.cfg_file = "propeller.cfg" propeller.test_iter = 10 - propeller.test_vals = [-3.378876, -8.396837, 0.000047, 0.055591] #last 4 columns + propeller.test_vals = [-3.389575, -8.409529, 0.000048, 0.056329] #last 4 columns propeller.su2_exec = "parallel_computation.py -f" propeller.timeout = 3200 propeller.tol = 0.00001 @@ -402,7 +402,7 @@ def main(): inc_turb_naca0012_sst_sust.cfg_dir = "incomp_rans/naca0012" inc_turb_naca0012_sst_sust.cfg_file = "naca0012_SST_SUST.cfg" inc_turb_naca0012_sst_sust.test_iter = 20 - inc_turb_naca0012_sst_sust.test_vals = [-7.277551, 0.147212, -0.000000, 0.311977] #last 4 columns + inc_turb_naca0012_sst_sust.test_vals = [-7.276357, 0.146097, -0.000000, 0.312019] #last 4 columns inc_turb_naca0012_sst_sust.su2_exec = "parallel_computation.py -f" inc_turb_naca0012_sst_sust.timeout = 1600 inc_turb_naca0012_sst_sust.tol = 0.00001 @@ -504,7 +504,7 @@ def main(): schubauer_klebanoff_transition.cfg_dir = "transition/Schubauer_Klebanoff" schubauer_klebanoff_transition.cfg_file = "transitional_BC_model_ConfigFile.cfg" schubauer_klebanoff_transition.test_iter = 10 - schubauer_klebanoff_transition.test_vals = [-7.994738, -14.278082, 0.000046, 0.007987] #last 4 columns + schubauer_klebanoff_transition.test_vals = [-7.994738, -14.268367, 0.000046, 0.007987] #last 4 columns schubauer_klebanoff_transition.su2_exec = "parallel_computation.py -f" schubauer_klebanoff_transition.timeout = 1600 schubauer_klebanoff_transition.tol = 0.00001 diff --git a/TestCases/rans/propeller/propeller.cfg b/TestCases/rans/propeller/propeller.cfg index 746bd07c96f4..d01ca9513424 100644 --- a/TestCases/rans/propeller/propeller.cfg +++ b/TestCases/rans/propeller/propeller.cfg @@ -203,7 +203,7 @@ TIME_DISCRE_TURB= EULER_IMPLICIT % --------------------------- CONVERGENCE PARAMETERS --------------------------% % % Number of total iterations -ITER= 15 +ITER= 9999 % % Convergence criteria (CAUCHY, RESIDUAL) % diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 9c2c0bf87e0c..8bb8f8457432 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -279,7 +279,7 @@ def main(): turb_naca0012_sst.cfg_dir = "rans/naca0012" turb_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" turb_naca0012_sst.test_iter = 10 - turb_naca0012_sst.test_vals = [-15.807519, -6.250396, 1.049989, 0.019166] #last 4 columns + turb_naca0012_sst.test_vals = [-15.274504, -6.250399, 1.049989, 0.019166] #last 4 columns turb_naca0012_sst.su2_exec = "SU2_CFD" turb_naca0012_sst.new_output = True turb_naca0012_sst.timeout = 3200 @@ -291,7 +291,7 @@ def main(): turb_naca0012_sst_sust.cfg_dir = "rans/naca0012" turb_naca0012_sst_sust.cfg_file = "turb_NACA0012_sst_sust.cfg" turb_naca0012_sst_sust.test_iter = 10 - turb_naca0012_sst_sust.test_vals = [-16.136911, -5.980663, 1.005228, 0.019014] #last 4 columns + turb_naca0012_sst_sust.test_vals = [-14.851294, -5.980664, 1.005228, 0.019014] #last 4 columns turb_naca0012_sst_sust.su2_exec = "SU2_CFD" turb_naca0012_sst_sust.timeout = 3200 turb_naca0012_sst_sust.tol = 0.00001 @@ -302,7 +302,7 @@ def main(): propeller.cfg_dir = "rans/propeller" propeller.cfg_file = "propeller.cfg" propeller.test_iter = 10 - propeller.test_vals = [-3.378876, -8.396837, 0.000047, 0.055591] #last 4 columns + propeller.test_vals = [-3.389575, -8.409529, 0.000048, 0.056329] #last 4 columns propeller.su2_exec = "SU2_CFD" propeller.new_output = True propeller.timeout = 3200 @@ -426,7 +426,7 @@ def main(): inc_turb_naca0012_sst_sust.cfg_dir = "incomp_rans/naca0012" inc_turb_naca0012_sst_sust.cfg_file = "naca0012_SST_SUST.cfg" inc_turb_naca0012_sst_sust.test_iter = 20 - inc_turb_naca0012_sst_sust.test_vals = [-7.277591, 0.146922, 0.000021, 0.311963] #last 4 columns + inc_turb_naca0012_sst_sust.test_vals = [-7.276170, 0.145809, 0.000021, 0.312006] #last 4 columns inc_turb_naca0012_sst_sust.su2_exec = "SU2_CFD" inc_turb_naca0012_sst_sust.timeout = 1600 inc_turb_naca0012_sst_sust.tol = 0.00001 @@ -537,7 +537,7 @@ def main(): schubauer_klebanoff_transition.cfg_file = "transitional_BC_model_ConfigFile.cfg" schubauer_klebanoff_transition.test_iter = 10 schubauer_klebanoff_transition.new_output = True - schubauer_klebanoff_transition.test_vals = [-8.029756, -14.278066, 0.000053, 0.007986] #last 4 columns + schubauer_klebanoff_transition.test_vals = [-8.029756, -14.268351, 0.000053, 0.007986] #last 4 columns schubauer_klebanoff_transition.su2_exec = "SU2_CFD" schubauer_klebanoff_transition.timeout = 1600 schubauer_klebanoff_transition.tol = 0.00001 From 982522ff180ef3c55945685f8138138a877ba383 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 8 Nov 2019 10:22:04 -0800 Subject: [PATCH 43/57] Continuous adjoint and UQ regressions checked and updated. --- TestCases/parallel_regression.py | 14 +++++++------- TestCases/serial_regression.py | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index fb61bae34743..806202e3dc59 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -541,7 +541,7 @@ def main(): contadj_wedge.cfg_dir = "cont_adj_euler/wedge" contadj_wedge.cfg_file = "inv_wedge_ROE.cfg" contadj_wedge.test_iter = 10 - contadj_wedge.test_vals = [2.856008, -2.767216, 1.0029e+06, 7.0328e-14] #last 4 columns + contadj_wedge.test_vals = [2.872691, -2.755572, 853010.000000, 0.000000] #last 4 columns contadj_wedge.su2_exec = "parallel_computation.py -f" contadj_wedge.timeout = 1600 contadj_wedge.tol = 0.00001 @@ -552,7 +552,7 @@ def main(): contadj_fixed_CL_naca0012.cfg_dir = "fixed_cl/naca0012" contadj_fixed_CL_naca0012.cfg_file = "inv_NACA0012_ContAdj.cfg" contadj_fixed_CL_naca0012.test_iter = 100 - contadj_fixed_CL_naca0012.test_vals = [0.319630, -5.191448, 0.361280, 0.000084] #last 4 columns + contadj_fixed_CL_naca0012.test_vals = [0.317289, -5.193066, 0.360470, 0.000069] #last 4 columns contadj_fixed_CL_naca0012.su2_exec = "parallel_computation.py -f" contadj_fixed_CL_naca0012.timeout = 1600 contadj_fixed_CL_naca0012.tol = 0.00001 @@ -641,7 +641,7 @@ def main(): turb_naca0012_1c.cfg_dir = "rans_uq/naca0012" turb_naca0012_1c.cfg_file = "turb_NACA0012_uq_1c.cfg" turb_naca0012_1c.test_iter = 10 - turb_naca0012_1c.test_vals = [-4.947380, 1.257714, 5.477923, 1.995089] #last 4 columns + turb_naca0012_1c.test_vals = [-4.906256, 1.337943, 6.052217, 2.395627] #last 4 columns turb_naca0012_1c.su2_exec = "parallel_computation.py -f" turb_naca0012_1c.timeout = 1600 turb_naca0012_1c.tol = 0.00001 @@ -652,7 +652,7 @@ def main(): turb_naca0012_2c.cfg_dir = "rans_uq/naca0012" turb_naca0012_2c.cfg_file = "turb_NACA0012_uq_2c.cfg" turb_naca0012_2c.test_iter = 10 - turb_naca0012_2c.test_vals = [-5.348057, 1.132068, 5.213200, 1.842256] #last 4 columns + turb_naca0012_2c.test_vals = [-5.230215, 1.262233, 6.052131, 2.395642] #last 4 columns turb_naca0012_2c.su2_exec = "parallel_computation.py -f" turb_naca0012_2c.timeout = 1600 turb_naca0012_2c.tol = 0.00001 @@ -663,7 +663,7 @@ def main(): turb_naca0012_3c.cfg_dir = "rans_uq/naca0012" turb_naca0012_3c.cfg_file = "turb_NACA0012_uq_3c.cfg" turb_naca0012_3c.test_iter = 10 - turb_naca0012_3c.test_vals = [-5.422180, 1.098616, 5.101282, 1.780416] #last 4 columns + turb_naca0012_3c.test_vals = [-5.277132, 1.246269, 6.052474, 2.395999] #last 4 columns turb_naca0012_3c.su2_exec = "parallel_computation.py -f" turb_naca0012_3c.timeout = 1600 turb_naca0012_3c.tol = 0.00001 @@ -674,7 +674,7 @@ def main(): turb_naca0012_p1c1.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c1.cfg_file = "turb_NACA0012_uq_p1c1.cfg" turb_naca0012_p1c1.test_iter = 10 - turb_naca0012_p1c1.test_vals = [-5.025765, 1.280442, 5.928243, 2.285755] #last 4 columns + turb_naca0012_p1c1.test_vals = [-5.007909, 1.310935, 6.054741, 2.397402] #last 4 columns turb_naca0012_p1c1.su2_exec = "parallel_computation.py -f" turb_naca0012_p1c1.timeout = 1600 turb_naca0012_p1c1.tol = 0.00001 @@ -685,7 +685,7 @@ def main(): turb_naca0012_p1c2.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c2.cfg_file = "turb_NACA0012_uq_p1c2.cfg" turb_naca0012_p1c2.test_iter = 10 - turb_naca0012_p1c2.test_vals = [-5.359000, 1.152959, 5.569891, 2.048355] #last 4 columns + turb_naca0012_p1c2.test_vals = [-5.264043, 1.251313, 6.055013, 2.397532] #last 4 columns turb_naca0012_p1c2.su2_exec = "parallel_computation.py -f" turb_naca0012_p1c2.timeout = 1600 turb_naca0012_p1c2.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 8bb8f8457432..a2ff672db6a6 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -576,7 +576,7 @@ def main(): contadj_wedge.cfg_dir = "cont_adj_euler/wedge" contadj_wedge.cfg_file = "inv_wedge_ROE.cfg" contadj_wedge.test_iter = 10 - contadj_wedge.test_vals = [2.856008, -2.767216, 1.0029e+06, 1.3024e-13] #last 4 columns + contadj_wedge.test_vals = [2.872691, -2.755572, 853000.000000, 0.000000] #last 4 columns contadj_wedge.su2_exec = "SU2_CFD" contadj_wedge.new_output = True contadj_wedge.timeout = 1600 @@ -588,7 +588,7 @@ def main(): contadj_fixedCL_naca0012.cfg_dir = "fixed_cl/naca0012" contadj_fixedCL_naca0012.cfg_file = "inv_NACA0012_ContAdj.cfg" contadj_fixedCL_naca0012.test_iter = 100 - contadj_fixedCL_naca0012.test_vals = [0.294602, -5.201081, 3.6098e-01, -1.3983e-05] #last 4 columns + contadj_fixedCL_naca0012.test_vals = [0.293257, -5.201691, 0.360610, -0.000021] #last 4 columns contadj_fixedCL_naca0012.su2_exec = "SU2_CFD" contadj_fixedCL_naca0012.new_output= True contadj_fixedCL_naca0012.timeout = 1600 @@ -684,7 +684,7 @@ def main(): turb_naca0012_1c.cfg_dir = "rans_uq/naca0012" turb_naca0012_1c.cfg_file = "turb_NACA0012_uq_1c.cfg" turb_naca0012_1c.test_iter = 10 - turb_naca0012_1c.test_vals = [-4.946093, 1.262346, 5.578729, 2.059523] #last 4 columns + turb_naca0012_1c.test_vals = [-4.906675, 1.337889, 6.085815, 2.413950] #last 4 columns turb_naca0012_1c.su2_exec = "SU2_CFD" turb_naca0012_1c.new_output = True turb_naca0012_1c.timeout = 1600 @@ -696,7 +696,7 @@ def main(): turb_naca0012_2c.cfg_dir = "rans_uq/naca0012" turb_naca0012_2c.cfg_file = "turb_NACA0012_uq_2c.cfg" turb_naca0012_2c.test_iter = 10 - turb_naca0012_2c.test_vals = [-5.343130, 1.137800, 5.337441, 1.919677] #last 4 columns + turb_naca0012_2c.test_vals = [-5.230275, 1.262205, 6.085899, 2.413590] #last 4 columns turb_naca0012_2c.su2_exec = "SU2_CFD" turb_naca0012_2c.new_output = True turb_naca0012_2c.timeout = 1600 @@ -708,7 +708,7 @@ def main(): turb_naca0012_3c.cfg_dir = "rans_uq/naca0012" turb_naca0012_3c.cfg_file = "turb_NACA0012_uq_3c.cfg" turb_naca0012_3c.test_iter = 10 - turb_naca0012_3c.test_vals = [-5.421229, 1.099570, 5.184366, 1.835606] #last 4 columns + turb_naca0012_3c.test_vals = [-5.277131, 1.246268, 6.086537, 2.413873] #last 4 columns turb_naca0012_3c.su2_exec = "SU2_CFD" turb_naca0012_3c.new_output = True turb_naca0012_3c.timeout = 1600 @@ -720,7 +720,7 @@ def main(): turb_naca0012_p1c1.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c1.cfg_file = "turb_NACA0012_uq_p1c1.cfg" turb_naca0012_p1c1.test_iter = 10 - turb_naca0012_p1c1.test_vals = [-5.021820, 1.281103, 5.960923, 2.302704] #last 4 columns + turb_naca0012_p1c1.test_vals = [-5.002978, 1.312367, 6.085205, 2.413463] #last 4 columns turb_naca0012_p1c1.su2_exec = "SU2_CFD" turb_naca0012_p1c1.new_output = True turb_naca0012_p1c1.timeout = 1600 @@ -732,7 +732,7 @@ def main(): turb_naca0012_p1c2.cfg_dir = "rans_uq/naca0012" turb_naca0012_p1c2.cfg_file = "turb_NACA0012_uq_p1c2.cfg" turb_naca0012_p1c2.test_iter = 10 - turb_naca0012_p1c2.test_vals = [-5.356937, 1.155037, 5.636379, 2.088827] #last 4 columns + turb_naca0012_p1c2.test_vals = [-5.263968, 1.251341, 6.085723, 2.413449] #last 4 columns turb_naca0012_p1c2.su2_exec = "SU2_CFD" turb_naca0012_p1c2.new_output = True turb_naca0012_p1c2.timeout = 1600 From 72734cc2bd0f60d44c6cf9022eee5c729b87a519 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 8 Nov 2019 11:56:06 -0800 Subject: [PATCH 44/57] More regression updates. --- .../spinning_cylinder/spinning_cylinder.cfg | 2 +- TestCases/parallel_regression.py | 12 ++++++------ TestCases/serial_regression.py | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/TestCases/moving_wall/spinning_cylinder/spinning_cylinder.cfg b/TestCases/moving_wall/spinning_cylinder/spinning_cylinder.cfg index 98f66ba40237..5b1ab1b6e590 100644 --- a/TestCases/moving_wall/spinning_cylinder/spinning_cylinder.cfg +++ b/TestCases/moving_wall/spinning_cylinder/spinning_cylinder.cfg @@ -173,7 +173,7 @@ CONV_NUM_METHOD_FLOW= ROE MUSCL_FLOW= YES % % Slope limiter (VENKATAKRISHNAN, MINMOD) -SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +SLOPE_LIMITER_FLOW= NONE % % 2nd and 4th order artificial dissipation coefficients JST_SENSOR_COEFF= ( 0.5, 0.02 ) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 806202e3dc59..b91dcdf5c956 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -302,7 +302,7 @@ def main(): turb_naca0012_sst_restart_mg.cfg_file = "turb_NACA0012_sst_multigrid_restart.cfg" turb_naca0012_sst_restart_mg.test_iter = 20 turb_naca0012_sst_restart_mg.ntest_vals = 5 - turb_naca0012_sst_restart_mg.test_vals = [-6.437400, -4.558626, 1.231779, -0.007820, 0.081480] #last 5 columns + turb_naca0012_sst_restart_mg.test_vals = [-7.826679, -8.082385, -3.174847, -0.000015, 0.081277] #last 5 columns turb_naca0012_sst_restart_mg.su2_exec = "parallel_computation.py -f" turb_naca0012_sst_restart_mg.timeout = 3200 turb_naca0012_sst_restart_mg.tol = 0.000001 @@ -700,7 +700,7 @@ def main(): harmonic_balance.cfg_dir = "harmonic_balance" harmonic_balance.cfg_file = "HB.cfg" harmonic_balance.test_iter = 25 - harmonic_balance.test_vals = [-1.592454, 3.916019, -0.001014, 0.096794] #last 4 columns + harmonic_balance.test_vals = [-1.589862, 3.922099, -0.001443, 0.099456] #last 4 columns harmonic_balance.su2_exec = "parallel_computation.py -f" harmonic_balance.timeout = 1600 harmonic_balance.tol = 0.00001 @@ -712,7 +712,7 @@ def main(): hb_rans_preconditioning.cfg_dir = "harmonic_balance/hb_rans_preconditioning" hb_rans_preconditioning.cfg_file = "davis.cfg" hb_rans_preconditioning.test_iter = 25 - hb_rans_preconditioning.test_vals = [-1.900984, -5.880441, 0.007759, 0.125931] #last 4 columns + hb_rans_preconditioning.test_vals = [-1.909596, -5.954720, 0.007773, 0.131219] #last 4 columns hb_rans_preconditioning.su2_exec = "parallel_computation.py -f" hb_rans_preconditioning.timeout = 1600 hb_rans_preconditioning.tol = 0.00001 @@ -754,7 +754,7 @@ def main(): square_cylinder.cfg_dir = "unsteady/square_cylinder" square_cylinder.cfg_file = "turb_square.cfg" square_cylinder.test_iter = 3 - square_cylinder.test_vals = [-1.164008, 0.077263, 1.398549, 2.197049] #last 4 columns + square_cylinder.test_vals = [-1.162621, 0.066395, 1.399789, 2.220408] #last 4 columns square_cylinder.su2_exec = "parallel_computation.py -f" square_cylinder.timeout = 1600 square_cylinder.tol = 0.00001 @@ -766,7 +766,7 @@ def main(): sine_gust.cfg_dir = "gust" sine_gust.cfg_file = "inv_gust_NACA0012.cfg" sine_gust.test_iter = 5 - sine_gust.test_vals = [-1.977545, 3.481778, -0.001297, -0.005845] #last 4 columns + sine_gust.test_vals = [-1.977545, 3.481778, -0.001525, -0.007375] #last 4 columns sine_gust.su2_exec = "parallel_computation.py -f" sine_gust.timeout = 1600 sine_gust.tol = 0.00001 @@ -778,7 +778,7 @@ def main(): aeroelastic.cfg_dir = "aeroelastic" aeroelastic.cfg_file = "aeroelastic_NACA64A010.cfg" aeroelastic.test_iter = 2 - aeroelastic.test_vals = [0.081587, 0.033262, -0.001666, -0.000155] #last 4 columns + aeroelastic.test_vals = [0.081326, 0.033214, -0.001666, -0.000155] #last 4 columns aeroelastic.su2_exec = "parallel_computation.py -f" aeroelastic.timeout = 1600 aeroelastic.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index a2ff672db6a6..81c410e00b65 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -319,7 +319,7 @@ def main(): turb_naca0012_sst_restart_mg.cfg_file = "turb_NACA0012_sst_multigrid_restart.cfg" turb_naca0012_sst_restart_mg.test_iter = 50 turb_naca0012_sst_restart_mg.ntest_vals = 5 - turb_naca0012_sst_restart_mg.test_vals = [-6.459444, -4.595710, 1.201844, -0.007146, 0.080517] #last 5 columns + turb_naca0012_sst_restart_mg.test_vals = [-7.708053, -8.082473, -3.175091, -0.000015, 0.081277] #last 5 columns turb_naca0012_sst_restart_mg.su2_exec = "SU2_CFD" turb_naca0012_sst_restart_mg.new_output = True turb_naca0012_sst_restart_mg.timeout = 3200 @@ -748,7 +748,7 @@ def main(): harmonic_balance.cfg_dir = "harmonic_balance" harmonic_balance.cfg_file = "HB.cfg" harmonic_balance.test_iter = 25 - harmonic_balance.test_vals = [-1.592454, 3.916019, -0.001014, 0.096794] #last 4 columns + harmonic_balance.test_vals = [-1.589862, 3.922099, -0.001443, 0.099456] #last 4 columns harmonic_balance.su2_exec = "SU2_CFD" harmonic_balance.new_output = False harmonic_balance.timeout = 1600 @@ -760,7 +760,7 @@ def main(): hb_rans_preconditioning.cfg_dir = "harmonic_balance/hb_rans_preconditioning" hb_rans_preconditioning.cfg_file = "davis.cfg" hb_rans_preconditioning.test_iter = 25 - hb_rans_preconditioning.test_vals = [-1.900982, -5.880438, 0.007758, 0.125934] #last 4 columns + hb_rans_preconditioning.test_vals = [-1.909598, -5.954721, 0.007773, 0.131219] #last 4 columns hb_rans_preconditioning.su2_exec = "SU2_CFD" hb_rans_preconditioning.new_output= False hb_rans_preconditioning.timeout = 1600 @@ -804,7 +804,7 @@ def main(): square_cylinder.cfg_dir = "unsteady/square_cylinder" square_cylinder.cfg_file = "turb_square.cfg" square_cylinder.test_iter = 3 - square_cylinder.test_vals = [-1.163944, 0.077283, 1.398548, 2.197047] #last 4 columns + square_cylinder.test_vals = [-1.162581, 0.066412, 1.399788, 2.220411] #last 4 columns square_cylinder.su2_exec = "SU2_CFD" square_cylinder.timeout = 1600 square_cylinder.tol = 0.00001 @@ -817,7 +817,7 @@ def main(): sine_gust.cfg_dir = "gust" sine_gust.cfg_file = "inv_gust_NACA0012.cfg" sine_gust.test_iter = 5 - sine_gust.test_vals = [-1.977545, 3.481778, 0.001295, -0.003793] #last 4 columns + sine_gust.test_vals = [-1.977545, 3.481778, -0.001572, -0.007286] #last 4 columns sine_gust.su2_exec = "SU2_CFD" sine_gust.timeout = 1600 sine_gust.tol = 0.00001 @@ -830,7 +830,7 @@ def main(): aeroelastic.cfg_dir = "aeroelastic" aeroelastic.cfg_file = "aeroelastic_NACA64A010.cfg" aeroelastic.test_iter = 2 - aeroelastic.test_vals = [0.080202, 0.033233, -0.001666, -0.000155] #last 4 columns + aeroelastic.test_vals = [0.079371, 0.033176, -0.001665, -0.000156] #last 4 columns aeroelastic.su2_exec = "SU2_CFD" aeroelastic.timeout = 1600 aeroelastic.tol = 0.00001 From 6523e74053e770f32f05ac8efe9c9a318c6f0a0d Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 8 Nov 2019 14:14:43 -0800 Subject: [PATCH 45/57] NICF and Turbomachinery regression updates. --- TestCases/parallel_regression.py | 16 ++++++++-------- TestCases/serial_regression.py | 18 +++++++++--------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index b91dcdf5c956..644af25ad9e3 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -739,7 +739,7 @@ def main(): spinning_cylinder.cfg_dir = "moving_wall/spinning_cylinder" spinning_cylinder.cfg_file = "spinning_cylinder.cfg" spinning_cylinder.test_iter = 25 - spinning_cylinder.test_vals = [-7.696962, -2.251552, 1.542932, 1.564127] #last 4 columns + spinning_cylinder.test_vals = [-7.857785, -2.425289, 1.554359, 1.531183] #last 4 columns spinning_cylinder.su2_exec = "parallel_computation.py -f" spinning_cylinder.timeout = 1600 spinning_cylinder.tol = 0.00001 @@ -818,7 +818,7 @@ def main(): edge_VW.cfg_dir = "nicf/edge" edge_VW.cfg_file = "edge_VW.cfg" edge_VW.test_iter = 100 - edge_VW.test_vals = [-5.192690, 0.944311, -0.000009, 0.000000] #last 4 columns + edge_VW.test_vals = [-5.203154, 0.933157, -0.000009, 0.000000] #last 4 columns edge_VW.su2_exec = "parallel_computation.py -f" edge_VW.timeout = 1600 edge_VW.tol = 0.00001 @@ -829,7 +829,7 @@ def main(): edge_PPR.cfg_dir = "nicf/edge" edge_PPR.cfg_file = "edge_PPR.cfg" edge_PPR.test_iter = 100 - edge_PPR.test_vals = [-5.387574, 0.753373, -0.000035, 0.000000] #last 4 columns + edge_PPR.test_vals = [-5.385223, 0.755862, -0.000035, 0.000000] #last 4 columns edge_PPR.su2_exec = "parallel_computation.py -f" edge_PPR.timeout = 1600 edge_PPR.tol = 0.00001 @@ -844,7 +844,7 @@ def main(): Jones_tc.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc.cfg_file = "Jones.cfg" Jones_tc.test_iter = 5 - Jones_tc.test_vals = [-5.301576, 0.418692, 78.467450, 0.990201] #last 4 columns + Jones_tc.test_vals = [-5.316335, 0.355081, 44.772280, 2.269966] #last 4 columns Jones_tc.su2_exec = "parallel_computation.py -f" Jones_tc.timeout = 1600 Jones_tc.new_output = False @@ -856,7 +856,7 @@ def main(): Jones_tc_rst.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_rst.cfg_file = "Jones_rst.cfg" Jones_tc_rst.test_iter = 5 - Jones_tc_rst.test_vals = [-4.344743, -1.553291, 82.250600, 2.791916] #last 4 columns + Jones_tc_rst.test_vals = [-3.034157, 0.013763, 82.263700, 2.792251] #last 4 columns Jones_tc_rst.su2_exec = "parallel_computation.py -f" Jones_tc_rst.timeout = 1600 Jones_tc_rst.new_output = False @@ -868,7 +868,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [-1.790261, 5.696650, 73.362820, 0.904306] #last 4 columns + axial_stage2D.test_vals = [-1.933241, 5.310060, 73.357650, 1.841414] #last 4 columns axial_stage2D.su2_exec = "parallel_computation.py -f" axial_stage2D.timeout = 1600 axial_stage2D.new_output = False @@ -880,7 +880,7 @@ def main(): transonic_stator.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator.cfg_file = "transonic_stator.cfg" transonic_stator.test_iter = 20 - transonic_stator.test_vals = [-1.198895, 6.148362, 96.766820, 0.063115] #last 4 columns + transonic_stator.test_vals = [-0.574121, 5.820564, 96.994080, 0.062865] #last 4 columns transonic_stator.su2_exec = "parallel_computation.py -f" transonic_stator.timeout = 1600 transonic_stator.new_output = False @@ -892,7 +892,7 @@ def main(): transonic_stator_rst.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_rst.cfg_file = "transonic_stator_rst.cfg" transonic_stator_rst.test_iter = 20 - transonic_stator_rst.test_vals = [-8.248805, -2.976199, 5.285722, 0.003100] #last 4 columns + transonic_stator_rst.test_vals = [-2.125313, 3.014645, 5.300089, 0.003103] #last 4 columns transonic_stator_rst.su2_exec = "parallel_computation.py -f" transonic_stator_rst.timeout = 1600 transonic_stator_rst.new_output = False diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 81c410e00b65..aa01f745a5ea 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -788,7 +788,7 @@ def main(): spinning_cylinder.cfg_dir = "moving_wall/spinning_cylinder" spinning_cylinder.cfg_file = "spinning_cylinder.cfg" spinning_cylinder.test_iter = 25 - spinning_cylinder.test_vals = [-7.719673, -2.279643, 1.721389, 1.710467] #last 4 columns + spinning_cylinder.test_vals = [-7.889994, -2.469385, 1.708162, 1.670039] #last 4 columns spinning_cylinder.su2_exec = "SU2_CFD" spinning_cylinder.new_output = True spinning_cylinder.timeout = 1600 @@ -872,7 +872,7 @@ def main(): ls89_sa.cfg_dir = "nicf/LS89" ls89_sa.cfg_file = "turb_SA_PR.cfg" ls89_sa.test_iter = 20 - ls89_sa.test_vals = [-5.046850, -13.386345, 0.174911, 0.430700] #last 4 columns + ls89_sa.test_vals = [-5.060859, -13.398192, 0.174451, 0.429491] #last 4 columns ls89_sa.su2_exec = "SU2_CFD" ls89_sa.new_output= True ls89_sa.timeout = 1600 @@ -884,7 +884,7 @@ def main(): edge_VW.cfg_dir = "nicf/edge" edge_VW.cfg_file = "edge_VW.cfg" edge_VW.test_iter = 20 - edge_VW.test_vals = [-0.711006, 5.491025, -0.000971, 0.000000] #last 4 columns + edge_VW.test_vals = [-0.711552, 5.490479, -0.000975, 0.000000] #last 4 columns edge_VW.su2_exec = "SU2_CFD" edge_VW.new_output = True edge_VW.timeout = 1600 @@ -896,7 +896,7 @@ def main(): edge_PPR.cfg_dir = "nicf/edge" edge_PPR.cfg_file = "edge_PPR.cfg" edge_PPR.test_iter = 20 - edge_PPR.test_vals = [-1.671554, 4.521719, 0.001027, 0.000000] #last 4 columns + edge_PPR.test_vals = [-1.670439, 4.522842, 0.001027, 0.000000] #last 4 columns edge_PPR.su2_exec = "SU2_CFD" edge_PPR.new_output = True edge_PPR.timeout = 1600 @@ -913,7 +913,7 @@ def main(): Jones_tc.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc.cfg_file = "Jones.cfg" Jones_tc.test_iter = 5 - Jones_tc.test_vals = [-5.301588, 0.418684, 78.467650, 0.990182] #last 4 columns + Jones_tc.test_vals = [-5.316334, 0.355080, 44.772250, 2.269935] #last 4 columns Jones_tc.su2_exec = "SU2_CFD" Jones_tc.new_output = False Jones_tc.timeout = 1600 @@ -925,7 +925,7 @@ def main(): Jones_tc_rst.cfg_dir = "turbomachinery/APU_turbocharger" Jones_tc_rst.cfg_file = "Jones_rst.cfg" Jones_tc_rst.test_iter = 5 - Jones_tc_rst.test_vals = [-4.344742, -1.553279, 82.250600, 2.791916] #last 4 columns + Jones_tc_rst.test_vals = [-3.034158, 0.013762, 82.263710, 2.792251] #last 4 columns Jones_tc_rst.su2_exec = "SU2_CFD" Jones_tc_rst.new_output = False Jones_tc_rst.timeout = 1600 @@ -937,7 +937,7 @@ def main(): axial_stage2D.cfg_dir = "turbomachinery/axial_stage_2D" axial_stage2D.cfg_file = "Axial_stage2D.cfg" axial_stage2D.test_iter = 20 - axial_stage2D.test_vals = [-1.790262, 5.696645, 73.362820, 0.904310] #last 4 columns + axial_stage2D.test_vals = [-1.933250, 5.305273, 73.357650, 1.841297] #last 4 columns axial_stage2D.su2_exec = "SU2_CFD" axial_stage2D.new_output = False axial_stage2D.timeout = 1600 @@ -949,7 +949,7 @@ def main(): transonic_stator.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator.cfg_file = "transonic_stator.cfg" transonic_stator.test_iter = 20 - transonic_stator.test_vals = [-1.201657, 6.150672, 96.239670, 0.062740] #last 4 columns + transonic_stator.test_vals = [-0.560481, 5.828675, 96.593740, 0.062507] #last 4 columns transonic_stator.su2_exec = "SU2_CFD" transonic_stator.new_output = False transonic_stator.timeout = 1600 @@ -961,7 +961,7 @@ def main(): transonic_stator_rst.cfg_dir = "turbomachinery/transonic_stator_2D" transonic_stator_rst.cfg_file = "transonic_stator_rst.cfg" transonic_stator_rst.test_iter = 20 - transonic_stator_rst.test_vals = [-8.248816, -2.976167, 5.285722, 0.003100] #last 4 columns + transonic_stator_rst.test_vals = [-2.127925, 2.936696, 5.298641, 0.003102] #last 4 columns transonic_stator_rst.su2_exec = "SU2_CFD" transonic_stator_rst.new_output = False transonic_stator_rst.timeout = 1600 From 94f559cd75f12d4fa507d6a8105c985e6a77ef96 Mon Sep 17 00:00:00 2001 From: Tim Albring Date: Mon, 11 Nov 2019 11:58:33 +0100 Subject: [PATCH 46/57] Fixing history/volume output for turbomachinery cases --- SU2_CFD/src/drivers/CDriver.cpp | 110 +++++++++++++++++- .../src/output/output_structure_legacy.cpp | 17 +-- 2 files changed, 111 insertions(+), 16 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 7c081ba1c108..9d689ac42395 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -4177,8 +4177,114 @@ bool CFluidDriver::Monitor(unsigned long ExtIter) { } -void CFluidDriver::Output(unsigned long InnerIter) { - +void CFluidDriver::Output(unsigned long Iter) { + + bool output_files = false; + + /*--- Determine whether a solution needs to be written + after the current iteration ---*/ + + if ( + + /*--- General if statements to print output statements ---*/ + + (Iter+1 >= Max_Iter) || (StopCalc) || + + /*--- Fixed CL problem ---*/ + + ((config_container[ZONE_0]->GetFixed_CL_Mode()) && + (config_container[ZONE_0]->GetnIter()-config_container[ZONE_0]->GetIter_dCL_dAlpha() - 1 == Iter)) || + + /*--- Steady problems ---*/ + + ((Iter % config_container[ZONE_0]->GetWrt_Sol_Freq() == 0) && (Iter != 0) && + ((config_container[ZONE_0]->GetTime_Marching() == STEADY) || + (config_container[ZONE_0]->GetTime_Marching() == HARMONIC_BALANCE) || + (config_container[ZONE_0]->GetTime_Marching() == ROTATIONAL_FRAME))) || + + /*--- Unsteady problems ---*/ + + (((config_container[ZONE_0]->GetTime_Marching() == DT_STEPPING_1ST) || + (config_container[ZONE_0]->GetTime_Marching() == TIME_STEPPING)) && + ((Iter == 0) || (Iter % config_container[ZONE_0]->GetWrt_Sol_Freq_DualTime() == 0))) || + + ((config_container[ZONE_0]->GetTime_Marching() == DT_STEPPING_2ND) && (!fsi) && + ((Iter == 0) || ((Iter % config_container[ZONE_0]->GetWrt_Sol_Freq_DualTime() == 0) || + ((Iter-1) % config_container[ZONE_0]->GetWrt_Sol_Freq_DualTime() == 0)))) || + + ((config_container[ZONE_0]->GetTime_Marching() == DT_STEPPING_2ND) && (fsi) && + ((Iter == 0) || ((Iter % config_container[ZONE_0]->GetWrt_Sol_Freq_DualTime() == 0)))) || + + ((config_container[ZONE_0]->GetDynamic_Analysis() == DYNAMIC) && + ((Iter == 0) || (Iter % config_container[ZONE_0]->GetWrt_Sol_Freq_DualTime() == 0))) + ) { + + output_files = true; + + } + + /*--- Determine whether a solution doesn't need to be written + after the current iteration ---*/ + + if (config_container[ZONE_0]->GetFixed_CL_Mode()) { + if (config_container[ZONE_0]->GetnIter()-config_container[ZONE_0]->GetIter_dCL_dAlpha() - 1 < Iter) output_files = false; + if (config_container[ZONE_0]->GetnIter() - 1 == Iter) output_files = true; + } + + /*--- write the solution ---*/ + + if (output_files) { + + /*--- Time the output for performance benchmarking. ---*/ +#ifndef HAVE_MPI + StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); +#else + StopTime = MPI_Wtime(); +#endif + UsedTimeCompute += StopTime-StartTime; +#ifndef HAVE_MPI + StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); +#else + StartTime = MPI_Wtime(); +#endif + + /*--- Add a statement about the type of solver exit. ---*/ + + if (((Iter+1 >= Max_Iter) || StopCalc) && (rank == MASTER_NODE)) { + cout << endl << "----------------------------- Solver Exit -------------------------------"; + if (StopCalc) cout << endl << "Convergence criteria satisfied." << endl; + else cout << endl << "Maximum number of external iterations reached (ITER)." << endl; + cout << "-------------------------------------------------------------------------" << endl; + } + + if (rank == MASTER_NODE) cout << endl << "-------------------------- File Output Summary --------------------------" << endl; + + /*--- Execute the routine for writing restart, volume solution, + surface solution, and surface comma-separated value files. ---*/ + + for (iZone = 0; iZone < nZone; iZone++){ + output_container[iZone]->SetResult_Files(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone], + solver_container[iZone][INST_0][MESH_0], Iter, output_files); + } + if (rank == MASTER_NODE) cout << endl << "-------------------------------------------------------------------------" << endl << endl; + + /*--- Store output time and restart the timer for the compute phase. ---*/ +#ifndef HAVE_MPI + StopTime = su2double(clock())/su2double(CLOCKS_PER_SEC); +#else + StopTime = MPI_Wtime(); +#endif + UsedTimeOutput += StopTime-StartTime; + OutputCount++; + BandwidthSum = config_container[ZONE_0]->GetRestart_Bandwidth_Agg(); +#ifndef HAVE_MPI + StartTime = su2double(clock())/su2double(CLOCKS_PER_SEC); +#else + StartTime = MPI_Wtime(); +#endif + + } } diff --git a/SU2_CFD/src/output/output_structure_legacy.cpp b/SU2_CFD/src/output/output_structure_legacy.cpp index 5e79b907b9fa..998f8b430244 100644 --- a/SU2_CFD/src/output/output_structure_legacy.cpp +++ b/SU2_CFD/src/output/output_structure_legacy.cpp @@ -4382,23 +4382,13 @@ void COutputLegacy::SetConvHistory_Header(ofstream *ConvHist_file, CConfig *conf if(config->GetnTimeInstances() > 1){ filename = config->GetMultiInstance_HistoryFileName(filename, val_iInst); } - strcpy (cstr, filename.data()); if (config->GetTime_Domain() && config->GetRestart()) { - long iExtIter = config->GetRestart_Iter(); - if (SU2_TYPE::Int(iExtIter) < 10) SPRINTF (buffer, "_0000%d", SU2_TYPE::Int(iExtIter)); - if ((SU2_TYPE::Int(iExtIter) >= 10) && (SU2_TYPE::Int(iExtIter) < 100)) SPRINTF (buffer, "_000%d", SU2_TYPE::Int(iExtIter)); - if ((SU2_TYPE::Int(iExtIter) >= 100) && (SU2_TYPE::Int(iExtIter) < 1000)) SPRINTF (buffer, "_00%d", SU2_TYPE::Int(iExtIter)); - if ((SU2_TYPE::Int(iExtIter) >= 1000) && (SU2_TYPE::Int(iExtIter) < 10000)) SPRINTF (buffer, "_0%d", SU2_TYPE::Int(iExtIter)); - if (SU2_TYPE::Int(iExtIter) >= 10000) SPRINTF (buffer, "_%d", SU2_TYPE::Int(iExtIter)); - strcat(cstr, buffer); + filename = config->GetUnsteady_FileName(filename, config->GetRestart_Iter(), hist_ext); } - if ((config->GetTabular_FileFormat() == TECPLOT)) SPRINTF (buffer, ".dat"); - else if ((config->GetTabular_FileFormat() == TAB_TECPLOT)) SPRINTF (buffer, ".plt"); - else if ((config->GetTabular_FileFormat() == TAB_CSV)) SPRINTF (buffer, ".csv"); - strcat(cstr, buffer); - + strcpy (cstr, filename.data()); + ConvHist_file->open(cstr, ios::out); ConvHist_file->precision(15); @@ -4627,7 +4617,6 @@ void COutputLegacy::SetConvHistory_Body(ofstream *ConvHist_file, } if (fea || fluid_structure) output_files = false; - if (config[val_iZone]->GetMultizone_Problem()) output_files = false; /*--- We need to evaluate some of the objective functions to write the value on the history file ---*/ From 3dd7b60477180662b70cacddc238ab6f76f7b9e6 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 11 Nov 2019 18:28:43 -0800 Subject: [PATCH 47/57] Sliding interface regressions updated. --- TestCases/parallel_regression.py | 14 +++++++------- TestCases/serial_regression.py | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 644af25ad9e3..50de90996e43 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -921,7 +921,7 @@ def main(): channel_2D.cfg_dir = "sliding_interface/channel_2D" channel_2D.cfg_file = "channel_2D_WA.cfg" channel_2D.test_iter = 2 - channel_2D.test_vals = [2.000000, 0.000000, 0.399698, 0.351908, 0.405704] #last 4 columns + channel_2D.test_vals = [2.000000, 0.000000, 0.398126, 0.353070, 0.405696] #last 4 columns channel_2D.su2_exec = "parallel_computation.py -f" channel_2D.timeout = 100 channel_2D.tol = 0.00001 @@ -934,7 +934,7 @@ def main(): channel_3D.cfg_dir = "sliding_interface/channel_3D" channel_3D.cfg_file = "channel_3D_WA.cfg" channel_3D.test_iter = 2 - channel_3D.test_vals = [2.000000, 0.000000, 0.624073, 0.502950, 0.417050] #last 4 columns + channel_3D.test_vals = [2.000000, 0.000000, 0.620109, 0.505162, 0.415445] #last 4 columns channel_3D.su2_exec = "parallel_computation.py -f" channel_3D.timeout = 1600 channel_3D.tol = 0.00001 @@ -947,7 +947,7 @@ def main(): pipe.cfg_dir = "sliding_interface/pipe" pipe.cfg_file = "pipe_NN.cfg" pipe.test_iter = 2 - pipe.test_vals = [0.117226, 0.491935, 0.676389, 0.974442, 1.024041] #last 4 columns + pipe.test_vals = [0.150025, 0.491954, 0.677756, 0.963980, 1.006936] #last 4 columns pipe.su2_exec = "parallel_computation.py -f" pipe.timeout = 1600 pipe.tol = 0.00001 @@ -960,7 +960,7 @@ def main(): rotating_cylinders.cfg_dir = "sliding_interface/rotating_cylinders" rotating_cylinders.cfg_file = "rot_cylinders_WA.cfg" rotating_cylinders.test_iter = 3 - rotating_cylinders.test_vals = [3.000000, 0.000000, 0.754346, 1.111512, 1.194307] #last 4 columns + rotating_cylinders.test_vals = [3.000000, 0.000000, 0.777044, 1.134689, 1.224326] #last 4 columns rotating_cylinders.su2_exec = "parallel_computation.py -f" rotating_cylinders.timeout = 1600 rotating_cylinders.tol = 0.00001 @@ -973,7 +973,7 @@ def main(): supersonic_vortex_shedding.cfg_dir = "sliding_interface/supersonic_vortex_shedding" supersonic_vortex_shedding.cfg_file = "sup_vor_shed_WA.cfg" supersonic_vortex_shedding.test_iter = 5 - supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.220915, 1.568306] #last 4 columns + supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.244192, 1.644524] #last 4 columns supersonic_vortex_shedding.su2_exec = "parallel_computation.py -f" supersonic_vortex_shedding.timeout = 1600 supersonic_vortex_shedding.tol = 0.00001 @@ -986,7 +986,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.719501, -1.608959] #last 4 columns + bars_SST_2D.test_vals = [13.000000, -0.590195, -1.955385] #last 4 columns bars_SST_2D.su2_exec = "SU2_CFD" bars_SST_2D.timeout = 1600 bars_SST_2D.tol = 0.00001 @@ -1062,7 +1062,7 @@ def main(): stat_fsi.cfg_dir = "fea_fsi/stat_fsi" stat_fsi.cfg_file = "config.cfg" stat_fsi.test_iter = 7 - stat_fsi.test_vals = [-3.312222, -4.959311, 0.000000, 46.000000] #last 5 columns + stat_fsi.test_vals = [-3.313322, -4.963786, 0.000000, 46.000000] #last 5 columns stat_fsi.su2_exec = "mpirun -n 2 SU2_CFD" stat_fsi.multizone = True stat_fsi.timeout = 1600 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index aa01f745a5ea..b36727937ef9 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -991,7 +991,7 @@ def main(): channel_2D.cfg_dir = "sliding_interface/channel_2D" channel_2D.cfg_file = "channel_2D_WA.cfg" channel_2D.test_iter = 2 - channel_2D.test_vals = [2.000000, 0.000000, 0.399677, 0.351915, 0.405680] #last 4 columns + channel_2D.test_vals = [2.000000, 0.000000, 0.397956, 0.353078, 0.405707] #last 4 columns channel_2D.su2_exec = "SU2_CFD" channel_2D.timeout = 100 channel_2D.tol = 0.00001 @@ -1004,7 +1004,7 @@ def main(): channel_3D.cfg_dir = "sliding_interface/channel_3D" channel_3D.cfg_file = "channel_3D_WA.cfg" channel_3D.test_iter = 1 - channel_3D.test_vals = [1.000000, 0.000000, 0.671143, 0.781742, 0.712844] #last 5 columns + channel_3D.test_vals = [1.000000, 0.000000, 0.661392, 0.769773, 0.696154] #last 5 columns channel_3D.su2_exec = "SU2_CFD" channel_3D.timeout = 1600 channel_3D.tol = 0.00001 @@ -1017,7 +1017,7 @@ def main(): pipe.cfg_dir = "sliding_interface/pipe" pipe.cfg_file = "pipe_NN.cfg" pipe.test_iter = 2 - pipe.test_vals = [0.491948, 0.676394, 0.974444, 1.024041] #last 4 columns + pipe.test_vals = [0.491954, 0.677756, 0.963981, 1.006936] #last 4 columns pipe.su2_exec = "SU2_CFD" pipe.timeout = 1600 pipe.tol = 0.00001 @@ -1030,7 +1030,7 @@ def main(): rotating_cylinders.cfg_dir = "sliding_interface/rotating_cylinders" rotating_cylinders.cfg_file = "rot_cylinders_WA.cfg" rotating_cylinders.test_iter = 3 - rotating_cylinders.test_vals = [3.000000, 0.000000, 0.754350, 1.111514, 1.194297] #last 4 columns + rotating_cylinders.test_vals = [3.000000, 0.000000, 0.777044, 1.134679, 1.224316] #last 4 columns rotating_cylinders.su2_exec = "SU2_CFD" rotating_cylinders.timeout = 1600 rotating_cylinders.tol = 0.00001 @@ -1043,7 +1043,7 @@ def main(): supersonic_vortex_shedding.cfg_dir = "sliding_interface/supersonic_vortex_shedding" supersonic_vortex_shedding.cfg_file = "sup_vor_shed_WA.cfg" supersonic_vortex_shedding.test_iter = 5 - supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.220867, 1.568306] #last 4 columns + supersonic_vortex_shedding.test_vals = [5.000000, 0.000000, 1.240131, 1.645383] #last 4 columns supersonic_vortex_shedding.su2_exec = "SU2_CFD" supersonic_vortex_shedding.timeout = 1600 supersonic_vortex_shedding.tol = 0.00001 @@ -1056,7 +1056,7 @@ def main(): bars_SST_2D.cfg_dir = "sliding_interface/bars_SST_2D" bars_SST_2D.cfg_file = "bars.cfg" bars_SST_2D.test_iter = 13 - bars_SST_2D.test_vals = [13.000000, -0.719501, -1.608959] #last 3 columns + bars_SST_2D.test_vals = [13.000000, -0.590195, -1.955385] #last 3 columns bars_SST_2D.su2_exec = "SU2_CFD" bars_SST_2D.timeout = 1600 bars_SST_2D.tol = 0.00001 @@ -1145,7 +1145,7 @@ def main(): stat_fsi.cfg_dir = "fea_fsi/stat_fsi" stat_fsi.cfg_file = "config.cfg" stat_fsi.test_iter = 7 - stat_fsi.test_vals = [-3.322483, -4.978664, 0.000000, 47.000000] #last 5 columns + stat_fsi.test_vals = [-3.323551, -4.982863, 0.000000, 47.000000] #last 5 columns stat_fsi.su2_exec = "SU2_CFD" stat_fsi.timeout = 1600 stat_fsi.multizone = True From 9529e19dae70ecd51fea0280ddfce358a488118c Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 18 Nov 2019 12:44:42 -0800 Subject: [PATCH 48/57] Updating discrete adjoint regressions. Also added new restarts for some to the test cases repo. --- .../disc_adj_rans/naca0012/turb_NACA0012_sa.cfg | 11 ++--------- .../disc_adj_rans/naca0012/turb_NACA0012_sst.cfg | 9 +-------- TestCases/parallel_regression_AD.py | 12 ++++++------ TestCases/serial_regression_AD.py | 10 +++++----- 4 files changed, 14 insertions(+), 28 deletions(-) diff --git a/TestCases/disc_adj_rans/naca0012/turb_NACA0012_sa.cfg b/TestCases/disc_adj_rans/naca0012/turb_NACA0012_sa.cfg index d05aeb17308c..29580ac333b4 100644 --- a/TestCases/disc_adj_rans/naca0012/turb_NACA0012_sa.cfg +++ b/TestCases/disc_adj_rans/naca0012/turb_NACA0012_sa.cfg @@ -19,20 +19,13 @@ SOLVER= RANS % % Specify turbulent model (NONE, SA, SA_NEG, SST) -KIND_TURB_MODEL= SA +KIND_TURB_MODEL= SA_NEG % % Mathematical problem (DIRECT, CONTINUOUS_ADJOINT) MATH_PROBLEM= DISCRETE_ADJOINT % % Restart solution (NO, YES) RESTART_SOL= NO -% -% Write binary restart files (YES, NO) -WRT_BINARY_RESTART= NO -% -% Read binary restart files (YES, NO) -READ_BINARY_RESTART= NO -% % -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% % @@ -253,5 +246,5 @@ WRT_SOL_FREQ= 1000 WRT_CON_FREQ= 1 % % Screen output -SCREEN_OUTPUT = (INNER_ITER, RMS_ADJ_DENSITY, RMS_ADJ_NU_TILDE, SENS_PRESS, SENS_AOA) +SCREEN_OUTPUT = (INNER_ITER, RMS_ADJ_DENSITY, RMS_ADJ_NU_TILDE, SENS_PRESS, SENS_AOA RMS_DENSITY RMS_NU_TILDE LIFT DRAG) diff --git a/TestCases/disc_adj_rans/naca0012/turb_NACA0012_sst.cfg b/TestCases/disc_adj_rans/naca0012/turb_NACA0012_sst.cfg index 0ec948c08c28..0abf1b412fb4 100644 --- a/TestCases/disc_adj_rans/naca0012/turb_NACA0012_sst.cfg +++ b/TestCases/disc_adj_rans/naca0012/turb_NACA0012_sst.cfg @@ -26,13 +26,6 @@ MATH_PROBLEM= DISCRETE_ADJOINT % % Restart solution (NO, YES) RESTART_SOL= NO -% -% Write binary restart files (YES, NO) -WRT_BINARY_RESTART= NO -% -% Read binary restart files (YES, NO) -READ_BINARY_RESTART= NO -% % -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% % @@ -252,5 +245,5 @@ WRT_SOL_FREQ= 1000 WRT_CON_FREQ= 1 % % Screen output -SCREEN_OUTPUT = (INNER_ITER, RMS_ADJ_DENSITY, RMS_ADJ_TKE, SENS_PRESS, SENS_AOA) +SCREEN_OUTPUT = (INNER_ITER, RMS_ADJ_DENSITY, RMS_ADJ_TKE, SENS_PRESS, SENS_AOA RMS_DENSITY RMS_TKE LIFT DRAG) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 2b92ccda0a58..6dc6c51a8e09 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -57,7 +57,7 @@ def main(): discadj_naca0012.cfg_dir = "cont_adj_euler/naca0012" discadj_naca0012.cfg_file = "inv_NACA0012_discadj.cfg" discadj_naca0012.test_iter = 100 - discadj_naca0012.test_vals = [-3.610567, -9.034912, -0.000000, 0.005621] #last 4 columns + discadj_naca0012.test_vals = [-3.559002, -8.926022, -0.000000, 0.005588] #last 4 columns discadj_naca0012.su2_exec = "parallel_computation.py -f" discadj_naca0012.timeout = 1600 discadj_naca0012.tol = 0.00001 @@ -68,7 +68,7 @@ def main(): discadj_cylinder3D.cfg_dir = "disc_adj_euler/cylinder3D" discadj_cylinder3D.cfg_file = "inv_cylinder3D.cfg" discadj_cylinder3D.test_iter = 5 - discadj_cylinder3D.test_vals = [-3.757340, -3.857847, 0.000000, 0.000000] #last 4 columns + discadj_cylinder3D.test_vals = [-3.724803, -3.838647, 0.000000, 0.000000] #last 4 columns discadj_cylinder3D.su2_exec = "parallel_computation.py -f" discadj_cylinder3D.timeout = 1600 discadj_cylinder3D.tol = 0.00001 @@ -79,7 +79,7 @@ def main(): discadj_arina2k.cfg_dir = "disc_adj_euler/arina2k" discadj_arina2k.cfg_file = "Arina2KRS.cfg" discadj_arina2k.test_iter = 20 - discadj_arina2k.test_vals = [2.275220, 1.750269, 47258.000000, 0.000000] #last 4 columns + discadj_arina2k.test_vals = [2.438813, 1.976484, 47258.000000, 0.000000] #last 4 columns discadj_arina2k.su2_exec = "parallel_computation.py -f" discadj_arina2k.timeout = 8400 discadj_arina2k.tol = 0.00001 @@ -208,7 +208,7 @@ def main(): discadj_pitchingNACA0012.cfg_dir = "disc_adj_euler/naca0012_pitching" discadj_pitchingNACA0012.cfg_file = "inv_NACA0012_pitching.cfg" discadj_pitchingNACA0012.test_iter = 4 - discadj_pitchingNACA0012.test_vals = [-1.167347, -1.635137, -0.020862, 0.000050] #last 4 columns + discadj_pitchingNACA0012.test_vals = [-1.091129, -1.545863, -0.037418, 0.000108] #last 4 columns discadj_pitchingNACA0012.su2_exec = "parallel_computation.py -f" discadj_pitchingNACA0012.timeout = 1600 discadj_pitchingNACA0012.tol = 0.00001 @@ -224,7 +224,7 @@ def main(): discadj_trans_stator.cfg_dir = "disc_adj_turbomachinery/transonic_stator_2D" discadj_trans_stator.cfg_file = "transonic_stator.cfg" discadj_trans_stator.test_iter = 79 - discadj_trans_stator.test_vals = [79.000000,-1.923936, -2.119783] #last 4 columns + discadj_trans_stator.test_vals = [79.000000, -1.927296, -1.401205] #last 4 columns discadj_trans_stator.su2_exec = "parallel_computation.py -f" discadj_trans_stator.timeout = 1600 discadj_trans_stator.tol = 0.00001 @@ -254,7 +254,7 @@ def main(): discadj_heat.cfg_dir = "disc_adj_heat" discadj_heat.cfg_file = "disc_adj_heat.cfg" discadj_heat.test_iter = 10 - discadj_heat.test_vals = [-2.281765, 0.706785, -0.743990, -6.866000] #last 4 columns + discadj_heat.test_vals = [-2.281765, 0.706808, -0.743990, -6.866000] #last 4 columns discadj_heat.su2_exec = "parallel_computation.py -f" discadj_heat.timeout = 1600 discadj_heat.tol = 0.00001 diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index 24da447dbea4..ba5b4506c7b8 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -57,7 +57,7 @@ def main(): discadj_naca0012.cfg_dir = "cont_adj_euler/naca0012" discadj_naca0012.cfg_file = "inv_NACA0012_discadj.cfg" discadj_naca0012.test_iter = 100 - discadj_naca0012.test_vals = [-3.610567, -9.034912, -0.000000, 0.005621] #last 4 columns + discadj_naca0012.test_vals = [-3.559002, -8.926022, -0.000000, 0.005588] #last 4 columns discadj_naca0012.su2_exec = "SU2_CFD_AD" discadj_naca0012.timeout = 1600 discadj_naca0012.tol = 0.00001 @@ -68,7 +68,7 @@ def main(): discadj_cylinder3D.cfg_dir = "disc_adj_euler/cylinder3D" discadj_cylinder3D.cfg_file = "inv_cylinder3D.cfg" discadj_cylinder3D.test_iter = 5 - discadj_cylinder3D.test_vals = [-3.758796, -3.863529, -0.000000, 0.000000] #last 4 columns + discadj_cylinder3D.test_vals = [-3.728728, -3.844274, -0.000000, 0.000000] #last 4 columns discadj_cylinder3D.su2_exec = "SU2_CFD_AD" discadj_cylinder3D.timeout = 1600 discadj_cylinder3D.tol = 0.00001 @@ -79,7 +79,7 @@ def main(): discadj_arina2k.cfg_dir = "disc_adj_euler/arina2k" discadj_arina2k.cfg_file = "Arina2KRS.cfg" discadj_arina2k.test_iter = 20 - discadj_arina2k.test_vals = [2.244006, 1.701303, 47250.000000, 0.000000]#last 4 columns + discadj_arina2k.test_vals = [2.416934, 1.944441, 47250.000000, 0.000000]#last 4 columns discadj_arina2k.su2_exec = "SU2_CFD_AD" discadj_arina2k.timeout = 8400 discadj_arina2k.tol = 0.00001 @@ -208,7 +208,7 @@ def main(): discadj_pitchingNACA0012.cfg_dir = "disc_adj_euler/naca0012_pitching" discadj_pitchingNACA0012.cfg_file = "inv_NACA0012_pitching.cfg" discadj_pitchingNACA0012.test_iter = 4 - discadj_pitchingNACA0012.test_vals = [-1.170348, -1.639086, -0.020749, 0.000040] #last 4 columns + discadj_pitchingNACA0012.test_vals = [-1.091207, -1.553655, -0.037855, 0.000088] #last 4 columns discadj_pitchingNACA0012.su2_exec = "SU2_CFD_AD" discadj_pitchingNACA0012.timeout = 1600 discadj_pitchingNACA0012.tol = 0.00001 @@ -239,7 +239,7 @@ def main(): discadj_heat.cfg_dir = "disc_adj_heat" discadj_heat.cfg_file = "disc_adj_heat.cfg" discadj_heat.test_iter = 10 - discadj_heat.test_vals = [-2.271573, 0.671194, -3.172000, -8.231600] #last 4 columns + discadj_heat.test_vals = [-2.271573, 0.671242, -3.172000, -8.231600] #last 4 columns discadj_heat.su2_exec = "SU2_CFD_AD" discadj_heat.timeout = 1600 discadj_heat.tol = 0.00001 From 19874e0166b343bf502a59e1b134ae9683a9164b Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Mon, 18 Nov 2019 16:21:00 -0800 Subject: [PATCH 49/57] Updating reference values for file diff regressions. --- SU2_CFD/src/solver_direct_mean_inc.cpp | 16 ++-- .../naca0012/of_grad_cd.dat.ref | 92 +++++++++++-------- .../naca0012/of_grad_cd_disc.dat.ref | 78 ++++++++-------- .../naca0012/of_grad_directdiff.dat.ref | 8 +- .../wedge/inv_wedge_ROE_multiobj.cfg | 2 +- .../wedge/of_grad_combo.dat.ref | 10 +- .../Airfoil_2d/grad_young.opt.ref | 2 +- .../multiple_ffd/naca0012/of_grad_cd.dat.ref | 6 +- .../naca0012/of_grad_directdiff.dat.ref | 6 +- TestCases/parallel_regression_AD.py | 6 +- TestCases/serial_regression.py | 4 +- TestCases/serial_regression_AD.py | 6 +- 12 files changed, 126 insertions(+), 110 deletions(-) diff --git a/SU2_CFD/src/solver_direct_mean_inc.cpp b/SU2_CFD/src/solver_direct_mean_inc.cpp index 0152a4695539..b387897d3886 100644 --- a/SU2_CFD/src/solver_direct_mean_inc.cpp +++ b/SU2_CFD/src/solver_direct_mean_inc.cpp @@ -6854,13 +6854,15 @@ CIncNSSolver::CIncNSSolver(CGeometry *geometry, CConfig *config, unsigned short gradients by least squares, S matrix := inv(R)*traspose(inv(R)), c vector := transpose(WA)*(Wb) ---*/ - Smatrix = new su2double* [nDim]; - for (iDim = 0; iDim < nDim; iDim++) - Smatrix[iDim] = new su2double [nDim]; - - Cvector = new su2double* [nPrimVarGrad]; - for (iVar = 0; iVar < nPrimVarGrad; iVar++) - Cvector[iVar] = new su2double [nDim]; + if (config->GetLeastSquaresRequired()) { + Smatrix = new su2double* [nDim]; + for (iDim = 0; iDim < nDim; iDim++) + Smatrix[iDim] = new su2double [nDim]; + + Cvector = new su2double* [nPrimVarGrad]; + for (iVar = 0; iVar < nPrimVarGrad; iVar++) + Cvector[iVar] = new su2double [nDim]; + } /*--- Store the value of the characteristic primitive variables at the boundaries ---*/ diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref index 51834640461c..00e62011a2a1 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref @@ -1,39 +1,53 @@ -VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , 0.00547874 , 0.0001 - 1 , 0.0243474 , 0.0001 - 2 , 0.0300065 , 0.0001 - 3 , 0.0234715 , 0.0001 - 4 , 0.00345121 , 0.0001 - 5 , -0.0307434 , 0.0001 - 6 , -0.0774773 , 0.0001 - 7 , -0.13197 , 0.0001 - 8 , -0.186782 , 0.0001 - 9 , -0.233914 , 0.0001 - 10 , -0.268098 , 0.0001 - 11 , -0.289809 , 0.0001 - 12 , -0.305806 , 0.0001 - 13 , -0.325957 , 0.0001 - 14 , -0.358284 , 0.0001 - 15 , -0.407284 , 0.0001 - 16 , -0.479307 , 0.0001 - 17 , -0.595933 , 0.0001 - 18 , -0.850309 , 0.0001 - 19 , 0.566108 , 0.0001 - 20 , 1.14466 , 0.0001 - 21 , 1.50253 , 0.0001 - 22 , 1.62876 , 0.0001 - 23 , 1.54945 , 0.0001 - 24 , 1.31552 , 0.0001 - 25 , 0.989768 , 0.0001 - 26 , 0.634351 , 0.0001 - 27 , 0.301435 , 0.0001 - 28 , 0.0285559 , 0.0001 - 29 , -0.160999 , 0.0001 - 30 , -0.254739 , 0.0001 - 31 , -0.248341 , 0.0001 - 32 , -0.148559 , 0.0001 - 33 , 0.0172426 , 0.0001 - 34 , 0.196759 , 0.0001 - 35 , 0.341483 , 0.0001 - 36 , 0.467392 , 0.0001 - 37 , 0.683048 , 0.0001 +VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" + 0 , 0.00535089 , 0.0001 + 1 , 0.0242911 , 0.0001 + 2 , 0.0299764 , 0.0001 + 3 , 0.0234387 , 0.0001 + 4 , 0.00340296 , 0.0001 + 5 , -0.0308074 , 0.0001 + 6 , -0.0775488 , 0.0001 + 7 , -0.132036 , 0.0001 + 8 , -0.186829 , 0.0001 + 9 , -0.23393 , 0.0001 + 10 , -0.268075 , 0.0001 + 11 , -0.28975 , 0.0001 + 12 , -0.305723 , 0.0001 + 13 , -0.325869 , 0.0001 + 14 , -0.358213 , 0.0001 + 15 , -0.407235 , 0.0001 + 16 , -0.479256 , 0.0001 + 17 , -0.595829 , 0.0001 + 18 , -0.849999 , 0.0001 + 19 , 0.56594 , 0.0001 + 20 , 1.14452 , 0.0001 + 21 , 1.50242 , 0.0001 + 22 , 1.6287 , 0.0001 + 23 , 1.54945 , 0.0001 + 24 , 1.31552 , 0.0001 + 25 , 0.989768 , 0.0001 + 26 , 0.634351 , 0.0001 + 27 , 0.301435 , 0.0001 + 28 , 0.0285559 , 0.0001 + 29 , -0.160999 , 0.0001 + 30 , -0.254739 , 0.0001 + 31 , -0.248341 , 0.0001 + 32 , -0.148559 , 0.0001 + 33 , 0.0172426 , 0.0001 + 34 , 0.196759 , 0.0001 + 35 , 0.341483 , 0.0001 + 36 , 0.467392 , 0.0001 + 37 , 0.683048 , 0.0001 + 24 , 1.3156 , 0.0001 + 25 , 0.989938 , 0.0001 + 26 , 0.634635 , 0.0001 + 27 , 0.301857 , 0.0001 + 28 , 0.0291461 , 0.0001 + 29 , -0.160219 , 0.0001 + 30 , -0.253768 , 0.0001 + 31 , -0.247224 , 0.0001 + 32 , -0.147422 , 0.0001 + 33 , 0.0181747 , 0.0001 + 34 , 0.197239 , 0.0001 + 35 , 0.341459 , 0.0001 + 36 , 0.467151 , 0.0001 + 37 , 0.682813 , 0.0001 diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref index 210df4b67cbd..fb08e3884437 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref @@ -1,39 +1,39 @@ -VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , -1501.32 , 0.001 - 1 , -8853.97 , 0.001 - 2 , -13557.1 , 0.001 - 3 , -14434.8 , 0.001 - 4 , -12487.9 , 0.001 - 5 , -9091.29 , 0.001 - 6 , -5397.59 , 0.001 - 7 , -2149.2 , 0.001 - 8 , 309.712 , 0.001 - 9 , 1914.46 , 0.001 - 10 , 2719.69 , 0.001 - 11 , 2757.37 , 0.001 - 12 , 1963.39 , 0.001 - 13 , 201.471 , 0.001 - 14 , -2599.03 , 0.001 - 15 , -6126.72 , 0.001 - 16 , -9129.12 , 0.001 - 17 , -9984.02 , 0.001 - 18 , -18443.1 , 0.001 - 19 , -9934.24 , 0.001 - 20 , -20497.1 , 0.001 - 21 , -22358.1 , 0.001 - 22 , -21058.4 , 0.001 - 23 , -20260.3 , 0.001 - 24 , -21304.1 , 0.001 - 25 , -23739.6 , 0.001 - 26 , -26013.5 , 0.001 - 27 , -26125.3 , 0.001 - 28 , -22227.0 , 0.001 - 29 , -13248.5 , 0.001 - 30 , 328.328 , 0.001 - 31 , 15562.7 , 0.001 - 32 , 26605.3 , 0.001 - 33 , 26411.8 , 0.001 - 34 , 12479.9 , 0.001 - 35 , -7567.83 , 0.001 - 36 , -23250.2 , 0.001 - 37 , -23417.7 , 0.001 +VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" + 0 , -3104.84 , 0.001 + 1 , -12744.7 , 0.001 + 2 , -17542.4 , 0.001 + 3 , -18273.9 , 0.001 + 4 , -16704.4 , 0.001 + 5 , -14262.7 , 0.001 + 6 , -11843.3 , 0.001 + 7 , -9867.41 , 0.001 + 8 , -8421.39 , 0.001 + 9 , -7414.08 , 0.001 + 10 , -6719.69 , 0.001 + 11 , -6278.28 , 0.001 + 12 , -6128.23 , 0.001 + 13 , -6361.53 , 0.001 + 14 , -7022.63 , 0.001 + 15 , -8027.63 , 0.001 + 16 , -9421.03 , 0.001 + 17 , -12856.8 , 0.001 + 18 , -21811.8 , 0.001 + 19 , -10009.3 , 0.001 + 20 , -22064.5 , 0.001 + 21 , -21920.4 , 0.001 + 22 , -18454.6 , 0.001 + 23 , -15764.5 , 0.001 + 24 , -14944.7 , 0.001 + 25 , -15338.8 , 0.001 + 26 , -15441.1 , 0.001 + 27 , -13583.4 , 0.001 + 28 , -8500.83 , 0.001 + 29 , 127.183 , 0.001 + 30 , 11095.3 , 0.001 + 31 , 21150.1 , 0.001 + 32 , 25103.9 , 0.001 + 33 , 17923.5 , 0.001 + 34 , -74.0778 , 0.001 + 35 , -18598.2 , 0.001 + 36 , -23657.5 , 0.001 + 37 , -16337.7 , 0.001 diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref index ae821034f0f1..5a8f985a190b 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref @@ -1,4 +1,4 @@ -VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" - 0 , 0.2372492479 , -114.3125628 , 0.2709181595 , -1.540436284 , 0.0 , -1.54597975 , 0.0 , 0.0 , 1.213847013 , 0.0 - 1 , 0.4025511296 , -185.8275927 , 0.45451385 , -2.377026434 , 0.0 , -2.386375933 , 0.0 , 0.0 , 1.049077447 , 0.0 - 2 , 0.5395721612 , -245.7671599 , 0.6071179277 , -3.089692602 , 0.0 , -3.102201546 , 0.0 , 0.0 , 0.6299667538 , 0.0 +VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" + 0 , 0.2285012284 , -106.6962871 , 0.2620099206 , -1.533188961 , 0.0 , -1.53853982 , 0.0 , 0.0 , 1.203388761 , 0.0 + 1 , 0.3866276739 , -174.5390955 , 0.439411593 , -2.414835143 , 0.0 , -2.423846191 , 0.0 , 0.0 , 1.053071502 , 0.0 + 2 , 0.5178161379 , -230.224511 , 0.5861998797 , -3.128333793 , 0.0 , -3.140377217 , 0.0 , 0.0 , 0.6530524517 , 0.0 diff --git a/TestCases/cont_adj_euler/wedge/inv_wedge_ROE_multiobj.cfg b/TestCases/cont_adj_euler/wedge/inv_wedge_ROE_multiobj.cfg index 573411c0d1dc..7e17d81c60a3 100644 --- a/TestCases/cont_adj_euler/wedge/inv_wedge_ROE_multiobj.cfg +++ b/TestCases/cont_adj_euler/wedge/inv_wedge_ROE_multiobj.cfg @@ -91,7 +91,7 @@ NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES CFL_NUMBER= 1.0 % % Adaptive CFL number (NO, YES) -CFL_ADAPT= YES +CFL_ADAPT= NO % % Parameters of the adaptive CFL number (factor down, factor up, CFL min value, % CFL max value ) diff --git a/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref b/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref index a82dace8db71..7c71680c304b 100644 --- a/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref +++ b/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref @@ -1,5 +1,5 @@ -VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , 0.00767938 , 0.0001 - 1 , 0.00499129 , 0.0001 - 2 , 0.00249092 , 0.0001 - 3 , 0.000902095 , 0.0001 +VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" + 0 , 0.00767938 , 0.0001 + 1 , 0.00499129 , 0.0001 + 2 , 0.00249092 , 0.0001 + 3 , 0.000902095 , 0.0001 diff --git a/TestCases/disc_adj_fsi/Airfoil_2d/grad_young.opt.ref b/TestCases/disc_adj_fsi/Airfoil_2d/grad_young.opt.ref index ad247c099fee..3038ad3dcca2 100644 --- a/TestCases/disc_adj_fsi/Airfoil_2d/grad_young.opt.ref +++ b/TestCases/disc_adj_fsi/Airfoil_2d/grad_young.opt.ref @@ -1,2 +1,2 @@ INDEX GRAD -0 -1.735284958051538e-03 +0 -1.733009427816183e-03 diff --git a/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref b/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref index f8a53f45e461..dfa1e662236c 100644 --- a/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref +++ b/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref @@ -1,3 +1,3 @@ -VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , 0.0681378 , 0.001 - 1 , -0.124933 , 0.001 +VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" + 0 , 0.0597229 , 0.001 + 1 , -0.108655 , 0.001 diff --git a/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref b/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref index 9b26b8580cf2..aaa7076ce538 100644 --- a/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref +++ b/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref @@ -1,3 +1,3 @@ -VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" - 0 , 0.06235436973 , -0.3961427924 , 0.05921156151 , 0.1447130695 , 0.0 , 0.1433869383 , 0.0 , 0.0 , 0.002242588997 , 0.0 - 1 , -0.07730334353 , 10.18344094 , -0.08433952825 , 0.3216204983 , 0.0 , 0.3233838184 , 0.0 , 0.0 , -0.01225607819 , 0.0 +VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" + 0 , 0.05698141666 , -0.4016762951 , 0.05429379682 , 0.1237934687 , 0.0 , 0.1225795963 , 0.0 , 0.0 , 0.009159910311 , 0.0 + 1 , -0.08029896733 , 8.980081481 , -0.08626576809 , 0.2725786469 , 0.0 , 0.2743956584 , 0.0 , 0.0 , 0.008211157534 , 0.0 diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 6dc6c51a8e09..0bc052ab64ff 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -94,7 +94,7 @@ def main(): discadj_rans_naca0012_sa.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" discadj_rans_naca0012_sa.test_iter = 10 - discadj_rans_naca0012_sa.test_vals = [-1.751966, 0.485697, 0.183154, -0.000018] #last 4 columns + discadj_rans_naca0012_sa.test_vals = [-2.230578, 0.678810, 0.181780, -0.000018] #last 4 columns discadj_rans_naca0012_sa.su2_exec = "parallel_computation.py -f" discadj_rans_naca0012_sa.timeout = 1600 discadj_rans_naca0012_sa.tol = 0.00001 @@ -105,7 +105,7 @@ def main(): discadj_rans_naca0012_sst.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" discadj_rans_naca0012_sst.test_iter = 10 - discadj_rans_naca0012_sst.test_vals = [-1.654042, -0.500944, 0.154703, -0.000022] #last 4 columns + discadj_rans_naca0012_sst.test_vals = [-2.223209, -0.496681, 0.154390, -0.000022] #last 4 columns discadj_rans_naca0012_sst.su2_exec = "parallel_computation.py -f" discadj_rans_naca0012_sst.timeout = 1600 discadj_rans_naca0012_sst.tol = 0.00001 @@ -161,7 +161,7 @@ def main(): discadj_incomp_turb_NACA0012_sst.cfg_dir = "disc_adj_incomp_rans/naca0012" discadj_incomp_turb_NACA0012_sst.cfg_file = "turb_naca0012_sst.cfg" discadj_incomp_turb_NACA0012_sst.test_iter = 10 - discadj_incomp_turb_NACA0012_sst.test_vals = [-3.845805, -2.415680, -8.430441, 0.000000] #last 4 columns + discadj_incomp_turb_NACA0012_sst.test_vals = [-3.845625, -2.413047, -8.419973, 0.000000] #last 4 columns discadj_incomp_turb_NACA0012_sst.su2_exec = "parallel_computation.py -f" discadj_incomp_turb_NACA0012_sst.timeout = 1600 discadj_incomp_turb_NACA0012_sst.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 64d9eb8578d8..b81e999a598b 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1544,7 +1544,7 @@ def main(): opt_multiobj1surf_py.cfg_dir = "optimization_euler/multiobjective_wedge" opt_multiobj1surf_py.cfg_file = "inv_wedge_ROE_multiobj_1surf.cfg" opt_multiobj1surf_py.test_iter = 1 - opt_multiobj1surf_py.test_vals = [1.000000, 1.000000, 30.371350, 2.226610] #last 4 columns + opt_multiobj1surf_py.test_vals = [1.000000, 1.000000, 30.428280, 2.039416] #last 4 columns opt_multiobj1surf_py.su2_exec = "shape_optimization.py -g CONTINUOUS_ADJOINT -f" opt_multiobj1surf_py.timeout = 1600 opt_multiobj1surf_py.tol = 0.00001 @@ -1556,7 +1556,7 @@ def main(): opt_2surf1obj_py.cfg_dir = "optimization_euler/multiobjective_wedge" opt_2surf1obj_py.cfg_file = "inv_wedge_ROE_2surf_1obj.cfg" opt_2surf1obj_py.test_iter = 1 - opt_2surf1obj_py.test_vals = [1.000000, 1.000000, 2.005700, 0.000203] #last 4 columns + opt_2surf1obj_py.test_vals = [1.000000, 1.000000, 2.005694, 0.000185] #last 4 columns opt_2surf1obj_py.su2_exec = "shape_optimization.py -g CONTINUOUS_ADJOINT -f" opt_2surf1obj_py.timeout = 1600 opt_2surf1obj_py.tol = 0.00001 diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index ba5b4506c7b8..17b4b7017e78 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -94,7 +94,7 @@ def main(): discadj_rans_naca0012_sa.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg" discadj_rans_naca0012_sa.test_iter = 10 - discadj_rans_naca0012_sa.test_vals = [-1.751962, 0.485751, 0.182121, -0.000018] #last 4 columns + discadj_rans_naca0012_sa.test_vals = [-2.230561, 0.678834, 0.180740, -0.000018] #last 4 columns discadj_rans_naca0012_sa.su2_exec = "SU2_CFD_AD" discadj_rans_naca0012_sa.timeout = 1600 discadj_rans_naca0012_sa.tol = 0.00001 @@ -105,7 +105,7 @@ def main(): discadj_rans_naca0012_sst.cfg_dir = "disc_adj_rans/naca0012" discadj_rans_naca0012_sst.cfg_file = "turb_NACA0012_sst.cfg" discadj_rans_naca0012_sst.test_iter = 10 - discadj_rans_naca0012_sst.test_vals = [-1.654903, -0.491485, 0.109160, 0.000011] #last 4 columns + discadj_rans_naca0012_sst.test_vals = [-2.216474, -0.485913, 0.109490, 0.000011] #last 4 columns discadj_rans_naca0012_sst.su2_exec = "SU2_CFD_AD" discadj_rans_naca0012_sst.timeout = 1600 discadj_rans_naca0012_sst.tol = 0.00001 @@ -161,7 +161,7 @@ def main(): discadj_incomp_turb_NACA0012_sst.cfg_dir = "disc_adj_incomp_rans/naca0012" discadj_incomp_turb_NACA0012_sst.cfg_file = "turb_naca0012_sst.cfg" discadj_incomp_turb_NACA0012_sst.test_iter = 10 - discadj_incomp_turb_NACA0012_sst.test_vals = [-3.845759, -2.416670, -8.430657, 0.000000] #last 4 columns + discadj_incomp_turb_NACA0012_sst.test_vals = [-3.845578, -2.414024, -8.420179, 0.000000] #last 4 columns discadj_incomp_turb_NACA0012_sst.su2_exec = "SU2_CFD_AD" discadj_incomp_turb_NACA0012_sst.timeout = 1600 discadj_incomp_turb_NACA0012_sst.tol = 0.00001 From 7c14cdbd52cc8e6f83b4f5383df1f976d4e15282 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Fri, 22 Nov 2019 15:19:52 -0800 Subject: [PATCH 50/57] Updating tutorial cases. --- .github/workflows/regression.yml | 2 +- QuickStart/inv_NACA0012.cfg | 22 +++++++++++++++------- config_template.cfg | 4 ---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index e0ded591c93f..1fccce4ecc21 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -87,5 +87,5 @@ jobs: - name: Run Tests in Container uses: docker://su2code/test-su2:20191031 with: - args: -b ${{github.ref}} -t develop -c feature_nlctrl -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t feature_nlctrl -c feature_nlctrl -s ${{matrix.testscript}} diff --git a/QuickStart/inv_NACA0012.cfg b/QuickStart/inv_NACA0012.cfg index 3685ae2972ad..2607cb0b75ff 100644 --- a/QuickStart/inv_NACA0012.cfg +++ b/QuickStart/inv_NACA0012.cfg @@ -19,10 +19,9 @@ SOLVER= EULER % Mathematical problem (DIRECT, CONTINUOUS_ADJOINT) MATH_PROBLEM= DIRECT % - % Restart solution (NO, YES) RESTART_SOL= NO -SCREEN_OUTPUT=(INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, CAUCHY_SENS_PRESS, CAUCHY_DRAG) + % ----------- COMPRESSIBLE AND INCOMPRESSIBLE FREE-STREAM DEFINITION ----------% % % Mach number (non-dimensional, based on the free-stream values) @@ -96,7 +95,14 @@ NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES OBJECTIVE_FUNCTION= DRAG % % Courant-Friedrichs-Lewy condition of the finest grid -CFL_NUMBER= 4.0 +CFL_NUMBER= 10.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= YES +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 0.1, 2.0, 10.0, 1e10 ) % % Number of total iterations ITER= 250 @@ -107,13 +113,13 @@ ITER= 250 LINEAR_SOLVER= FGMRES % % Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) -LINEAR_SOLVER_PREC= LU_SGS +LINEAR_SOLVER_PREC= ILU % % Minimum error of the linear solver for implicit formulations -LINEAR_SOLVER_ERROR= 1E-6 +LINEAR_SOLVER_ERROR= 1E-10 % % Max number of iterations of the linear solver for the implicit formulation -LINEAR_SOLVER_ITER= 5 +LINEAR_SOLVER_ITER= 10 % -------------------------- MULTIGRID PARAMETERS -----------------------------% % @@ -150,7 +156,7 @@ MUSCL_FLOW= YES % % Slope limiter (NONE, VENKATAKRISHNAN, VENKATAKRISHNAN_WANG, % BARTH_JESPERSEN, VAN_ALBADA_EDGE) -SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +SLOPE_LIMITER_FLOW= VENKATAKRISHNAN_WANG % % 2nd and 4th order artificial dissipation coefficients JST_SENSOR_COEFF= ( 0.5, 0.02 ) @@ -254,6 +260,8 @@ CONV_CAUCHY_ELEMS= 100 % % Epsilon to control the series convergence CONV_CAUCHY_EPS= 1E-6 +% +SCREEN_OUTPUT=(INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, CAUCHY_SENS_PRESS, CAUCHY_DRAG RMS_ADJ_DENSITY RMS_ADJ_ENERGY) % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % Mesh input file diff --git a/config_template.cfg b/config_template.cfg index 597f4f860005..85ee569a39a3 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -753,10 +753,6 @@ MARKER_ANALYZE_AVERAGE = MASSFLUX % Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) NUM_METHOD_GRAD= GREEN_GAUSS % -% Numerical method for spatial gradients used for upwind reconstruction -% (NONE, GREEN_GAUSS, LEAST_SQUARES, WEIGHTED_LEAST_SQUARES) -NUM_METHOD_GRAD_RECON= LEAST_SQUARES -% % CFL number (initial value for the adaptive CFL number) CFL_NUMBER= 15.0 % From 2d9bd616fff87a19eb601daacc5b7df87c86e94a Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Tue, 26 Nov 2019 08:31:42 -0800 Subject: [PATCH 51/57] Final parallel regression updates. --- TestCases/parallel_regression.py | 16 ++++++++-------- TestCases/parallel_regression_AD.py | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 5ef9436b4de2..ffcc3a6df3fc 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1207,7 +1207,7 @@ def main(): tutorial_inv_bump.cfg_dir = "../Tutorials/Inviscid_Bump" tutorial_inv_bump.cfg_file = "inv_channel.cfg" tutorial_inv_bump.test_iter = 0 - tutorial_inv_bump.test_vals = [-1.437425, 4.075857, -0.134610, 0.083745] #last 4 columns + tutorial_inv_bump.test_vals = [-1.437425, 4.075857, 0.003000, 0.012720] #last 4 columns tutorial_inv_bump.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_inv_bump.timeout = 1600 tutorial_inv_bump.tol = 0.00001 @@ -1219,7 +1219,7 @@ def main(): tutorial_inv_wedge.cfg_dir = "../Tutorials/Inviscid_Wedge" tutorial_inv_wedge.cfg_file = "inv_wedge_HLLC.cfg" tutorial_inv_wedge.test_iter = 0 - tutorial_inv_wedge.test_vals = [-0.481460, 5.253008, -0.266096, 0.046783] #last 4 columns + tutorial_inv_wedge.test_vals = [-0.481460, 5.253008, -0.292159, 0.052922] #last 4 columns tutorial_inv_wedge.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_inv_wedge.timeout = 1600 tutorial_inv_wedge.tol = 0.00001 @@ -1231,7 +1231,7 @@ def main(): tutorial_inv_onera.cfg_dir = "../Tutorials/Inviscid_ONERAM6" tutorial_inv_onera.cfg_file = "inv_ONERAM6.cfg" tutorial_inv_onera.test_iter = 0 - tutorial_inv_onera.test_vals = [-5.204928, -4.597762, 0.256216, 0.122658] #last 4 columns + tutorial_inv_onera.test_vals = [-5.204928, -4.597762, 0.247124, 0.085734] #last 4 columns tutorial_inv_onera.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_inv_onera.timeout = 1600 tutorial_inv_onera.tol = 0.00001 @@ -1243,7 +1243,7 @@ def main(): tutorial_lam_cylinder.cfg_dir = "../Tutorials/Laminar_Cylinder" tutorial_lam_cylinder.cfg_file = "lam_cylinder.cfg" tutorial_lam_cylinder.test_iter = 0 - tutorial_lam_cylinder.test_vals = [-6.162141, -0.699617, -0.119017, 60.376542] #last 4 columns + tutorial_lam_cylinder.test_vals = [-6.162141, -0.699617, 0.186570, 69.267308] #last 4 columns tutorial_lam_cylinder.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_lam_cylinder.timeout = 1600 tutorial_lam_cylinder.tol = 0.00001 @@ -1255,7 +1255,7 @@ def main(): tutorial_lam_flatplate.cfg_dir = "../Tutorials/Laminar_Flat_Plate" tutorial_lam_flatplate.cfg_file = "lam_flatplate.cfg" tutorial_lam_flatplate.test_iter = 0 - tutorial_lam_flatplate.test_vals = [-2.821818, 2.657591, -0.683968, 0.028634] #last 4 columns + tutorial_lam_flatplate.test_vals = [-2.821818, 2.657591, -0.400044, 0.029413] #last 4 columns tutorial_lam_flatplate.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_lam_flatplate.timeout = 1600 tutorial_lam_flatplate.tol = 0.00001 @@ -1267,7 +1267,7 @@ def main(): tutorial_turb_flatplate.cfg_dir = "../Tutorials/Turbulent_Flat_Plate" tutorial_turb_flatplate.cfg_file = "turb_SA_flatplate.cfg" tutorial_turb_flatplate.test_iter = 0 - tutorial_turb_flatplate.test_vals = [-2.258584, -4.899474, -0.753783, 0.200410] #last 4 columns + tutorial_turb_flatplate.test_vals = [-2.258584, -4.899502, -0.429387, 0.201236] #last 4 columns tutorial_turb_flatplate.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_turb_flatplate.timeout = 1600 tutorial_turb_flatplate.tol = 0.00001 @@ -1291,7 +1291,7 @@ def main(): tutorial_turb_oneram6.cfg_dir = "../Tutorials/Turbulent_ONERAM6" tutorial_turb_oneram6.cfg_file = "turb_ONERAM6.cfg" tutorial_turb_oneram6.test_iter = 0 - tutorial_turb_oneram6.test_vals = [-4.499497, -11.518421, 0.391293, 0.343702] #last 4 columns + tutorial_turb_oneram6.test_vals = [-4.499497, -11.473637, 0.332666, 0.098280] #last 4 columns tutorial_turb_oneram6.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_turb_oneram6.timeout = 1600 tutorial_turb_oneram6.tol = 0.00001 @@ -1302,7 +1302,7 @@ def main(): tutorial_design_inv_naca0012.cfg_dir = "../Tutorials/Inviscid_2D_Unconstrained_NACA0012" tutorial_design_inv_naca0012.cfg_file = "inv_NACA0012_basic.cfg" tutorial_design_inv_naca0012.test_iter = 0 - tutorial_design_inv_naca0012.test_vals = [-3.585391, -2.989014, 0.086210, 0.174381] #last 4 columns + tutorial_design_inv_naca0012.test_vals = [-3.585391, -2.989014, 0.134515, 0.208523] #last 4 columns tutorial_design_inv_naca0012.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_design_inv_naca0012.timeout = 1600 tutorial_design_inv_naca0012.tol = 0.00001 diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index bf2c3727b37e..1aa63913c25c 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -280,7 +280,7 @@ def main(): discadj_fsi2.cfg_dir = "disc_adj_fsi/Airfoil_2d" discadj_fsi2.cfg_file = "config.cfg" discadj_fsi2.test_iter = 8 - discadj_fsi2.test_vals = [-5.207224, -2.5436e-13] #last 2 columns + discadj_fsi2.test_vals = [-5.070991, -0.000000] #last 2 columns discadj_fsi2.su2_exec = "mpirun -n 2 SU2_CFD_AD" discadj_fsi2.timeout = 1600 discadj_fsi2.tol = 1e-16 From 33c85a18f7ee6a3e8c6203d453177e430f8a4a86 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Tue, 26 Nov 2019 09:38:23 -0800 Subject: [PATCH 52/57] More regressions. --- TestCases/parallel_regression.py | 2 +- TestCases/parallel_regression_AD.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index ffcc3a6df3fc..cc7e6a16a7d4 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1314,7 +1314,7 @@ def main(): tutorial_design_turb_rae2822.cfg_dir = "../Tutorials/Turbulent_2D_Constrained_RAE2822" tutorial_design_turb_rae2822.cfg_file = "turb_SA_RAE2822.cfg" tutorial_design_turb_rae2822.test_iter = 0 - tutorial_design_turb_rae2822.test_vals = [-1.700114, -4.931291, 0.293884, 0.331019] #last 4 columns + tutorial_design_turb_rae2822.test_vals = [-1.700114, -4.941261, 0.218432, 0.190639] #last 4 columns tutorial_design_turb_rae2822.su2_exec = "mpirun -np 2 SU2_CFD" tutorial_design_turb_rae2822.timeout = 1600 tutorial_design_turb_rae2822.tol = 0.00001 diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 1aa63913c25c..4d74dcfc317a 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -280,7 +280,7 @@ def main(): discadj_fsi2.cfg_dir = "disc_adj_fsi/Airfoil_2d" discadj_fsi2.cfg_file = "config.cfg" discadj_fsi2.test_iter = 8 - discadj_fsi2.test_vals = [-5.070991, -0.000000] #last 2 columns + discadj_fsi2.test_vals = [-5.070991, -2.5239e-13] #last 2 columns discadj_fsi2.su2_exec = "mpirun -n 2 SU2_CFD_AD" discadj_fsi2.timeout = 1600 discadj_fsi2.tol = 1e-16 From 89421cef5ce32ce19ad5abeb0cabd70fd59a6aad Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Tue, 26 Nov 2019 19:42:45 -0800 Subject: [PATCH 53/57] File diff fixes for regressions. --- .../cont_adj_euler/naca0012/of_grad_cd.dat.ref | 14 -------------- .../cont_adj_euler/wedge/of_grad_combo.dat.ref | 10 +++++----- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref index 00e62011a2a1..3090720c180c 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref @@ -23,20 +23,6 @@ VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" 21 , 1.50242 , 0.0001 22 , 1.6287 , 0.0001 23 , 1.54945 , 0.0001 - 24 , 1.31552 , 0.0001 - 25 , 0.989768 , 0.0001 - 26 , 0.634351 , 0.0001 - 27 , 0.301435 , 0.0001 - 28 , 0.0285559 , 0.0001 - 29 , -0.160999 , 0.0001 - 30 , -0.254739 , 0.0001 - 31 , -0.248341 , 0.0001 - 32 , -0.148559 , 0.0001 - 33 , 0.0172426 , 0.0001 - 34 , 0.196759 , 0.0001 - 35 , 0.341483 , 0.0001 - 36 , 0.467392 , 0.0001 - 37 , 0.683048 , 0.0001 24 , 1.3156 , 0.0001 25 , 0.989938 , 0.0001 26 , 0.634635 , 0.0001 diff --git a/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref b/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref index 7c71680c304b..0d54e740402b 100644 --- a/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref +++ b/TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref @@ -1,5 +1,5 @@ -VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , 0.00767938 , 0.0001 - 1 , 0.00499129 , 0.0001 - 2 , 0.00249092 , 0.0001 - 3 , 0.000902095 , 0.0001 +VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" + 0 , 0.00766235 , 0.0001 + 1 , 0.00499567 , 0.0001 + 2 , 0.00249665 , 0.0001 + 3 , 0.000904607 , 0.0001 From af79b7f04657c7fbb028407498284b2ba97fe0b3 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 27 Nov 2019 08:27:14 -0800 Subject: [PATCH 54/57] White space issue in file diff. --- .../naca0012/of_grad_cd.dat.ref | 78 +++++++++---------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref index 3090720c180c..37151f9b51b8 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_cd.dat.ref @@ -1,39 +1,39 @@ -VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , 0.00535089 , 0.0001 - 1 , 0.0242911 , 0.0001 - 2 , 0.0299764 , 0.0001 - 3 , 0.0234387 , 0.0001 - 4 , 0.00340296 , 0.0001 - 5 , -0.0308074 , 0.0001 - 6 , -0.0775488 , 0.0001 - 7 , -0.132036 , 0.0001 - 8 , -0.186829 , 0.0001 - 9 , -0.23393 , 0.0001 - 10 , -0.268075 , 0.0001 - 11 , -0.28975 , 0.0001 - 12 , -0.305723 , 0.0001 - 13 , -0.325869 , 0.0001 - 14 , -0.358213 , 0.0001 - 15 , -0.407235 , 0.0001 - 16 , -0.479256 , 0.0001 - 17 , -0.595829 , 0.0001 - 18 , -0.849999 , 0.0001 - 19 , 0.56594 , 0.0001 - 20 , 1.14452 , 0.0001 - 21 , 1.50242 , 0.0001 - 22 , 1.6287 , 0.0001 - 23 , 1.54945 , 0.0001 - 24 , 1.3156 , 0.0001 - 25 , 0.989938 , 0.0001 - 26 , 0.634635 , 0.0001 - 27 , 0.301857 , 0.0001 - 28 , 0.0291461 , 0.0001 - 29 , -0.160219 , 0.0001 - 30 , -0.253768 , 0.0001 - 31 , -0.247224 , 0.0001 - 32 , -0.147422 , 0.0001 - 33 , 0.0181747 , 0.0001 - 34 , 0.197239 , 0.0001 - 35 , 0.341459 , 0.0001 - 36 , 0.467151 , 0.0001 - 37 , 0.682813 , 0.0001 +VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" + 0 , 0.00535089 , 0.0001 + 1 , 0.0242911 , 0.0001 + 2 , 0.0299764 , 0.0001 + 3 , 0.0234387 , 0.0001 + 4 , 0.00340296 , 0.0001 + 5 , -0.0308074 , 0.0001 + 6 , -0.0775488 , 0.0001 + 7 , -0.132036 , 0.0001 + 8 , -0.186829 , 0.0001 + 9 , -0.23393 , 0.0001 + 10 , -0.268075 , 0.0001 + 11 , -0.28975 , 0.0001 + 12 , -0.305723 , 0.0001 + 13 , -0.325869 , 0.0001 + 14 , -0.358213 , 0.0001 + 15 , -0.407235 , 0.0001 + 16 , -0.479256 , 0.0001 + 17 , -0.595829 , 0.0001 + 18 , -0.849999 , 0.0001 + 19 , 0.56594 , 0.0001 + 20 , 1.14452 , 0.0001 + 21 , 1.50242 , 0.0001 + 22 , 1.6287 , 0.0001 + 23 , 1.54945 , 0.0001 + 24 , 1.3156 , 0.0001 + 25 , 0.989938 , 0.0001 + 26 , 0.634635 , 0.0001 + 27 , 0.301857 , 0.0001 + 28 , 0.0291461 , 0.0001 + 29 , -0.160219 , 0.0001 + 30 , -0.253768 , 0.0001 + 31 , -0.247224 , 0.0001 + 32 , -0.147422 , 0.0001 + 33 , 0.0181747 , 0.0001 + 34 , 0.197239 , 0.0001 + 35 , 0.341459 , 0.0001 + 36 , 0.467151 , 0.0001 + 37 , 0.682813 , 0.0001 From 11af27f74b0df3d6e432c01e18471a2b4d977c87 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 27 Nov 2019 11:59:25 -0800 Subject: [PATCH 55/57] Updating branch for tutorials. --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 1fccce4ecc21..a1b3122151f0 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -87,5 +87,5 @@ jobs: - name: Run Tests in Container uses: docker://su2code/test-su2:20191031 with: - args: -b ${{github.ref}} -t feature_nlctrl -c feature_nlctrl -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t release_v7.0.0 -c feature_nlctrl -s ${{matrix.testscript}} From e530059aaf6092288f9560d225a34ebec0a048b8 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 27 Nov 2019 16:33:05 -0800 Subject: [PATCH 56/57] More white space fixes for file diff regressions. --- .../naca0012/of_grad_cd_disc.dat.ref | 78 +++++++++---------- .../naca0012/of_grad_directdiff.dat.ref | 8 +- .../multiple_ffd/naca0012/of_grad_cd.dat.ref | 6 +- .../naca0012/of_grad_directdiff.dat.ref | 6 +- 4 files changed, 49 insertions(+), 49 deletions(-) diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref index fb08e3884437..abde9ba2e9d0 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_cd_disc.dat.ref @@ -1,39 +1,39 @@ -VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , -3104.84 , 0.001 - 1 , -12744.7 , 0.001 - 2 , -17542.4 , 0.001 - 3 , -18273.9 , 0.001 - 4 , -16704.4 , 0.001 - 5 , -14262.7 , 0.001 - 6 , -11843.3 , 0.001 - 7 , -9867.41 , 0.001 - 8 , -8421.39 , 0.001 - 9 , -7414.08 , 0.001 - 10 , -6719.69 , 0.001 - 11 , -6278.28 , 0.001 - 12 , -6128.23 , 0.001 - 13 , -6361.53 , 0.001 - 14 , -7022.63 , 0.001 - 15 , -8027.63 , 0.001 - 16 , -9421.03 , 0.001 - 17 , -12856.8 , 0.001 - 18 , -21811.8 , 0.001 - 19 , -10009.3 , 0.001 - 20 , -22064.5 , 0.001 - 21 , -21920.4 , 0.001 - 22 , -18454.6 , 0.001 - 23 , -15764.5 , 0.001 - 24 , -14944.7 , 0.001 - 25 , -15338.8 , 0.001 - 26 , -15441.1 , 0.001 - 27 , -13583.4 , 0.001 - 28 , -8500.83 , 0.001 - 29 , 127.183 , 0.001 - 30 , 11095.3 , 0.001 - 31 , 21150.1 , 0.001 - 32 , 25103.9 , 0.001 - 33 , 17923.5 , 0.001 - 34 , -74.0778 , 0.001 - 35 , -18598.2 , 0.001 - 36 , -23657.5 , 0.001 - 37 , -16337.7 , 0.001 +VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" + 0 , -3104.84 , 0.001 + 1 , -12744.7 , 0.001 + 2 , -17542.4 , 0.001 + 3 , -18273.9 , 0.001 + 4 , -16704.4 , 0.001 + 5 , -14262.7 , 0.001 + 6 , -11843.3 , 0.001 + 7 , -9867.41 , 0.001 + 8 , -8421.39 , 0.001 + 9 , -7414.08 , 0.001 + 10 , -6719.69 , 0.001 + 11 , -6278.28 , 0.001 + 12 , -6128.23 , 0.001 + 13 , -6361.53 , 0.001 + 14 , -7022.63 , 0.001 + 15 , -8027.63 , 0.001 + 16 , -9421.03 , 0.001 + 17 , -12856.8 , 0.001 + 18 , -21811.8 , 0.001 + 19 , -10009.3 , 0.001 + 20 , -22064.5 , 0.001 + 21 , -21920.4 , 0.001 + 22 , -18454.6 , 0.001 + 23 , -15764.5 , 0.001 + 24 , -14944.7 , 0.001 + 25 , -15338.8 , 0.001 + 26 , -15441.1 , 0.001 + 27 , -13583.4 , 0.001 + 28 , -8500.83 , 0.001 + 29 , 127.183 , 0.001 + 30 , 11095.3 , 0.001 + 31 , 21150.1 , 0.001 + 32 , 25103.9 , 0.001 + 33 , 17923.5 , 0.001 + 34 , -74.0778 , 0.001 + 35 , -18598.2 , 0.001 + 36 , -23657.5 , 0.001 + 37 , -16337.7 , 0.001 diff --git a/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref b/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref index 5a8f985a190b..1c0e0f22f813 100644 --- a/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref +++ b/TestCases/cont_adj_euler/naca0012/of_grad_directdiff.dat.ref @@ -1,4 +1,4 @@ -VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" - 0 , 0.2285012284 , -106.6962871 , 0.2620099206 , -1.533188961 , 0.0 , -1.53853982 , 0.0 , 0.0 , 1.203388761 , 0.0 - 1 , 0.3866276739 , -174.5390955 , 0.439411593 , -2.414835143 , 0.0 , -2.423846191 , 0.0 , 0.0 , 1.053071502 , 0.0 - 2 , 0.5178161379 , -230.224511 , 0.5861998797 , -3.128333793 , 0.0 , -3.140377217 , 0.0 , 0.0 , 0.6530524517 , 0.0 +VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" + 0 , 0.2285012284 , -106.6962871 , 0.2620099206 , -1.533188961 , 0.0 , -1.53853982 , 0.0 , 0.0 , 1.203388761 , 0.0 + 1 , 0.3866276739 , -174.5390955 , 0.439411593 , -2.414835143 , 0.0 , -2.423846191 , 0.0 , 0.0 , 1.053071502 , 0.0 + 2 , 0.5178161379 , -230.224511 , 0.5861998797 , -3.128333793 , 0.0 , -3.140377217 , 0.0 , 0.0 , 0.6530524517 , 0.0 diff --git a/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref b/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref index dfa1e662236c..a1f7b64fddb2 100644 --- a/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref +++ b/TestCases/multiple_ffd/naca0012/of_grad_cd.dat.ref @@ -1,3 +1,3 @@ -VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" - 0 , 0.0597229 , 0.001 - 1 , -0.108655 , 0.001 +VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP" + 0 , 0.0597229 , 0.001 + 1 , -0.108655 , 0.001 diff --git a/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref b/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref index aaa7076ce538..e279f1f88b94 100644 --- a/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref +++ b/TestCases/multiple_ffd/naca0012/of_grad_directdiff.dat.ref @@ -1,3 +1,3 @@ -VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" - 0 , 0.05698141666 , -0.4016762951 , 0.05429379682 , 0.1237934687 , 0.0 , 0.1225795963 , 0.0 , 0.0 , 0.009159910311 , 0.0 - 1 , -0.08029896733 , 8.980081481 , -0.08626576809 , 0.2725786469 , 0.0 , 0.2743956584 , 0.0 , 0.0 , 0.008211157534 , 0.0 +VARIABLES="VARIABLE" , "DRAG" , "EFFICIENCY" , "FORCE_X" , "FORCE_Y" , "FORCE_Z" , "LIFT" , "MOMENT_X" , "MOMENT_Y" , "MOMENT_Z" , "SIDEFORCE" + 0 , 0.05698141666 , -0.4016762951 , 0.05429379682 , 0.1237934687 , 0.0 , 0.1225795963 , 0.0 , 0.0 , 0.009159910311 , 0.0 + 1 , -0.08029896733 , 8.980081481 , -0.08626576809 , 0.2725786469 , 0.0 , 0.2743956584 , 0.0 , 0.0 , 0.008211157534 , 0.0 From 054266e29c73402cc6c332f862f0dd024e9413b7 Mon Sep 17 00:00:00 2001 From: "Thomas D. Economon" Date: Wed, 27 Nov 2019 20:30:50 -0800 Subject: [PATCH 57/57] Switching test case branch back to develop. Leaving tutorials pointing to v7 branch. --- .github/workflows/regression.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index a1b3122151f0..9326c472348b 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -87,5 +87,5 @@ jobs: - name: Run Tests in Container uses: docker://su2code/test-su2:20191031 with: - args: -b ${{github.ref}} -t release_v7.0.0 -c feature_nlctrl -s ${{matrix.testscript}} + args: -b ${{github.ref}} -t release_v7.0.0 -c develop -s ${{matrix.testscript}}